]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9937 Display error message when license don't match selected edition in marketplace
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 27 Oct 2017 07:13:05 +0000 (09:13 +0200)
committerGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 27 Oct 2017 14:03:44 +0000 (16:03 +0200)
server/sonar-web/src/main/js/apps/marketplace/components/LicenseEditionSet.tsx
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 3ec3bb3485b182fd67ac07c39f13b9f67a229802..74e2874c1a0d35b45e61f0b8e388f0e4c71549db 100644 (file)
@@ -67,10 +67,11 @@ export default class LicenseEditionSet extends React.PureComponent<Props, State>
     getLicensePreview({ license }).then(
       ({ previewStatus, nextEditionKey }) => {
         if (this.mounted) {
+          const { edition } = this.props;
           this.updateLicense(
             license,
             this.props.editions.find(edition => edition.key === nextEditionKey),
-            previewStatus
+            edition && edition.key !== nextEditionKey ? undefined : previewStatus
           );
         }
       },
@@ -89,7 +90,7 @@ export default class LicenseEditionSet extends React.PureComponent<Props, State>
           this.setState({ formData });
         }
       },
-      () => { }
+      () => {}
     );
   };
 
@@ -122,8 +123,18 @@ export default class LicenseEditionSet extends React.PureComponent<Props, State>
   renderAlert() {
     const { licenseEdition, previewStatus } = this.state;
     if (!previewStatus) {
+      const { edition } = this.props;
+      if (edition && licenseEdition && edition.key !== licenseEdition.key) {
+        return (
+          <p className="alert alert-danger spacer-top">
+            {translateWithParameters('marketplace.wrong_license_type_x', edition.name)}
+          </p>
+        );
+      }
+
       return undefined;
     }
+
     return (
       <p
         className={classNames('alert spacer-top', {
index 11440377ec63393b9d45a163de370f47ce8af258..5fbb5c85f05eea6454e89aeb164b5176cde08370 100644 (file)
@@ -2110,6 +2110,7 @@ marketplace.status_X.UNINSTALL_IN_PROGRESS={0} successfully uninstalled. Please
 marketplace.status_x.MANUAL_IN_PROGRESS=Can't install {0} because of internet access issue. Please manually install the package in your SonarQube's plugins folder.
 marketplace.how_to_install=How to install it?
 marketplace.enter_license_for_x=Enter your license key for {0}
+marketplace.wrong_license_type_x=Your license is not compatible with the selected edition. Please provide a valid license for {0}.
 marketplace.i_need_a_license=I need a license key
 marketplace.download_package=Download package