mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-12 08:25:44 +01:00
show execute and restart button only if restarting is supported
This commit is contained in:
@@ -27,6 +27,7 @@ import { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import { WithTranslation, withTranslation } from "react-i18next";
|
||||
import waitForRestart from "./waitForRestart";
|
||||
import SuccessNotification from "./SuccessNotification";
|
||||
import PendingPluginsQueue from "./PendingPluginsQueue";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
onClose: () => void;
|
||||
@@ -85,70 +86,14 @@ class ExecutePendingModal extends React.Component<Props, State> {
|
||||
});
|
||||
};
|
||||
|
||||
renderInstallQueue = () => {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins._embedded && pendingPlugins._embedded.new.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.installQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.new.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
renderUpdateQueue = () => {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins._embedded && pendingPlugins._embedded.update.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.updateQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.update.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
renderUninstallQueue = () => {
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
{pendingPlugins._embedded && pendingPlugins._embedded.uninstall.length > 0 && (
|
||||
<>
|
||||
<strong>{t("plugins.modal.uninstallQueue")}</strong>
|
||||
<ul>
|
||||
{pendingPlugins._embedded.uninstall.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
)}
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
renderBody = () => {
|
||||
const { t } = this.props;
|
||||
const { pendingPlugins, t } = this.props;
|
||||
return (
|
||||
<>
|
||||
<div className="media">
|
||||
<div className="content">
|
||||
<p>{t("plugins.modal.executePending")}</p>
|
||||
{this.renderInstallQueue()}
|
||||
{this.renderUpdateQueue()}
|
||||
{this.renderUninstallQueue()}
|
||||
<PendingPluginsQueue pendingPlugins={pendingPlugins} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="media">{this.renderNotifications()}</div>
|
||||
|
||||
@@ -0,0 +1,66 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
|
||||
import React, { FC } from "react";
|
||||
import { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
|
||||
type Props = {
|
||||
pendingPlugins: PendingPlugins;
|
||||
};
|
||||
|
||||
type SectionProps = Props & {
|
||||
type: string;
|
||||
label: string;
|
||||
};
|
||||
|
||||
const Section: FC<SectionProps> = ({ pendingPlugins, type, label }) => {
|
||||
const plugins = pendingPlugins?._embedded[type];
|
||||
if (!plugins || plugins.length === 0) {
|
||||
return null;
|
||||
}
|
||||
return (
|
||||
<>
|
||||
<strong>{label}</strong>
|
||||
<ul>
|
||||
{plugins.map(plugin => (
|
||||
<li key={plugin.name}>{plugin.name}</li>
|
||||
))}
|
||||
</ul>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
const PendingPluginsQueue: FC<Props> = ({ pendingPlugins }) => {
|
||||
const [t] = useTranslation("admin");
|
||||
return (
|
||||
<>
|
||||
<Section pendingPlugins={pendingPlugins} type="new" label={t("plugins.modal.installQueue")} />
|
||||
<Section pendingPlugins={pendingPlugins} type="update" label={t("plugins.modal.updateQueue")} />
|
||||
<Section pendingPlugins={pendingPlugins} type="uninstall" label={t("plugins.modal.uninstallQueue")} />
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
export default PendingPluginsQueue;
|
||||
@@ -0,0 +1,70 @@
|
||||
/*
|
||||
* MIT License
|
||||
*
|
||||
* Copyright (c) 2020-present Cloudogu GmbH and Contributors
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in all
|
||||
* copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
* SOFTWARE.
|
||||
*/
|
||||
import React, { FC } from "react";
|
||||
import { Button, Modal, Notification } from "@scm-manager/ui-components";
|
||||
import { PendingPlugins } from "@scm-manager/ui-types";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import PendingPluginsQueue from "./PendingPluginsQueue";
|
||||
|
||||
|
||||
type ModalBodyProps = {
|
||||
pendingPlugins: PendingPlugins;
|
||||
};
|
||||
|
||||
const ModalBody: FC<ModalBodyProps> = ({ pendingPlugins }) => {
|
||||
const [t] = useTranslation("admin");
|
||||
return (
|
||||
<>
|
||||
<div className="media">
|
||||
<div className="content">
|
||||
<p>{t("plugins.modal.showPending")}</p>
|
||||
<PendingPluginsQueue pendingPlugins={pendingPlugins} />
|
||||
</div>
|
||||
</div>
|
||||
<div className="media">
|
||||
<Notification type="warning">{t("plugins.modal.restartNotification")}</Notification>
|
||||
</div>
|
||||
</>
|
||||
);
|
||||
};
|
||||
|
||||
type Props = {
|
||||
onClose: () => void;
|
||||
pendingPlugins: PendingPlugins;
|
||||
};
|
||||
|
||||
const ShowPendingModal: FC<Props> = ({ pendingPlugins, onClose }) => {
|
||||
const [t] = useTranslation("admin");
|
||||
return (
|
||||
<Modal
|
||||
title={t("plugins.showPending")}
|
||||
closeFunction={onClose}
|
||||
body={<ModalBody pendingPlugins={pendingPlugins} />}
|
||||
footer={<Button label={t("plugins.modal.close")} action={onClose} />}
|
||||
active={true}
|
||||
/>
|
||||
);
|
||||
};
|
||||
|
||||
export default ShowPendingModal;
|
||||
@@ -55,6 +55,7 @@ import ExecutePendingActionModal from "../components/ExecutePendingActionModal";
|
||||
import CancelPendingActionModal from "../components/CancelPendingActionModal";
|
||||
import UpdateAllActionModal from "../components/UpdateAllActionModal";
|
||||
import { Plugin } from "@scm-manager/ui-types/src";
|
||||
import ShowPendingModal from "../components/ShowPendingModal";
|
||||
|
||||
type Props = WithTranslation & {
|
||||
loading: boolean;
|
||||
@@ -74,6 +75,7 @@ type Props = WithTranslation & {
|
||||
|
||||
type State = {
|
||||
showPendingModal: boolean;
|
||||
showExecutePendingModal: boolean;
|
||||
showUpdateAllModal: boolean;
|
||||
showCancelModal: boolean;
|
||||
};
|
||||
@@ -83,6 +85,7 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
super(props);
|
||||
this.state = {
|
||||
showPendingModal: false,
|
||||
showExecutePendingModal: false,
|
||||
showUpdateAllModal: false,
|
||||
showCancelModal: false
|
||||
};
|
||||
@@ -138,38 +141,57 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
const { pendingPlugins, collection, t } = this.props;
|
||||
const buttons = [];
|
||||
|
||||
if (pendingPlugins && pendingPlugins._links && pendingPlugins._links.execute) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"executePending"}
|
||||
icon={"arrow-circle-right"}
|
||||
label={t("plugins.executePending")}
|
||||
action={() =>
|
||||
this.setState({
|
||||
showPendingModal: true
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
if (pendingPlugins && pendingPlugins._links) {
|
||||
if (pendingPlugins._links.execute) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"executePending"}
|
||||
icon={"arrow-circle-right"}
|
||||
label={t("plugins.executePending")}
|
||||
action={() =>
|
||||
this.setState({
|
||||
showExecutePendingModal: true
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (pendingPlugins && pendingPlugins._links && pendingPlugins._links.cancel) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"cancelPending"}
|
||||
icon={"times"}
|
||||
label={t("plugins.cancelPending")}
|
||||
action={() =>
|
||||
this.setState({
|
||||
showCancelModal: true
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
if (pendingPlugins._links.cancel) {
|
||||
if (!pendingPlugins._links.execute) {
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"showPending"}
|
||||
icon={"info"}
|
||||
label={t("plugins.showPending")}
|
||||
action={() =>
|
||||
this.setState({
|
||||
showPendingModal: true
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
buttons.push(
|
||||
<Button
|
||||
color="primary"
|
||||
reducedMobile={true}
|
||||
key={"cancelPending"}
|
||||
icon={"times"}
|
||||
label={t("plugins.cancelPending")}
|
||||
action={() =>
|
||||
this.setState({
|
||||
showCancelModal: true
|
||||
})
|
||||
}
|
||||
/>
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if (collection && collection._links && collection._links.update) {
|
||||
@@ -228,14 +250,27 @@ class PluginsOverview extends React.Component<Props, State> {
|
||||
|
||||
renderModals = () => {
|
||||
const { collection, pendingPlugins } = this.props;
|
||||
const { showPendingModal, showCancelModal, showUpdateAllModal } = this.state;
|
||||
const { showPendingModal, showExecutePendingModal, showCancelModal, showUpdateAllModal } = this.state;
|
||||
|
||||
if (showPendingModal) {
|
||||
return (
|
||||
<ShowPendingModal
|
||||
onClose={() =>
|
||||
this.setState({
|
||||
showPendingModal: false
|
||||
})
|
||||
}
|
||||
pendingPlugins={pendingPlugins}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
if (showExecutePendingModal) {
|
||||
return (
|
||||
<ExecutePendingActionModal
|
||||
onClose={() =>
|
||||
this.setState({
|
||||
showPendingModal: false
|
||||
showExecutePendingModal: false
|
||||
})
|
||||
}
|
||||
pendingPlugins={pendingPlugins}
|
||||
|
||||
Reference in New Issue
Block a user