2019-08-21 14:54:01 +02:00
|
|
|
// @flow
|
|
|
|
|
import React from "react";
|
2019-08-21 16:46:50 +02:00
|
|
|
import { Button } from "@scm-manager/ui-components";
|
2019-09-16 14:31:55 +02:00
|
|
|
import type { PendingPlugins } from "@scm-manager/ui-types";
|
2019-08-21 14:54:01 +02:00
|
|
|
import { translate } from "react-i18next";
|
2019-09-16 14:31:55 +02:00
|
|
|
import ExecutePendingModal from "./ExecutePendingModal";
|
2019-08-21 14:54:01 +02:00
|
|
|
|
|
|
|
|
type Props = {
|
2019-09-16 14:31:55 +02:00
|
|
|
pendingPlugins: PendingPlugins,
|
2019-08-21 14:54:01 +02:00
|
|
|
|
|
|
|
|
// context props
|
|
|
|
|
t: string => string
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
type State = {
|
|
|
|
|
showModal: boolean
|
|
|
|
|
};
|
|
|
|
|
|
2019-09-16 14:31:55 +02:00
|
|
|
class ExecutePendingAction extends React.Component<Props, State> {
|
2019-08-21 14:54:01 +02:00
|
|
|
constructor(props: Props) {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
showModal: false
|
|
|
|
|
};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
openModal = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
showModal: true
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
closeModal = () => {
|
|
|
|
|
this.setState({
|
|
|
|
|
showModal: false
|
|
|
|
|
});
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
renderModal = () => {
|
|
|
|
|
const { showModal } = this.state;
|
2019-09-16 14:31:55 +02:00
|
|
|
const { pendingPlugins } = this.props;
|
2019-08-21 14:54:01 +02:00
|
|
|
if (showModal) {
|
|
|
|
|
return (
|
2019-09-16 14:31:55 +02:00
|
|
|
<ExecutePendingModal
|
|
|
|
|
pendingPlugins={pendingPlugins}
|
2019-08-21 14:54:01 +02:00
|
|
|
onClose={this.closeModal}
|
|
|
|
|
/>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const { t } = this.props;
|
|
|
|
|
return (
|
|
|
|
|
<>
|
|
|
|
|
{this.renderModal()}
|
|
|
|
|
<Button
|
|
|
|
|
color="primary"
|
2019-09-16 14:31:55 +02:00
|
|
|
label={t("plugins.executePending")}
|
2019-08-21 14:54:01 +02:00
|
|
|
action={this.openModal}
|
|
|
|
|
/>
|
|
|
|
|
</>
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2019-09-16 14:31:55 +02:00
|
|
|
export default translate("admin")(ExecutePendingAction);
|