From c948b71216a95514409415abfb847d1444297184 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Tue, 22 May 2018 14:55:16 +0200 Subject: [PATCH] SONAR-10710 Improve error message of licenses issues for normal users --- .../nav/component/ComponentNavBgTaskNotif.tsx | 8 +++++--- .../__tests__/ComponentNavBgTaskNotif-test.tsx | 10 ++++++++-- .../ComponentNavBgTaskNotif-test.tsx.snap | 18 ++++++++++++++++-- .../resources/org/sonar/l10n/core.properties | 1 + 4 files changed, 30 insertions(+), 7 deletions(-) diff --git a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx index 5b906826ecc..99c01c71910 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/ComponentNavBgTaskNotif.tsx @@ -87,11 +87,13 @@ export default class ComponentNavBgTaskNotif extends React.PureComponent ) { return ( - {currentTask.errorMessage} - {this.context.canAdmin && ( - + {currentTask.errorMessage} + {this.context.canAdmin ? ( + {translate('license.component_navigation.button', currentTask.errorType)}. + ) : ( + translate('please_contact_administrator') )} ); diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx index 72e517426cc..b155d6dde17 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/ComponentNavBgTaskNotif-test.tsx @@ -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( , - { context: { canAdmin: true } } + { context: { canAdmin: true, ...context } } ); } diff --git a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap index 679067cb000..a8426344156 100644 --- a/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap +++ b/server/sonar-web/src/main/js/app/components/nav/component/__tests__/__snapshots__/ComponentNavBgTaskNotif-test.tsx.snap @@ -27,11 +27,12 @@ exports[`renders background task license info correctly 1`] = ` - + Foo `; +exports[`renders background task license info correctly 2`] = ` + + + Foo + + please_contact_administrator + +`; + exports[`renders background task pending info correctly 1`] = `