diff --git a/scm-ui/src/admin/plugins/components/PluginModal.js b/scm-ui/src/admin/plugins/components/PluginModal.js index cfa5a858e4..f09f252cc5 100644 --- a/scm-ui/src/admin/plugins/components/PluginModal.js +++ b/scm-ui/src/admin/plugins/components/PluginModal.js @@ -5,9 +5,10 @@ import { translate } from "react-i18next"; import injectSheet from "react-jss"; import type { Plugin } from "@scm-manager/ui-types"; import { + apiClient, Button, ButtonGroup, - Checkbox, + Checkbox, ErrorNotification, Modal, SubmitButton } from "@scm-manager/ui-components"; @@ -20,7 +21,12 @@ type Props = { // context props classes: any, - t: string => string + t: (key: string, params?: Object) => string +}; + +type State = { + loading: boolean, + error?: Error }; const styles = { @@ -37,10 +43,55 @@ const styles = { }, listSpacing: { marginTop: "0 !important" + }, + error: { + marginTop: "1em" } }; -class PluginModal extends React.Component { +class PluginModal extends React.Component { + + constructor(props: Props) { + super(props); + this.state = { + loading: false + }; + } + + install = (e: Event) => { + const { plugin, onClose } = this.props; + this.setState({ + loading: true + }); + e.preventDefault(); + apiClient.post(plugin._links.install.href) + .then(() => { + this.setState({ + loading: false, + error: undefined + }, onClose); + }) + .catch(error => { + this.setState({ + loading: false, + error: error + }); + }); + }; + + footer = () => { + const { onClose, t } = this.props; + const { loading, error } = this.state; + return ( +
+ + +