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