Overview

Introduce a new menu item called Manage library. Display the folders under Manage Library as well as Library. Allow users to create new folders under Manage library.

→ See: #3540576: [META] Library organization with folders

Proposed resolution

Manage library

  1. Introduce a new menu item called Manage library. Clicking on its icon should only affect what's shown in the left sidebar, similar to Layers.
  2. Implement tab switching at the top: Components, Patterns, Code (internal code components — status=false in the JavaScriptComponent entity).
  3. List all the folders using the config entity introduced in #3539729: Implement Folder config entity where parent is set to components, folders, or code. See comment #14 and on: the property may get named differently.
  4. Display the components, patterns, or internal code components under each folder. The components can be SDCs, blocks, or external code components. Display each of them with a different icon. Keep support for displaying items at the root level.
  5. Clicking on code components should open the code editor.
  6. Display the number of items inside each folder.
  7. Implement creating new folders by adding an Add button to display a dropdown that allows adding a folder. (We'll add more options later, but that is out of scope.) Set components, patterns, or code as the parent for the newly created folders.
  8. When adding a new folder, handle the error from the backend that ensures unique folder names within a parent.
  9. Set new folder weights to 0. Display them alphabetically.

Library

  1. Remove Code (internal code components) from the Library. They will only be shown under Manage Library. Merge the listing of Components and Dynamic components under the label Components. The library then will consist of Patterns and Components.
  2. Implement tab switching between Components and Patterns.
  3. List all the folders using the config entity introduced in #3539729: Implement Folder config entity to list components and patterns (where parent is set to components or patterns).
  4. Display the components or patterns under each folder. The components can be SDCs, blocks, or external code components. Display each of them with the same icon. Keep support for displaying items at the root level.
  5. Display the number of components or patterns inside each folder.

User interface changes

Manage library

Manage library menu item

  • Ignore: search bar, "Uncategorized", "Draft components".
  • Add button can span to full length.

Library

Visually similar to Manage Library. The difference is that components should use the same icon for SDCs, blocks, and exposed code components.

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

balintbrews created an issue. See original summary.

lauriii’s picture

Issue tags: -stable blocker

Parent issue is already tracked as a stable blocker.

bnjmnm made their first commit to this issue’s fork.

balintbrews’s picture

Issue summary: View changes
StatusFileSize
new406.81 KB
bnjmnm’s picture

Question 1

Step 1 in the Libraries instructions includes
Merge the listing of Components and Dynamic components under the label Components.

Dynamic components are already organized into collapsible subsections sections based on their block_category:, which would mean two different forms of collection next to each other:

  1. Folders (ui configurable)
  2. Block categories (hard coded)

Perhaps this is fine and is why there's no additional explanation, but I'd like to confirm that.

Question 2

Is adding a new folder done via a dialog with a single text field for the dialog name, or was a different type of interaction envisioned? Are there any format requirements of the name provided?

Question 3

In the screenshot for Manage Library the root level shows only folders. Item 4 mentions "Keep support for displaying items at the root level." which I believe means un-foldered items can be displayed alongside the folders.

  • Could I get confirmation of this and (if capacity allows) a visual example?
  • Assuming this is the case, should folders and components be listed interchangeably as alphabetical order dictates, or should they be grouped together and alphabetically sorted within those groups? Is this different depending on if we're in Library or Manage Library?

Question 4

In the screenshot for Manage Library I don't see any controls where one might be able to rename or delete existing folders. Even if this is something to be added later, knowing where the controls might be will inform how this gets implemented.

Question 5

I could not find a folder icon in Radix. Could the svg used in the designs be provided in this issue?

Question 6

Do folder weights have any impact at this time? Based on the current requirements it looks like they're all being set to 0 and sorting is alphabetical - which is fine of course but I wanted to be sure I wasn't overlooking somewhere they get used.

balintbrews’s picture

Issue summary: View changes

I just had a conversation with @lauriii. Internal code components should live under Manage library. I adjusted the issue summary accordingly.

balintbrews’s picture

Answers to questions in #5:

  1. I missed when we added that. 🙂 Those need to be replaced by folders, which will be initially auto-created from those block categories in #3541364: Delete folders. In other words, folders are superseding the hard-coded block categories.
  2. Correct, single text field in a dialog, @/components/Dialog should be sufficient. The only requirement is that folder names need to be unique within a parent (i.e. components, patterns, code).
  3. Confirmed. I'll ping @callumharrod for the visual example.
  4. I would vote for grouping them together, starting with folders. @callumharrod, can you please confirm? It should be the same in Library and Manage library.
  5. See #3540580: Renaming, moving, and deleting folders through contextual menu.
  6. @callumharrod, please.
  7. We'll expand on that in #3540580: Renaming, moving, and deleting folders through contextual menu, alphabetical order and 0 weights are what's in scope of this issue.
callumharrod’s picture

  1. Question 1: I believe the intention is to allow dynamic components to be placed in categories in the same way that we could group any other component type. This is to allow a user to control where every component goes, including dynamic components. The only thing that wouldn't be able to be grouped with components is the code used for code components.
  2. Question 2: There may be another method to add a new folder in the future. However, for now it's only manage by a dialog. I didn't have any formatting as a requirement, so I don't think it's needed here.
  3. Question 3: Not sure if we're allowing top level components (not in a folder.). I'll await confirmation before adding designs.
  4. Question 4: The folders have a context menu available on hover. From here you can delete or rename folders.
  5. Question 5: Adding code for SVG here as d.org doesn't allow uploading svgs...
  6. Question 6: I hadn't planned to make it alphabetical. My intention was when a new folder is added, it is added to the end of the list of folders. These can be freely moved up/down (changing the weight) so they can be placed anywhere within the sidebar hierarchy.
<svg width="16" height="16" viewBox="0 0 16 16" fill="none" xmlns="http://www.w3.org/2000/svg">
<mask id="mask0_14031_57331" style="mask-type:alpha" maskUnits="userSpaceOnUse" x="0" y="0" width="16" height="16">
<rect x="0.5" y="0.5" width="15" height="15" fill="#D9D9D9"/>
</mask>
<g mask="url(#mask0_14031_57331)">
<path d="M3.19234 12.6875C2.87661 12.6875 2.60937 12.5781 2.39062 12.3594C2.17188 12.1406 2.0625 11.8734 2.0625 11.5577V4.44234C2.0625 4.12661 2.17188 3.85938 2.39062 3.64063C2.60937 3.42188 2.87661 3.3125 3.19234 3.3125H6.15625C6.30687 3.3125 6.45172 3.34177 6.59078 3.40031C6.72974 3.45875 6.85052 3.53927 6.95313 3.64188L7.87375 4.5625H12.8077C13.1234 4.5625 13.3906 4.67188 13.6094 4.89063C13.8281 5.10938 13.9375 5.37661 13.9375 5.69234V11.5577C13.9375 11.8734 13.8281 12.1406 13.6094 12.3594C13.3906 12.5781 13.1234 12.6875 12.8077 12.6875H3.19234ZM3.19234 11.75H12.8077C12.8638 11.75 12.9099 11.732 12.9459 11.6959C12.982 11.6599 13 11.6138 13 11.5577V5.69234C13 5.6362 12.982 5.5901 12.9459 5.55406C12.9099 5.51802 12.8638 5.5 12.8077 5.5H7.49031L6.29453 4.30406C6.27443 4.28406 6.25339 4.27005 6.23141 4.26203C6.20932 4.25401 6.18625 4.25 6.16219 4.25H3.19234C3.1362 4.25 3.0901 4.26802 3.05406 4.30406C3.01802 4.3401 3 4.3862 3 4.44234V11.5577C3 11.6138 3.01802 11.6599 3.05406 11.6959C3.0901 11.732 3.1362 11.75 3.19234 11.75Z" fill="#00051D" fill-opacity="0.454902"/>
</g>
</svg>
balintbrews’s picture

#8.3: Yes, we should. I discussed that with @lauriii.

wim leers’s picture

#3539729: Implement Folder config entity is in! That means this is unblocked now (and won't need to chase changes anymore 😅).

bnjmnm’s picture

Status: Active » Needs review
StatusFileSize
new151.16 KB
new114.34 KB
new78.32 KB
new67.81 KB

Setting to NR. e2e tests, particularly Playwright at the moment, are a bit flaky, so don't let fails there get in the way of a review.. there's plenty that needs looking at.

Library

Manage Library

wim leers’s picture

Assigned: Unassigned » bnjmnm
Status: Needs review » Needs work

Seems like this incorporated most of the scope of #3541364: Delete folders? That makes this MR way bigger (and much more back-end centric) than what is described in this issue's summary.

If this is just more pragmatic: WFM. But landing this massive MR (44 files, +2584, -285) then is likely to take longer.

wim leers’s picture

Discussed with @bnjmnm: this includes the auto-creation subset of #3541364, and we won't be extracting that out of this MR: that'll be too painful/not worth it. See #3541364-5: Delete folders.

balintbrews’s picture

A proposal by @jessebaker that we decided to implement:

In Manage library, let's display both internal and exposed code components under the Code tab. The backend already supports the organization into folders for JavaScriptComponent entities, which will be separate from organizing the Component entities, which will take effect under the Components tab — where exposed code components are represented by Component entities.

balintbrews’s picture

I approved from the frontend side with the following observations:

  1. Display both internal and exposed code components in Manage library under the Code tab. See #16.
  2. When a new code component is created from Library, the Code tab of Manage library should be opened.
  3. When a code component is clicked under Manage Library, and the current route is not the code editor, the Code tab should remain selected.
  4. Appearance of empty folders need to be adjusted, see #note_575777.
  5. Appearance of hovered folders need to be adjusted, see #note_575778.
  6. Adding new folders should use @/components/Dialog and handle errors, see #note_575780.
  7. Components and patterns should not be draggable to the canvas from Manage library, see #note_575781.

I think the issue can land without these. @bnjmnm, I'll leave it up to you how you would like to structure the follow-up issue(s).

wim leers’s picture

Nice progress!

Most important: the Folder auto-creation logic is incorrect AFAICT: https://git.drupalcode.org/project/experience_builder/-/merge_requests/1...

Because it is easily missed: I reopened a number of threads that have been IMHO closed too early.

wim leers’s picture

Assigned: bnjmnm » wim leers

Discussed with @bnjmnm last night. We want to get this merged before the big rename.

Ben tackled the needed FE changes last night, I'll tackle the BE changes needed to be able to merge this (if any remain, that is), plus updating related issues to ensure whatever scope this did not tackle, will be tackled elsewhere.

wim leers’s picture

Assigned: wim leers » Unassigned
Status: Needs work » Reviewed & tested by the community
Issue tags: +Needs followup

For the BE, follow-ups:

Still to do: organize follow-up issues for @balintbrews' remarks in #17. I've created one of those (for #17.1): #3543533: [PP-1] Display both internal and exposed code components in "Manage library". In doing so, I paved the path as much in this MR as I could, which involved making xb_test_folders use the test code components that already existed in HEAD before this MR (which are exposed).

Doing that surfaced an interesting consequence of a loose end from back in January: JsComponent::createConfigEntity() always sets category: @todo, which now results in a "@todo" Folder getting created for Components, whenever a code component changes from status: false to status: true. Updated test expectations. We'll have to fix it at #3541364-9: Delete folders.


Now just needs a conflict to be solved, @jessebaker is handling that :)

  • wim leers committed 98956c52 on 1.x authored by bnjmnm
    Issue #3540577 by bnjmnm, wim leers, balintbrews, jessebaker, lauriii,...
wim leers’s picture

Assigned: Unassigned » bnjmnm
Status: Reviewed & tested by the community » Patch (to be ported)

Yay, it's in! 🚀

Back to @bnjmnm for creating follow-ups for @balintbrews' #17 — except #17.1, that's already taken care of — see #20.

bnjmnm’s picture

Status: Patch (to be ported) » Fixed

Followups created as needed:

bnjmnm’s picture

Assigned: bnjmnm » Unassigned
wim leers’s picture

wim leers’s picture

mayur-sose’s picture

Verified below scenarios and please check failing scenarios TC9, TC10 and TC19:

ID Test Scenario Steps Expected Result Pass/Fail
TC1 "Manage Library" menu item appears in sidebar
  1. Open the application.
  2. Examine the sidebar/menu items.
New "Manage Library" menu item is visible in the sidebar. Pass
TC2 Clicking "Manage Library" updates only sidebar
  1. Click "Manage Library".
  2. Observe left sidebar and main content area.
Only the left sidebar view changes; main workspace/content area is unchanged. Pass
TC3 Tab switching (Components/Patterns/Code) in "Manage Library"
  1. In "Manage Library," use tabs to switch between "Components", "Patterns", and "Code".
Sidebar content updates to reflect the current tab; items update accordingly. Pass
TC4 Folders listed correctly in "Manage Library" and "Library"
  1. Open both "Manage Library" and "Library".
  2. Check folder listing under each.
All folders (from config entity) are listed in both areas. Pass
TC5 Items displayed under correct folders/tabs in "Manage Library"
  1. Select "Components", "Patterns", or "Code" tab.
  2. Expand/collapse folders.
  3. Check items shown.
Each folder displays correct items:

Components: SDCs, blocks, external/internal code components.

Patterns: correct ones.
Pass
TC6 Item icons differentiate type in "Manage Library"
  1. In "Manage Library", observe icons for SDCs, blocks, code components.
Each type of item (e.g., SDC, block, code component) uses a unique icon. Pass
TC7 Number of items is displayed next to each folder in "Manage Library"
  1. View folders with various numbers of items.
  2. Observe item count on folder label.
Number representing how many components/patterns/code are inside each folder is shown. Pass
TC8 Items at root (not in a folder) are still displayed
  1. Ensure some components/patterns/code are in no folder.
  2. Check the root level in sidebar.
Root-level items are displayed outside folders. Pass
TC9 Clicking internal code component opens code editor
  1. In "Manage Library", under Code tab, click any internal code component.
  2. Observe what opens.
Code editor gets open but internal tab shifted from “Code“ to “Components“. Fail
TC10 Cannot create new folder with non-unique name within a parent
  1. Click "Add New Folder" button in desired parent (e.g., Components/Patterns/Code).
  2. Enter folder name that already exists under that parent.
  3. Submit.
No Error message displayed for already existing folders.

We can see 422 error message in console and network tab.
Fail
TC11 Can create a new folder and it appears alphabetically/with weight=0
  1. Click "Add" button in any parent (e.g., Components).
  2. Enter new unique folder name.
  3. Submit and observe position.
Folder is added alphabetically among siblings and assigned weight 0 by default. Pass
TC12 Created folder reflects correct tab parent
  1. Under each tab, create a new folder.
  2. Observe parent assignment.
  3. Switch tabs to confirm folder is only under selected parent type.
New folder is a child of the selected tab (Components/Patterns/Code) and does not show under other tabs. Pass
TC13 Library shows only Components and Patterns
  1. Open "Library" tab.
  2. Review tabs and listing.
Only "Components" and "Patterns" tabs are present; "Code" is NOT present in the Library view. Pass
TC14 Tabs in Library switch between Components and Patterns
  1. In Library, switch tabs between Components and Patterns.
  2. In Library, only drop down is implemented not tabs for Components and patterns.
Dropdown is implemented for Components and Patterns in Library. Pass
TC15 All folders listed and managed via config entity
  1. Add/edit/delete a folder using the config entity method.
  2. Observe both "Library" and "Manage Library" for update.
All folder changes reflect instantly in both areas. Pass
TC16 Components/Patterns in Library—one icon regardless of type
  1. In Library, observe icons for folder contents under Components/Patterns.
All types (SDCs, blocks, code components, etc.) use the same icon. Pass
TC17 Number of components/patterns shown next to each folder in Library
  1. Observe item count badge/number next to folders in Library.
Correct count displayed for each folder. Pass
TC18 Root-level components/patterns shown in Library
  1. Ensure some items have no folder.
  2. Confirm they appear at root in Library view.
All root-level items are visible under their respective tab (outside folders). Pass
TC19 Try to delete, rename, edit code component from Manage library
  1. Open Manage library.
  2. Click on three dots and perform rename, edit and delete operations.
Delete code component from Manage library is not working and throwing 403 error. Fail
mayur-sose’s picture

I have created follow-up issues for the bugs identified above:

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.