From eed8ff41542ace3fb83d15e3807097cadb1e1d01 Mon Sep 17 00:00:00 2001 From: Wojtek Wajerowicz <115081248+wojciech-wajerowicz-sonarsource@users.noreply.github.com> Date: Tue, 30 Jan 2024 10:57:53 +0100 Subject: [PATCH] SONAR-21163 Rename isBaseRole to baseRole in GitHub permission mapping endpoints to comply with Web API guidelines --- .../js/api/mocks/GithubProvisioningServiceMock.ts | 4 ++-- .../authentication/GitHubMappingModal.tsx | 14 ++++++-------- .../main/js/queries/identity-provider/github.ts | 2 +- server/sonar-web/src/main/js/types/provisioning.ts | 2 +- 4 files changed, 10 insertions(+), 12 deletions(-) diff --git a/server/sonar-web/src/main/js/api/mocks/GithubProvisioningServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/GithubProvisioningServiceMock.ts index 32e22935de3..afcd5fe884a 100644 --- a/server/sonar-web/src/main/js/api/mocks/GithubProvisioningServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/GithubProvisioningServiceMock.ts @@ -63,11 +63,11 @@ const defaultConfigurationStatus: GitHubConfigurationStatus = { const githubMappingMock = ( id: string, permissions: (keyof GitHubMapping['permissions'])[], - isBaseRole = false, + baseRole = false, ) => ({ id, githubRole: id, - isBaseRole, + baseRole, permissions: { user: permissions.includes('user'), codeViewer: permissions.includes('codeViewer'), diff --git a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubMappingModal.tsx b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubMappingModal.tsx index 6d2fca0333a..6291b5d9410 100644 --- a/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubMappingModal.tsx +++ b/server/sonar-web/src/main/js/apps/settings/components/authentication/GitHubMappingModal.tsx @@ -72,12 +72,12 @@ function PermissionRow(props: Readonly) {
{mapping.githubRole} - {!mapping.isBaseRole && ( + {!mapping.baseRole && ( - el.isBaseRole - ? el.githubRole.toLowerCase() === value.toLowerCase() - : el.githubRole === value, + el.baseRole ? el.githubRole.toLowerCase() === value.toLowerCase() : el.githubRole === value, ) ) { setMapping([ @@ -153,7 +151,7 @@ export default function GitHubMappingModal({ mapping, setMapping, onClose }: Rea }; const haveEmptyCustomRoles = !!mapping?.some( - (el) => !el.isBaseRole && !Object.values(el.permissions).some(Boolean), + (el) => !el.baseRole && !Object.values(el.permissions).some(Boolean), ); const formBody = ( @@ -179,7 +177,7 @@ export default function GitHubMappingModal({ mapping, setMapping, onClose }: Rea } > {list - ?.filter((r) => r.isBaseRole) + ?.filter((r) => r.baseRole) .map((mapping) => ( ))} @@ -226,7 +224,7 @@ export default function GitHubMappingModal({ mapping, setMapping, onClose }: Rea {list - ?.filter((r) => !r.isBaseRole) + ?.filter((r) => !r.baseRole) .map((mapping) => ( ))} diff --git a/server/sonar-web/src/main/js/queries/identity-provider/github.ts b/server/sonar-web/src/main/js/queries/identity-provider/github.ts index 1fba6a530f7..d7b6152ec49 100644 --- a/server/sonar-web/src/main/js/queries/identity-provider/github.ts +++ b/server/sonar-web/src/main/js/queries/identity-provider/github.ts @@ -118,7 +118,7 @@ export function useGithubRolesMappingMutation() { const [maybeChangedRoles, newRoles] = partition(mapping, (m) => state[m.id]); const changedRoles = maybeChangedRoles.filter((item) => !isEqual(item, state[item.id])); const deletedRoles = Object.values(state).filter( - (m) => !m.isBaseRole && !mapping.some((cm) => m.id === cm.id), + (m) => !m.baseRole && !mapping.some((cm) => m.id === cm.id), ); return { diff --git a/server/sonar-web/src/main/js/types/provisioning.ts b/server/sonar-web/src/main/js/types/provisioning.ts index 4b818db08fe..594970d3b43 100644 --- a/server/sonar-web/src/main/js/types/provisioning.ts +++ b/server/sonar-web/src/main/js/types/provisioning.ts @@ -81,7 +81,7 @@ export interface GitHubConfigurationStatus { export interface GitHubMapping { readonly id: string; readonly githubRole: string; - readonly isBaseRole?: boolean; + readonly baseRole?: boolean; permissions: { user: boolean; codeViewer: boolean; -- 2.39.5