mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-11 16:05:44 +01:00
use index resources plugin link for loading plugins
This commit is contained in:
@@ -4,14 +4,8 @@ import App from "./App";
|
||||
import { connect } from "react-redux";
|
||||
import { translate } from "react-i18next";
|
||||
import { withRouter } from "react-router-dom";
|
||||
import {
|
||||
fetchMe
|
||||
} from "../modules/auth";
|
||||
|
||||
import {
|
||||
Loading,
|
||||
ErrorPage,
|
||||
} from "@scm-manager/ui-components";
|
||||
import { Loading, ErrorPage } from "@scm-manager/ui-components";
|
||||
import {
|
||||
fetchIndexResources,
|
||||
getFetchIndexResourcesFailure,
|
||||
@@ -35,11 +29,7 @@ class Index extends Component<Props> {
|
||||
}
|
||||
|
||||
render() {
|
||||
const {
|
||||
loading,
|
||||
error,
|
||||
t,
|
||||
} = this.props;
|
||||
const { loading, error, t } = this.props;
|
||||
|
||||
if (loading) {
|
||||
return <Loading />;
|
||||
@@ -59,7 +49,6 @@ class Index extends Component<Props> {
|
||||
|
||||
const mapDispatchToProps = (dispatch: any) => {
|
||||
return {
|
||||
fetchMe: (link: string) => dispatch(fetchMe(link)),
|
||||
fetchIndexResources: () => dispatch(fetchIndexResources())
|
||||
};
|
||||
};
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
// @flow
|
||||
import * as React from "react";
|
||||
import { apiClient, Loading } from "@scm-manager/ui-components";
|
||||
import {
|
||||
callFetchIndexResources,
|
||||
getUiPluginsLink
|
||||
} from "../modules/indexResource";
|
||||
import { connect } from "react-redux";
|
||||
|
||||
type Props = {
|
||||
children: React.Node
|
||||
children: React.Node,
|
||||
link: string
|
||||
};
|
||||
|
||||
type State = {
|
||||
@@ -29,8 +35,16 @@ class PluginLoader extends React.Component<Props, State> {
|
||||
this.setState({
|
||||
message: "loading plugin information"
|
||||
});
|
||||
|
||||
callFetchIndexResources().then(response => {
|
||||
const link = response._links.uiPlugins.href;
|
||||
this.getPlugins(link);
|
||||
});
|
||||
}
|
||||
|
||||
getPlugins = (link: string) => {
|
||||
apiClient
|
||||
.get("ui/plugins")
|
||||
.get(link)
|
||||
.then(response => response.text())
|
||||
.then(JSON.parse)
|
||||
.then(pluginCollection => pluginCollection._embedded.plugins)
|
||||
@@ -40,7 +54,7 @@ class PluginLoader extends React.Component<Props, State> {
|
||||
finished: true
|
||||
});
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
loadPlugins = (plugins: Plugin[]) => {
|
||||
this.setState({
|
||||
@@ -87,4 +101,14 @@ class PluginLoader extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default PluginLoader;
|
||||
const mapStateToProps = state => {
|
||||
const link = getUiPluginsLink(state);
|
||||
return {
|
||||
link
|
||||
};
|
||||
};
|
||||
|
||||
export default connect(
|
||||
mapStateToProps,
|
||||
null
|
||||
)(PluginLoader);
|
||||
|
||||
Reference in New Issue
Block a user