From 2cf778372468362a37a4c9b102bbf2db3fee22c8 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Tue, 12 Dec 2023 20:13:16 +0100 Subject: [PATCH] remove hacky check for children --- .../file-system-tree-item.context.ts | 13 --------- .../file-system-tree-item.element.ts | 1 - .../partial-views/entity-actions/manifests.ts | 19 +++++-------- .../templating/partial-views/entity.ts | 1 - .../scripts/entity-actions/manifests.ts | 21 ++++++--------- .../src/packages/templating/scripts/entity.ts | 1 - .../stylesheets/entity-actions/manifests.ts | 27 +++++-------------- .../packages/templating/stylesheets/entity.ts | 2 -- 8 files changed, 22 insertions(+), 63 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.context.ts b/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.context.ts index 3b6abd2e58..d8dcaac634 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.context.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.context.ts @@ -13,19 +13,6 @@ export class UmbFileSystemTreeItemContext extends UmbTreeItemContextBase x.path); } - //TODO: this is not a nice solution! There should be a better way to distinguish in the tree between folders and files. Additionally we need to be able to register an action only on empty folder. - - checkIfIsFolder() { - const treeItem = this.getTreeItem(); - if (treeItem?.isFolder) { - if (treeItem.hasChildren) { - this.entityType = `${this.getTreeItem()?.entityType}-folder`; - } else { - this.entityType = `${this.getTreeItem()?.entityType}-folder-empty`; - } - } - } - constructPath(pathname: string, entityType: string, path: string) { return `section/${pathname}/workspace/${entityType}/edit/${encodeURIComponent(path).replace('.', '-')}`; } diff --git a/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.element.ts b/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.element.ts index 19c45d5daf..b6eec125ba 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.element.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/core/tree/file-system-tree-item/file-system-tree-item.element.ts @@ -39,7 +39,6 @@ export class UmbFileSystemTreeItemElement extends UmbLitElement implements UmbTr public set item(value: UmbFileSystemTreeItemModel | undefined) { this._item = value; this.#context.setTreeItem(value); - this.#context.checkIfIsFolder(); } #context = new UmbFileSystemTreeItemContext(this); diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity-actions/manifests.ts index 97d3ed9f02..af499e75a7 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity-actions/manifests.ts @@ -1,6 +1,5 @@ import { UMB_PARTIAL_VIEW_ENTITY_TYPE, - UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE, UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE, UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE, } from '../entity.js'; @@ -24,7 +23,7 @@ const partialViewActions: Array = [ api: UmbDeleteEntityAction, meta: { icon: 'icon-trash', - label: 'Delete', + label: 'Delete...', repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS, entityTypes: [UMB_PARTIAL_VIEW_ENTITY_TYPE], }, @@ -61,29 +60,25 @@ const partialViewFolderActions: Array = [ { type: 'entityAction', alias: 'Umb.EntityAction.PartialViewFolder.DeleteFolder', - name: 'Remove empty folder', + name: 'Delete Partial View Folder', api: UmbDeleteFolderEntityAction, meta: { icon: 'icon-trash', - label: 'Remove folder', + label: 'Delete folder...', repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS, - entityTypes: [UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE], + entityTypes: [UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE], }, }, { type: 'entityAction', alias: 'Umb.EntityAction.PartialViewFolder.CreateFolder', - name: 'Create empty folder', + name: 'Create Partial View folder', api: UmbCreateFolderEntityAction, meta: { icon: 'icon-add', - label: 'Create folder', + label: 'Create folder...', repositoryAlias: UMB_PARTIAL_VIEW_REPOSITORY_ALIAS, - entityTypes: [ - UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE, - UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE, - UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE, - ], + entityTypes: [UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE, UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE], }, }, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity.ts index 8dad3dfad9..1fb1ccb3d9 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/partial-views/entity.ts @@ -1,4 +1,3 @@ export const UMB_PARTIAL_VIEW_ENTITY_TYPE = 'partial-view'; export const UMB_PARTIAL_VIEW_ROOT_ENTITY_TYPE = 'partial-view-root'; export const UMB_PARTIAL_VIEW_FOLDER_ENTITY_TYPE = 'partial-view-folder'; -export const UMB_PARTIAL_VIEW_FOLDER_EMPTY_ENTITY_TYPE = 'partial-view-folder-empty'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity-actions/manifests.ts index 556c0194de..b2068289f8 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity-actions/manifests.ts @@ -1,10 +1,5 @@ import { UMB_SCRIPT_REPOSITORY_ALIAS } from '../repository/index.js'; -import { - UMB_SCRIPT_ENTITY_TYPE, - UMB_SCRIPT_FOLDER_ENTITY_TYPE, - UMB_SCRIPT_ROOT_ENTITY_TYPE, - UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE, -} from '../entity.js'; +import { UMB_SCRIPT_ENTITY_TYPE, UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE } from '../entity.js'; import { UmbCreateScriptAction } from './create/create-empty.action.js'; import { UmbCreateFolderEntityAction, @@ -43,31 +38,31 @@ const scriptFolderActions: Array = [ icon: 'icon-article', label: 'New empty script', repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS, - entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE], + entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE], }, }, { type: 'entityAction', alias: UMB_DELETE_SCRIPT_FOLDER_ENTITY_ACTION_ALIAS, - name: 'Remove empty folder', + name: 'Delete Script folder', api: UmbDeleteFolderEntityAction, meta: { icon: 'icon-trash', - label: 'Remove folder', + label: 'Delete folder...', repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS, - entityTypes: [UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE], + entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE], }, }, { type: 'entityAction', alias: UMB_CREATE_SCRIPT_FOLDER_ENTITY_ACTION_ALIAS, - name: 'Create empty folder', + name: 'Create Script folder', api: UmbCreateFolderEntityAction, meta: { icon: 'icon-add', - label: 'Create folder', + label: 'Create folder...', repositoryAlias: UMB_SCRIPT_REPOSITORY_ALIAS, - entityTypes: [UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE, UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE], + entityTypes: [UMB_SCRIPT_FOLDER_ENTITY_TYPE, UMB_SCRIPT_ROOT_ENTITY_TYPE], }, }, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity.ts index 86304ba46c..a8cd48af2b 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/scripts/entity.ts @@ -1,4 +1,3 @@ export const UMB_SCRIPT_ENTITY_TYPE = 'script'; export const UMB_SCRIPT_ROOT_ENTITY_TYPE = 'script-root'; export const UMB_SCRIPT_FOLDER_ENTITY_TYPE = 'script-folder'; -export const UMB_SCRIPT_FOLDER_EMPTY_ENTITY_TYPE = 'script-folder-empty'; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity-actions/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity-actions/manifests.ts index ca93618fe7..358a77e1aa 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity-actions/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity-actions/manifests.ts @@ -1,6 +1,5 @@ import { UMB_STYLESHEET_ENTITY_TYPE, - UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE, UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE, } from '../entity.js'; @@ -45,11 +44,7 @@ const stylesheetFolderActions: Array = [ icon: 'icon-script', label: 'New stylesheet file', repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS, - entityTypes: [ - UMB_STYLESHEET_FOLDER_ENTITY_TYPE, - UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE, - UMB_STYLESHEET_ROOT_ENTITY_TYPE, - ], + entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE], }, }, { @@ -61,39 +56,31 @@ const stylesheetFolderActions: Array = [ icon: 'icon-script', label: 'New Rich Text Editor style sheet file', repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS, - entityTypes: [ - UMB_STYLESHEET_FOLDER_ENTITY_TYPE, - UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE, - UMB_STYLESHEET_ROOT_ENTITY_TYPE, - ], + entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE], }, }, { type: 'entityAction', alias: 'Umb.EntityAction.Stylesheet.Folder.DeleteFolder', - name: 'Remove empty folder', + name: 'Delete folder...', api: UmbDeleteFolderEntityAction, meta: { icon: 'icon-trash', - label: 'Remove folder', + label: 'Delete folder', repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS, - entityTypes: [UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE], + entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE], }, }, { type: 'entityAction', alias: 'Umb.EntityAction.Stylesheet.Folder.CreateFolder', - name: 'Create empty folder', + name: 'Create folder...', api: UmbCreateFolderEntityAction, meta: { icon: 'icon-add', label: 'Create folder', repositoryAlias: UMB_STYLESHEET_REPOSITORY_ALIAS, - entityTypes: [ - UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE, - UMB_STYLESHEET_FOLDER_ENTITY_TYPE, - UMB_STYLESHEET_ROOT_ENTITY_TYPE, - ], + entityTypes: [UMB_STYLESHEET_FOLDER_ENTITY_TYPE, UMB_STYLESHEET_ROOT_ENTITY_TYPE], }, }, ]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity.ts b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity.ts index 8dbd996a3e..5e5f91b596 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/templating/stylesheets/entity.ts @@ -1,5 +1,3 @@ export const UMB_STYLESHEET_ENTITY_TYPE = 'stylesheet'; export const UMB_STYLESHEET_ROOT_ENTITY_TYPE = 'stylesheet-root'; - export const UMB_STYLESHEET_FOLDER_ENTITY_TYPE = 'stylesheet-folder'; -export const UMB_STYLESHEET_FOLDER_EMPTY_ENTITY_TYPE = 'stylesheet-folder-empty';