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 { connect } from "react-redux";
|
||||||
import { translate } from "react-i18next";
|
import { translate } from "react-i18next";
|
||||||
import { withRouter } from "react-router-dom";
|
import { withRouter } from "react-router-dom";
|
||||||
import {
|
|
||||||
fetchMe
|
|
||||||
} from "../modules/auth";
|
|
||||||
|
|
||||||
import {
|
import { Loading, ErrorPage } from "@scm-manager/ui-components";
|
||||||
Loading,
|
|
||||||
ErrorPage,
|
|
||||||
} from "@scm-manager/ui-components";
|
|
||||||
import {
|
import {
|
||||||
fetchIndexResources,
|
fetchIndexResources,
|
||||||
getFetchIndexResourcesFailure,
|
getFetchIndexResourcesFailure,
|
||||||
@@ -35,11 +29,7 @@ class Index extends Component<Props> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const {
|
const { loading, error, t } = this.props;
|
||||||
loading,
|
|
||||||
error,
|
|
||||||
t,
|
|
||||||
} = this.props;
|
|
||||||
|
|
||||||
if (loading) {
|
if (loading) {
|
||||||
return <Loading />;
|
return <Loading />;
|
||||||
@@ -59,7 +49,6 @@ class Index extends Component<Props> {
|
|||||||
|
|
||||||
const mapDispatchToProps = (dispatch: any) => {
|
const mapDispatchToProps = (dispatch: any) => {
|
||||||
return {
|
return {
|
||||||
fetchMe: (link: string) => dispatch(fetchMe(link)),
|
|
||||||
fetchIndexResources: () => dispatch(fetchIndexResources())
|
fetchIndexResources: () => dispatch(fetchIndexResources())
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,9 +1,15 @@
|
|||||||
// @flow
|
// @flow
|
||||||
import * as React from "react";
|
import * as React from "react";
|
||||||
import { apiClient, Loading } from "@scm-manager/ui-components";
|
import { apiClient, Loading } from "@scm-manager/ui-components";
|
||||||
|
import {
|
||||||
|
callFetchIndexResources,
|
||||||
|
getUiPluginsLink
|
||||||
|
} from "../modules/indexResource";
|
||||||
|
import { connect } from "react-redux";
|
||||||
|
|
||||||
type Props = {
|
type Props = {
|
||||||
children: React.Node
|
children: React.Node,
|
||||||
|
link: string
|
||||||
};
|
};
|
||||||
|
|
||||||
type State = {
|
type State = {
|
||||||
@@ -29,8 +35,16 @@ class PluginLoader extends React.Component<Props, State> {
|
|||||||
this.setState({
|
this.setState({
|
||||||
message: "loading plugin information"
|
message: "loading plugin information"
|
||||||
});
|
});
|
||||||
|
|
||||||
|
callFetchIndexResources().then(response => {
|
||||||
|
const link = response._links.uiPlugins.href;
|
||||||
|
this.getPlugins(link);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
getPlugins = (link: string) => {
|
||||||
apiClient
|
apiClient
|
||||||
.get("ui/plugins")
|
.get(link)
|
||||||
.then(response => response.text())
|
.then(response => response.text())
|
||||||
.then(JSON.parse)
|
.then(JSON.parse)
|
||||||
.then(pluginCollection => pluginCollection._embedded.plugins)
|
.then(pluginCollection => pluginCollection._embedded.plugins)
|
||||||
@@ -40,7 +54,7 @@ class PluginLoader extends React.Component<Props, State> {
|
|||||||
finished: true
|
finished: true
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
};
|
||||||
|
|
||||||
loadPlugins = (plugins: Plugin[]) => {
|
loadPlugins = (plugins: Plugin[]) => {
|
||||||
this.setState({
|
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