Skip to content

Commit

Permalink
Fix add/edit folder actions
Browse files Browse the repository at this point in the history
  • Loading branch information
bjoern.eschle committed Feb 7, 2023
1 parent e20b172 commit dfe1705
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,16 @@
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;

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"
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<Node> {
private final OpenCreateDialogActionDefinition definition;
Expand All @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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"
);
Expand Down

0 comments on commit dfe1705

Please sign in to comment.