-
-
Notifications
You must be signed in to change notification settings - Fork 223
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TASK: Render menu prototypes without fluid #4623
Conversation
9a9645c
to
63c8ea7
Compare
Have a question wether we really need the calculateItemState flag if the cost is merely a single Also the findAncestors could be used for detecting the starting point aswell so we ideally would end up with 2 queries |
Neos.Neos/Resources/Private/Fusion/Prototypes/MenuItemListRenderer.fusion
Outdated
Show resolved
Hide resolved
63c8ea7
to
9e33add
Compare
The prototypes `Neos.Neos:Menu`, `Neos.Neos:DimensionsMenu` and `Neos.Neos:BreadcrumbMenu` are now implemented in pure fusion. The prototype `Neos.Neos:MenuItemListRenderer` is added that is used by those prototypes to render the result as a very basic unordered list. The flag `calculateItemStates` is added to the prototypes `Neos.Neos:MenuItems`, `Neos.Neos:DimensionsMenuItems` and `Neos.Neos:BreadcrumbMenuItems` with the default value being false. Once enabled the itemState of each menuItem is calculated. In addition the following issues are fixed: - DimensionMenuItems did not contain a url - MenuItems did not calculate item states.
9e33add
to
8e04b9a
Compare
Good point indeed. Hmm we seem to need the ancestors to highlight the trace: But when we would use But i think that @bwaidelich is currently creating test cases for the menu so that we can refactor it to use |
@mhsdesign that is a good point and could help to keep this pr in scope. I thought about refactoring this now but it makes more sense with tests. Regarding the |
I think first should be a findAncestors from currentDocument up. Needed to determine the starting point via entryLevel. From there a single findSubtree should be enough. 2 queries for a menu sounds quite ok to me. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, this looks and feels so much nicer already! <3
A couple of thoughts (in addition to the - mostly nitpicky – comments):
We should always have large sites in the back of our heads. Even if we only load document ancestor nodes, those can be tens of thousands so we should not load them into memory (Neos already has quite an excessive RAM usage).
So calculating the active
state will probably have to be calculated for every item in the menu.
But IMO the bigger issue is that this results in an individual cache entry for every menu for every page which – in turn – means that you'll basically have to flush the whole content cache if you change anything in the menu implementation.
That's why I like the calculateItemState
prop and IMO we could even make the @cache
configuration depend on it, such that we create a common cache entry if it is disabled
Short note. After this is merged and with tests for menu items in place we should try to cleanup the dependencies between the MenuItems prototypes (that all are derived from MenuItems). I would like all *MenuItems prototypes to be standalone fusion prototypes with an implementation class. |
Yes, great idea! And we could use that chance to replace the |
Absent is a state that can happen in dimension menus. Using enums is a good idea we can aswell implement here. |
… nodes This is more memory efficient and we only compare the AggregateIds anyways In addition the signature of `NodeAggregateIds::fromNodes(array $nodes)` is changed to `NodeAggregateIds::fromNodes(Nodes $nodes)` and the method `NodeAggregateIds::contain(NodeAggregateId $nodeAggregateId)` is added. There were no users of this to be found so this should be safe.
Co-authored-by: Bastian Waidelich <[email protected]>
Co-authored-by: Bastian Waidelich <[email protected]>
850ea62
to
d2ebddb
Compare
…mState to a BackedEnum In addition the RenderAttributesTrait was adjusted to handle backed enums like stringables.
d2ebddb
to
300f84f
Compare
@bwaidelich i think your issues are addressed. We could think about backporting the backedEnum in attributes support to 8.3 but i would decide upon that later. |
@mficzel you're the man, this looks awesome! Just one last thing for now (and we can also postpone it to a separate PR): Do you think it makes sense to make the |
@bwaidelich not safely as entryLevel -x also depends on the current document would try that separately |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it! +1 by reading
I like to wait with merges until Bastians tests are ready ;) |
@mhsdesign this changes nothing that was not broken/missing before. Other than the renderers only the state calculation and uris for the dimension menu were added again. By waiting we will only make this more complex by fixing more stuff in a single pr. |
For me it's the other way around. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There's potentially some follow up work to be done (backports, more tests, cache mode tricks to allow reusability) but this can all be done in separate PRs.
I really love this, thanks for taking care! <3
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you! Amazing :)
Neos.ContentRepository.Core/Classes/SharedModel/Node/NodeAggregateIds.php
Show resolved
Hide resolved
documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)} | ||
} | ||
entryTags { | ||
1 = ${Neos.Caching.nodeTypeTag('Neos.Neos:Document', documentNode)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we flush on any document change and not just the current one?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Because any document below the starting point could require invalidation.
So descendantOfTag with the startingPoint would be the right choice but that collides with this entry level magic. Also it would invalidate on any content change below.
I really think we should make startingPoint a requirement with default ${site} but that is for another pr.
documentNode = ${Neos.Caching.entryIdentifierForNode(documentNode)} | ||
} | ||
entryTags { | ||
1 = ${Neos.Caching.nodeTypeTag('Neos.Neos:Document', documentNode)} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we only include the document nodes parents for flushing?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already flush for all documents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So this way the DimensionsMenu and the Breadcrumb of every site is flushed when any document is changed in the website...
So IMO just including parents and the current node for both cases would solve both and reduce the flushing by a lot
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Decided not to do this as this pr is about de-fluidizing not optimizing. Before the prototype inherited the cache annotations of menu which flush for all documents.
There are plans to optimize the menus further so this is only the first step. This pr should not make anything worse but as it is but also should not need to fix more than it promises.
Would like to get this merged to look into the optimizing topic without piling too many changes upon each other.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would suggest to merge this one ASAP so that I can rebase the test-PR on it.
yes i agree as discussed ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fine for now. Just hope the caching topic for this case doesn't get lost. Performance is really important and didn't get enough attention in the past, especially if we want to intrigue our users with the performance of the new CR.
I agree! |
The prototypes
Neos.Neos:Menu
,Neos.Neos:DimensionsMenu
andNeos.Neos:BreadcrumbMenu
are now implemented in pure fusion. The prototypeNeos.Neos:MenuItemListRenderer
is added that is used by those prototypes to render the result as a very basic unordered list.The option
calculateItemStates
is added to the prototypesNeos.Neos:MenuItems
,Neos.Neos:DimensionsMenuItems
andNeos.Neos:BreadcrumbMenuItems
with the default value being false. Once enabled the itemState of each menuItem is calculated. While the calculation of itemState is not overly expensive the calculation depends on the current documentNode and this is only valid for the single document. This makes sharing menu caches between documents harder.In addition the following issues are fixed:
DimensionMenuItems
did not contain a urlMenuItems
did not calculate item states other than normalNodeAggregateIds::fromNodes(array $nodes)
is changed toNodeAggregateIds::fromNodes(Nodes $nodes)
and the methodNodeAggregateIds::contain(NodeAggregateId $nodeAggregateId)
is added. There were no users of this to be found so this should be safe.RenderAttributesTrait
will now use the value of backedEnums which allows to use Enums inNeos.Fusion:Tag.attributes
andNeos.Fusion:Augmenter
this was needed for theMenuItemListRenderer
Upgrade instructions
Since the Menus are no longer Templates the
templatePathAndFilename
was removed together with all state specific attribute rendering properties. You should adjust your rendering accordingly or create custom Menu prototypes that either have a renderer the suits your needs or are based on a Fluid Template again.Checklist
FEATURE|TASK|BUGFIX
!!!
and have upgrade-instructions