From aeb42e29c3ba93bb46b1485c1dc16429b0c13945 Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Wed, 5 Jun 2024 09:21:08 +0100 Subject: [PATCH 1/7] added translations refresh Signed-off-by: Agnieszka Gancarczyk --- js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx | 2 ++ .../src/realm-settings/localization/RealmOverrides.tsx | 4 +++- .../src/realm-settings/user-profile/AttributesGroupForm.tsx | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx b/js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx index f906af097c09..97ac03ae029c 100644 --- a/js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx +++ b/js/apps/admin-ui/src/realm-settings/NewAttributeSettings.tsx @@ -31,6 +31,7 @@ import { AttributeAnnotations } from "./user-profile/attribute/AttributeAnnotati import { AttributeGeneralSettings } from "./user-profile/attribute/AttributeGeneralSettings"; import { AttributePermission } from "./user-profile/attribute/AttributePermission"; import { AttributeValidations } from "./user-profile/attribute/AttributeValidations"; +import { i18n } from "../i18n/i18n"; type TranslationForm = { locale: string; @@ -394,6 +395,7 @@ export default function NewAttributeSettings() { }); await saveTranslations(); + i18n.reloadResources(); navigate(toUserProfile({ realm: realmName, tab: "attributes" })); addAlert(t("createAttributeSuccess"), AlertVariant.success); diff --git a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx index b9cde01c58c2..aa805e8d6c24 100644 --- a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx +++ b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx @@ -49,7 +49,7 @@ import { ListEmptyState } from "../../components/list-empty-state/ListEmptyState import { PaginatingTableToolbar } from "../../components/table-toolbar/PaginatingTableToolbar"; import { useRealm } from "../../context/realm-context/RealmContext"; import { useWhoAmI } from "../../context/whoami/WhoAmI"; -import { DEFAULT_LOCALE } from "../../i18n/i18n"; +import { DEFAULT_LOCALE, i18n } from "../../i18n/i18n"; import { localeToDisplayName } from "../../util"; import { AddTranslationModal } from "../AddTranslationModal"; @@ -247,6 +247,7 @@ export const RealmOverrides = ({ setAreAllRowsSelected(false); setSelectedRowKeys([]); refreshTable(); + addAlert(t("deleteAllTranslationsSuccess"), AlertVariant.success); } catch (error) { addError("deleteAllTranslationsError", error); @@ -309,6 +310,7 @@ export const RealmOverrides = ({ }, value, ); + i18n.reloadResources(); addAlert(t("updateTranslationSuccess"), AlertVariant.success); setTableRows(newRows); diff --git a/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx b/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx index 14aaf3e87f20..3581e6a41a13 100644 --- a/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx +++ b/js/apps/admin-ui/src/realm-settings/user-profile/AttributesGroupForm.tsx @@ -40,6 +40,7 @@ import { AddTranslationsDialog, TranslationsType, } from "./attribute/AddTranslationsDialog"; +import { i18n } from "../../i18n/i18n"; function parseAnnotations(input: Record): KeyValueType[] { return Object.entries(input).reduce((p, [key, value]) => { @@ -346,6 +347,7 @@ export default function AttributesGroupForm() { if (success) { await saveTranslations(); + i18n.reloadResources(); navigate(toUserProfile({ realm: realmName, tab: "attributes-group" })); } }; From 159818d631e6ab2069d4427de6033f1d2a7a5bdd Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Wed, 5 Jun 2024 11:59:47 +0100 Subject: [PATCH 2/7] added translation refresh on adding new translation from realm overrides Signed-off-by: Agnieszka Gancarczyk --- .../admin-ui/src/realm-settings/localization/RealmOverrides.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx index aa805e8d6c24..30c4d4dcaa15 100644 --- a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx +++ b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx @@ -218,6 +218,8 @@ export const RealmOverrides = ({ refreshTable(); translationForm.setValue("key", ""); translationForm.setValue("value", ""); + i18n.reloadResources(); + addAlert(t("addTranslationSuccess"), AlertVariant.success); } catch (error) { addError(t("addTranslationError"), error); From 641733e20173bf0098979dd8f7a6ec9b43a11fd8 Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Wed, 5 Jun 2024 16:50:14 +0100 Subject: [PATCH 3/7] added translation refresh on deleting translations from realm overrides Signed-off-by: Agnieszka Gancarczyk --- .../localization/RealmOverrides.tsx | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx index 30c4d4dcaa15..845e96bad1fd 100644 --- a/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx +++ b/js/apps/admin-ui/src/realm-settings/localization/RealmOverrides.tsx @@ -240,11 +240,17 @@ export const RealmOverrides = ({ onConfirm: async () => { try { for (const key of selectedRowKeys) { - await adminClient.realms.deleteRealmLocalizationTexts({ - realm: currentRealm!, - selectedLocale: selectMenuLocale, - key: key, - }); + delete ( + i18n.store.data[whoAmI.getLocale()]["translation"] as Record< + string, + string + > + )[key], + await adminClient.realms.deleteRealmLocalizationTexts({ + realm: currentRealm!, + selectedLocale: selectMenuLocale, + key: key, + }); } setAreAllRowsSelected(false); setSelectedRowKeys([]); From cd27dadfd05b50a4bf3ae5640a4c28eb1201239d Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Thu, 13 Jun 2024 14:16:12 +0100 Subject: [PATCH 4/7] fixed test Signed-off-by: Agnieszka Gancarczyk --- .../cypress/e2e/partial_import_test.spec.ts | 14 +++---------- .../partial-import-test-data/client-only.json | 21 +++++++++---------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts index 2ad43ee0c8f8..3df84470223b 100644 --- a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts @@ -21,18 +21,10 @@ describe("Partial import test", () => { realmSettings.clickActionMenu(); }); - before(() => - Promise.all([ - adminClient.createRealm(TEST_REALM), - adminClient.createRealm(TEST_REALM_2), - ]), - ); + before(() => Promise.all([adminClient.createRealm(TEST_REALM), adminClient.createRealm(TEST_REALM_2)])); after(async () => { - await Promise.all([ - adminClient.deleteRealm(TEST_REALM), - adminClient.deleteRealm(TEST_REALM_2), - ]); + await Promise.all([adminClient.deleteRealm(TEST_REALM), adminClient.deleteRealm(TEST_REALM_2)]); }); it("Opens and closes partial import dialog", () => { @@ -110,7 +102,7 @@ describe("Partial import test", () => { modal.importButton().click(); cy.contains("One record added"); - cy.contains("customer-portal"); + cy.contains("customer-portal3"); modal.closeButton().click(); }); diff --git a/js/apps/admin-ui/cypress/fixtures/partial-import-test-data/client-only.json b/js/apps/admin-ui/cypress/fixtures/partial-import-test-data/client-only.json index fa7b64ad8bdc..b051e3a1fae1 100644 --- a/js/apps/admin-ui/cypress/fixtures/partial-import-test-data/client-only.json +++ b/js/apps/admin-ui/cypress/fixtures/partial-import-test-data/client-only.json @@ -1,13 +1,12 @@ { - "clients": [ - { - "clientId": "customer-portal", - "enabled": true, - "adminUrl": "/customer-portal", - "baseUrl": "/customer-portal", - "redirectUris": [ - "/customer-portal/*" - ], - "secret": "password" - }] + "clients": [ + { + "clientId": "customer-portal3", + "enabled": true, + "adminUrl": "/customer-portal", + "baseUrl": "/customer-portal", + "redirectUris": ["/customer-portal/*"], + "secret": "password" + } + ] } From 9c330aad7624d14b2704c6a8f01a6b4f8963ee29 Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Thu, 13 Jun 2024 14:23:04 +0100 Subject: [PATCH 5/7] fixed test Signed-off-by: Agnieszka Gancarczyk --- .../admin-ui/cypress/e2e/partial_import_test.spec.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts index 3df84470223b..0940a8db8c78 100644 --- a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts @@ -21,10 +21,18 @@ describe("Partial import test", () => { realmSettings.clickActionMenu(); }); - before(() => Promise.all([adminClient.createRealm(TEST_REALM), adminClient.createRealm(TEST_REALM_2)])); + before(() => + Promise.all([ + adminClient.createRealm(TEST_REALM), + adminClient.createRealm(TEST_REALM_2), + ]), + ); after(async () => { - await Promise.all([adminClient.deleteRealm(TEST_REALM), adminClient.deleteRealm(TEST_REALM_2)]); + await Promise.all([ + adminClient.deleteRealm(TEST_REALM), + adminClient.deleteRealm(TEST_REALM_2), + ]); }); it("Opens and closes partial import dialog", () => { From bf1636039adf4d4ff528363a26c922c184c037af Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Mon, 17 Jun 2024 21:14:12 +0100 Subject: [PATCH 6/7] fixed test Signed-off-by: Agnieszka Gancarczyk --- .../cypress/e2e/partial_import_test.spec.ts | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts index 0940a8db8c78..7218e38b02a4 100644 --- a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts @@ -21,18 +21,10 @@ describe("Partial import test", () => { realmSettings.clickActionMenu(); }); - before(() => - Promise.all([ - adminClient.createRealm(TEST_REALM), - adminClient.createRealm(TEST_REALM_2), - ]), - ); + before(() => Promise.all([adminClient.createRealm(TEST_REALM), adminClient.createRealm(TEST_REALM_2)])); after(async () => { - await Promise.all([ - adminClient.deleteRealm(TEST_REALM), - adminClient.deleteRealm(TEST_REALM_2), - ]); + await Promise.all([adminClient.deleteRealm(TEST_REALM), adminClient.deleteRealm(TEST_REALM_2)]); }); it("Opens and closes partial import dialog", () => { @@ -119,8 +111,9 @@ describe("Partial import test", () => { //clear button should be disabled if there is nothing in the dialog modal.clearButton().should("be.disabled"); - modal.textArea().type("test", { force: true }); - modal.textArea().get(".view-lines").should("have.text", "test"); + modal.textArea().get(".view-lines").should("have.text", ""); + modal.textArea().type("{}", { force: true }); + modal.textArea().get(".view-lines").should("have.text", "{}"); modal.clearButton().should("not.be.disabled"); modal.clearButton().click(); modal.clickClearConfirmButton(); From 8d795984fb741224a08ac69d994e3ca359f57c58 Mon Sep 17 00:00:00 2001 From: Agnieszka Gancarczyk Date: Mon, 17 Jun 2024 21:26:33 +0100 Subject: [PATCH 7/7] fixed test Signed-off-by: Agnieszka Gancarczyk --- .../admin-ui/cypress/e2e/partial_import_test.spec.ts | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts index 7218e38b02a4..ad3871a4e6a6 100644 --- a/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts +++ b/js/apps/admin-ui/cypress/e2e/partial_import_test.spec.ts @@ -21,10 +21,18 @@ describe("Partial import test", () => { realmSettings.clickActionMenu(); }); - before(() => Promise.all([adminClient.createRealm(TEST_REALM), adminClient.createRealm(TEST_REALM_2)])); + before(() => + Promise.all([ + adminClient.createRealm(TEST_REALM), + adminClient.createRealm(TEST_REALM_2), + ]), + ); after(async () => { - await Promise.all([adminClient.deleteRealm(TEST_REALM), adminClient.deleteRealm(TEST_REALM_2)]); + await Promise.all([ + adminClient.deleteRealm(TEST_REALM), + adminClient.deleteRealm(TEST_REALM_2), + ]); }); it("Opens and closes partial import dialog", () => {