add label interpolation to description fields (#30325)
fixes: #30271 Signed-off-by: Erik Jan de Wit <erikjan.dewit@gmail.com>
This commit is contained in:
parent
716e2d4e68
commit
ece72cd491
7 changed files with 36 additions and 16 deletions
|
@ -1,5 +1,6 @@
|
||||||
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
import type ClientRepresentation from "@keycloak/keycloak-admin-client/lib/defs/clientRepresentation";
|
||||||
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
|
import type { ClientQuery } from "@keycloak/keycloak-admin-client/lib/resources/clients";
|
||||||
|
import { label } from "@keycloak/keycloak-ui-shared";
|
||||||
import {
|
import {
|
||||||
AlertVariant,
|
AlertVariant,
|
||||||
Badge,
|
Badge,
|
||||||
|
@ -10,7 +11,14 @@ import {
|
||||||
TabTitleText,
|
TabTitleText,
|
||||||
ToolbarItem,
|
ToolbarItem,
|
||||||
} from "@patternfly/react-core";
|
} from "@patternfly/react-core";
|
||||||
import { IRowData, TableText, cellWidth } from "@patternfly/react-table";
|
import {
|
||||||
|
IFormatter,
|
||||||
|
IFormatterValueType,
|
||||||
|
IRowData,
|
||||||
|
TableText,
|
||||||
|
cellWidth,
|
||||||
|
} from "@patternfly/react-table";
|
||||||
|
import { TFunction } from "i18next";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link } from "react-router-dom";
|
import { Link } from "react-router-dom";
|
||||||
|
@ -40,6 +48,12 @@ import { ClientsTab, toClients } from "./routes/Clients";
|
||||||
import { toImportClient } from "./routes/ImportClient";
|
import { toImportClient } from "./routes/ImportClient";
|
||||||
import { getProtocolName, isRealmClient } from "./utils";
|
import { getProtocolName, isRealmClient } from "./utils";
|
||||||
|
|
||||||
|
export const translationFormatter =
|
||||||
|
(t: TFunction): IFormatter =>
|
||||||
|
(data?: IFormatterValueType) => {
|
||||||
|
return data ? label(t, data as string) || "—" : "—";
|
||||||
|
};
|
||||||
|
|
||||||
const ClientDetailLink = (client: ClientRepresentation) => {
|
const ClientDetailLink = (client: ClientRepresentation) => {
|
||||||
const { t } = useTranslation();
|
const { t } = useTranslation();
|
||||||
const { realm } = useRealm();
|
const { realm } = useRealm();
|
||||||
|
@ -60,11 +74,14 @@ const ClientDetailLink = (client: ClientRepresentation) => {
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const ClientName = (client: ClientRepresentation) => (
|
const ClientName = (client: ClientRepresentation) => {
|
||||||
|
const { t } = useTranslation();
|
||||||
|
return (
|
||||||
<TableText wrapModifier="truncate">
|
<TableText wrapModifier="truncate">
|
||||||
{emptyFormatter()(client.name) as string}
|
{translationFormatter(t)(client.name) as string}
|
||||||
</TableText>
|
</TableText>
|
||||||
);
|
);
|
||||||
|
};
|
||||||
|
|
||||||
const ClientDescription = (client: ClientRepresentation) => (
|
const ClientDescription = (client: ClientRepresentation) => (
|
||||||
<TableText wrapModifier="truncate">
|
<TableText wrapModifier="truncate">
|
||||||
|
|
|
@ -41,6 +41,7 @@ import {
|
||||||
import { useAccess } from "../../context/access/Access";
|
import { useAccess } from "../../context/access/Access";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import useLocaleSort, { mapByKey } from "../../utils/useLocaleSort";
|
import useLocaleSort, { mapByKey } from "../../utils/useLocaleSort";
|
||||||
|
import { translationFormatter } from "../ClientsSection";
|
||||||
import { toDedicatedScope } from "../routes/DedicatedScopeDetails";
|
import { toDedicatedScope } from "../routes/DedicatedScopeDetails";
|
||||||
import { AddScopeDialog } from "./AddScopeDialog";
|
import { AddScopeDialog } from "./AddScopeDialog";
|
||||||
|
|
||||||
|
@ -368,7 +369,7 @@ export const ClientScopes = ({
|
||||||
<TypeSelector clientId={clientId} refresh={refresh} {...row} />
|
<TypeSelector clientId={clientId} refresh={refresh} {...row} />
|
||||||
),
|
),
|
||||||
},
|
},
|
||||||
{ name: "description" },
|
{ name: "description", cellFormatters: [translationFormatter(t)] },
|
||||||
]}
|
]}
|
||||||
actions={
|
actions={
|
||||||
isManager
|
isManager
|
||||||
|
|
|
@ -5,6 +5,7 @@ import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, To, useNavigate } from "react-router-dom";
|
import { Link, To, useNavigate } from "react-router-dom";
|
||||||
import { useAdminClient } from "../../admin-client";
|
import { useAdminClient } from "../../admin-client";
|
||||||
|
import { translationFormatter } from "../../clients/ClientsSection";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { toRealmSettings } from "../../realm-settings/routes/RealmSettings";
|
import { toRealmSettings } from "../../realm-settings/routes/RealmSettings";
|
||||||
import { emptyFormatter, upperCaseFormatter } from "../../util";
|
import { emptyFormatter, upperCaseFormatter } from "../../util";
|
||||||
|
@ -162,8 +163,7 @@ export const RolesList = ({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
displayKey: "description",
|
cellFormatters: [translationFormatter(t)],
|
||||||
cellFormatters: [emptyFormatter()],
|
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
emptyState={
|
emptyState={
|
||||||
|
|
|
@ -4,6 +4,7 @@ import { Button, Label, Modal, ModalVariant } from "@patternfly/react-core";
|
||||||
import { useState } from "react";
|
import { useState } from "react";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { useAdminClient } from "../admin-client";
|
import { useAdminClient } from "../admin-client";
|
||||||
|
import { translationFormatter } from "../clients/ClientsSection";
|
||||||
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
||||||
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
import { ListEmptyState } from "../components/list-empty-state/ListEmptyState";
|
||||||
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
import { KeycloakDataTable } from "../components/table-toolbar/KeycloakDataTable";
|
||||||
|
@ -116,7 +117,7 @@ export const AddClientProfileModal = (props: AddClientProfileModalProps) => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
displayKey: "description",
|
cellFormatters: [translationFormatter(t)],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
emptyState={
|
emptyState={
|
||||||
|
|
|
@ -19,6 +19,7 @@ import { Controller, useForm, type UseFormReturn } from "react-hook-form";
|
||||||
import { useTranslation } from "react-i18next";
|
import { useTranslation } from "react-i18next";
|
||||||
import { Link, useNavigate } from "react-router-dom";
|
import { Link, useNavigate } from "react-router-dom";
|
||||||
import { useAdminClient } from "../admin-client";
|
import { useAdminClient } from "../admin-client";
|
||||||
|
import { translationFormatter } from "../clients/ClientsSection";
|
||||||
import { useAlerts } from "../components/alert/Alerts";
|
import { useAlerts } from "../components/alert/Alerts";
|
||||||
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
import { useConfirmDialog } from "../components/confirm-dialog/ConfirmDialog";
|
||||||
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
import { KeycloakSpinner } from "../components/keycloak-spinner/KeycloakSpinner";
|
||||||
|
@ -280,6 +281,7 @@ export const PoliciesTab = () => {
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
|
cellFormatters: [translationFormatter(t)],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
/>
|
/>
|
||||||
|
|
|
@ -1,11 +1,11 @@
|
||||||
import { useTranslation } from "react-i18next";
|
|
||||||
import { Button, ToolbarItem } from "@patternfly/react-core";
|
import { Button, ToolbarItem } from "@patternfly/react-core";
|
||||||
|
import { useTranslation } from "react-i18next";
|
||||||
|
import { translationFormatter } from "../../clients/ClientsSection";
|
||||||
|
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
|
||||||
import {
|
import {
|
||||||
Action,
|
Action,
|
||||||
KeycloakDataTable,
|
KeycloakDataTable,
|
||||||
} from "../../components/table-toolbar/KeycloakDataTable";
|
} from "../../components/table-toolbar/KeycloakDataTable";
|
||||||
import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState";
|
|
||||||
|
|
||||||
export type EventType = {
|
export type EventType = {
|
||||||
id: string;
|
id: string;
|
||||||
|
@ -66,7 +66,7 @@ export function EventsTypeTable({
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "description",
|
name: "description",
|
||||||
displayKey: "description",
|
cellFormatters: [translationFormatter(t)],
|
||||||
},
|
},
|
||||||
]}
|
]}
|
||||||
emptyState={
|
emptyState={
|
||||||
|
|
|
@ -5,11 +5,10 @@ import { saveAs } from "file-saver";
|
||||||
import { flatten } from "flat";
|
import { flatten } from "flat";
|
||||||
import { cloneDeep } from "lodash-es";
|
import { cloneDeep } from "lodash-es";
|
||||||
import { FieldValues, Path, PathValue, UseFormSetValue } from "react-hook-form";
|
import { FieldValues, Path, PathValue, UseFormSetValue } from "react-hook-form";
|
||||||
|
|
||||||
import {
|
import {
|
||||||
|
KeyValueType,
|
||||||
arrayToKeyValue,
|
arrayToKeyValue,
|
||||||
keyValueToArray,
|
keyValueToArray,
|
||||||
KeyValueType,
|
|
||||||
} from "./components/key-value-form/key-value-convert";
|
} from "./components/key-value-form/key-value-convert";
|
||||||
import { ReplaceString } from "./utils/types";
|
import { ReplaceString } from "./utils/types";
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue