]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10710 Improve error message of licenses issues for normal users
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Tue, 22 May 2018 12:55:16 +0000 (14:55 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 23 May 2018 06:47:36 +0000 (08:47 +0200)
server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx
server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 5b906826ecc7fda2692dff3320fae3ddf0a63ff3..99c01c71910924d4b2674aab3e4cfc737d1381a0 100644 (file)
@@ -87,11 +87,13 @@ export default class ComponentNavBgTaskNotif extends React.PureComponent<Props>
       ) {
         return (
           <NavBarNotif className="alert alert-danger">
-            <span>{currentTask.errorMessage}</span>
-            {this.context.canAdmin && (
-              <Link className="little-spacer-left" to="/admin/extension/license/app">
+            <span className="little-spacer-right">{currentTask.errorMessage}</span>
+            {this.context.canAdmin ? (
+              <Link to="/admin/extension/license/app">
                 {translate('license.component_navigation.button', currentTask.errorType)}.
               </Link>
+            ) : (
+              translate('please_contact_administrator')
             )}
           </NavBarNotif>
         );
index 72e517426ccb9e7e879d5c8bb1778c41e90497aa..b155d6dde171c54f92e4ea7fb582dbe5ecb81214 100644 (file)
@@ -54,15 +54,21 @@ it('renders background task license info correctly', () => {
   expect(
     getWrapper({ currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } })
   ).toMatchSnapshot();
+  expect(
+    getWrapper(
+      { currentTask: { status: 'FAILED', errorType: 'LICENSING', errorMessage: 'Foo' } },
+      { canAdmin: false }
+    )
+  ).toMatchSnapshot();
 });
 
-function getWrapper(props = {}) {
+function getWrapper(props = {}, context = {}) {
   return shallow(
     <ComponentNavBgTaskNotif
       component={component}
       currentTask={{ status: 'FAILED' } as Task}
       {...props}
     />,
-    { context: { canAdmin: true } }
+    { context: { canAdmin: true, ...context } }
   );
 }
index 679067cb000c8a2e8022ff7caaa716a5627c643a..a8426344156f6a4f0e89ec58e64f133e8235ba67 100644 (file)
@@ -27,11 +27,12 @@ exports[`renders background task license info correctly 1`] = `
 <NavBarNotif
   className="alert alert-danger"
 >
-  <span>
+  <span
+    className="little-spacer-right"
+  >
     Foo
   </span>
   <Link
-    className="little-spacer-left"
     onlyActiveOnIndex={false}
     style={Object {}}
     to="/admin/extension/license/app"
@@ -42,6 +43,19 @@ exports[`renders background task license info correctly 1`] = `
 </NavBarNotif>
 `;
 
+exports[`renders background task license info correctly 2`] = `
+<NavBarNotif
+  className="alert alert-danger"
+>
+  <span
+    className="little-spacer-right"
+  >
+    Foo
+  </span>
+  please_contact_administrator
+</NavBarNotif>
+`;
+
 exports[`renders background task pending info correctly 1`] = `
 <NavBarNotif
   className="alert alert-info"
index 2ee56009dfaa9b10f619f87a15adcec9f8566c46..dccba131f7b479c3cd218aaf703e3fb7854ff443 100644 (file)
@@ -216,6 +216,7 @@ no_results_search.favorites=We couldn't find any results matching selected crite
 no_results_search.2=Try to change filters to get some results.
 no_results_search.favorites.2=Would you like to search among {url} projects?
 page_extension_failed=Page extension failed.
+please_contact_administrator=Please contact the instance administrator.
 set_as_default=Set as Default
 unset_as_default=Unset as Default
 show_more=Show More