From dfe1705d23972f42fe1c55176bd93e88d6281fbc Mon Sep 17 00:00:00 2001 From: "bjoern.eschle" Date: Tue, 7 Feb 2023 12:08:19 +0100 Subject: [PATCH] Fix add/edit folder actions --- .../action/add/AddAppActionDefinition.java | 4 +++- .../action/add/OpenCreateDialogAction.java | 15 ++++----------- .../action/edit/EditAppActionDefinition.java | 4 ++-- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/AddAppActionDefinition.java b/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/AddAppActionDefinition.java index 9b53297..9b8d825 100644 --- a/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/AddAppActionDefinition.java +++ b/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/AddAppActionDefinition.java @@ -4,6 +4,7 @@ import com.namics.oss.magnolia.appbuilder.action.AppActionDefinition; import com.namics.oss.magnolia.appbuilder.action.AvailabilityDefinitionBuilder; import com.namics.oss.magnolia.appbuilder.action.JcrIsNotDeletedRuleDefinition; +import info.magnolia.jcr.util.NodeTypes; import info.magnolia.ui.api.action.ConfiguredActionDefinition; import javax.annotation.Nullable; @@ -11,7 +12,8 @@ public class AddAppActionDefinition implements AppActionDefinition { public static final AddAppActionDefinition FOLDER = new AddAppActionDefinition( "addFolder", - "ui-framework:folder", + NodeTypes.Folder.NAME, + "ui-framework-jcr:rename", MgnlIcon.ADD_FOLDER, "actions.addFolder" ); diff --git a/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/OpenCreateDialogAction.java b/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/OpenCreateDialogAction.java index dcdd211..46999fa 100644 --- a/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/OpenCreateDialogAction.java +++ b/src/main/java/com/namics/oss/magnolia/appbuilder/action/add/OpenCreateDialogAction.java @@ -4,16 +4,12 @@ import info.magnolia.ui.UIComponent; import info.magnolia.ui.ValueContext; import info.magnolia.ui.api.i18n.I18NAuthoringSupport; -import info.magnolia.ui.dialog.ConfiguredDialogDefinition; import info.magnolia.ui.dialog.DialogDefinition; import info.magnolia.ui.dialog.DialogDefinitionRegistry; import info.magnolia.ui.dialog.actions.OpenDialogAction; import info.magnolia.ui.editor.LocaleContext; import javax.jcr.Node; -import java.util.Map; -import java.util.stream.Collectors; -import java.util.stream.Stream; public class OpenCreateDialogAction extends OpenDialogAction { private final OpenCreateDialogActionDefinition definition; @@ -31,12 +27,9 @@ public OpenCreateDialogAction( } @Override - protected DialogDefinition getDialogDefinition(DialogDefinitionRegistry dialogDefinitionRegistry, I18nizer i18nizer) { - final ConfiguredDialogDefinition dialogDefinition = (ConfiguredDialogDefinition) super.getDialogDefinition(dialogDefinitionRegistry, i18nizer); - dialogDefinition.setActions(Stream.concat( - dialogDefinition.getActions().entrySet().stream(), - Stream.of(Map.entry("commit", definition.getCommitAction())) - ).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (d1, d2) -> d2))); - return dialogDefinition; + protected DialogDefinition getDialogDefinition(final DialogDefinitionRegistry dialogDefinitionRegistry, final I18nizer i18nizer) { + final DialogDefinition dialogDefinition = dialogDefinitionRegistry.getProvider(getDefinition().getDialogId()).get(); + dialogDefinition.getActions().put("commit", definition.getCommitAction()); //we can't generate a new map due to byteBuddy (I18nizer), but since it is a mutable hash map this is fine + return i18nizer.decorate(dialogDefinition); } } \ No newline at end of file diff --git a/src/main/java/com/namics/oss/magnolia/appbuilder/action/edit/EditAppActionDefinition.java b/src/main/java/com/namics/oss/magnolia/appbuilder/action/edit/EditAppActionDefinition.java index 3da3f57..d010f2c 100644 --- a/src/main/java/com/namics/oss/magnolia/appbuilder/action/edit/EditAppActionDefinition.java +++ b/src/main/java/com/namics/oss/magnolia/appbuilder/action/edit/EditAppActionDefinition.java @@ -10,9 +10,9 @@ import javax.annotation.Nullable; public class EditAppActionDefinition implements AppActionDefinition { - public static EditAppActionDefinition FOLDER = new EditAppActionDefinition( + public static final EditAppActionDefinition FOLDER = new EditAppActionDefinition( "editFolder", - "ui-framework:folder", + "ui-framework-jcr:rename", MgnlIcon.EDIT, "actions.editFolder" );