mirror of
https://github.com/scm-manager/scm-manager.git
synced 2025-11-13 08:55:44 +01:00
Include cloudogu plugins to plugin center (#1709)
Co-authored-by: René Pfeuffer <rene.pfeuffer@cloudogu.com>
This commit is contained in:
@@ -58,12 +58,18 @@ const PluginEntry: FC<Props> = ({ plugin, openModal }) => {
|
||||
const isInstallable = plugin._links.install && (plugin._links.install as Link).href;
|
||||
const isUpdatable = plugin._links.update && (plugin._links.update as Link).href;
|
||||
const isUninstallable = plugin._links.uninstall && (plugin._links.uninstall as Link).href;
|
||||
const isCloudoguPlugin = plugin.type === "CLOUDOGU";
|
||||
|
||||
const pendingSpinner = () => (
|
||||
<Icon className="fa-spin fa-lg" name="spinner" color={plugin.markedForUninstall ? "danger" : "info"} />
|
||||
);
|
||||
const actionBar = () => (
|
||||
<ActionbarWrapper className="is-flex">
|
||||
{isCloudoguPlugin && (
|
||||
<IconWrapper className="level-item" onClick={() => openModal({ plugin, action: PluginAction.CLOUDOGU })}>
|
||||
<Icon title={t("plugins.modal.cloudoguInstall")} name="link" color="success-dark" />
|
||||
</IconWrapper>
|
||||
)}
|
||||
{isInstallable && (
|
||||
<IconWrapper className="level-item" onClick={() => openModal({ plugin, action: PluginAction.INSTALL })}>
|
||||
<Icon title={t("plugins.modal.install")} name="download" color="info" />
|
||||
|
||||
@@ -33,7 +33,7 @@ type Props = {
|
||||
};
|
||||
|
||||
const PluginGroupEntry: FC<Props> = ({ openModal, group }) => {
|
||||
const entries = group.plugins.map(plugin => {
|
||||
const entries = group.plugins.map((plugin) => {
|
||||
return <PluginEntry plugin={plugin} openModal={openModal} key={plugin.name} />;
|
||||
});
|
||||
return <CardColumnGroup name={group.name} elements={entries} />;
|
||||
|
||||
@@ -36,7 +36,7 @@ const PluginList: FC<Props> = ({ plugins, openModal }) => {
|
||||
const groups = groupByCategory(plugins);
|
||||
return (
|
||||
<div className="content is-plugin-page">
|
||||
{groups.map(group => {
|
||||
{groups.map((group) => {
|
||||
return <PluginGroupEntry group={group} openModal={openModal} key={group.name} />;
|
||||
})}
|
||||
</div>
|
||||
|
||||
@@ -25,7 +25,7 @@ import React, { FC, useEffect, useState } from "react";
|
||||
import { useTranslation } from "react-i18next";
|
||||
import classNames from "classnames";
|
||||
import styled from "styled-components";
|
||||
import { Plugin } from "@scm-manager/ui-types";
|
||||
import { Link, Plugin } from "@scm-manager/ui-types";
|
||||
import { Button, ButtonGroup, Checkbox, ErrorNotification, Modal, Notification } from "@scm-manager/ui-components";
|
||||
import SuccessNotification from "./SuccessNotification";
|
||||
import { useInstallPlugin, useUninstallPlugin, useUpdatePlugins } from "@scm-manager/ui-api";
|
||||
@@ -33,13 +33,17 @@ import { PluginAction } from "../containers/PluginsOverview";
|
||||
|
||||
type Props = {
|
||||
plugin: Plugin;
|
||||
pluginAction: string;
|
||||
pluginAction: PluginAction;
|
||||
onClose: () => void;
|
||||
};
|
||||
|
||||
const ListParent = styled.div`
|
||||
type ParentWithPluginAction = {
|
||||
pluginAction?: PluginAction;
|
||||
};
|
||||
|
||||
const ListParent = styled.div.attrs((props) => ({}))<ParentWithPluginAction>`
|
||||
margin-right: 0;
|
||||
min-width: ${props => (props.pluginAction === PluginAction.INSTALL ? "5.5em" : "10em")};
|
||||
min-width: ${(props) => (props.pluginAction === PluginAction.INSTALL ? "5.5em" : "10em")};
|
||||
text-align: left;
|
||||
`;
|
||||
|
||||
@@ -63,9 +67,12 @@ const PluginModal: FC<Props> = ({ onClose, pluginAction, plugin }) => {
|
||||
}
|
||||
}, [isDone]);
|
||||
|
||||
const handlePluginAction = (e: Event) => {
|
||||
const handlePluginAction = (e: React.MouseEvent<Element, MouseEvent>) => {
|
||||
e.preventDefault();
|
||||
switch (pluginAction) {
|
||||
case PluginAction.CLOUDOGU:
|
||||
window.open((plugin._links.cloudoguInstall as Link).href, "_blank");
|
||||
break;
|
||||
case PluginAction.INSTALL:
|
||||
install(plugin, { restart: shouldRestart });
|
||||
break;
|
||||
@@ -76,7 +83,7 @@ const PluginModal: FC<Props> = ({ onClose, pluginAction, plugin }) => {
|
||||
update(plugin, { restart: shouldRestart });
|
||||
break;
|
||||
default:
|
||||
throw new Error(`Unkown plugin action ${pluginAction}`);
|
||||
throw new Error(`Unknown plugin action ${pluginAction}`);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -172,7 +179,7 @@ const PluginModal: FC<Props> = ({ onClose, pluginAction, plugin }) => {
|
||||
disabled={false}
|
||||
/>
|
||||
);
|
||||
} else {
|
||||
} else if (pluginAction !== PluginAction.CLOUDOGU) {
|
||||
return <Notification type="warning">{t("plugins.modal.manualRestartRequired")}</Notification>;
|
||||
}
|
||||
};
|
||||
@@ -192,6 +199,13 @@ const PluginModal: FC<Props> = ({ onClose, pluginAction, plugin }) => {
|
||||
</ListParent>
|
||||
<ListChild className={classNames("field-body", "is-inline-flex")}>{plugin.author}</ListChild>
|
||||
</div>
|
||||
{pluginAction === PluginAction.CLOUDOGU && (
|
||||
<div className="field is-horizontal">
|
||||
<Notification type="info" className="is-full-width">
|
||||
{t("plugins.modal.cloudoguInstallInfo")}
|
||||
</Notification>
|
||||
</div>
|
||||
)}
|
||||
{pluginAction === PluginAction.INSTALL && (
|
||||
<div className="field is-horizontal">
|
||||
<ListParent className={classNames("field-label", "is-inline-flex")} pluginAction={pluginAction}>
|
||||
@@ -230,7 +244,7 @@ const PluginModal: FC<Props> = ({ onClose, pluginAction, plugin }) => {
|
||||
return (
|
||||
<Modal
|
||||
title={t(`plugins.modal.title.${pluginAction}`, {
|
||||
name: plugin.displayName ? plugin.displayName : plugin.name
|
||||
name: plugin.displayName ? plugin.displayName : plugin.name,
|
||||
})}
|
||||
closeFunction={onClose}
|
||||
body={body}
|
||||
|
||||
@@ -32,7 +32,7 @@ import {
|
||||
Loading,
|
||||
Notification,
|
||||
Subtitle,
|
||||
Title
|
||||
Title,
|
||||
} from "@scm-manager/ui-components";
|
||||
import PluginsList from "../components/PluginList";
|
||||
import PluginTopActions from "../components/PluginTopActions";
|
||||
@@ -47,13 +47,14 @@ import PluginModal from "../components/PluginModal";
|
||||
export enum PluginAction {
|
||||
INSTALL = "install",
|
||||
UPDATE = "update",
|
||||
UNINSTALL = "uninstall"
|
||||
UNINSTALL = "uninstall",
|
||||
CLOUDOGU = "cloudoguInstall",
|
||||
}
|
||||
|
||||
export type PluginModalContent = {
|
||||
plugin: Plugin;
|
||||
action: PluginAction;
|
||||
}
|
||||
};
|
||||
|
||||
type Props = {
|
||||
installed: boolean;
|
||||
@@ -64,12 +65,12 @@ const PluginsOverview: FC<Props> = ({ installed }) => {
|
||||
const {
|
||||
data: availablePlugins,
|
||||
isLoading: isLoadingAvailablePlugins,
|
||||
error: availablePluginsError
|
||||
error: availablePluginsError,
|
||||
} = useAvailablePlugins({ enabled: !installed });
|
||||
const {
|
||||
data: installedPlugins,
|
||||
isLoading: isLoadingInstalledPlugins,
|
||||
error: installedPluginsError
|
||||
error: installedPluginsError,
|
||||
} = useInstalledPlugins({ enabled: installed });
|
||||
const { data: pendingPlugins, isLoading: isLoadingPendingPlugins, error: pendingPluginsError } = usePendingPlugins();
|
||||
const [showPendingModal, setShowPendingModal] = useState(false);
|
||||
@@ -166,7 +167,7 @@ const PluginsOverview: FC<Props> = ({ installed }) => {
|
||||
const computeUpdateAllSize = () => {
|
||||
const outdatedPlugins = collection?._embedded.plugins.filter((p: Plugin) => p._links.update).length;
|
||||
return t("plugins.outdatedPlugins", {
|
||||
count: outdatedPlugins
|
||||
count: outdatedPlugins,
|
||||
});
|
||||
};
|
||||
|
||||
@@ -187,28 +188,14 @@ const PluginsOverview: FC<Props> = ({ installed }) => {
|
||||
);
|
||||
}
|
||||
if (showCancelModal && pendingPlugins) {
|
||||
return (
|
||||
<CancelPendingActionModal
|
||||
onClose={() => setShowCancelModal(false)}
|
||||
pendingPlugins={pendingPlugins}
|
||||
/>
|
||||
);
|
||||
return <CancelPendingActionModal onClose={() => setShowCancelModal(false)} pendingPlugins={pendingPlugins} />;
|
||||
}
|
||||
if (showUpdateAllModal && collection) {
|
||||
return (
|
||||
<UpdateAllActionModal
|
||||
onClose={() => setShowUpdateAllModal(false)}
|
||||
installedPlugins={collection}
|
||||
/>
|
||||
);
|
||||
return <UpdateAllActionModal onClose={() => setShowUpdateAllModal(false)} installedPlugins={collection} />;
|
||||
}
|
||||
if (pluginModalContent) {
|
||||
const { action, plugin } = pluginModalContent;
|
||||
return <PluginModal
|
||||
plugin={plugin}
|
||||
pluginAction={action}
|
||||
onClose={() => setPluginModalContent(null)}
|
||||
/>
|
||||
return <PluginModal plugin={plugin} pluginAction={action} onClose={() => setPluginModalContent(null)} />;
|
||||
}
|
||||
return null;
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user