Skip to content
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

V15: Document Type Create Options #17669

Merged
merged 12 commits into from
Jan 7, 2025

Conversation

leekelleher
Copy link
Member

Description

Creates an entityCreateOptionAction extension for each of the Document Type create actions. This builds on the work started in umbraco/Umbraco.CMS.Backoffice#2509, and replaces the existing "Document Type Create Options modal" (which has hardcoded options).

To align the UI/UX consistency for the existing Create Options, amends were required to the <umb-ref-item> component, (refactored to extend uui-ref-node rather than duplicate code/functionality). This mostly meant updating existing usage to add the select-only attribute.

// @madsrasmussen Tagging you in, as you may wish to cast an eye on these amends.

How to test?

Go to the Settings section, try creating a new document type:

  • Does the create modal appear?
  • Does it have any options?
  • Do they work?

if (this.icon) {
const umbIcon = document.createElement('umb-icon');
umbIcon.setAttribute('name', this.icon);
this.shadowRoot?.querySelector('#icon')?.replaceWith(umbIcon);
Copy link
Member

@nielslyngsoe nielslyngsoe Nov 28, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is a little dangerous,, cause what if something caused Lit to re-render.. then it would not be overriden any more..

Could you try to just add it as a direct child, not in the shadowRoot and then set the attribute slot='icon'?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It felt a bit hacky when I was developing that part. I did try a few other approaches, but I couldn't get the icon to display, the fallback icon kept being rendered.

For reference: https://github.com/umbraco/Umbraco.UI/blob/v1.12.2/packages/uui-ref-node/lib/uui-ref-node.element.ts#L109-L112

When you say "add it as a direct child", do you mean that it overrides the render() method? If so, I'm not quite sure how that would work.

I'm wondering if UUIRefNodeElement could have a protected renderIcon() method added to it, that may simplify this. 🤔

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have changed this to append a child of it self. This can later be updated to override a method.


@property({ type: String })
detail = '';
const elementName = 'umb-ref-item';
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we agreed not to do this any longer? :-D

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought we agreed the opposite, that we would do this. 😂 I'm cool with reverting this, just let me know.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yeah, well the idea is to get rid of it in time. so I would say yes, lets not add it in this PR. :-)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have corrected this

@nielslyngsoe
Copy link
Member

Hi @leekelleher really great refactoring, that is so nice to get aligned and make extendable. so thanks for that. I just skimmed the code of interest, so not because I'm reviewing per say, but I had two minor comments :-)

@madsrasmussen
Copy link
Contributor

madsrasmussen commented Nov 28, 2024

Hi @leekelleher ,

It's fantastic to see that you have implemented the create options for Document Types. This is one of the more interesting cases! :D

Based on the current state of your PR, I would appreciate it if we could address these areas to ensure maximum flexibility for extensions and at the same time decouple our own code more. I suggest we move all template logic from the Document Type into the "Template"-module. This means that if the template package is not installed, all related logic around Document Types with templates would be removed (headless cms):

  • The "Document Type with Template"-create option should be registered within the "template"-module.

  • We need to find a solution for the hardcoded presets inside the Document Type workspace. Having these hardcoded limits the possibilities for the create option extension. One potential solution could be to introduce another extension point for "presets." A create option could pass a preset extension alias to the workspace, allowing the workspace to find the registered preset and execute any related logic.

  • Register the template workspace view from the template module, but I don’t think that’s directly relevant to this PR.

As we work on these changes, we should also consider how to implement a solution that can be reused across all workspaces. We already have a snippet/preset functionality for Partials Views which could utilize the same system.

import type { MetaEntityCreateOptionAction } from '@umbraco-cms/backoffice/entity-create-option-action';

export class UmbDefaultDocumentTypeCreateOptionAction extends UmbEntityCreateOptionActionBase<MetaEntityCreateOptionAction> {
override async execute() {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we are generating a HREF/URL, then we should not use an exeucte method, but instead use the getHref method. so the actual URL is exposed to the user and the user can use such to open in a new tab etc. More transparent and accessible. I have corrected this.

override async execute() {
if (!this.args.entityType) throw new Error('Entity type is required to create a folder');

const createFolderAction = new UmbCreateFolderEntityAction(this, {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have also changed this to use inheritance instead

@nielslyngsoe
Copy link
Member

I have been through this code changes and a bit related code to correct a few things. I have added comments on each change so its clear and we can discuss if necessary. Feel free to let me know what you think, and then I hope this will help move this PR forward :-)

@madsrasmussen do you have some structural changes you like to take part of this PR. I like your idea but I'm unsure if it fits within this PR. Your call, I'm open for the inputs :-)

@nielslyngsoe nielslyngsoe removed the request for review from iOvergaard January 7, 2025 06:36
@madsrasmussen madsrasmussen self-assigned this Jan 7, 2025
@madsrasmussen
Copy link
Contributor

FYI: I have removed the custom headline option for the create dialog. I would like to solve this in a more generic way so the dialog will handle it. It could be showing a breadcrumb of where something will be created. We will have to live with a general "Create" text for now. I hope it makes sense.

Copy link
Contributor

@madsrasmussen madsrasmussen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi Hi,

I think we have all been over this now, so let's get it merged 😄

  • Everything works as expected 👍
  • We have removed code duplication by using an extension point 👍

My dream for code splitting and extendable presets will be for another PR.

Awesome work 💯

@iOvergaard iOvergaard enabled auto-merge January 7, 2025 12:15
@iOvergaard iOvergaard disabled auto-merge January 7, 2025 12:18
@iOvergaard iOvergaard enabled auto-merge (squash) January 7, 2025 12:18
@iOvergaard iOvergaard merged commit 1fdf32f into v15/dev Jan 7, 2025
29 checks passed
@iOvergaard iOvergaard deleted the v15/feature/doctype-create-options branch January 7, 2025 12:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants