mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 17:05:43 +01:00
Cleanup
This commit is contained in:
@@ -1,10 +1,10 @@
|
||||
// @flow
|
||||
|
||||
import React from "react";
|
||||
import MultiPluginActionModal from "./MultiPluginActionModal";
|
||||
import type {PendingPlugins} from "@scm-manager/ui-types";
|
||||
import {apiClient} from "@scm-manager/ui-components";
|
||||
import {translate} from "react-i18next";
|
||||
import PluginActionModal from "./PluginActionModal";
|
||||
import type { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
onClose: () => void,
|
||||
@@ -15,16 +15,19 @@ type Props = {
|
||||
t: string => string
|
||||
};
|
||||
|
||||
|
||||
class CancelPendingActionModal extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const {onClose, pendingPlugins, t} = this.props;
|
||||
const { onClose, pendingPlugins, t } = this.props;
|
||||
|
||||
return <MultiPluginActionModal
|
||||
description={t("plugins.modal.cancelPending")} label={t("plugins.cancelPending")}
|
||||
onClose={onClose} pendingPlugins={pendingPlugins} execute={this.cancelPending}>
|
||||
</MultiPluginActionModal>;
|
||||
return (
|
||||
<PluginActionModal
|
||||
description={t("plugins.modal.cancelPending")}
|
||||
label={t("plugins.cancelPending")}
|
||||
onClose={onClose}
|
||||
pendingPlugins={pendingPlugins}
|
||||
execute={this.cancelPending}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
cancelPending = () => {
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
// @flow
|
||||
|
||||
import React from "react";
|
||||
import MultiPluginActionModal from "./MultiPluginActionModal";
|
||||
import type {PendingPlugins} from "@scm-manager/ui-types";
|
||||
import PluginActionModal from "./PluginActionModal";
|
||||
import type { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import waitForRestart from "./waitForRestart";
|
||||
import {apiClient, Notification} from "@scm-manager/ui-components";
|
||||
import {translate} from "react-i18next";
|
||||
import { apiClient, Notification } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
onClose: () => void,
|
||||
@@ -15,23 +15,27 @@ type Props = {
|
||||
t: string => string
|
||||
};
|
||||
|
||||
|
||||
class ExecutePendingActionModal extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const {onClose, pendingPlugins, t} = this.props;
|
||||
const { onClose, pendingPlugins, t } = this.props;
|
||||
|
||||
return <MultiPluginActionModal
|
||||
description={t("plugins.modal.executePending")} label={t("plugins.modal.executeAndRestart")}
|
||||
onClose={onClose} pendingPlugins={pendingPlugins} execute={this.executeAndRestart}>
|
||||
return (
|
||||
<PluginActionModal
|
||||
description={t("plugins.modal.executePending")}
|
||||
label={t("plugins.modal.executeAndRestart")}
|
||||
onClose={onClose}
|
||||
pendingPlugins={pendingPlugins}
|
||||
execute={this.executeAndRestart}
|
||||
>
|
||||
<Notification type="warning">
|
||||
{t("plugins.modal.restartNotification")}
|
||||
</Notification>
|
||||
</MultiPluginActionModal>;
|
||||
</PluginActionModal>
|
||||
);
|
||||
}
|
||||
|
||||
executeAndRestart = () => {
|
||||
const {pendingPlugins} = this.props;
|
||||
const { pendingPlugins } = this.props;
|
||||
return apiClient
|
||||
.post(pendingPlugins._links.execute.href)
|
||||
.then(waitForRestart);
|
||||
|
||||
@@ -1,36 +0,0 @@
|
||||
// @flow
|
||||
import React from "react";
|
||||
import { Button } from "@scm-manager/ui-components";
|
||||
import type { PendingPlugins, PluginCollection } from "@scm-manager/ui-types";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
export const MultiPluginActionType = {
|
||||
UPDATE_ALL: "updateAll",
|
||||
CANCEL_PENDING: "cancelPending",
|
||||
EXECUTE_PENDING: "executePending"
|
||||
};
|
||||
|
||||
type Props = {
|
||||
icon: string,
|
||||
label: string,
|
||||
onClick: () => void,
|
||||
};
|
||||
|
||||
class MultiPluginAction extends React.Component<Props> {
|
||||
render() {
|
||||
const { onClick, icon, label } = this.props;
|
||||
return (
|
||||
<>
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
icon={icon}
|
||||
label={label}
|
||||
action={() => onClick()}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
export default MultiPluginAction;
|
||||
@@ -32,7 +32,7 @@ type State = {
|
||||
error?: Error
|
||||
};
|
||||
|
||||
class MultiPluginActionModal extends React.Component<Props, State> {
|
||||
class PluginActionModal extends React.Component<Props, State> {
|
||||
constructor(props: Props) {
|
||||
super(props);
|
||||
this.state = {
|
||||
@@ -42,7 +42,7 @@ class MultiPluginActionModal extends React.Component<Props, State> {
|
||||
}
|
||||
|
||||
renderNotifications = () => {
|
||||
const {children} = this.props;
|
||||
const { children } = this.props;
|
||||
const { error, success } = this.state;
|
||||
if (error) {
|
||||
return <ErrorNotification error={error} />;
|
||||
@@ -58,7 +58,8 @@ class MultiPluginActionModal extends React.Component<Props, State> {
|
||||
loading: true
|
||||
});
|
||||
|
||||
this.props.execute()
|
||||
this.props
|
||||
.execute()
|
||||
.then(() => {
|
||||
this.setState({
|
||||
success: true,
|
||||
@@ -212,4 +213,4 @@ class MultiPluginActionModal extends React.Component<Props, State> {
|
||||
}
|
||||
}
|
||||
|
||||
export default translate("admin")(MultiPluginActionModal);
|
||||
export default translate("admin")(PluginActionModal);
|
||||
@@ -1,10 +1,10 @@
|
||||
// @flow
|
||||
|
||||
import React from "react";
|
||||
import MultiPluginActionModal from "./MultiPluginActionModal";
|
||||
import type {PluginCollection} from "@scm-manager/ui-types";
|
||||
import {apiClient} from "@scm-manager/ui-components";
|
||||
import {translate} from "react-i18next";
|
||||
import PluginActionModal from "./PluginActionModal";
|
||||
import type { PluginCollection } from "@scm-manager/ui-types";
|
||||
import { apiClient } from "@scm-manager/ui-components";
|
||||
import { translate } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
onClose: () => void,
|
||||
@@ -15,16 +15,19 @@ type Props = {
|
||||
t: string => string
|
||||
};
|
||||
|
||||
|
||||
class UpdateAllActionModal extends React.Component<Props> {
|
||||
|
||||
render() {
|
||||
const {onClose, installedPlugins, t} = this.props;
|
||||
const { onClose, installedPlugins, t } = this.props;
|
||||
|
||||
return <MultiPluginActionModal
|
||||
description={t("plugins.modal.updateAll")} label={t("plugins.updateAll")}
|
||||
onClose={onClose} installedPlugins={installedPlugins} execute={this.updateAll}>
|
||||
</MultiPluginActionModal>;
|
||||
return (
|
||||
<PluginActionModal
|
||||
description={t("plugins.modal.updateAll")}
|
||||
label={t("plugins.updateAll")}
|
||||
onClose={onClose}
|
||||
installedPlugins={installedPlugins}
|
||||
execute={this.updateAll}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
updateAll = () => {
|
||||
|
||||
@@ -10,7 +10,8 @@ import {
|
||||
Loading,
|
||||
Notification,
|
||||
Subtitle,
|
||||
Title
|
||||
Title,
|
||||
Button
|
||||
} from "@scm-manager/ui-components";
|
||||
import {
|
||||
fetchPendingPlugins,
|
||||
@@ -28,7 +29,6 @@ import {
|
||||
} from "../../../modules/indexResource";
|
||||
import PluginTopActions from "../components/PluginTopActions";
|
||||
import PluginBottomActions from "../components/PluginBottomActions";
|
||||
import MultiPluginAction from "../components/MultiPluginAction";
|
||||
import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
|
||||
import CancelPendingActionModal from "../components/CancelPendingActionModal";
|
||||
import UpdateAllActionModal from "../components/UpdateAllActionModal";
|
||||
@@ -56,11 +56,9 @@ type State = {
|
||||
showPendingModal: boolean,
|
||||
showUpdateAllModal: boolean,
|
||||
showCancelModal: boolean
|
||||
}
|
||||
};
|
||||
|
||||
class PluginsOverview extends React.Component<Props, State> {
|
||||
|
||||
|
||||
constructor(props: Props, context: *) {
|
||||
super(props, context);
|
||||
this.state = {
|
||||
@@ -139,12 +137,13 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
pendingPlugins._links.execute
|
||||
) {
|
||||
buttons.push(
|
||||
<MultiPluginAction
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"executePending"}
|
||||
icon={"arrow-circle-right"}
|
||||
label={t("plugins.executePending")}
|
||||
refresh={this.fetchPlugins}
|
||||
onClick={() => this.setState({showPendingModal: true})}
|
||||
action={() => this.setState({ showPendingModal: true })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -155,24 +154,26 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
pendingPlugins._links.cancel
|
||||
) {
|
||||
buttons.push(
|
||||
<MultiPluginAction
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"cancelPending"}
|
||||
icon={"times"}
|
||||
label={t("plugins.cancelPending")}
|
||||
refresh={this.fetchPlugins}
|
||||
onClick={() => this.setState({showCancelModal: true})}
|
||||
action={() => this.setState({ showCancelModal: true })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (collection && collection._links && collection._links.update) {
|
||||
buttons.push(
|
||||
<MultiPluginAction
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"updateAll"}
|
||||
icon={"sync-alt"}
|
||||
label={this.computeUpdateAllSize()}
|
||||
refresh={this.fetchPlugins}
|
||||
onClick={() => this.setState({showUpdateAllModal: true})}
|
||||
onClick={() => this.setState({ showUpdateAllModal: true })}
|
||||
/>
|
||||
);
|
||||
}
|
||||
@@ -184,7 +185,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
};
|
||||
|
||||
computeUpdateAllSize = () => {
|
||||
const {collection, t} = this.props;
|
||||
const { collection, t } = this.props;
|
||||
const outdatedPlugins = collection._embedded.plugins.filter(
|
||||
p => p._links.update
|
||||
).length;
|
||||
@@ -196,27 +197,37 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
render() {
|
||||
const { loading, error, collection, pendingPlugins } = this.props;
|
||||
|
||||
const { showPendingModal, showCancelModal, showUpdateAllModal} = this.state;
|
||||
const {
|
||||
showPendingModal,
|
||||
showCancelModal,
|
||||
showUpdateAllModal
|
||||
} = this.state;
|
||||
|
||||
if (showPendingModal) {
|
||||
return <ExecutePendingActionModal
|
||||
onClose={() => this.setState({showPendingModal: false})}
|
||||
return (
|
||||
<ExecutePendingActionModal
|
||||
onClose={() => this.setState({ showPendingModal: false })}
|
||||
pendingPlugins={pendingPlugins}
|
||||
/>;
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (showCancelModal) {
|
||||
return <CancelPendingActionModal
|
||||
onClose={() => this.setState({showCancelModal: false})}
|
||||
return (
|
||||
<CancelPendingActionModal
|
||||
onClose={() => this.setState({ showCancelModal: false })}
|
||||
refresh={this.fetchPlugins}
|
||||
pendingPlugins={pendingPlugins}
|
||||
/>;
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (showUpdateAllModal) {
|
||||
return <UpdateAllActionModal
|
||||
onClose={() => this.setState({showUpdateAllModal: false})}
|
||||
return (
|
||||
<UpdateAllActionModal
|
||||
onClose={() => this.setState({ showUpdateAllModal: false })}
|
||||
refresh={this.fetchPlugins}
|
||||
installedPlugins={collection}
|
||||
/>;
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (error) {
|
||||
|
||||
Reference in New Issue
Block a user