]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-10435 Improve error message of licenses issues for normal users
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 14 Feb 2018 16:08:36 +0000 (17:08 +0100)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Thu, 15 Feb 2018 12:28:33 +0000 (13:28 +0100)
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 a28f8088ae5204d965f26e65f79d1f289082fd84..b5bb9a7a3dcc760d06730cdc2723bd25d1b16c7b 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 08c36de0e12abb4eb279112d93bfe96f260fdd66..c404f6ee227a2b13a379bdf749752b64e1e1f474 100644 (file)
@@ -64,15 +64,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 bb69e51c46d330324f127f3e5877cba165940a32..2c7d92f06fbc65da6ad695e0e86a7e9ae54cbf04 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 5471f9e08e74604d21747d74cabdc32714015a3f..a8e95ab42bb28236376d22c4fbcd9b2763e07dc4 100644 (file)
@@ -222,6 +222,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
 short_number_suffix.g=G
 short_number_suffix.k=k