2019-10-20 18:02:52 +02:00
|
|
|
import React from "react";
|
2019-10-23 15:47:08 +02:00
|
|
|
import { WithTranslation, withTranslation } from "react-i18next";
|
2019-10-20 18:02:52 +02:00
|
|
|
import { PendingPlugins } from "@scm-manager/ui-types";
|
|
|
|
|
import { apiClient, Notification } from "@scm-manager/ui-components";
|
2019-10-23 15:47:08 +02:00
|
|
|
import waitForRestart from "./waitForRestart";
|
|
|
|
|
import PluginActionModal from "./PluginActionModal";
|
2019-10-19 16:38:07 +02:00
|
|
|
|
2019-10-23 15:47:08 +02:00
|
|
|
type Props = WithTranslation & {
|
2019-10-19 16:38:07 +02:00
|
|
|
onClose: () => void;
|
|
|
|
|
pendingPlugins: PendingPlugins;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class ExecutePendingActionModal extends React.Component<Props> {
|
|
|
|
|
render() {
|
|
|
|
|
const { onClose, pendingPlugins, t } = this.props;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<PluginActionModal
|
2019-10-20 18:02:52 +02:00
|
|
|
description={t("plugins.modal.executePending")}
|
|
|
|
|
label={t("plugins.modal.executeAndRestart")}
|
2019-10-19 16:38:07 +02:00
|
|
|
onClose={onClose}
|
|
|
|
|
pendingPlugins={pendingPlugins}
|
|
|
|
|
execute={this.executeAndRestart}
|
|
|
|
|
>
|
2019-10-21 10:57:56 +02:00
|
|
|
<Notification type="warning">{t("plugins.modal.restartNotification")}</Notification>
|
2019-10-19 16:38:07 +02:00
|
|
|
</PluginActionModal>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
executeAndRestart = () => {
|
|
|
|
|
const { pendingPlugins } = this.props;
|
2019-10-21 10:57:56 +02:00
|
|
|
return apiClient.post(pendingPlugins._links.execute.href).then(waitForRestart);
|
2019-10-19 16:38:07 +02:00
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
2019-10-23 15:47:08 +02:00
|
|
|
export default withTranslation("admin")(ExecutePendingActionModal);
|