Fixed refreshing translations on user detail's tab (#30199)
* added translations refresh Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * added translation refresh on adding new translation from realm overrides Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * added translation refresh on deleting translations from realm overrides Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * fixed test Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * fixed test Signed-off-by: Agnieszka Gancarczyk <agancarc@redhat.com> * fixed test 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
67098f0469
commit
83af3bc455
5 changed files with 34 additions and 20 deletions
|
@ -110,7 +110,7 @@ describe("Partial import test", () => {
|
||||||
modal.importButton().click();
|
modal.importButton().click();
|
||||||
|
|
||||||
cy.contains("One record added");
|
cy.contains("One record added");
|
||||||
cy.contains("customer-portal");
|
cy.contains("customer-portal3");
|
||||||
modal.closeButton().click();
|
modal.closeButton().click();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -119,8 +119,9 @@ describe("Partial import test", () => {
|
||||||
|
|
||||||
//clear button should be disabled if there is nothing in the dialog
|
//clear button should be disabled if there is nothing in the dialog
|
||||||
modal.clearButton().should("be.disabled");
|
modal.clearButton().should("be.disabled");
|
||||||
modal.textArea().type("test", { force: true });
|
modal.textArea().get(".view-lines").should("have.text", "");
|
||||||
modal.textArea().get(".view-lines").should("have.text", "test");
|
modal.textArea().type("{}", { force: true });
|
||||||
|
modal.textArea().get(".view-lines").should("have.text", "{}");
|
||||||
modal.clearButton().should("not.be.disabled");
|
modal.clearButton().should("not.be.disabled");
|
||||||
modal.clearButton().click();
|
modal.clearButton().click();
|
||||||
modal.clickClearConfirmButton();
|
modal.clickClearConfirmButton();
|
||||||
|
|
|
@ -1,13 +1,12 @@
|
||||||
{
|
{
|
||||||
"clients": [
|
"clients": [
|
||||||
{
|
{
|
||||||
"clientId": "customer-portal",
|
"clientId": "customer-portal3",
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"adminUrl": "/customer-portal",
|
"adminUrl": "/customer-portal",
|
||||||
"baseUrl": "/customer-portal",
|
"baseUrl": "/customer-portal",
|
||||||
"redirectUris": [
|
"redirectUris": ["/customer-portal/*"],
|
||||||
"/customer-portal/*"
|
|
||||||
],
|
|
||||||
"secret": "password"
|
"secret": "password"
|
||||||
}]
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import { AttributeAnnotations } from "./user-profile/attribute/AttributeAnnotati
|
||||||
import { AttributeGeneralSettings } from "./user-profile/attribute/AttributeGeneralSettings";
|
import { AttributeGeneralSettings } from "./user-profile/attribute/AttributeGeneralSettings";
|
||||||
import { AttributePermission } from "./user-profile/attribute/AttributePermission";
|
import { AttributePermission } from "./user-profile/attribute/AttributePermission";
|
||||||
import { AttributeValidations } from "./user-profile/attribute/AttributeValidations";
|
import { AttributeValidations } from "./user-profile/attribute/AttributeValidations";
|
||||||
|
import { i18n } from "../i18n/i18n";
|
||||||
|
|
||||||
type TranslationForm = {
|
type TranslationForm = {
|
||||||
locale: string;
|
locale: string;
|
||||||
|
@ -394,6 +395,7 @@ export default function NewAttributeSettings() {
|
||||||
});
|
});
|
||||||
|
|
||||||
await saveTranslations();
|
await saveTranslations();
|
||||||
|
i18n.reloadResources();
|
||||||
navigate(toUserProfile({ realm: realmName, tab: "attributes" }));
|
navigate(toUserProfile({ realm: realmName, tab: "attributes" }));
|
||||||
|
|
||||||
addAlert(t("createAttributeSuccess"), AlertVariant.success);
|
addAlert(t("createAttributeSuccess"), AlertVariant.success);
|
||||||
|
|
|
@ -49,7 +49,7 @@ import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState
|
||||||
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
|
import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar";
|
||||||
import { useRealm } from "../../context/realm-context/RealmContext";
|
import { useRealm } from "../../context/realm-context/RealmContext";
|
||||||
import { useWhoAmI } from "../../context/whoami/WhoAmI";
|
import { useWhoAmI } from "../../context/whoami/WhoAmI";
|
||||||
import { DEFAULT_LOCALE } from "../../i18n/i18n";
|
import { DEFAULT_LOCALE, i18n } from "../../i18n/i18n";
|
||||||
import { localeToDisplayName } from "../../util";
|
import { localeToDisplayName } from "../../util";
|
||||||
import { AddTranslationModal } from "../AddTranslationModal";
|
import { AddTranslationModal } from "../AddTranslationModal";
|
||||||
|
|
||||||
|
@ -218,6 +218,8 @@ export const RealmOverrides = ({
|
||||||
refreshTable();
|
refreshTable();
|
||||||
translationForm.setValue("key", "");
|
translationForm.setValue("key", "");
|
||||||
translationForm.setValue("value", "");
|
translationForm.setValue("value", "");
|
||||||
|
i18n.reloadResources();
|
||||||
|
|
||||||
addAlert(t("addTranslationSuccess"), AlertVariant.success);
|
addAlert(t("addTranslationSuccess"), AlertVariant.success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError(t("addTranslationError"), error);
|
addError(t("addTranslationError"), error);
|
||||||
|
@ -238,6 +240,12 @@ export const RealmOverrides = ({
|
||||||
onConfirm: async () => {
|
onConfirm: async () => {
|
||||||
try {
|
try {
|
||||||
for (const key of selectedRowKeys) {
|
for (const key of selectedRowKeys) {
|
||||||
|
delete (
|
||||||
|
i18n.store.data[whoAmI.getLocale()]["translation"] as Record<
|
||||||
|
string,
|
||||||
|
string
|
||||||
|
>
|
||||||
|
)[key],
|
||||||
await adminClient.realms.deleteRealmLocalizationTexts({
|
await adminClient.realms.deleteRealmLocalizationTexts({
|
||||||
realm: currentRealm!,
|
realm: currentRealm!,
|
||||||
selectedLocale: selectMenuLocale,
|
selectedLocale: selectMenuLocale,
|
||||||
|
@ -247,6 +255,7 @@ export const RealmOverrides = ({
|
||||||
setAreAllRowsSelected(false);
|
setAreAllRowsSelected(false);
|
||||||
setSelectedRowKeys([]);
|
setSelectedRowKeys([]);
|
||||||
refreshTable();
|
refreshTable();
|
||||||
|
|
||||||
addAlert(t("deleteAllTranslationsSuccess"), AlertVariant.success);
|
addAlert(t("deleteAllTranslationsSuccess"), AlertVariant.success);
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
addError("deleteAllTranslationsError", error);
|
addError("deleteAllTranslationsError", error);
|
||||||
|
@ -309,6 +318,7 @@ export const RealmOverrides = ({
|
||||||
},
|
},
|
||||||
value,
|
value,
|
||||||
);
|
);
|
||||||
|
i18n.reloadResources();
|
||||||
|
|
||||||
addAlert(t("updateTranslationSuccess"), AlertVariant.success);
|
addAlert(t("updateTranslationSuccess"), AlertVariant.success);
|
||||||
setTableRows(newRows);
|
setTableRows(newRows);
|
||||||
|
|
|
@ -40,6 +40,7 @@ import {
|
||||||
AddTranslationsDialog,
|
AddTranslationsDialog,
|
||||||
TranslationsType,
|
TranslationsType,
|
||||||
} from "./attribute/AddTranslationsDialog";
|
} from "./attribute/AddTranslationsDialog";
|
||||||
|
import { i18n } from "../../i18n/i18n";
|
||||||
|
|
||||||
function parseAnnotations(input: Record<string, unknown>): KeyValueType[] {
|
function parseAnnotations(input: Record<string, unknown>): KeyValueType[] {
|
||||||
return Object.entries(input).reduce((p, [key, value]) => {
|
return Object.entries(input).reduce((p, [key, value]) => {
|
||||||
|
@ -346,6 +347,7 @@ export default function AttributesGroupForm() {
|
||||||
|
|
||||||
if (success) {
|
if (success) {
|
||||||
await saveTranslations();
|
await saveTranslations();
|
||||||
|
i18n.reloadResources();
|
||||||
navigate(toUserProfile({ realm: realmName, tab: "attributes-group" }));
|
navigate(toUserProfile({ realm: realmName, tab: "attributes-group" }));
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Reference in a new issue