mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-14 17:26:22 +01:00
Load plugins sequentially (sorted alphabetically)
This commit is contained in:
@@ -55,12 +55,19 @@ class PluginLoader extends React.Component<Props, State> {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const promises = [];
|
const promises = [];
|
||||||
for (let plugin of plugins) {
|
const sortedPlugins = plugins.sort(comparePluginsByName);
|
||||||
|
for (let plugin of sortedPlugins) {
|
||||||
promises.push(this.loadPlugin(plugin));
|
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) => {
|
loadPlugin = (plugin: Plugin) => {
|
||||||
this.setState({
|
this.setState({
|
||||||
message: `loading ${plugin.name}`
|
message: `loading ${plugin.name}`
|
||||||
@@ -94,7 +101,15 @@ class PluginLoader extends React.Component<Props, State> {
|
|||||||
return <Loading message={message} />;
|
return <Loading message={message} />;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
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 mapStateToProps = state => {
|
||||||
const link = getUiPluginsLink(state);
|
const link = getUiPluginsLink(state);
|
||||||
return {
|
return {
|
||||||
|
|||||||
Reference in New Issue
Block a user