Skip to content

Commit

Permalink
MM-18517: Plugin Marketplace (Phase 2) (mattermost#4212)
Browse files Browse the repository at this point in the history
* MM-17549: support upgrading plugins (mattermost#4108)

* marketplace: jsx -> js

* marketplace: fix indentation

* marketplace: remove confirm, and always overwrite

* avoid isEqual dependency

* MM-17549: Plugin upgrade in marketplace

Support plugin upgrades from the marketplace. This change also reworks
the state modelling of the marketplace to move some logic out of the
components and into the views reducers, simplifying some transitions.

Fixes: https://mattermost.atlassian.net/browse/MM-17549

* extend marketplace e2e tests

Include coverage for upgrading plugins, as well as coverage for existing functionality. Extend the cypress utilities to support installation and uninstallation of plugins for test setup.

* fix missing translations

* use Client4 directly

* clarify marketplace spec search & install

* Remove "Installing..." checks, since flaky when fast

* simplify CSS, fix hover effect

* suppress update subsection when installing

* Update actions/marketplace.js

Co-Authored-By: Maria A Nunez <[email protected]>

* Update actions/marketplace.js

Co-Authored-By: Maria A Nunez <[email protected]>

* Update components/plugin_marketplace/marketplace_item/marketplace_item.test.js

Co-Authored-By: Maria A Nunez <[email protected]>

* drop unnecessary .js on imports

* handle loading error after filterPlugins

* updated snapshots

* actually fix snapshots

* tweak CSS styling

* MM-18517: release notes, upgrade confirmation, local-tag (mattermost#4192)

* MM-19603: upgrade release notes link

* MM-19263: annotate local plugins

Add a `Local` tag with hover text in the plugin marketplace for any plugin installed manually.

Fixes: https://mattermost.atlassian.net/browse/MM-19263

* MM-19604: confirm plugin upgrade

* update i18n/en.json

* suppress update if installed is newer

* Update components/plugin_marketplace/marketplace_item/marketplace_item.test.js

Co-Authored-By: Maria A Nunez <[email protected]>

* make MarketplaceItem default export

* s/Local/LOCAL/g

also fix snapshots for other change

* externalize <p> tags

* tweak language, localization templates

* updated snapshots

* use pluginDetailsInner for clarity

* fix comment in e2e tests

* updated redux commit
  • Loading branch information
lieut-data committed Nov 18, 2019
1 parent 2820cf3 commit 630bfdb
Show file tree
Hide file tree
Showing 27 changed files with 3,291 additions and 1,328 deletions.
82 changes: 82 additions & 0 deletions actions/marketplace.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// 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';

// fetchPlugins fetches the latest marketplace plugins, subject to any existing search filter.
export function fetchPlugins() {
return async (dispatch, getState) => {
const state = getState();
const filter = getFilter(state);

try {
const plugins = await Client4.getMarketplacePlugins(filter);

dispatch({
type: ActionTypes.RECEIVED_MARKETPLACE_PLUGINS,
plugins,
});

return {plugins};
} catch (error) {
return {error};
}
};
}

// 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) {
return async (dispatch, getState) => {
dispatch({
type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN,
id,
});

const state = getState();

const marketplacePlugin = getPlugin(state, id);
if (!marketplacePlugin) {
dispatch({
type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN_FAILED,
id,
error: 'Unknown plugin: ' + id,
});
return;
}

const downloadUrl = marketplacePlugin.download_url;
const {error} = await dispatch(installPluginFromUrl(downloadUrl, true));
if (error) {
dispatch({
type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN_FAILED,
id,
error: error.message,
});
return;
}

await dispatch(fetchPlugins());
dispatch({
type: ActionTypes.INSTALLING_MARKETPLACE_PLUGIN_SUCCEEDED,
id,
});
};
}

// filterPlugins sets a search filter for marketplace plugins, fetching the latest data.
export function filterPlugins(filter) {
return async (dispatch) => {
dispatch({
type: ActionTypes.FILTER_MARKETPLACE_PLUGINS,
filter,
});

return dispatch(fetchPlugins());
};
}
Loading

0 comments on commit 630bfdb

Please sign in to comment.