change plugin overview action buttons

This commit is contained in:
Eduard Heimbuch
2019-09-30 10:26:32 +02:00
parent 78b17c17e8
commit 66d4eb7a7f
5 changed files with 77 additions and 40 deletions

View File

@@ -29,9 +29,11 @@
"installedNavLink": "Installiert",
"availableNavLink": "Verfügbar"
},
"executePending": "Ausstehende Änderungen ausführen",
"executePending": "Änderungen ausführen",
"outdatedPlugins": "{{count}} veraltetes Plugin",
"outdatedPlugins_plural": "{{count}} veraltete Plugins",
"updateAll": "Alle Plugins aktualisieren",
"cancelPending": "Ausstehende Änderungen abbrechen",
"cancelPending": "Änderungen abbrechen",
"noPlugins": "Keine Plugins gefunden.",
"modal": {
"title": {
@@ -50,7 +52,7 @@
"updateAndRestart": "Aktualisieren und Neustarten",
"uninstallAndRestart": "Deinstallieren and Neustarten",
"executeAndRestart": "Ausführen und Neustarten",
"updateAllAndRestart": "Alle aktualisieren und Neustarten",
"updateAll": "Alle Plugins aktualisieren",
"abort": "Abbrechen",
"author": "Autor",
"version": "Version",

View File

@@ -29,9 +29,11 @@
"installedNavLink": "Installed",
"availableNavLink": "Available"
},
"executePending": "Execute pending changes",
"updateAll": "Update all",
"cancelPending": "Cancel pending changes",
"executePending": "Execute changes",
"outdatedPlugins": "{{count}} outdated plugin",
"outdatedPlugins_plural": "{{count}} outdated plugins",
"updateAll": "Update all plugins",
"cancelPending": "Cancel changes",
"noPlugins": "No plugins found.",
"modal": {
"title": {

View File

@@ -17,7 +17,7 @@ type Props = {
installedPlugins?: PluginCollection,
// context props
t: string => string
t: (key: string, params?: Object) => string
};
type State = {
@@ -39,13 +39,19 @@ class MultiPluginAction extends React.Component<Props, State> {
};
renderLabel = () => {
const {t, actionType} = this.props;
const { t, actionType, installedPlugins } = this.props;
const outdatedPlugins =
actionType === MultiPluginActionType.UPDATE_ALL &&
installedPlugins._embedded.plugins.filter(p => p._links.update).length;
if (actionType === MultiPluginActionType.EXECUTE_PENDING) {
return t("plugins.executePending");
} else if (actionType === MultiPluginActionType.CANCEL_PENDING) {
return t("plugins.cancelPending");
} else {
return t("plugins.updateAll");
return t("plugins.outdatedPlugins", {
count: outdatedPlugins
});
}
};
@@ -73,12 +79,26 @@ class MultiPluginAction extends React.Component<Props, State> {
return null;
};
renderIcon = () => {
const { actionType } = this.props;
if (actionType === MultiPluginActionType.EXECUTE_PENDING) {
return "arrow-circle-right";
} else if (actionType === MultiPluginActionType.CANCEL_PENDING) {
return "times";
} else {
return "sync-alt";
}
};
render() {
return (
<>
{this.renderModal()}
<Button
color="primary"
reducedMobile={true}
icon={this.renderIcon()}
label={this.renderLabel()}
action={this.toggleModal}
/>

View File

@@ -113,34 +113,47 @@ class PluginsOverview extends React.Component<Props> {
createActions = () => {
const { pendingPlugins, collection } = this.props;
return (
<ButtonGroup>
{pendingPlugins &&
const buttons = [];
if (
pendingPlugins &&
pendingPlugins._links &&
pendingPlugins._links.execute && (
pendingPlugins._links.execute
) {
buttons.push(
<MultiPluginAction
pendingPlugins={pendingPlugins}
actionType={MultiPluginActionType.EXECUTE_PENDING}
/>
)}
{pendingPlugins &&
);
}
if (
pendingPlugins &&
pendingPlugins._links &&
pendingPlugins._links.cancel && (
pendingPlugins._links.cancel
) {
buttons.push(
<MultiPluginAction
pendingPlugins={pendingPlugins}
actionType={MultiPluginActionType.CANCEL_PENDING}
/>
)}
{collection &&
collection._links &&
collection._links.update && (
);
}
if (collection && collection._links && collection._links.update) {
buttons.push(
<MultiPluginAction
installedPlugins={collection}
actionType={MultiPluginActionType.UPDATE_ALL}
/>
)}
</ButtonGroup>
);
}
if (buttons.length > 0) {
return <ButtonGroup>{buttons}</ButtonGroup>;
}
return null;
};
render() {

View File

@@ -66,7 +66,7 @@ public class InstalledPluginResource {
@ResponseCode(code = 500, condition = "internal server error")
})
@TypeHint(CollectionDto.class)
public Response updateAll(@QueryParam("restart") boolean restartAfterInstallation) {
public Response updateAll() {
pluginManager.updateAll();
return Response.ok().build();
}