From 4b150993a6ab3b72b21321f4ab663740f613d89a Mon Sep 17 00:00:00 2001 From: Erik Jan de Wit Date: Tue, 5 Apr 2022 17:02:27 +0200 Subject: [PATCH] Fixed text of empty state (#2295) --- .../integration/client_scopes_test.spec.ts | 2 +- cypress/integration/clients_test.spec.ts | 2 +- .../admin_console/manage/RoleMappingTab.ts | 10 ++++++++-- src/client-scopes/messages.ts | 5 +++++ src/clients/messages.ts | 5 ----- src/common-messages.ts | 7 +++++++ .../role-mapping/AddRoleMappingModal.tsx | 4 ++-- src/components/role-mapping/RoleMapping.tsx | 20 +++++++++---------- src/realm-roles/AssociatedRolesTab.tsx | 2 +- src/user/messages.ts | 3 +++ 10 files changed, 38 insertions(+), 22 deletions(-) diff --git a/cypress/integration/client_scopes_test.spec.ts b/cypress/integration/client_scopes_test.spec.ts index cd23c05504..165624fd68 100644 --- a/cypress/integration/client_scopes_test.spec.ts +++ b/cypress/integration/client_scopes_test.spec.ts @@ -316,7 +316,7 @@ describe("Client Scopes test", () => { }); describe("Scope test", () => { - const scopeTab = new RoleMappingTab(); + const scopeTab = new RoleMappingTab("client-scope"); const scopeName = "address"; it("Assign role", () => { const role = "admin"; diff --git a/cypress/integration/clients_test.spec.ts b/cypress/integration/clients_test.spec.ts index f48ac01ba2..f6b9619ec2 100644 --- a/cypress/integration/clients_test.spec.ts +++ b/cypress/integration/clients_test.spec.ts @@ -637,7 +637,7 @@ describe("Clients test", () => { }); describe("Service account tab test", () => { - const serviceAccountTab = new RoleMappingTab(); + const serviceAccountTab = new RoleMappingTab("user"); const serviceAccountName = "service-account-client"; before(() => { diff --git a/cypress/support/pages/admin_console/manage/RoleMappingTab.ts b/cypress/support/pages/admin_console/manage/RoleMappingTab.ts index ef337b980b..7474a714a8 100644 --- a/cypress/support/pages/admin_console/manage/RoleMappingTab.ts +++ b/cypress/support/pages/admin_console/manage/RoleMappingTab.ts @@ -1,8 +1,10 @@ const expect = chai.expect; export default class RoleMappingTab { + private type = "client"; private tab = "serviceAccountTab"; private scopeTab = "scopeTab"; - private assignEmptyRoleBtn = "no-roles-for-this-client-empty-action"; + private assignEmptyRoleBtn = (type: string) => + `no-roles-for-this-${type}-empty-action`; private assignRoleBtn = "assignRole"; private unAssignBtn = "unAssignRole"; private assignBtn = "assign"; @@ -10,6 +12,10 @@ export default class RoleMappingTab { private assignedRolesTable = "assigned-roles"; private namesColumn = 'td[data-label="Name"]:visible'; + constructor(type: string) { + this.type = type; + } + goToServiceAccountTab() { cy.findByTestId(this.tab).click(); return this; @@ -22,7 +28,7 @@ export default class RoleMappingTab { assignRole(notEmpty = true) { cy.findByTestId( - notEmpty ? this.assignEmptyRoleBtn : this.assignRoleBtn + notEmpty ? this.assignEmptyRoleBtn(this.type) : this.assignRoleBtn ).click(); return this; } diff --git a/src/client-scopes/messages.ts b/src/client-scopes/messages.ts index 3db4d2410c..6f4a8b2681 100644 --- a/src/client-scopes/messages.ts +++ b/src/client-scopes/messages.ts @@ -58,4 +58,9 @@ export default { "openid-connect": "openid-connect", }, }, + clientScopes: { + noRoles: "No roles for this client scope", + noRolesInstructions: + "You haven't created any roles for this client scope. Create a role to get started.", + }, }; diff --git a/src/clients/messages.ts b/src/clients/messages.ts index e0071219ae..12f9b7be25 100644 --- a/src/clients/messages.ts +++ b/src/clients/messages.ts @@ -99,8 +99,6 @@ export default { password: "Password", oneTimePassword: "One-Time Password", kerberos: "Kerberos", - assignRole: "Assign role", - unAssignRole: "Unassign", removeMappingTitle: "Remove mapping?", removeMappingConfirm_one: "Are you sure you want to remove this mapping?", removeMappingConfirm_other: @@ -265,8 +263,6 @@ export default { policySaveError: "Could not update the policy due to {{error}}", assignedClientScope: "Assigned client scope", assignedType: "Assigned type", - hideInheritedRoles: "Hide inherited roles", - inherentFrom: "Inherited from", emptyClientScopes: "This client doesn't have any added client scopes", emptyClientScopesInstructions: "There are currently no client scopes linked to this client. You can add existing client scopes to this client to share protocol mappers and roles.", @@ -355,7 +351,6 @@ export default { oauthDeviceAuthorizationGrant: "OAuth 2.0 Device Authorization Grant", oidcCibaGrant: "OIDC CIBA Grant", enableServiceAccount: "Enable service account roles", - assignRolesTo: "Assign roles to {{client}} account", searchByRoleName: "Search by role name", filterByOrigin: "Filter by Origin", realmRoles: "Realm roles", diff --git a/src/common-messages.ts b/src/common-messages.ts index 90426852f7..6fe8d03b3e 100644 --- a/src/common-messages.ts +++ b/src/common-messages.ts @@ -115,6 +115,13 @@ export default { Friday: "Friday", Saturday: "Saturday", + assignRole: "Assign role", + assign: "Assign", + unAssignRole: "Unassign", + hideInheritedRoles: "Hide inherited roles", + assignRolesTo: "Assign roles to {{client}} account", + inherentFrom: "Inherited from", + unitLabel: "Select a time unit", times: { seconds: "Seconds", diff --git a/src/components/role-mapping/AddRoleMappingModal.tsx b/src/components/role-mapping/AddRoleMappingModal.tsx index 23131b823c..ce896fd215 100644 --- a/src/components/role-mapping/AddRoleMappingModal.tsx +++ b/src/components/role-mapping/AddRoleMappingModal.tsx @@ -55,7 +55,7 @@ export const AddRoleMappingModal = ({ onAssign, onClose, }: AddRoleMappingModalProps) => { - const { t } = useTranslation("clients"); + const { t } = useTranslation("common"); const adminClient = useAdminClient(); const [clients, setClients] = useState([]); @@ -228,7 +228,7 @@ export const AddRoleMappingModal = ({ hasInlineFilter placeholderText={ <> - {t("filterByOrigin")} + {t("clients:filterByOrigin")} } isGrouped diff --git a/src/components/role-mapping/RoleMapping.tsx b/src/components/role-mapping/RoleMapping.tsx index 1da91f33ca..b85916e227 100644 --- a/src/components/role-mapping/RoleMapping.tsx +++ b/src/components/role-mapping/RoleMapping.tsx @@ -168,7 +168,7 @@ export const RoleMapping = ({ save, onHideRolesToggle, }: RoleMappingProps) => { - const { t } = useTranslation("clients"); + const { t } = useTranslation(type); const adminClient = useAdminClient(); const { addAlert, addError } = useAlerts(); @@ -186,7 +186,7 @@ export const RoleMapping = ({ const [toggleDeleteDialog, DeleteConfirm] = useConfirmDialog({ titleKey: "clients:removeMappingTitle", - messageKey: t("removeMappingConfirm", { count: selected.length }), + messageKey: t("clients:removeMappingConfirm", { count: selected.length }), continueButtonLabel: "common:remove", continueButtonVariant: ButtonVariant.danger, onConfirm: async () => { @@ -243,7 +243,7 @@ export const RoleMapping = ({ <> { @@ -258,7 +258,7 @@ export const RoleMapping = ({ data-testid="assignRole" onClick={() => setShowAssign(true)} > - {t("assignRole")} + {t("common:assignRole")} @@ -268,14 +268,14 @@ export const RoleMapping = ({ onClick={toggleDeleteDialog} isDisabled={selected.length === 0} > - {t("unAssignRole")} + {t("common:unAssignRole")} } actions={[ { - title: t("unAssignRole"), + title: t("common:unAssignRole"), onRowClick: async (role) => { setSelected([role]); toggleDeleteDialog(); @@ -286,17 +286,17 @@ export const RoleMapping = ({ columns={[ { name: "role.name", - displayKey: t("name"), + displayKey: t("common:name"), cellRenderer: ServiceRole, }, { name: "role.parent.name", - displayKey: t("inherentFrom"), + displayKey: t("common:inherentFrom"), cellFormatters: [emptyFormatter()], }, { name: "role.description", - displayKey: t("description"), + displayKey: t("common:description"), cellFormatters: [emptyFormatter()], }, ]} @@ -304,7 +304,7 @@ export const RoleMapping = ({ setShowAssign(true)} /> } diff --git a/src/realm-roles/AssociatedRolesTab.tsx b/src/realm-roles/AssociatedRolesTab.tsx index 9f0fd4cc87..bcc509c6dd 100644 --- a/src/realm-roles/AssociatedRolesTab.tsx +++ b/src/realm-roles/AssociatedRolesTab.tsx @@ -310,7 +310,7 @@ export const AssociatedRolesTab = ({ ]} emptyState={