From 2be524ab5330f302c8c12a6959adcb72e6249666 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Gr=C3=A9goire=20Aubert?= Date: Wed, 18 Oct 2017 15:26:48 +0200 Subject: [PATCH] SONAR-9936 Better handling of button disabled depending on the edition status --- .../marketplace/components/EditionBox.tsx | 11 ++- .../components/__tests__/EditionBox-test.tsx | 29 +++++- .../__snapshots__/EditionBox-test.tsx.snap | 92 +++++++++++++++++-- .../resources/org/sonar/l10n/core.properties | 1 + 4 files changed, 115 insertions(+), 18 deletions(-) diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx index 147cb081c5f..91142a45cf7 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx @@ -33,10 +33,13 @@ export default class EditionBox extends React.PureComponent { render() { const { edition, editionStatus } = this.props; - const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; - const isInstalling = editionStatus && editionStatus.nextEditionKey === edition.key; const installInProgress = - editionStatus && editionStatus.installationStatus === 'AUTOMATIC_IN_PROGRESS'; + editionStatus && + ['AUTOMATIC_IN_PROGRESS', 'AUTOMATIC_READY'].includes(editionStatus.installationStatus); + const installReady = editionStatus && editionStatus.installationStatus === 'AUTOMATIC_READY'; + const isInstalled = editionStatus && editionStatus.currentEditionKey === edition.key; + const isInstalling = + installInProgress && editionStatus && editionStatus.nextEditionKey === edition.key; return (
{isInstalled && @@ -48,7 +51,7 @@ export default class EditionBox extends React.PureComponent { )} {isInstalling && ( - {translate('marketplace.installing')} + {installReady ? translate('marketplace.pending') : translate('marketplace.installing')} )}
diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx index 2b89b1bc1e2..c1a000d33ad 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx @@ -59,7 +59,19 @@ it('should display installing badge', () => { editionStatus: { currentEditionKey: 'foo', nextEditionKey: 'foo', - installationStatus: 'NONE' + installationStatus: 'AUTOMATIC_IN_PROGRESS' + } + }) + ).toMatchSnapshot(); +}); + +it('should display pending badge', () => { + expect( + getWrapper({ + editionStatus: { + currentEditionKey: '', + nextEditionKey: 'foo', + installationStatus: 'AUTOMATIC_READY' } }) ).toMatchSnapshot(); @@ -69,19 +81,28 @@ it('should disable install button', () => { expect( getWrapper({ editionStatus: { - currentEditionKey: 'foo', - nextEditionKey: '', + currentEditionKey: '', + nextEditionKey: 'foo', installationStatus: 'AUTOMATIC_IN_PROGRESS' } }) ).toMatchSnapshot(); + expect( + getWrapper({ + editionStatus: { + currentEditionKey: '', + nextEditionKey: 'foo', + installationStatus: 'AUTOMATIC_READY' + } + }) + ).toMatchSnapshot(); }); it('should disable uninstall button', () => { expect( getWrapper({ editionStatus: { - currentEditionKey: '', + currentEditionKey: 'foo', nextEditionKey: 'foo', installationStatus: 'AUTOMATIC_IN_PROGRESS' } diff --git a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap index e37bd585c1b..6aabd158c3a 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap +++ b/server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap @@ -7,11 +7,7 @@ exports[`should disable install button 1`] = ` - - marketplace.installed + marketplace.installing

`; -exports[`should disable uninstall button 1`] = ` +exports[`should disable install button 2`] = `
- marketplace.installing + marketplace.pending

`; +exports[`should disable uninstall button 1`] = ` +
+ + marketplace.installing + +
+

+ Foo +

+

+ Foo desc +

+
+
+ + marketplace.learn_more + + +
+
+`; + exports[`should display installed badge 1`] = `
@@ -160,6 +194,44 @@ exports[`should display installing badge 1`] = `
`; +exports[`should display pending badge 1`] = ` +
+ + marketplace.pending + +
+

+ Foo +

+

+ Foo desc +

+
+
+ + marketplace.learn_more + + +
+
+`; + exports[`should display the edition 1`] = `