From c5ec1baf0f6be6e5d34f17cd873fcf736594d700 Mon Sep 17 00:00:00 2001 From: Jeremy Date: Mon, 6 Jan 2020 16:58:38 +0100 Subject: [PATCH] SONAR-12797 Handle branch parameter SONAR-12719: * Prevent action button text from wrapping * Conditional submit button label --- .../src/main/js/api/security-hotspots.ts | 11 +- .../securityHotspots/SecurityHotspotsApp.tsx | 5 +- .../__tests__/SecurityHotspotsApp-test.tsx | 5 +- .../components/HotspotActions.tsx | 4 +- .../components/HotspotActionsForm.tsx | 15 +- .../components/HotspotActionsFormRenderer.tsx | 12 +- .../__tests__/HotspotActionsForm-test.tsx | 3 +- .../HotspotActionsFormRenderer-test.tsx | 4 +- .../HotspotActions-test.tsx.snap | 307 +++++++++++++++++- .../HotspotActionsForm-test.tsx.snap | 2 +- .../HotspotActionsFormRenderer-test.tsx.snap | 8 +- .../src/main/js/types/security-hotspots.ts | 2 +- .../resources/org/sonar/l10n/core.properties | 3 +- 13 files changed, 345 insertions(+), 36 deletions(-) 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 6f266bb7801..c4518a65d61 100644 --- a/server/sonar-web/src/main/js/api/security-hotspots.ts +++ b/server/sonar-web/src/main/js/api/security-hotspots.ts @@ -59,8 +59,15 @@ export function getSecurityHotspots( return getJSON('/api/hotspots/search', data).catch(throwGlobalError); } -export function getSecurityHotspotList(hotspotKeys: string[]): Promise { - return getJSON('/api/hotspots/search', { hotspots: hotspotKeys.join() }).catch(throwGlobalError); +export function getSecurityHotspotList( + hotspotKeys: string[], + data: { + projectKey: string; + } & BranchParameters +): Promise { + return getJSON('/api/hotspots/search', { ...data, hotspots: hotspotKeys.join() }).catch( + throwGlobalError + ); } export function getSecurityHotspotDetails(securityHotspotKey: string): Promise { diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx index 0060c223e4a..1e8f7221f4a 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/SecurityHotspotsApp.tsx @@ -157,7 +157,10 @@ export class SecurityHotspotsApp extends React.PureComponent { this.setState({ hotspotKeys }); if (hotspotKeys && hotspotKeys.length > 0) { - return getSecurityHotspotList(hotspotKeys); + return getSecurityHotspotList(hotspotKeys, { + projectKey: component.key, + ...getBranchLikeQuery(branchLike) + }); } const status = diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx index eed79943cbb..15315cd7c8f 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/__tests__/SecurityHotspotsApp-test.tsx @@ -113,7 +113,10 @@ it('should load data correctly when hotspot key list is forced', async () => { }); await waitAndUpdate(wrapper); - expect(getSecurityHotspotList).toBeCalledWith(hotspotKeys); + expect(getSecurityHotspotList).toBeCalledWith(hotspotKeys, { + projectKey: 'my-project', + branch: 'branch-6.7' + }); expect(wrapper.state().hotspotKeys).toEqual(hotspotKeys); expect(wrapper.find(SecurityHotspotsAppRenderer).props().isStaticListOfHotspots).toBeTruthy(); diff --git a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx index bca775c9ad7..87cff37e935 100644 --- a/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx +++ b/server/sonar-web/src/main/js/apps/securityHotspots/components/HotspotActions.tsx @@ -53,7 +53,7 @@ export default function HotspotActions(props: HotspotActionsProps) { }); return ( -
+