From: Grégoire Aubert Date: Fri, 13 Oct 2017 09:22:57 +0000 (+0200) Subject: SONAR-9934 Prevent user to install/update/uninstall plugins part of an edition X-Git-Tag: 6.7-RC1~107 X-Git-Url: https://source.dussan.org/?a=commitdiff_plain;h=d04f3466ac7eda479ddd559e8b245eff971c6ee2;p=sonarqube.git SONAR-9934 Prevent user to install/update/uninstall plugins part of an edition --- diff --git a/server/sonar-web/src/main/js/api/plugins.ts b/server/sonar-web/src/main/js/api/plugins.ts index 75004b3fc1d..9d2a96b3eec 100644 --- a/server/sonar-web/src/main/js/api/plugins.ts +++ b/server/sonar-web/src/main/js/api/plugins.ts @@ -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 => { diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx index d14cc83cd94..f2fce9f658e 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginActions.tsx @@ -18,11 +18,12 @@ * 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 { render() { const { plugin } = this.props; const { loading } = this.state; + + if (plugin.editionBundled) { + return ( +
+ {isPluginAvailable(plugin) && ( +
+

+ {translate('marketplace.available_under_commercial_license')} +

+ + {translate('marketplace.learn_more')} + +
+ )} + {isPluginInstalled(plugin) && ( +

+ + {translate('marketplace.installed')} +

+ )} + {isPluginInstalled(plugin) && + plugin.updates && + plugin.updates.length > 0 && ( +
+ {plugin.updates.map((update, idx) => ( + + ))} +
+ )} +
+ ); + } + return (
{isPluginAvailable(plugin) && diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx index 26c12116a49..c80f5969e62 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginAvailable.tsx @@ -18,11 +18,12 @@ * 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
    +
diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx index ec87c9ea26c..61b309cb291 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginChangeLogButton.tsx @@ -41,7 +41,7 @@ export default class PluginChangeLogButton extends React.PureComponent { - 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/PluginInstalled.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx index 85202411f18..b9225f3820e 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginInstalled.tsx @@ -20,9 +20,10 @@ 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 diff --git a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx b/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx index f4d9d19d1c8..ea5d581362d 100644 --- a/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginUpdateItem.tsx @@ -42,7 +42,7 @@ export default class PluginUpdateItem extends React.PureComponent }; 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 index 00000000000..adcdd816168 --- /dev/null +++ b/server/sonar-web/src/main/js/apps/marketplace/PluginUrls.tsx @@ -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 ( +
  • + +
  • + ); +} diff --git a/sonar-core/src/main/resources/org/sonar/l10n/core.properties b/sonar-core/src/main/resources/org/sonar/l10n/core.properties index 4b66f3917df..ead056362e4 100644 --- a/sonar-core/src/main/resources/org/sonar/l10n/core.properties +++ b/sonar-core/src/main/resources/org/sonar/l10n/core.properties @@ -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}