]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-12115 Disable delete button if no projects have been selected
authorWouter Admiraal <wouter.admiraal@sonarsource.com>
Fri, 31 May 2019 13:31:54 +0000 (15:31 +0200)
committerSonarTech <sonartech@sonarsource.com>
Thu, 13 Jun 2019 18:21:12 +0000 (20:21 +0200)
server/sonar-web/src/main/js/apps/projectsManagement/Search.tsx
server/sonar-web/src/main/js/apps/projectsManagement/__tests__/Search-test.tsx
server/sonar-web/src/main/js/apps/projectsManagement/__tests__/__snapshots__/Search-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 6b040fb0abb2f962187a6205a2c3622e6f77869c..65041f5269b3793aca23ae37aee45fa1aa0d7b88 100644 (file)
@@ -231,15 +231,20 @@ export default class Search extends React.PureComponent<Props, State> {
               <td className="thin nowrap text-middle">
                 <Button
                   className="js-bulk-apply-permission-template"
-                  disabled={this.props.total === 0}
+                  disabled={this.props.selection.length === 0}
                   onClick={this.handleBulkApplyTemplateClick}>
                   {translate('permission_templates.bulk_apply_permission_template')}
                 </Button>
                 {this.props.qualifiers === 'TRK' && (
                   <Button
                     className="js-delete spacer-left button-red"
-                    disabled={this.props.total === 0}
-                    onClick={this.handleDeleteClick}>
+                    disabled={this.props.selection.length === 0}
+                    onClick={this.handleDeleteClick}
+                    title={
+                      this.props.selection.length === 0
+                        ? translate('permission_templates.select_to_delete')
+                        : translate('permission_templates.delete_selected')
+                    }>
                     {translate('delete')}
                   </Button>
                 )}
index bb3060d940123b112d1d8b508de03b5f44dc97be..bd9d701f2dd865df00771f0221b39fcbe25995ee 100644 (file)
@@ -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();
 });
index 4457cd20ade43520b8e46d72ff4de6fce7d0c75d..8bdabb174bf54358031a49998dd9e3f070de6c94 100644 (file)
@@ -155,15 +155,16 @@ exports[`render qualifiers filter 1`] = `
         >
           <Button
             className="js-bulk-apply-permission-template"
-            disabled={false}
+            disabled={true}
             onClick={[Function]}
           >
             permission_templates.bulk_apply_permission_template
           </Button>
           <Button
             className="js-delete spacer-left button-red"
-            disabled={false}
+            disabled={true}
             onClick={[Function]}
+            title="permission_templates.select_to_delete"
           >
             delete
           </Button>
@@ -268,15 +269,16 @@ exports[`renders 1`] = `
         >
           <Button
             className="js-bulk-apply-permission-template"
-            disabled={false}
+            disabled={true}
             onClick={[Function]}
           >
             permission_templates.bulk_apply_permission_template
           </Button>
           <Button
             className="js-delete spacer-left button-red"
-            disabled={false}
+            disabled={true}
             onClick={[Function]}
+            title="permission_templates.select_to_delete"
           >
             delete
           </Button>
index 7ad743d73e10fcf94f88346a7d45131ced7dea2e..ebf9c0aa1996e212e51a3ad20fc1b1b4f62b2d9c 100644 (file)
@@ -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
 
 
 #------------------------------------------------------------------------------