[MGNLUI-2931] Add Component action availability Created: 21/May/14  Updated: 17/Mar/16  Resolved: 11/Jul/14

Status: Closed
Project: Magnolia UI
Component/s: actionbar, pages app, user interaction
Affects Version/s: 5.2.4, 5.3
Fix Version/s: 5.2.7, 5.3.1

Type: Bug Priority: Neutral
Reporter: Richard Gange Assignee: Mikaël Geljić
Resolution: Fixed Votes: 0
Labels: support
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: PNG File Screen Shot 2014-07-10 at 17.49.12.png    
Issue Links:
Relates
relates to MGNLUI-1586 PageEditor: action availability is in... Closed
relates to MAGNOLIA-5826 Revise node type of singletons Open
relates to MGNLUI-3050 Shorthand action "New Content Compone... Closed
relates to MGNLUI-3054 Refine component action availability Closed
causality
dependency
depends upon MGNLUI-2982 Availability rule is processed only i... Closed
duplicate
duplicates MGNLUI-2930 Add Component action should be disabl... Closed
is duplicated by MGNLUI-3056 An area allows adding components when... Closed
relation
is related to PAGES-62 Disable duplicate action in 'single' ... Closed
Template:
Acceptance criteria:
Empty
Task DoD:
[ ]* Doc/release notes changes? Comment present?
[ ]* Downstream builds green?
[ ]* Solution information and context easily available?
[ ]* Tests
[ ]* FixVersion filled and not yet released
[ ]  Architecture Decision Record (ADR)
Bug DoR:
[ ]* Steps to reproduce, expected, and actual results filled
[ ]* Affected version filled
Date of First Response:

 Description   
  • If you set an area to be of type noComponent then the "+ Add Component" action should be disabled/removed when that area has the focus.
    You can see an example by looking the page /demo-project/about/subsection-articles/article and bringing the PAGE HEADER into focus. Notice "+ Add Component" is still available.
  • If you set an area to have a maxComponents property then when that area has reached its max it should cause the "+ Add Component" action to be disabled/removed when that area has the focus.
    Steps to recreate:
    • In template defs configure stkArticle base area to have a max of 2 components
    • Edit the base area of /demo-project/about/subsection-articles/article
    • Add 2 components
    • Observe the max message is showing but you still have the ability to execute the add component action.
      The system still prevents the third component from being added but not until the save button is pushed in the dialog. A warning is is logged but there is no indication to the user that something has been restricted.

At first it was attempted to fix this using an availability rule, but that turned to be complex to implement, regarding e.g. merged prototype in rendering whose definitions couldn't be accessed from the rule, + it was actually creating a second mechanism that was out-of-sync w/ what's done on the client-side, so we decided against this approach.

The good news is that there is already a 'custom' availability mechanism in page-editor that checks for client-side "addibility", since MGNLUI-1586, it just doesn't take maxComponent into account.



 Comments   
Comment by Roman Kovařík [ 05/Jun/14 ]

Please solve together with MGNLUI-2930.

Comment by Aleksandr Pchelintcev [ 02/Jul/14 ]

Instead of
Node areaNode = SessionUtil.getNodeByIdentifier(jcrItemId.getWorkspace(), jcrItemId.getUuid());
maybe
Node areaNode = JcrItemUtil.getJcrItem(jcrItemId); - would be shorter?

Also instead of
if (itemId instanceof JcrItemId && !(itemId instanceof JcrPropertyItemId))
if (itemId instanceof JcrNodeItemId) - is sufficient.

Comment by Roman Kovařík [ 07/Jul/14 ]

Reopen:

Comment by Roman Kovařík [ 07/Jul/14 ]

Reopen:

[INFO] [talledLocalContainer] java.lang.NullPointerException
[INFO] [talledLocalContainer] 	at info.magnolia.pages.app.availability.CanAddComponentRule.isAvailableForItem(CanAddComponentRule.java:87)

Looks like area doesn't have to have a definition, the code should handle that.

Comment by Roman Kovařík [ 07/Jul/14 ]

Reopen:

  1. http://localhost:8080/magnoliaAuthor/.magnolia/admincentral#app:pages:detail;/demo-project/about/subsection-articles/article:edit
  2. Click extras.
  3. Add component action in action bar is disabled because extras1 area is inside of extras area which doesn't have a template (RegistrationException).
Comment by Philip Mundt [ 08/Jul/14 ]

Log message doesn't correspond to return value of isAvailableForItem method. Method will return true but the log.warn says ..returning false...

Comment by Philip Mundt [ 08/Jul/14 ]

Attention: Last commit wasn't integrated to master yet but to 5.2.x-branch.

Integrated in git commit:
https://git.magnolia-cms.com/gitweb/?p=magnolia_ui.git;a=commitdiff;h=2c9f0a4ee9a15eafb5e8661fa205d2e4999023d7
As the defect was causing UI tests to fail.

Comment by Roman Kovařík [ 10/Jul/14 ]

Reopen: incorrect error log message:

log.warn("Error evaluating availability for node [{}], returning false: {}", areaNode, e);
            }
        }
        return true;
Comment by Espen Jervidalo [ 10/Jul/14 ]

second part of the ticket is still not solved, reopened during QA

The problem with the current implementation, is that it is moving up the hierarchy to get the pages template definition, and then tries to get the areas definition directly from the page template:

String template = NodeTypes.Renderable.getTemplate(areaNode.getParent());
if (template != null) {
  TemplateDefinition parentTemplateDefinition = templateRegistry.getTemplateDefinition(template);
  AreaDefinition areaDefinition = parentTemplateDefinition.getAreas().get(areaNode.getName());

  if (areaDefinition != null) {

Looking at the template definitions the content node is defined under the main area node, and not directly under the page template. See attached screenshot. The resulting areaDefinition for "content" is null.

Comment by Philip Mundt [ 11/Jul/14 ]

Doesn't work with extras1, because the template cannot be found.

Comment by Philip Mundt [ 11/Jul/14 ]

Resolving maxComponents which are defined in the prototype template definition is currently not possible.

Comment by Mikaël Geljić [ 11/Jul/14 ]

We should revert the CanAddComponentRule, see updated description.

Comment by Mikaël Geljić [ 11/Jul/14 ]

https://git.magnolia-cms.com/gitweb/?p=magnolia_ui.git;a=shortlog;h=refs/heads/MGNLUI-2931-mge

Generated at Mon Feb 12 09:01:33 CET 2024 using Jira 9.4.2#940002-sha1:46d1a51de284217efdcb32434eab47a99af2938b.