diff --git a/scm-ui/src/containers/PluginLoader.js b/scm-ui/src/containers/PluginLoader.js index 308f532270..599ffcb67c 100644 --- a/scm-ui/src/containers/PluginLoader.js +++ b/scm-ui/src/containers/PluginLoader.js @@ -34,7 +34,7 @@ class PluginLoader extends React.Component { this.setState({ message: "loading plugin information" }); - + this.getPlugins(this.props.link); } } @@ -55,12 +55,19 @@ class PluginLoader extends React.Component { }); const promises = []; - for (let plugin of plugins) { + const sortedPlugins = plugins.sort(comparePluginsByName); + for (let plugin of sortedPlugins) { promises.push(this.loadPlugin(plugin)); } - return Promise.all(promises); + return promises.reduce((chain, current) => { + return chain.then(chainResults => { + return current.then(currentResult => [...chainResults, currentResult]) + } + ); + }, Promise.resolve([])); }; + loadPlugin = (plugin: Plugin) => { this.setState({ message: `loading ${plugin.name}` @@ -94,7 +101,15 @@ class PluginLoader extends React.Component { return ; } } - +const comparePluginsByName = (a: Plugin, b: Plugin) => { + if (a.name < b.name) { + return -1; + } + if (a.name > b.name) { + return 1; + } + return 0; +}; const mapStateToProps = state => { const link = getUiPluginsLink(state); return {