]> source.dussan.org Git - sonarqube.git/commitdiff
SONAR-9934 Prevent user to install/update/uninstall plugins part of an edition
authorGrégoire Aubert <gregoire.aubert@sonarsource.com>
Fri, 13 Oct 2017 09:22:57 +0000 (11:22 +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/api/plugins.ts
server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx
server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx
server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx
server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx
server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx
server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx [new file with mode: 0644]
sonar-core/src/main/resources/org/sonar/l10n/core.properties

index 75004b3fc1d39ef47c36b24714bd6b2ef27c1f90..9d2a96b3eecff5e34e12c27076eba2e64532ec51 100644 (file)
@@ -24,12 +24,13 @@ import throwGlobalError from '../app/utils/throwGlobalError';
 export interface Plugin {
   key: string;
   name: string;
-  description: string;
   category?: string;
+  description: string;
+  editionBundled?: boolean;
   license?: string;
   organizationName?: string;
-  organizationUrl?: string;
   homepageUrl?: string;
+  organizationUrl?: string;
   issueTrackerUrl?: string;
   termsAndConditionsUrl?: string;
 }
@@ -86,7 +87,7 @@ function getLastUpdates(updates: undefined | Update[]): Update[] {
     return [];
   }
   const lastUpdate = [
-    'INCOMPATIBLE',
+    'COMPATIBLE',
     'REQUIRES_SYSTEM_UPGRADE',
     'DEPS_REQUIRE_SYSTEM_UPGRADE'
   ].map(status => {
index d14cc83cd9477049d4bfdefe473df32df360cd9b..f2fce9f658e042f72d8247b265dca84d0df7a2b2 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
-import Checkbox from '../../components/controls/Checkbox';
+import Checkbox from '../../../components/controls/Checkbox';
+import CheckIcon from '../../../components/icons-components/CheckIcon';
 import PluginUpdateButton from './PluginUpdateButton';
-import { Plugin, installPlugin, updatePlugin, uninstallPlugin } from '../../api/plugins';
-import { isPluginAvailable, isPluginInstalled } from './utils';
-import { translate } from '../../helpers/l10n';
+import { Plugin, installPlugin, updatePlugin, uninstallPlugin } from '../../../api/plugins';
+import { isPluginAvailable, isPluginInstalled } from '../utils';
+import { translate } from '../../../helpers/l10n';
 
 interface Props {
   plugin: Plugin;
@@ -71,6 +72,44 @@ export default class PluginActions extends React.PureComponent<Props, State> {
   render() {
     const { plugin } = this.props;
     const { loading } = this.state;
+
+    if (plugin.editionBundled) {
+      return (
+        <div className="js-actions">
+          {isPluginAvailable(plugin) && (
+            <div>
+              <p className="little-spacer-bottom">
+                {translate('marketplace.available_under_commercial_license')}
+              </p>
+              <a href={plugin.homepageUrl} target="_blank">
+                {translate('marketplace.learn_more')}
+              </a>
+            </div>
+          )}
+          {isPluginInstalled(plugin) && (
+            <p>
+              <CheckIcon className="little-spacer-right" />
+              {translate('marketplace.installed')}
+            </p>
+          )}
+          {isPluginInstalled(plugin) &&
+          plugin.updates &&
+          plugin.updates.length > 0 && (
+            <div className="spacer-top button-group">
+              {plugin.updates.map((update, idx) => (
+                <PluginUpdateButton
+                  key={idx}
+                  onClick={this.handleUpdate}
+                  update={update}
+                  disabled={loading}
+                />
+              ))}
+            </div>
+          )}
+        </div>
+      );
+    }
+
     return (
       <div className="js-actions">
         {isPluginAvailable(plugin) &&
index 26c12116a496c9095a0479de7cbda9a28a9538a9..c80f5969e62838d03a4265ea321a861c07c1e563 100644 (file)
  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  */
 import * as React from 'react';
+import PluginChangeLogButton from './PluginChangeLogButton';
 import PluginDescription from './PluginDescription';
 import PluginLicense from './PluginLicense';
 import PluginOrganization from './PluginOrganization';
 import PluginStatus from './PluginStatus';
-import PluginChangeLogButton from './PluginChangeLogButton';
+import PluginUrls from './PluginUrls';
 import { PluginAvailable } from '../../api/plugins';
 import { translateWithParameters } from '../../helpers/l10n';
 import { Query } from './utils';
@@ -64,6 +65,7 @@ export default function PluginAvailable({ plugin, refreshPending, status, update
 
       <td className="text-top width-20 big-spacer-right">
         <ul>
+          <PluginUrls plugin={plugin} />
           <PluginLicense license={plugin.license} />
           <PluginOrganization plugin={plugin} />
         </ul>
index ec87c9ea26c0fbbd8d1c05045d3bfe15b48d1d6b..61b309cb291d17abb3ae0cbf3cf941a729275b2d 100644 (file)
@@ -41,7 +41,7 @@ export default class PluginChangeLogButton extends React.PureComponent<Props, St
   };
 
   toggleChangelog = (show?: boolean) => {
-    if (show != undefined) {
+    if (show !== undefined) {
       this.setState({ changelogOpen: show });
     } else {
       this.setState(state => ({ changelogOpen: !state.changelogOpen }));
index 85202411f188a56560e242ed56d7c2213f501dc2..b9225f3820e3b9d2f640f951cf6d2e7a28703af0 100644 (file)
 import * as React from 'react';
 import PluginDescription from './PluginDescription';
 import PluginLicense from './PluginLicense';
-import PluginStatus from './PluginStatus';
 import PluginOrganization from './PluginOrganization';
+import PluginStatus from './PluginStatus';
 import PluginUpdates from './PluginUpdates';
+import PluginUrls from './PluginUrls';
 import { PluginInstalled } from '../../api/plugins';
 import { translate } from '../../helpers/l10n';
 import { Query } from './utils';
@@ -52,26 +53,7 @@ export default function PluginInstalled({ plugin, refreshPending, status, update
 
       <td className="text-top width-20 big-spacer-right">
         <ul>
-          {(plugin.homepageUrl || plugin.issueTrackerUrl) && (
-            <li className="little-spacer-bottom">
-              <ul className="list-inline">
-                {plugin.homepageUrl && (
-                  <li>
-                    <a className="js-plugin-homepage" href={plugin.homepageUrl} target="_blank">
-                      {translate('marketplace.homepage')}
-                    </a>
-                  </li>
-                )}
-                {plugin.issueTrackerUrl && (
-                  <li>
-                    <a className="js-plugin-issues" href={plugin.issueTrackerUrl} target="_blank">
-                      {translate('marketplace.issue_tracker')}
-                    </a>
-                  </li>
-                )}
-              </ul>
-            </li>
-          )}
+          <PluginUrls plugin={plugin} />
           <PluginLicense license={plugin.license} />
           <PluginOrganization plugin={plugin} />
         </ul>
index f4d9d19d1c8afb271b81bed7704bbfd247881cf0..ea5d581362d1d4a51523a830898def05bff4c508 100644 (file)
@@ -42,7 +42,7 @@ export default class PluginUpdateItem extends React.PureComponent<Props, State>
   };
 
   toggleChangelog = (show?: boolean) => {
-    if (show != undefined) {
+    if (show !== undefined) {
       this.setState({ changelogOpen: show });
     } else {
       this.setState(state => ({ changelogOpen: !state.changelogOpen }));
diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx
new file mode 100644 (file)
index 0000000..adcdd81
--- /dev/null
@@ -0,0 +1,52 @@
+/*
+ * SonarQube
+ * Copyright (C) 2009-2017 SonarSource SA
+ * mailto:info AT sonarsource DOT com
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 3 of the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
+ */
+import * as React from 'react';
+import { Plugin } from '../../api/plugins';
+import { translate } from '../../helpers/l10n';
+
+interface Props {
+  plugin: Plugin;
+}
+
+export default function PluginUrls({ plugin }: Props) {
+  if (!plugin.homepageUrl && !plugin.issueTrackerUrl) {
+    return null;
+  }
+  return (
+    <li className="little-spacer-bottom">
+      <ul className="list-inline">
+        {plugin.homepageUrl && (
+          <li>
+            <a className="js-plugin-homepage" href={plugin.homepageUrl} target="_blank">
+              {translate('marketplace.homepage')}
+            </a>
+          </li>
+        )}
+        {plugin.issueTrackerUrl && (
+          <li>
+            <a className="js-plugin-issues" href={plugin.issueTrackerUrl} target="_blank">
+              {translate('marketplace.issue_tracker')}
+            </a>
+          </li>
+        )}
+      </ul>
+    </li>
+  );
+}
index 4b66f3917df93c0996aea2bf0e54b18162b328c0..ead056362e4af5fcd2cfa1837ca0e13cdc4539d2 100644 (file)
@@ -2068,7 +2068,10 @@ marketplace.restart=Restart
 marketplace.revert=Revert
 marketplace.system_upgrades=System Upgrades
 marketplace.install=Install
+marketplace.installed=Installed
 marketplace._installed=installed
+marketplace.available_under_commercial_license=Available under our commercial editions
+marketplace.learn_more=Learn more
 marketplace.homepage=Homepage
 marketplace.issue_tracker=Issue Tracker
 marketplace.licensed_under_x=Licensed under {license}