// @flow import React from "react"; import { apiClient, Button, ButtonGroup, ErrorNotification, Modal, Notification } from "@scm-manager/ui-components"; import type { PluginCollection } from "@scm-manager/ui-types"; import { translate } from "react-i18next"; import waitForRestart from "./waitForRestart"; import InstallSuccessNotification from "./InstallSuccessNotification"; type Props = { onClose: () => void, collection: PluginCollection, // context props t: string => string }; type State = { loading: boolean, success: boolean, error?: Error }; class InstallPendingModal extends React.Component { constructor(props: Props) { super(props); this.state = { loading: false, success: false }; } renderNotifications = () => { const { t } = this.props; const { error, success } = this.state; if (error) { return ; } else if (success) { return ; } else { return ( {t("plugins.modal.restartNotification")} ); } }; installAndRestart = () => { const { collection } = this.props; this.setState({ loading: true }); apiClient .post(collection._links.installPending.href) .then(waitForRestart) .then(() => { this.setState({ success: true, loading: false, error: undefined }); }) .catch(error => { this.setState({ success: false, loading: false, error: error }); }); }; renderBody = () => { const { collection, t } = this.props; return ( <>

{t("plugins.modal.installPending")}

    {collection._embedded.plugins .filter(plugin => plugin.pending) .map(plugin => (
  • {plugin.name}
  • ))}
{this.renderNotifications()}
); }; renderFooter = () => { const { onClose, t } = this.props; const { loading, error, success } = this.state; return (