]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9936 Better handling of button disabled depending on the edition status
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Wed, 18 Oct 2017 13:26:48 +0000 (15:26 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Mon, 23 Oct 2017 15:01:13 +0000 (08:01 -0700)
server/sonar-web/src/main/js/apps/marketplace/components/EditionBox.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/EditionBox-test.tsx
server/sonar-web/src/main/js/apps/marketplace/components/__tests__/__snapshots__/EditionBox-test.tsx.snap
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 147cb081c5ffc3dbf6c15482348e265aad53e812..91142a45cf784cbbc44e44168fb87c88b5206d07 100644 (file)
@@ -33,10 +33,13 @@ export default class EditionBox extends React.PureComponent<Props> {
 
   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 (
       <div className="boxed-group boxed-group-inner marketplace-edition">
         {isInstalled &&
@@ -48,7 +51,7 @@ export default class EditionBox extends React.PureComponent<Props> {
         )}
         {isInstalling && (
           <span className="marketplace-edition-badge badge badge-normal-size">
-            {translate('marketplace.installing')}
+            {installReady ? translate('marketplace.pending') : translate('marketplace.installing')}
           </span>
         )}
         <div>
index 2b89b1bc1e2c23e84177d74e638edb305b25cf58..c1a000d33ad6614eaedc6e5301ff2fe2a191e369 100644 (file)
@@ -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'
       }
index e37bd585c1bd1f31644943046ae83c92a134905e..6aabd158c3a4c1be1a2ccc0f0c23de4744197fa2 100644 (file)
@@ -7,11 +7,7 @@ exports[`should disable install button 1`] = `
   <span
     className="marketplace-edition-badge badge badge-normal-size"
   >
-    <CheckIcon
-      className="little-spacer-right text-text-top"
-      size={14}
-    />
-    marketplace.installed
+    marketplace.installing
   </span>
   <div>
     <h3
@@ -33,23 +29,23 @@ exports[`should disable install button 1`] = `
       marketplace.learn_more
     </a>
     <button
-      className="button-red"
       disabled={true}
+      onClick={[Function]}
     >
-      marketplace.uninstall
+      marketplace.install
     </button>
   </div>
 </div>
 `;
 
-exports[`should disable uninstall button 1`] = `
+exports[`should disable install button 2`] = `
 <div
   className="boxed-group boxed-group-inner marketplace-edition"
 >
   <span
     className="marketplace-edition-badge badge badge-normal-size"
   >
-    marketplace.installing
+    marketplace.pending
   </span>
   <div>
     <h3
@@ -80,6 +76,44 @@ exports[`should disable uninstall button 1`] = `
 </div>
 `;
 
+exports[`should disable uninstall button 1`] = `
+<div
+  className="boxed-group boxed-group-inner marketplace-edition"
+>
+  <span
+    className="marketplace-edition-badge badge badge-normal-size"
+  >
+    marketplace.installing
+  </span>
+  <div>
+    <h3
+      className="spacer-bottom"
+    >
+      Foo
+    </h3>
+    <p>
+      Foo desc
+    </p>
+  </div>
+  <div
+    className="marketplace-edition-action spacer-top"
+  >
+    <a
+      href="more_url"
+      target="_blank"
+    >
+      marketplace.learn_more
+    </a>
+    <button
+      className="button-red"
+      disabled={true}
+    >
+      marketplace.uninstall
+    </button>
+  </div>
+</div>
+`;
+
 exports[`should display installed badge 1`] = `
 <div
   className="boxed-group boxed-group-inner marketplace-edition"
@@ -152,7 +186,7 @@ exports[`should display installing badge 1`] = `
     </a>
     <button
       className="button-red"
-      disabled={false}
+      disabled={true}
     >
       marketplace.uninstall
     </button>
@@ -160,6 +194,44 @@ exports[`should display installing badge 1`] = `
 </div>
 `;
 
+exports[`should display pending badge 1`] = `
+<div
+  className="boxed-group boxed-group-inner marketplace-edition"
+>
+  <span
+    className="marketplace-edition-badge badge badge-normal-size"
+  >
+    marketplace.pending
+  </span>
+  <div>
+    <h3
+      className="spacer-bottom"
+    >
+      Foo
+    </h3>
+    <p>
+      Foo desc
+    </p>
+  </div>
+  <div
+    className="marketplace-edition-action spacer-top"
+  >
+    <a
+      href="more_url"
+      target="_blank"
+    >
+      marketplace.learn_more
+    </a>
+    <button
+      disabled={true}
+      onClick={[Function]}
+    >
+      marketplace.install
+    </button>
+  </div>
+</div>
+`;
+
 exports[`should display the edition 1`] = `
 <div
   className="boxed-group boxed-group-inner marketplace-edition"
index 9d717313a9bdc584b1e130138382e3b475b120d6..7a09e8ffc2bfe8959ee07f5fb64aaa55f19faf61 100644 (file)
@@ -2071,6 +2071,7 @@ marketplace.install=Install
 marketplace.install_x=Install {0}
 marketplace.installed=Installed
 marketplace.installing=Installing...
+marketplace.pending=Pending...
 marketplace._installed=installed
 marketplace.available_under_commercial_license=Available under our commercial editions
 marketplace.learn_more=Learn more