Fix 'Home URL' link in clients overview (#4363)
This commit is contained in:
parent
c6e6bceb10
commit
ddc0b3ebaf
2 changed files with 14 additions and 13 deletions
|
@ -16,7 +16,7 @@ import { useTranslation } from "react-i18next";
|
|||
import { Link } from "react-router-dom";
|
||||
import { useAlerts } from "../components/alert/Alerts";
|
||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||
import { formattedLinkTableCell } from "../components/external-link/FormattedLink";
|
||||
import { FormattedLink } from "../components/external-link/FormattedLink";
|
||||
import {
|
||||
Action,
|
||||
KeycloakDataTable,
|
||||
|
@ -68,6 +68,17 @@ const ClientDescription = (client: ClientRepresentation) => (
|
|||
</TableText>
|
||||
);
|
||||
|
||||
const ClientHomeLink = (client: ClientRepresentation) => {
|
||||
const { adminClient } = useAdminClient();
|
||||
const href = convertClientToUrl(client, adminClient.baseUrl);
|
||||
|
||||
if (!href) {
|
||||
return "—";
|
||||
}
|
||||
|
||||
return <FormattedLink href={href} />;
|
||||
};
|
||||
|
||||
export default function ClientsSection() {
|
||||
const { t } = useTranslation("clients");
|
||||
const { addAlert, addError } = useAlerts();
|
||||
|
@ -233,9 +244,7 @@ export default function ClientsSection() {
|
|||
name: "baseUrl",
|
||||
displayKey: "clients:homeURL",
|
||||
transforms: [cellWidth(20)],
|
||||
cellFormatters: [formattedLinkTableCell(), emptyFormatter()],
|
||||
cellRenderer: (c) =>
|
||||
convertClientToUrl(c, adminClient.baseUrl) || "",
|
||||
cellRenderer: ClientHomeLink,
|
||||
},
|
||||
]}
|
||||
/>
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
import { AnchorHTMLAttributes } from "react";
|
||||
import { ExternalLinkAltIcon } from "@patternfly/react-icons";
|
||||
import type { IFormatter, IFormatterValueType } from "@patternfly/react-table";
|
||||
import { AnchorHTMLAttributes } from "react";
|
||||
|
||||
export type FormattedLinkProps = AnchorHTMLAttributes<HTMLAnchorElement> & {
|
||||
isInline?: boolean;
|
||||
|
@ -25,10 +24,3 @@ export const FormattedLink = ({
|
|||
</a>
|
||||
);
|
||||
};
|
||||
|
||||
export const formattedLinkTableCell =
|
||||
(): IFormatter => (data?: IFormatterValueType) => {
|
||||
return (
|
||||
data ? <FormattedLink href={data.toString()} /> : undefined
|
||||
) as object;
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue