Renamed messages in localization/realm overrides (#26663)
* renamed messages Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * fixed test Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> --------- Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> Co-authored-by: Agnieszka Gancarczyk <agancarc@redhat.com>
This commit is contained in:
parent
ac1b189350
commit
93a6d56af3
5 changed files with 69 additions and 73 deletions
|
@ -199,7 +199,7 @@ describe("Realm settings tabs tests", () => {
|
|||
addBundle();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Success! The message bundle has been added.",
|
||||
"Success! The translation has been added.",
|
||||
);
|
||||
|
||||
cy.findByTestId("editable-rows-table")
|
||||
|
@ -209,9 +209,7 @@ describe("Realm settings tabs tests", () => {
|
|||
cy.get('td.pf-c-table__action button[aria-label="Actions"]').click();
|
||||
cy.contains("button", "Delete").click();
|
||||
cy.findByTestId("confirm").click();
|
||||
masthead.checkNotificationMessage(
|
||||
"Successfully removed message(s) from the bundle.",
|
||||
);
|
||||
masthead.checkNotificationMessage("Successfully removed translation(s).");
|
||||
});
|
||||
|
||||
it("Realm Overrides - Search for and delete bundle", () => {
|
||||
|
@ -229,11 +227,9 @@ describe("Realm settings tabs tests", () => {
|
|||
|
||||
cy.findByTestId("selectAll").click();
|
||||
cy.get('[data-testid="toolbar-deleteBtn"] button').click();
|
||||
cy.findByTestId("delete-selected-bundleBtn").click();
|
||||
cy.findByTestId("delete-selected-TranslationBtn").click();
|
||||
cy.findByTestId("confirm").click();
|
||||
masthead.checkNotificationMessage(
|
||||
"Successfully removed message(s) from the bundle.",
|
||||
);
|
||||
masthead.checkNotificationMessage("Successfully removed translation(s).");
|
||||
});
|
||||
|
||||
it("Realm Overrides - Edit and cancel edit message bundle", () => {
|
||||
|
@ -261,9 +257,7 @@ describe("Realm settings tabs tests", () => {
|
|||
cy.contains("button", "Delete").click();
|
||||
cy.findByTestId("confirm").click();
|
||||
|
||||
masthead.checkNotificationMessage(
|
||||
"Successfully removed message(s) from the bundle.",
|
||||
);
|
||||
masthead.checkNotificationMessage("Successfully removed translation(s).");
|
||||
});
|
||||
|
||||
it("Effective Message Bundles - Check before search message", () => {
|
||||
|
|
|
@ -96,7 +96,7 @@ export default class RealmSettingsPage extends CommonPage {
|
|||
modalTestConnectionButton = "modal-test-connection-button";
|
||||
emailAddressInput = "email-address-input";
|
||||
addBundleButton = "add-translationBtn";
|
||||
confirmAddBundle = "add-bundle-confirm-button";
|
||||
confirmAddTranslation = "add-translation-confirm-button";
|
||||
keyInput = "key-input";
|
||||
valueInput = "value-input";
|
||||
deleteAction = "delete-action";
|
||||
|
@ -474,7 +474,7 @@ export default class RealmSettingsPage extends CommonPage {
|
|||
cy.findByTestId(this.keyInput).type(key);
|
||||
cy.findByTestId(this.valueInput).type(value);
|
||||
|
||||
cy.findByTestId(this.confirmAddBundle).click({ force: true });
|
||||
cy.findByTestId(this.confirmAddTranslation).click({ force: true });
|
||||
|
||||
return this;
|
||||
}
|
||||
|
|
|
@ -343,7 +343,7 @@ clientScopes=Client scopes
|
|||
loadingRealms=Loading realms…
|
||||
eventTypes.SEND_RESET_PASSWORD_ERROR.description=Send reset password error
|
||||
httpPostBindingLogout=HTTP-POST binding logout
|
||||
updateMessageBundleSuccess=Success\! Message bundle updated.
|
||||
updateTranslationSuccess=Success\! Translation updated.
|
||||
permissionDescription=A description for this permission.
|
||||
policyClientHelp=Specifies which client(s) are allowed by this policy.
|
||||
multivalued.label=Multivalued
|
||||
|
@ -1224,7 +1224,7 @@ eventTypes.UNREGISTER_NODE_ERROR.description=Unregister node error
|
|||
clientScopeTypes.optional=Optional
|
||||
nameIdFormat=Name ID format
|
||||
eventTypes.SEND_VERIFY_EMAIL_ERROR.name=Send verify email error
|
||||
addMessageBundleSuccess=Success\! The message bundle has been added.
|
||||
addTranslationSuccess=Success\! The translation has been added.
|
||||
validRedirectUri=Valid redirect URIs
|
||||
webauthnIntro=What is this form used for?
|
||||
wantAssertionsEncryptedHelp=Indicates whether this service provider expects an encrypted Assertion.
|
||||
|
@ -1917,7 +1917,7 @@ emptyProfiles=No client profiles configured
|
|||
createClientProfileError=Could not create client profile\: '{{error}}'
|
||||
usermodel.clientRoleMapping.clientId.tooltip=Client ID for role mappings. Just client roles of this client will be added to the token. If this is unset, client roles of all clients will be added to the token.
|
||||
targetOptions.local=LOCAL
|
||||
addMessageBundleError=Error creating message bundle, {{error}}
|
||||
addTranslationError=Error creating translation, {{error}}
|
||||
pkceMethodHelp=PKCE Method to use
|
||||
encryption=Encryption
|
||||
addExecutorError=Executor not created
|
||||
|
@ -2843,7 +2843,7 @@ jwtX509HeadersEnabledHelp=If enabled, the x5t (X.509 Certificate SHA-1 Thumbprin
|
|||
addProvider_other=Add {{provider}} providers
|
||||
cibaExpiresIn=Expires In
|
||||
dynamicScopeFormatHelp=This is the regular expression that the system will use to extract the scope name and variable.
|
||||
updateMessageBundleError=Error updating message bundle.
|
||||
updateTranslationError=Error updating translation.
|
||||
resetPasswordConfirmText=Are you sure you want to reset the password for the user {{username}}?
|
||||
create=Create
|
||||
noAvailableIdentityProviders=No available identity providers.
|
||||
|
@ -2945,8 +2945,8 @@ realmOverridesHelp=You can only edit the supported locales. If you haven't selec
|
|||
effectiveMessageBundles=Effective message bundles
|
||||
effectiveMessageBundlesHelp=You can search for effective message bundles based on themes, features, language, and free text.
|
||||
deleteMessageBundle=Delete message bundle {{key}}
|
||||
deleteAllMessagesBundleSuccess=Successfully removed message(s) from the bundle.
|
||||
deleteAllMessagesBundleError=Error removing message(s) from the bundle, {{error}}
|
||||
deleteAllTranslationsSuccess=Successfully removed translation(s).
|
||||
deleteAllTranslationsError=Error removing translation(s), {{error}}
|
||||
noRealmOverridesSearchResultsInstructions=Click on the search bar above to search for realm overrides
|
||||
emptyEffectiveMessageBundles=Search for effective messages
|
||||
emptyEffectiveMessageBundlesInstructions=You can search for the effective messages you want by theme, feature and language in the search box above.
|
||||
|
|
|
@ -13,20 +13,20 @@ import { useTranslation } from "react-i18next";
|
|||
import type { KeyValueType } from "../components/key-value-form/key-value-convert";
|
||||
import { KeycloakTextInput } from "../components/keycloak-text-input/KeycloakTextInput";
|
||||
|
||||
type AddMessageBundleModalProps = {
|
||||
type AddTranslationModalProps = {
|
||||
id?: string;
|
||||
form: UseFormReturn<BundleForm>;
|
||||
save: SubmitHandler<BundleForm>;
|
||||
form: UseFormReturn<TranslationForm>;
|
||||
save: SubmitHandler<TranslationForm>;
|
||||
handleModalToggle: () => void;
|
||||
};
|
||||
|
||||
export type BundleForm = {
|
||||
export type TranslationForm = {
|
||||
key: string;
|
||||
value: string;
|
||||
messageBundle: KeyValueType;
|
||||
translation: KeyValueType;
|
||||
};
|
||||
|
||||
export const AddMessageBundleModal = ({
|
||||
export const AddTranslationModal = ({
|
||||
handleModalToggle,
|
||||
save,
|
||||
form: {
|
||||
|
@ -34,22 +34,22 @@ export const AddMessageBundleModal = ({
|
|||
handleSubmit,
|
||||
formState: { errors },
|
||||
},
|
||||
}: AddMessageBundleModalProps) => {
|
||||
}: AddTranslationModalProps) => {
|
||||
const { t } = useTranslation();
|
||||
|
||||
return (
|
||||
<Modal
|
||||
variant={ModalVariant.small}
|
||||
title={t("addMessageBundle")}
|
||||
title={t("AddTranslation")}
|
||||
isOpen
|
||||
onClose={handleModalToggle}
|
||||
actions={[
|
||||
<Button
|
||||
data-testid="add-bundle-confirm-button"
|
||||
data-testid="add-translation-confirm-button"
|
||||
key="confirm"
|
||||
variant="primary"
|
||||
type="submit"
|
||||
form="bundle-form"
|
||||
form="translation-form"
|
||||
>
|
||||
{t("create")}
|
||||
</Button>,
|
||||
|
@ -66,7 +66,7 @@ export const AddMessageBundleModal = ({
|
|||
</Button>,
|
||||
]}
|
||||
>
|
||||
<Form id="bundle-form" isHorizontal onSubmit={handleSubmit(save)}>
|
||||
<Form id="translation-form" isHorizontal onSubmit={handleSubmit(save)}>
|
||||
<FormGroup
|
||||
label={t("key")}
|
||||
name="key"
|
|
@ -50,7 +50,7 @@ import { useRealm } from "../../context/realm-context/RealmContext";
|
|||
import { useWhoAmI } from "../../context/whoami/WhoAmI";
|
||||
import { DEFAULT_LOCALE } from "../../i18n/i18n";
|
||||
import { localeToDisplayName } from "../../util";
|
||||
import { AddMessageBundleModal } from "../AddMessageBundleModal";
|
||||
import { AddTranslationModal } from "../AddTranslationModal";
|
||||
|
||||
type RealmOverridesProps = {
|
||||
internationalizationEnabled: boolean;
|
||||
|
@ -60,10 +60,10 @@ type RealmOverridesProps = {
|
|||
|
||||
type EditStatesType = { [key: number]: boolean };
|
||||
|
||||
export type BundleForm = {
|
||||
export type TranslationForm = {
|
||||
key: string;
|
||||
value: string;
|
||||
messageBundle: KeyValueType;
|
||||
translation: KeyValueType;
|
||||
};
|
||||
|
||||
export enum RowEditAction {
|
||||
|
@ -79,10 +79,9 @@ export const RealmOverrides = ({
|
|||
realm,
|
||||
}: RealmOverridesProps) => {
|
||||
const { t } = useTranslation();
|
||||
const [addMessageBundleModalOpen, setAddMessageBundleModalOpen] =
|
||||
useState(false);
|
||||
const [addTranslationModalOpen, setAddTranslationModalOpen] = useState(false);
|
||||
const [filterDropdownOpen, setFilterDropdownOpen] = useState(false);
|
||||
const [messageBundles, setMessageBundles] = useState<[string, string][]>([]);
|
||||
const [translations, setTranslations] = useState<[string, string][]>([]);
|
||||
const [selectMenuLocale, setSelectMenuLocale] = useState(DEFAULT_LOCALE);
|
||||
const [kebabOpen, setKebabOpen] = useState(false);
|
||||
const { getValues, handleSubmit } = useForm();
|
||||
|
@ -92,7 +91,7 @@ export const RealmOverrides = ({
|
|||
const [max, setMax] = useState(10);
|
||||
const [first, setFirst] = useState(0);
|
||||
const [filter, setFilter] = useState("");
|
||||
const bundleForm = useForm<BundleForm>({ mode: "onChange" });
|
||||
const translationForm = useForm<TranslationForm>({ mode: "onChange" });
|
||||
const { addAlert, addError } = useAlerts();
|
||||
const { realm: currentRealm } = useRealm();
|
||||
const { whoAmI } = useWhoAmI();
|
||||
|
@ -118,14 +117,14 @@ export const RealmOverrides = ({
|
|||
});
|
||||
|
||||
if (filter) {
|
||||
const searchInBundles = (idx: number) => {
|
||||
const searchInTranslations = (idx: number) => {
|
||||
return Object.entries(result).filter((i) =>
|
||||
i[idx].includes(filter),
|
||||
);
|
||||
};
|
||||
|
||||
const filtered = uniqWith(
|
||||
searchInBundles(0).concat(searchInBundles(1)),
|
||||
searchInTranslations(0).concat(searchInTranslations(1)),
|
||||
isEqual,
|
||||
);
|
||||
|
||||
|
@ -138,34 +137,34 @@ export const RealmOverrides = ({
|
|||
}
|
||||
};
|
||||
|
||||
fetchLocalizationTexts().then((bundles) => {
|
||||
setMessageBundles(bundles);
|
||||
fetchLocalizationTexts().then((translations) => {
|
||||
setTranslations(translations);
|
||||
|
||||
const updatedRows: IRow[] = bundles.map(
|
||||
(messageBundle): IRow => ({
|
||||
const updatedRows: IRow[] = translations.map(
|
||||
(translation): IRow => ({
|
||||
rowEditBtnAriaLabel: () =>
|
||||
t("rowEditBtnAriaLabel", {
|
||||
messageBundle: messageBundle[1],
|
||||
translation: translation[1],
|
||||
}),
|
||||
rowSaveBtnAriaLabel: () =>
|
||||
t("rowSaveBtnAriaLabel", {
|
||||
messageBundle: messageBundle[1],
|
||||
translation: translation[1],
|
||||
}),
|
||||
rowCancelBtnAriaLabel: () =>
|
||||
t("rowCancelBtnAriaLabel", {
|
||||
messageBundle: messageBundle[1],
|
||||
translation: translation[1],
|
||||
}),
|
||||
cells: [
|
||||
{
|
||||
title: messageBundle[0],
|
||||
title: translation[0],
|
||||
props: {
|
||||
value: messageBundle[0],
|
||||
value: translation[0],
|
||||
},
|
||||
},
|
||||
{
|
||||
title: messageBundle[1],
|
||||
title: translation[1],
|
||||
props: {
|
||||
value: messageBundle[1],
|
||||
value: translation[1],
|
||||
},
|
||||
},
|
||||
],
|
||||
|
@ -177,7 +176,7 @@ export const RealmOverrides = ({
|
|||
}, [tableKey, first, max, filter]);
|
||||
|
||||
const handleModalToggle = () => {
|
||||
setAddMessageBundleModalOpen(!addMessageBundleModalOpen);
|
||||
setAddTranslationModalOpen(!addTranslationModalOpen);
|
||||
};
|
||||
|
||||
const options = [
|
||||
|
@ -212,11 +211,11 @@ export const RealmOverrides = ({
|
|||
realmName: currentRealm!,
|
||||
});
|
||||
refreshTable();
|
||||
bundleForm.setValue("key", "");
|
||||
bundleForm.setValue("value", "");
|
||||
addAlert(t("addMessageBundleSuccess"), AlertVariant.success);
|
||||
translationForm.setValue("key", "");
|
||||
translationForm.setValue("value", "");
|
||||
addAlert(t("addTranslationSuccess"), AlertVariant.success);
|
||||
} catch (error) {
|
||||
addError(t("addMessageBundleError"), error);
|
||||
addError(t("addTranslationError"), error);
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -243,9 +242,9 @@ export const RealmOverrides = ({
|
|||
setAreAllRowsSelected(false);
|
||||
setSelectedRowKeys([]);
|
||||
refreshTable();
|
||||
addAlert(t("deleteAllMessagesBundleSuccess"), AlertVariant.success);
|
||||
addAlert(t("deleteAllTranslationsSuccess"), AlertVariant.success);
|
||||
} catch (error) {
|
||||
addError("deleteAllMessagesBundleError", error);
|
||||
addError("deleteAllTranslationsError", error);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
@ -306,10 +305,10 @@ export const RealmOverrides = ({
|
|||
value,
|
||||
);
|
||||
|
||||
addAlert(t("updateMessageBundleSuccess"), AlertVariant.success);
|
||||
addAlert(t("updateTranslationSuccess"), AlertVariant.success);
|
||||
setTableRows(newRows);
|
||||
} catch (error) {
|
||||
addAlert(t("updateMessageBundleError"), AlertVariant.danger);
|
||||
addAlert(t("updateTranslationError"), AlertVariant.danger);
|
||||
}
|
||||
|
||||
setEditStates((prevEditStates) => ({
|
||||
|
@ -321,14 +320,14 @@ export const RealmOverrides = ({
|
|||
return (
|
||||
<>
|
||||
<DeleteConfirm />
|
||||
{addMessageBundleModalOpen && (
|
||||
<AddMessageBundleModal
|
||||
{addTranslationModalOpen && (
|
||||
<AddTranslationModal
|
||||
handleModalToggle={handleModalToggle}
|
||||
save={(pair: any) => {
|
||||
addKeyValue(pair);
|
||||
handleModalToggle();
|
||||
}}
|
||||
form={bundleForm}
|
||||
form={translationForm}
|
||||
/>
|
||||
)}
|
||||
<TextContent>
|
||||
|
@ -337,7 +336,7 @@ export const RealmOverrides = ({
|
|||
</Text>
|
||||
</TextContent>
|
||||
<PaginatingTableToolbar
|
||||
count={messageBundles.length}
|
||||
count={translations.length}
|
||||
first={first}
|
||||
max={max}
|
||||
onNextClick={setFirst}
|
||||
|
@ -357,7 +356,11 @@ export const RealmOverrides = ({
|
|||
<>
|
||||
<Button
|
||||
data-testid="add-translationBtn"
|
||||
onClick={() => setAddMessageBundleModalOpen(true)}
|
||||
onClick={() => {
|
||||
setAddTranslationModalOpen(true);
|
||||
setAreAllRowsSelected(false);
|
||||
setSelectedRowKeys([]);
|
||||
}}
|
||||
>
|
||||
{t("addTranslation")}
|
||||
</Button>
|
||||
|
@ -373,10 +376,9 @@ export const RealmOverrides = ({
|
|||
<DropdownItem
|
||||
key="action"
|
||||
component="button"
|
||||
data-testid="delete-selected-bundleBtn"
|
||||
data-testid="delete-selected-TranslationBtn"
|
||||
isDisabled={
|
||||
messageBundles.length === 0 ||
|
||||
selectedRowKeys.length === 0
|
||||
translations.length === 0 || selectedRowKeys.length === 0
|
||||
}
|
||||
onClick={() => {
|
||||
toggleDeleteDialog();
|
||||
|
@ -418,7 +420,7 @@ export const RealmOverrides = ({
|
|||
</ToolbarItem>
|
||||
}
|
||||
>
|
||||
{messageBundles.length === 0 && !filter && (
|
||||
{translations.length === 0 && !filter && (
|
||||
<ListEmptyState
|
||||
hasIcon
|
||||
message={t("noTranslations")}
|
||||
|
@ -426,7 +428,7 @@ export const RealmOverrides = ({
|
|||
onPrimaryAction={handleModalToggle}
|
||||
/>
|
||||
)}
|
||||
{messageBundles.length === 0 && filter && (
|
||||
{translations.length === 0 && filter && (
|
||||
<ListEmptyState
|
||||
hasIcon
|
||||
icon={SearchIcon}
|
||||
|
@ -435,7 +437,7 @@ export const RealmOverrides = ({
|
|||
instructions={t("noRealmOverridesSearchResultsInstructions")}
|
||||
/>
|
||||
)}
|
||||
{messageBundles.length !== 0 && (
|
||||
{translations.length !== 0 && (
|
||||
<Table
|
||||
aria-label={t("editableRowsTable")}
|
||||
data-testid="editable-rows-table"
|
||||
|
@ -483,13 +485,13 @@ export const RealmOverrides = ({
|
|||
>
|
||||
<Form
|
||||
isHorizontal
|
||||
className="kc-form-bundleValue"
|
||||
className="kc-form-translationValue"
|
||||
onSubmit={handleSubmit(() => {
|
||||
onSubmit(formValue, rowIndex);
|
||||
})}
|
||||
>
|
||||
<FormGroup
|
||||
fieldId="kc-bundleValue"
|
||||
fieldId="kc-translationValue"
|
||||
className="pf-u-display-inline-block"
|
||||
>
|
||||
{editStates[rowIndex] ? (
|
||||
|
@ -567,7 +569,7 @@ export const RealmOverrides = ({
|
|||
setSelectedRowKeys([
|
||||
(row.cells?.[0] as IRowCell).props.value,
|
||||
]);
|
||||
messageBundles.length === 1 &&
|
||||
translations.length === 1 &&
|
||||
setAreAllRowsSelected(true);
|
||||
toggleDeleteDialog();
|
||||
setKebabOpen(false);
|
||||
|
|
Loading…
Reference in a new issue