diff --git a/actions/marketplace.js b/actions/marketplace.js index 4c568e03ace9..763a8df19cf7 100644 --- a/actions/marketplace.js +++ b/actions/marketplace.js @@ -2,7 +2,6 @@ // See LICENSE.txt for license information. import {Client4} from 'mattermost-redux/client'; -import {installPluginFromUrl} from 'mattermost-redux/actions/admin'; import {getFilter, getPlugin} from 'selectors/views/marketplace'; import {ActionTypes} from 'utils/constants'; @@ -31,7 +30,7 @@ export function fetchPlugins() { // installPlugin installs the latest version of the given plugin from the marketplace. // // On success, it also requests the current state of the plugins to reflect the newly installed plugin. -export function installPlugin(id) { +export function installPlugin(id, version) { return async (dispatch, getState) => { dispatch({ type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN, @@ -50,9 +49,9 @@ export function installPlugin(id) { return; } - const downloadUrl = marketplacePlugin.download_url; - const {error} = await dispatch(installPluginFromUrl(downloadUrl, true)); - if (error) { + try { + await Client4.installMarketplacePlugin(id, version); + } catch (error) { dispatch({ type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN_FAILED, id, diff --git a/components/admin_console/plugin_management/__snapshots__/plugin_management.test.jsx.snap b/components/admin_console/plugin_management/__snapshots__/plugin_management.test.jsx.snap index ba3a471af319..3a33fb71e9b1 100644 --- a/components/admin_console/plugin_management/__snapshots__/plugin_management.test.jsx.snap +++ b/components/admin_console/plugin_management/__snapshots__/plugin_management.test.jsx.snap @@ -61,6 +61,40 @@ exports[`components/PluginManagement should match snapshot 1`] = ` } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -271,6 +305,40 @@ exports[`components/PluginManagement should match snapshot when \`Enable Plugins id="PluginSettings" show={true} > + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -454,6 +522,284 @@ exports[`components/PluginManagement should match snapshot when \`Enable Plugins `; +exports[`components/PluginManagement should match snapshot when \`Require Signature Plugin\` is true 1`] = ` +
+
+ + + +
+
+ + + } + helpText={ + + } + id="enable" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={true} + /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={true} + /> +
+ +
+
+ + +
+ +
+

+ +

+
+
+ + } + helpText={ + + } + id="enableMarketplace" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={true} + /> + + +
+ } + id="marketplaceUrl" + label={ + + } + onChange={[Function]} + setByEnv={false} + type="input" + value="marketplace.example.com" + /> +
+ +
+

+ +

+
+
+
+
+
+
+
+ +
+ +
+ + + +
+
+
+`; + exports[`components/PluginManagement should match snapshot, No installed plugins 1`] = `
+ + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -741,15 +1121,49 @@ exports[`components/PluginManagement should match snapshot, allow insecure URL e } helpText={ + } + id="enable" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={true} + /> + + } + helpText={ + } - id="enable" + id="requirePluginSignature" label={ } @@ -762,7 +1176,7 @@ exports[`components/PluginManagement should match snapshot, allow insecure URL e values={Object {}} /> } - value={true} + value={false} />
+ + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -1224,6 +1672,40 @@ exports[`components/PluginManagement should match snapshot, text entered into th } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -1468,6 +1950,40 @@ exports[`components/PluginManagement should match snapshot, upload disabled 1`] } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -1712,6 +2228,40 @@ exports[`components/PluginManagement should match snapshot, with installed plugi } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -2019,6 +2569,40 @@ exports[`components/PluginManagement should match snapshot, with installed plugi } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -2294,6 +2878,40 @@ exports[`components/PluginManagement should match snapshot, with installed plugi } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -2569,6 +3187,40 @@ exports[`components/PluginManagement should match snapshot, with installed plugi } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
@@ -2844,6 +3496,40 @@ exports[`components/PluginManagement should match snapshot, with installed plugi } value={true} /> + + } + helpText={ + + } + id="requirePluginSignature" + label={ + + } + onChange={[Function]} + setByEnv={false} + trueText={ + + } + value={false} + />
diff --git a/components/admin_console/plugin_management/plugin_management.jsx b/components/admin_console/plugin_management/plugin_management.jsx index c0af83c453ab..a79ab72dda78 100644 --- a/components/admin_console/plugin_management/plugin_management.jsx +++ b/components/admin_console/plugin_management/plugin_management.jsx @@ -5,6 +5,8 @@ import PropTypes from 'prop-types'; import React from 'react'; import {FormattedHTMLMessage, FormattedMessage} from 'react-intl'; import {Link} from 'react-router-dom'; +import classNames from 'classnames'; + import PluginState from 'mattermost-redux/constants/plugins'; import * as Utils from 'utils/utils.jsx'; @@ -435,6 +437,7 @@ export default class PluginManagement extends AdminSettings { config.PluginSettings.AllowInsecureDownloadUrl = this.state.allowInsecureDownloadUrl; config.PluginSettings.EnableMarketplace = this.state.enableMarketplace; config.PluginSettings.MarketplaceUrl = this.state.marketplaceUrl; + config.PluginSettings.RequirePluginSignature = this.state.requirePluginSignature; return config; } @@ -446,6 +449,7 @@ export default class PluginManagement extends AdminSettings { allowInsecureDownloadUrl: config.PluginSettings.AllowInsecureDownloadUrl, enableMarketplace: config.PluginSettings.EnableMarketplace, marketplaceUrl: config.PluginSettings.MarketplaceUrl, + requirePluginSignature: config.PluginSettings.RequirePluginSignature, }; return state; @@ -916,7 +920,7 @@ export default class PluginManagement extends AdminSettings { defaultMessage='Upload a plugin for your Mattermost server. See [documentation](!https://about.mattermost.com/default-plugin-uploads) to learn more.' /> ); - } else if (enable === true && enableUploads === false) { + } else if (enable && !enableUploads) { uploadHelpText = ( {this.renderEnablePluginsSetting()} + + } + helpText={ + + } + value={this.state.requirePluginSignature} + disabled={!this.state.enable} + onChange={this.handleChange} + setByEnv={this.isSetByEnv('PluginSettings.RequirePluginSignature')} + /> +