diff --git a/scm-ui/src/containers/Index.js b/scm-ui/src/containers/Index.js index d894215fab..0e79b1487e 100644 --- a/scm-ui/src/containers/Index.js +++ b/scm-ui/src/containers/Index.js @@ -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 { } render() { - const { - loading, - error, - t, - } = this.props; + const { loading, error, t } = this.props; if (loading) { return ; @@ -59,7 +49,6 @@ class Index extends Component { const mapDispatchToProps = (dispatch: any) => { return { - fetchMe: (link: string) => dispatch(fetchMe(link)), fetchIndexResources: () => dispatch(fetchIndexResources()) }; }; diff --git a/scm-ui/src/containers/PluginLoader.js b/scm-ui/src/containers/PluginLoader.js index 16a5dd8d4d..ecc287b743 100644 --- a/scm-ui/src/containers/PluginLoader.js +++ b/scm-ui/src/containers/PluginLoader.js @@ -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 { 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 { finished: true }); }); - } + }; loadPlugins = (plugins: Plugin[]) => { this.setState({ @@ -87,4 +101,14 @@ class PluginLoader extends React.Component { } } -export default PluginLoader; +const mapStateToProps = state => { + const link = getUiPluginsLink(state); + return { + link + }; +}; + +export default connect( + mapStateToProps, + null +)(PluginLoader);