//@flow import React from "react"; import { compose } from "redux"; import { translate } from "react-i18next"; import injectSheet from "react-jss"; import type { Plugin } from "@scm-manager/ui-types"; import { apiClient, Button, ButtonGroup, Checkbox, ErrorNotification, Modal, SubmitButton } from "@scm-manager/ui-components"; import classNames from "classnames"; type Props = { plugin: Plugin, onSubmit: () => void, onClose: () => void, // context props classes: any, t: (key: string, params?: Object) => string }; type State = { loading: boolean, error?: Error }; const styles = { titleVersion: { marginLeft: "0.75rem" }, userLabelAlignment: { textAlign: "left", marginRight: 0, minWidth: "5.5em" }, userFieldFlex: { flexGrow: 4 }, listSpacing: { marginTop: "0 !important" }, error: { marginTop: "1em" } }; 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 (