From f711ef2f80d01bfa7852c7e44d06cac2b698d67a Mon Sep 17 00:00:00 2001 From: "ilya.rudyi" Date: Tue, 15 Aug 2023 14:47:40 +0300 Subject: [PATCH 1/5] fix edit user modal was not opening in admin --- react/components/OrganizationUsersTable.tsx | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/react/components/OrganizationUsersTable.tsx b/react/components/OrganizationUsersTable.tsx index 2f8f3742..2da4e7a5 100644 --- a/react/components/OrganizationUsersTable.tsx +++ b/react/components/OrganizationUsersTable.tsx @@ -567,7 +567,20 @@ const OrganizationUsersTable: FunctionComponent = ({ ) { // eslint-disable-next-line no-useless-return return - } + } else { + setEditUserDetails({ + id: rowData.id, + roleId: rowData.roleId, + userId: rowData.userId, + clId: rowData.clId, + orgId: rowData.orgId, + costId: rowData.costId, + name: rowData.name, + email: rowData.email, + canImpersonate: rowData.canImpersonate, + }) + setEditUserModalOpen(true) + } } const handleSort = ({ From 953fd88e631a319a3bc8323ec9cfd1d436b320f6 Mon Sep 17 00:00:00 2001 From: "ilya.rudyi" Date: Tue, 15 Aug 2023 14:52:35 +0300 Subject: [PATCH 2/5] update changelog --- CHANGELOG.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2423f10e..6ce601f4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Fix + +- `EditUserModal` was not opening in the admin + ### Added - Add condition to use the `manage-organization` permission From d656fe2751c8284fdde1628875970b511eb03cfd Mon Sep 17 00:00:00 2001 From: "ilya.rudyi" Date: Tue, 15 Aug 2023 18:13:48 +0300 Subject: [PATCH 3/5] handle click update --- react/components/OrganizationUsersTable.tsx | 37 ++++++--------------- 1 file changed, 10 insertions(+), 27 deletions(-) diff --git a/react/components/OrganizationUsersTable.tsx b/react/components/OrganizationUsersTable.tsx index bd1525e6..dd209d49 100644 --- a/react/components/OrganizationUsersTable.tsx +++ b/react/components/OrganizationUsersTable.tsx @@ -550,32 +550,16 @@ const OrganizationUsersTable: FunctionComponent = ({ } const handleRowClick = ({ rowData }: CellRendererProps) => { - if (canManageOrganization) { - setEditUserDetails({ - id: rowData.id, - roleId: rowData.roleId, - userId: rowData.userId, - clId: rowData.clId, - orgId: rowData.orgId, - costId: rowData.costId, - name: rowData.name, - email: rowData.email, - canImpersonate: rowData.canImpersonate, - }) - setEditUserModalOpen(true) - } else if ( - !ruleClickEnabled({ - isAdmin, - canEditSales, - slug: rowData.role?.slug ?? '', - canEdit, - isSalesAdmin, - }) - ) { - // eslint-disable-next-line no-useless-return - return - } else { - setEditUserDetails({ + const canClick = canManageOrganization || ruleClickEnabled({ + isAdmin, + canEditSales, + slug: rowData.role?.slug ?? '', + canEdit, + isSalesAdmin, + }) + if (!canClick) return + + setEditUserDetails({ id: rowData.id, roleId: rowData.roleId, userId: rowData.userId, @@ -588,7 +572,6 @@ const OrganizationUsersTable: FunctionComponent = ({ }) setEditUserModalOpen(true) } - } const handleSort = ({ sortOrder: _sortOrder, From c3db74c1573f3884913999122795c110a804a7a1 Mon Sep 17 00:00:00 2001 From: "ilya.rudyi" Date: Wed, 16 Aug 2023 18:21:07 +0300 Subject: [PATCH 4/5] fix prettier issues --- react/components/OrganizationUsersTable.tsx | 27 ++++++++++++--------- 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/react/components/OrganizationUsersTable.tsx b/react/components/OrganizationUsersTable.tsx index dd209d49..67ed8584 100644 --- a/react/components/OrganizationUsersTable.tsx +++ b/react/components/OrganizationUsersTable.tsx @@ -212,7 +212,7 @@ const OrganizationUsersTable: FunctionComponent = ({ }, 2000) } ) - .catch(error => { + .catch((error) => { console.error(error) contextualToast( formatMessage( @@ -267,7 +267,7 @@ const OrganizationUsersTable: FunctionComponent = ({ }, 2000) } ) - .catch(error => { + .catch((error) => { console.error(error) contextualToast( formatMessage( @@ -313,7 +313,7 @@ const OrganizationUsersTable: FunctionComponent = ({ setRemoveUserLoading(false) refetch() }) - .catch(error => { + .catch((error) => { console.error(error) contextualToast( formatMessage( @@ -367,7 +367,7 @@ const OrganizationUsersTable: FunctionComponent = ({ impersonateUser({ variables: { id: rowData.id }, }) - .then(result => { + .then((result) => { if (result?.data?.impersonateB2BUser?.status === 'error') { console.error( 'Impersonation error:', @@ -390,7 +390,7 @@ const OrganizationUsersTable: FunctionComponent = ({ window.location.reload() } }) - .catch(error => { + .catch((error) => { console.error(error) showToast(formatMessage(storeMessages.toastImpersonateFailure)) }) @@ -550,13 +550,16 @@ const OrganizationUsersTable: FunctionComponent = ({ } const handleRowClick = ({ rowData }: CellRendererProps) => { - const canClick = canManageOrganization || ruleClickEnabled({ - isAdmin, - canEditSales, - slug: rowData.role?.slug ?? '', - canEdit, - isSalesAdmin, - }) + const canClick = + canManageOrganization || + ruleClickEnabled({ + isAdmin, + canEditSales, + slug: rowData.role?.slug ?? '', + canEdit, + isSalesAdmin, + }) + if (!canClick) return setEditUserDetails({ From b35ddb8702e7b9acbec223916e382944858ac37b Mon Sep 17 00:00:00 2001 From: "ilya.rudyi" Date: Thu, 17 Aug 2023 10:45:33 +0300 Subject: [PATCH 5/5] fix prettier-2 --- react/components/OrganizationUsersTable.tsx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/react/components/OrganizationUsersTable.tsx b/react/components/OrganizationUsersTable.tsx index 67ed8584..a45d95a3 100644 --- a/react/components/OrganizationUsersTable.tsx +++ b/react/components/OrganizationUsersTable.tsx @@ -212,7 +212,7 @@ const OrganizationUsersTable: FunctionComponent = ({ }, 2000) } ) - .catch((error) => { + .catch(error => { console.error(error) contextualToast( formatMessage( @@ -267,7 +267,7 @@ const OrganizationUsersTable: FunctionComponent = ({ }, 2000) } ) - .catch((error) => { + .catch(error => { console.error(error) contextualToast( formatMessage( @@ -313,7 +313,7 @@ const OrganizationUsersTable: FunctionComponent = ({ setRemoveUserLoading(false) refetch() }) - .catch((error) => { + .catch(error => { console.error(error) contextualToast( formatMessage( @@ -367,7 +367,7 @@ const OrganizationUsersTable: FunctionComponent = ({ impersonateUser({ variables: { id: rowData.id }, }) - .then((result) => { + .then(result => { if (result?.data?.impersonateB2BUser?.status === 'error') { console.error( 'Impersonation error:', @@ -390,7 +390,7 @@ const OrganizationUsersTable: FunctionComponent = ({ window.location.reload() } }) - .catch((error) => { + .catch(error => { console.error(error) showToast(formatMessage(storeMessages.toastImpersonateFailure)) })