From e5f61c4ab51161d50087f2939044e30719b78bdb Mon Sep 17 00:00:00 2001 From: Wouter Admiraal Date: Fri, 31 May 2019 15:31:54 +0200 Subject: [PATCH] SONAR-12115 Disable delete button if no projects have been selected --- .../src/main/js/apps/projectsManagement/Search.tsx | 11 ++++++++--- .../apps/projectsManagement/__tests__/Search-test.tsx | 10 ++++++++++ .../__tests__/__snapshots__/Search-test.tsx.snap | 10 ++++++---- .../src/main/resources/org/sonar/l10n/core.properties | 2 ++ 4 files changed, 26 insertions(+), 7 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx index 6b040fb0abb..65041f5269b 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx @@ -231,15 +231,20 @@ export default class Search extends React.PureComponent { {this.props.qualifiers === 'TRK' && ( )} diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx index bb3060d9401..bd9d701f2dd 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx @@ -28,6 +28,16 @@ it('renders', () => { expect(shallowRender()).toMatchSnapshot(); }); +it('disables the delete and bulk apply buttons unless a project is selected', () => { + const wrapper = shallowRender(); + expect(wrapper.find('Button.js-delete').prop('disabled')).toBe(true); + expect(wrapper.find('Button.js-bulk-apply-permission-template').prop('disabled')).toBe(true); + + wrapper.setProps({ selection: ['foo'] }); + expect(wrapper.find('Button.js-delete').prop('disabled')).toBe(false); + expect(wrapper.find('Button.js-bulk-apply-permission-template').prop('disabled')).toBe(false); +}); + it('render qualifiers filter', () => { expect(shallowRender({ topLevelQualifiers: ['TRK', 'VW', 'APP'] })).toMatchSnapshot(); }); diff --git a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap index 4457cd20ade..8bdabb174bf 100644 --- a/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap @@ -155,15 +155,16 @@ exports[`render qualifiers filter 1`] = ` > @@ -268,15 +269,16 @@ exports[`renders 1`] = ` > diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 7ad743d73e1..ebf9c0aa199 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -2151,6 +2151,8 @@ permission_templates.project_creators.explanation.sonarcloud=When a new project permission_templates.bulk_apply_permission_template=Bulk Apply Permission Template permission_templates.bulk_apply_permission_template.apply_to_selected=You're about to apply the selected permission template to {0} selected item(s). permission_templates.bulk_apply_permission_template.apply_to_all=You're about to apply the selected permission template to {0} item(s). +permission_templates.select_to_delete=You must select at least one item +permission_templates.delete_selected=Delete all selected items #------------------------------------------------------------------------------ -- 2.39.5