determine if tree item is folder, add actions to folder and root items

This commit is contained in:
Julia Gru
2023-07-20 09:14:38 +02:00
parent eadcdd832f
commit 9ef044621f
3 changed files with 15 additions and 3 deletions

View File

@@ -13,6 +13,12 @@ export class UmbFileSystemTreeItemContext extends UmbTreeItemContextBase<FileSys
super(host, (x: FileSystemTreeItemPresentationModel) => x.path);
}
checkIfIsFolder() {
if (this.getTreeItem()?.isFolder) {
this.type = `${this.getTreeItem()?.type}-folder`;
}
}
constructPath(pathname: string, entityType: string, path: string) {
return `section/${pathname}/workspace/${entityType}/edit/${encodeURIComponent(path).replace('.', '-')}`;
}

View File

@@ -39,6 +39,7 @@ export class UmbFileSystemTreeItemElement extends UmbLitElement implements UmbTr
public set item(value: FileSystemTreeItemPresentationModel | undefined) {
this._item = value;
this.#context.setTreeItem(value);
this.#context.checkIfIsFolder();
}
#context = new UmbFileSystemTreeItemContext(this);

View File

@@ -1,4 +1,9 @@
import { PARTIAL_VIEW_ENTITY_TYPE, PARTIAL_VIEW_FOLDER_ENTITY_TYPE, PARTIAL_VIEW_REPOSITORY_ALIAS } from '../config.js';
import {
PARTIAL_VIEW_ENTITY_TYPE,
PARTIAL_VIEW_FOLDER_ENTITY_TYPE,
PARTIAL_VIEW_REPOSITORY_ALIAS,
PARTIAL_VIEW_ROOT_ENTITY_TYPE,
} from '../config.js';
import { UmbCreateFromSnippetPartialViewAction } from './create/create-from-snippet.action.js';
import { UmbCreateEmptyPartialViewAction } from './create/create-empty.action.js';
import { UmbDeleteEntityAction } from '@umbraco-cms/backoffice/entity-action';
@@ -38,7 +43,7 @@ const partialViewFolderActions: Array<ManifestEntityAction> = [
repositoryAlias: PARTIAL_VIEW_REPOSITORY_ALIAS,
},
conditions: {
entityTypes: [PARTIAL_VIEW_FOLDER_ENTITY_TYPE],
entityTypes: [PARTIAL_VIEW_FOLDER_ENTITY_TYPE, PARTIAL_VIEW_ROOT_ENTITY_TYPE],
},
},
{
@@ -52,7 +57,7 @@ const partialViewFolderActions: Array<ManifestEntityAction> = [
repositoryAlias: PARTIAL_VIEW_REPOSITORY_ALIAS,
},
conditions: {
entityTypes: [PARTIAL_VIEW_FOLDER_ENTITY_TYPE],
entityTypes: [PARTIAL_VIEW_FOLDER_ENTITY_TYPE, PARTIAL_VIEW_ROOT_ENTITY_TYPE],
},
},
];