From: Kevin Silva Date: Wed, 6 Dec 2023 13:50:11 +0000 (+0100) Subject: SONAR-19974 - Update hotspot search api payload X-Git-Tag: 10.4.0.87286~350 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=e16ff4d2200a32df057d7b8baa682df0190f691e;p=sonarqube.git SONAR-19974 - Update hotspot search api payload --- diff --git a/server/sonar-web/src/main/js/api/mocks/SecurityHotspotServiceMock.ts b/server/sonar-web/src/main/js/api/mocks/SecurityHotspotServiceMock.ts index a71f7271513..70727896309 100644 --- a/server/sonar-web/src/main/js/api/mocks/SecurityHotspotServiceMock.ts +++ b/server/sonar-web/src/main/js/api/mocks/SecurityHotspotServiceMock.ts @@ -134,7 +134,7 @@ export default class SecurityHotspotServiceMock { handleGetSecurityHotspotList = ( hotspotKeys: string[], data: { - projectKey: string; + project: string; branch?: string; }, ) => { @@ -190,7 +190,7 @@ export default class SecurityHotspotServiceMock { }; handleGetSecurityHotspots = (data: { - projectKey: string; + project: string; p: number; ps: number; status?: HotspotStatus; diff --git a/server/sonar-web/src/main/js/api/security-hotspots.ts b/server/sonar-web/src/main/js/api/security-hotspots.ts index 5b481b8460d..635d6f00b75 100644 --- a/server/sonar-web/src/main/js/api/security-hotspots.ts +++ b/server/sonar-web/src/main/js/api/security-hotspots.ts @@ -75,30 +75,28 @@ export function getSecurityHotspots( inNewCodePeriod?: boolean; onlyMine?: boolean; p: number; - projectKey: string; + project: string; ps: number; resolution?: HotspotResolution; status?: HotspotStatus; } & BranchParameters, projectIsIndexing = false, ): Promise { - return getJSON( - projectIsIndexing ? HOTSPOTS_LIST_URL : HOTSPOTS_SEARCH_URL, - projectIsIndexing ? { ...data, project: data.projectKey } : data, - ).catch(throwGlobalError); + return getJSON(projectIsIndexing ? HOTSPOTS_LIST_URL : HOTSPOTS_SEARCH_URL, data).catch( + throwGlobalError, + ); } export function getSecurityHotspotList( hotspotKeys: string[], data: { - projectKey: string; + project: string; } & BranchParameters, projectIsIndexing = false, ): Promise { return getJSON(projectIsIndexing ? HOTSPOTS_LIST_URL : HOTSPOTS_SEARCH_URL, { ...data, hotspots: hotspotKeys.join(), - ...(projectIsIndexing ? { project: data.projectKey } : {}), }).catch(throwGlobalError); } diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx index 52484985071..ceee5a273e1 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/SecurityHotspotsApp.tsx @@ -366,7 +366,7 @@ export class SecurityHotspotsApp extends React.PureComponent { ...hotspotFilters, inNewCodePeriod: filters.inNewCodePeriod && Boolean(filterByFile), // only add new code period when filtering by file p: page, - projectKey: component.key, + project: component.key, ps: PAGE_SIZE, status: HotspotStatus.TO_REVIEW, // we're only interested in unresolved hotspots ...getBranchLikeQuery(branchLike), @@ -401,7 +401,7 @@ export class SecurityHotspotsApp extends React.PureComponent { return getSecurityHotspotList( hotspotKeys, { - projectKey: component.key, + project: component.key, ...getBranchLikeQuery(branchLike), }, component.needIssueSync, @@ -432,7 +432,7 @@ export class SecurityHotspotsApp extends React.PureComponent { inNewCodePeriod: filters.inNewCodePeriod, ...(component.needIssueSync ? {} : { onlyMine: filters.assignedToMe }), p: page, - projectKey: component.key, + project: component.key, ps: PAGE_SIZE, resolution, status, diff --git a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx index 12aeddb6cca..97f5c5bfb6c 100644 --- a/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx +++ b/server/sonar-web/src/main/js/apps/security-hotspots/__tests__/SecurityHotspotsApp-it.tsx @@ -442,7 +442,7 @@ it('should be able to filter the hotspot list', async () => { inNewCodePeriod: false, onlyMine: true, p: 1, - projectKey: 'guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed', + project: 'guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed', ps: 500, resolution: undefined, status: 'TO_REVIEW', @@ -458,7 +458,7 @@ it('should be able to filter the hotspot list', async () => { inNewCodePeriod: true, onlyMine: true, p: 1, - projectKey: 'guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed', + project: 'guillaume-peoch-sonarsource_benflix_AYGpXq2bd8qy4i0eO9ed', ps: 500, resolution: undefined, status: 'TO_REVIEW',