clear queues after abort pending changes / do not restart after update all plugins

This commit is contained in:
Eduard Heimbuch
2019-09-28 15:28:40 +02:00
parent 333579ef2a
commit 78b17c17e8
4 changed files with 58 additions and 51 deletions

View File

@@ -29,9 +29,9 @@
"installedNavLink": "Installiert", "installedNavLink": "Installiert",
"availableNavLink": "Verfügbar" "availableNavLink": "Verfügbar"
}, },
"executePending": "Ausstehende Plugin-Änderungen ausführen", "executePending": "Ausstehende Änderungen ausführen",
"updateAll": "Alle Plugins aktualisieren", "updateAll": "Alle Plugins aktualisieren",
"cancelPending": "Ausstehende Plugin-Änderungen abbrechen", "cancelPending": "Ausstehende Änderungen abbrechen",
"noPlugins": "Keine Plugins gefunden.", "noPlugins": "Keine Plugins gefunden.",
"modal": { "modal": {
"title": { "title": {
@@ -50,6 +50,7 @@
"updateAndRestart": "Aktualisieren und Neustarten", "updateAndRestart": "Aktualisieren und Neustarten",
"uninstallAndRestart": "Deinstallieren and Neustarten", "uninstallAndRestart": "Deinstallieren and Neustarten",
"executeAndRestart": "Ausführen und Neustarten", "executeAndRestart": "Ausführen und Neustarten",
"updateAllAndRestart": "Alle aktualisieren und Neustarten",
"abort": "Abbrechen", "abort": "Abbrechen",
"author": "Autor", "author": "Autor",
"version": "Version", "version": "Version",
@@ -60,7 +61,9 @@
"successNotification": "Das Plugin wurde erfolgreich installiert. Um Änderungen an der UI zu sehen, muss die Seite neu geladen werden:", "successNotification": "Das Plugin wurde erfolgreich installiert. Um Änderungen an der UI zu sehen, muss die Seite neu geladen werden:",
"reload": "jetzt neu laden", "reload": "jetzt neu laden",
"restartNotification": "Der SCM-Manager Kontext sollte nur neu gestartet werden, wenn aktuell niemand damit arbeitet.", "restartNotification": "Der SCM-Manager Kontext sollte nur neu gestartet werden, wenn aktuell niemand damit arbeitet.",
"executePending": "Die folgenden Plugin-Änderungen werden ausgeführt. Anschließend wird der SCM-Manager Kontext neu gestartet." "executePending": "Die folgenden Plugin-Änderungen werden ausgeführt. Anschließend wird der SCM-Manager Kontext neu gestartet.",
"cancelPending": "Die folgenden Plugin-Änderungen werden abgebrochen und zurückgesetzt.",
"updateAllInfo": "Die folgenden Plugins werden aktualisiert. Die Änderungen werden nach dem nächsten Neustart wirksam."
} }
}, },
"repositoryRole": { "repositoryRole": {

View File

@@ -29,9 +29,9 @@
"installedNavLink": "Installed", "installedNavLink": "Installed",
"availableNavLink": "Available" "availableNavLink": "Available"
}, },
"executePending": "Execute pending plugin changes", "executePending": "Execute pending changes",
"updateAll": "Update all plugins", "updateAll": "Update all",
"cancelPending": "Cancel pending plugin changes", "cancelPending": "Cancel pending changes",
"noPlugins": "No plugins found.", "noPlugins": "No plugins found.",
"modal": { "modal": {
"title": { "title": {
@@ -50,6 +50,7 @@
"updateAndRestart": "Update and Restart", "updateAndRestart": "Update and Restart",
"uninstallAndRestart": "Uninstall and Restart", "uninstallAndRestart": "Uninstall and Restart",
"executeAndRestart": "Execute and Restart", "executeAndRestart": "Execute and Restart",
"updateAll": "Update all plugins",
"abort": "Abort", "abort": "Abort",
"author": "Author", "author": "Author",
"version": "Version", "version": "Version",
@@ -60,7 +61,9 @@
"successNotification": "Successful installed plugin. You have to reload the page, to see ui changes:", "successNotification": "Successful installed plugin. You have to reload the page, to see ui changes:",
"reload": "reload now", "reload": "reload now",
"restartNotification": "You should only restart the scm-manager context if no one else is currently working with it.", "restartNotification": "You should only restart the scm-manager context if no one else is currently working with it.",
"executePending": "The following plugin changes will be executed and after that the scm-manager context will be restarted." "executePending": "The following plugin changes will be executed and after that the scm-manager context will be restarted.",
"cancelPending": "The following plugin changes will be canceled.",
"updateAllInfo": "The following plugin changes will be executed. You need to restart the scm-manager to make these changes effective."
} }
}, },
"repositoryRole": { "repositoryRole": {

View File

@@ -63,7 +63,7 @@ class MultiPluginActionModal extends React.Component<Props, State> {
} else if (actionType === MultiPluginActionType.CANCEL_PENDING) { } else if (actionType === MultiPluginActionType.CANCEL_PENDING) {
this.cancelPending(); this.cancelPending();
} else if (actionType === MultiPluginActionType.UPDATE_ALL) { } else if (actionType === MultiPluginActionType.UPDATE_ALL) {
this.updateAllWithRestart(); this.updateAll();
} }
}; };
@@ -97,24 +97,10 @@ class MultiPluginActionModal extends React.Component<Props, State> {
loading: true loading: true
}); });
apiClient apiClient.post(pendingPlugins._links.cancel.href).then(() => this.reload());
.post(pendingPlugins._links.cancel.href)
.then(() => {
this.setState({
success: true,
loading: false
});
})
.catch(error => {
this.setState({
success: false,
loading: false,
error: error
});
});
}; };
updateAllWithRestart = () => { updateAll = () => {
const { installedPlugins } = this.props; const { installedPlugins } = this.props;
this.setState({ this.setState({
loading: true loading: true
@@ -122,20 +108,11 @@ class MultiPluginActionModal extends React.Component<Props, State> {
apiClient apiClient
.post(installedPlugins._links.update.href) .post(installedPlugins._links.update.href)
.then(waitForRestart) .then(() => this.reload());
.then(() => { };
this.setState({
success: true, reload = () => {
loading: false window.location.reload(true);
});
})
.catch(error => {
this.setState({
success: false,
loading: false,
error: error
});
});
}; };
renderModalContent = () => { renderModalContent = () => {
@@ -155,7 +132,7 @@ class MultiPluginActionModal extends React.Component<Props, State> {
}; };
renderUpdatable = () => { renderUpdatable = () => {
const {installedPlugins, t} = this.props; const { installedPlugins, t } = this.props;
return ( return (
<> <>
{installedPlugins && {installedPlugins &&
@@ -236,17 +213,43 @@ class MultiPluginActionModal extends React.Component<Props, State> {
); );
}; };
renderDescription = () => {
const { t, actionType } = this.props;
if (actionType === MultiPluginActionType.EXECUTE_PENDING) {
return t("plugins.modal.executePending");
} else if (actionType === MultiPluginActionType.CANCEL_PENDING) {
return t("plugins.modal.cancelPending");
} else if (actionType === MultiPluginActionType.UPDATE_ALL) {
return t("plugins.modal.updateAllInfo");
}
};
renderLabel = () => {
const { t, actionType } = this.props;
if (actionType === MultiPluginActionType.EXECUTE_PENDING) {
return t("plugins.modal.executeAndRestart");
} else if (actionType === MultiPluginActionType.CANCEL_PENDING) {
return t("plugins.cancelPending");
} else if (actionType === MultiPluginActionType.UPDATE_ALL) {
return t("plugins.updateAll");
}
};
renderBody = () => { renderBody = () => {
const { t } = this.props; const { actionType } = this.props;
return ( return (
<> <>
<div className="media"> <div className="media">
<div className="content"> <div className="content">
<p>{t("plugins.modal.executePending")}</p> <p>{this.renderDescription()}</p>
{this.renderModalContent()} {this.renderModalContent()}
</div> </div>
</div> </div>
<div className="media">{this.renderNotifications()}</div> {actionType === MultiPluginActionType.EXECUTE_PENDING && (
<div className="media">{this.renderNotifications()}</div>
)}
</> </>
); );
}; };
@@ -258,7 +261,7 @@ class MultiPluginActionModal extends React.Component<Props, State> {
<ButtonGroup> <ButtonGroup>
<Button <Button
color="warning" color="warning"
label={t("plugins.modal.executeAndRestart")} label={this.renderLabel()}
loading={loading} loading={loading}
action={this.executeAction} action={this.executeAction}
disabled={error || success} disabled={error || success}
@@ -269,10 +272,10 @@ class MultiPluginActionModal extends React.Component<Props, State> {
}; };
render() { render() {
const { onClose, t } = this.props; const { onClose } = this.props;
return ( return (
<Modal <Modal
title={t("plugins.modal.executeAndRestart")} title={this.renderLabel()}
closeFunction={onClose} closeFunction={onClose}
body={this.renderBody()} body={this.renderBody()}
footer={this.renderFooter()} footer={this.renderFooter()}

View File

@@ -144,6 +144,7 @@ public class DefaultPluginManager implements PluginManager {
return getInstalled() return getInstalled()
.stream() .stream()
.filter(p -> isUpdatable(p.getDescriptor().getInformation().getName())) .filter(p -> isUpdatable(p.getDescriptor().getInformation().getName()))
.filter(p -> !p.isMarkedForUninstall())
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
@@ -285,22 +286,19 @@ public class DefaultPluginManager implements PluginManager {
PluginPermissions.manage().check(); PluginPermissions.manage().check();
pendingUninstallQueue.forEach(PendingPluginUninstallation::cancel); pendingUninstallQueue.forEach(PendingPluginUninstallation::cancel);
pendingInstallQueue.forEach(PendingPluginInstallation::cancel); pendingInstallQueue.forEach(PendingPluginInstallation::cancel);
pendingUninstallQueue.clear();
pendingInstallQueue.clear();
getInstalled().forEach(p -> p.setUninstallable(isUninstallable(p)));
} }
@Override @Override
public void updateAll() { public void updateAll() {
PluginPermissions.manage().check(); PluginPermissions.manage().check();
boolean pluginUpdated = false;
for (InstalledPlugin installedPlugin : getInstalled()) { for (InstalledPlugin installedPlugin : getInstalled()) {
String pluginName = installedPlugin.getDescriptor().getInformation().getName(); String pluginName = installedPlugin.getDescriptor().getInformation().getName();
if (isUpdatable(pluginName)) { if (isUpdatable(pluginName)) {
install(pluginName, false); install(pluginName, false);
pluginUpdated = true;
} }
} }
if (pluginUpdated) {
restart("update all plugins");
}
} }
} }