show specific notification for each plugin action

This commit is contained in:
Eduard Heimbuch
2020-03-19 10:06:54 +01:00
parent ae8c6a2391
commit 99e2781d93
4 changed files with 29 additions and 6 deletions

View File

@@ -161,7 +161,7 @@ class PluginModal extends React.Component<Props, State> {
}
renderNotifications = () => {
const { t } = this.props;
const { t, pluginAction } = this.props;
const { restart, error, success } = this.state;
if (error) {
return (
@@ -172,7 +172,7 @@ class PluginModal extends React.Component<Props, State> {
} else if (success) {
return (
<div className="media">
<SuccessNotification />
<SuccessNotification pluginAction={pluginAction} />
</div>
);
} else if (restart) {

View File

@@ -1,13 +1,30 @@
import React from "react";
import { WithTranslation, withTranslation } from "react-i18next";
import { Notification } from "@scm-manager/ui-components";
import { PluginAction } from "./PluginEntry";
type Props = WithTranslation & {
pluginAction?: string;
};
class InstallSuccessNotification extends React.Component<Props> {
createMessageForPluginAction = () => {
const { pluginAction, t } = this.props;
if (pluginAction === PluginAction.INSTALL) {
return t("plugins.modal.installedNotification");
} else if (pluginAction === PluginAction.UPDATE) {
return t("plugins.modal.updatedNotification");
} else if (pluginAction === PluginAction.UNINSTALL) {
return t("plugins.modal.uninstalledNotification");
}
return t("plugins.modal.executedChangesNotification");
};
class InstallSuccessNotification extends React.Component<WithTranslation> {
render() {
const { t } = this.props;
return (
<Notification type="success">
{t("plugins.modal.successNotification")}{" "}
{this.createMessageForPluginAction()}{" "}
<a onClick={e => window.location.reload(true)}>{t("plugins.modal.reload")}</a>
</Notification>
);