[6.x] Lazy-load actions for assets, collections, submissions & terms#14097
[6.x] Lazy-load actions for assets, collections, submissions & terms#14097duncanmcclean wants to merge 2 commits into6.xfrom
Conversation
jasonvarga
left a comment
There was a problem hiding this comment.
Changes via AI review, but confirmed with my browser, eyes, and mouse:
The direction (lazy-load actions for assets, collections, submissions, terms) is good and matches the entry listing. Submissions and terms are safe because they use prepended row actions and the shared Listing with actionUrl/actionContext. Collections are safe with actions_url.
The asset browser is not yet compatible with omitting actions:
- Guard against undefined
actionsinAssetBrowserMixin.js(and any other asset browser code that touchesfolder.actions/asset.actions), e.g. optional chaining:asset.actions?.some(...),folder.actions?.some(...), and equivalent for.find()and.length. Ensure drag/drop and “move” behaviour degrade safely when actions are not yet loaded (or add a path to load them before enabling move). - Table view – folder row actions: Either show the folder actions dropdown when
actionUrl/context exist (e.g. show whenfolderActionUrlis set, and passundefinedfor:actionssoItemActionslazy-loads on hover), or ensureloadActionsis triggered when the user opens the folder actions menu so the dropdown can populate. - Grid view: Ensure folder and asset context menus (or dropdowns) either trigger
loadActionswhen opened or handleactionsbeing undefined without throwing (e.g. avoidasset.actions.lengthwhenactionsmay be undefined).
Until the asset browser is updated along these lines, removing actions from FolderAsset (and any asset list payload) will introduce regressions and possible JS errors.
Suggested Changes
- Blocking: In
AssetBrowserMixin.js, use optional chaining (or equivalent) whereverasset.actionsorfolder.actionsis used (e.g.canMoveAsset,canMoveFolder,handleFolderDrop), so missingactionsdoes not throw. Decide how move/drag should behave when actions are not loaded (e.g. disable until loaded, or trigger load on first interaction). - Blocking: In
Table.vue, change folder row actions so the dropdown is shown when folder actions can be lazy-loaded (e.g. whenfolderActionUrlis set), and pass:actions="folder.actions"(soundefinedtriggers lazy-load inItemActions). Add a way to triggerloadActionson dropdown/menu open (e.g.@mouseoveror equivalent) so actions appear. - Blocking: In
Grid.vue, fix any direct use ofasset.actions(e.g.asset.actions.length) so it is safe whenactionsis undefined; ensure folder/asset menus can triggerloadActionswhen opened so lazy-loaded actions appear.
I intentionally left asset browser actions how they were. We rely on actions being loaded here to determine whether assets/folders can be moved via drag & drop. |
You didn't though. FolderAsset has actions removed. |
|
Edit: Opened an issue for this: #14205 |
This pull request avoids sending
actionsfrom the server, in favour of lazy-loading them over AJAX when the dropdown is hovered over.We already do this in the entry listing by just not passing the
actionskey, so I've copied that over to other places where it makes sense.