Skip to content

Commit a6b9f20

Browse files
Feature: Data type create options (#18023)
* add folder create option action kind * register data type create options * register folder collection actions * use kind for document type folder option * fix types * fix weight * update translations * add icon label, description * add deprecation warning
1 parent 6c1c851 commit a6b9f20

File tree

20 files changed

+196
-65
lines changed

20 files changed

+196
-65
lines changed

src/Umbraco.Web.UI.Client/src/assets/lang/en-us.ts

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -445,10 +445,9 @@ export default {
445445
compositionDescription:
446446
"Defines a re-usable set of properties that can be included in the definition of\n multiple other Document Types. For example, a set of 'Common Page Settings'.\n ",
447447
folder: 'Folder',
448-
folderDescription:
449-
'Used to organise the Document Types, Compositions and Element Types created in this\n Document Type tree.\n ',
450-
newFolder: 'New folder',
451-
newDataType: 'New Data Type',
448+
folderDescription: 'Used to organize items and other folders. Keep items structured and easy to access.',
449+
newFolder: 'Folder',
450+
newDataType: 'Data Type',
452451
newJavascriptFile: 'New JavaScript file',
453452
newEmptyPartialView: 'New empty partial view',
454453
newPartialViewMacro: 'New partial view macro',
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import type { MetaEntityCreateOptionActionFolderKind } from './types.js';
2+
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
3+
import { UmbCreateFolderEntityAction } from '@umbraco-cms/backoffice/tree';
4+
import type { UmbEntityCreateOptionActionArgs } from '@umbraco-cms/backoffice/entity-create-option-action';
5+
6+
export class UmbFolderCreateOptionAction extends UmbCreateFolderEntityAction {
7+
constructor(host: UmbControllerHost, args: UmbEntityCreateOptionActionArgs<MetaEntityCreateOptionActionFolderKind>) {
8+
super(host, { ...args, meta: { ...args.meta } });
9+
}
10+
}
11+
12+
export { UmbFolderCreateOptionAction as api };
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
2+
3+
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
4+
{
5+
type: 'kind',
6+
alias: 'Umb.Kind.EntityCreateOptionAction.Folder.Create',
7+
matchKind: 'folder',
8+
matchType: 'entityCreateOptionAction',
9+
manifest: {
10+
type: 'entityCreateOptionAction',
11+
kind: 'folder',
12+
api: () => import('./folder-entity-create-option-action.js'),
13+
weight: 1,
14+
forEntityTypes: [],
15+
meta: {
16+
icon: 'icon-folder',
17+
label: '#create_folder',
18+
description: '#create_folderDescription',
19+
},
20+
},
21+
},
22+
];
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import type {
2+
ManifestEntityCreateOptionAction,
3+
MetaEntityCreateOptionAction,
4+
} from '@umbraco-cms/backoffice/entity-create-option-action';
5+
6+
export interface ManifestEntityCreateOptionActionFolderKind
7+
extends ManifestEntityCreateOptionAction<MetaEntityCreateOptionActionFolderKind> {
8+
type: 'entityCreateOptionAction';
9+
kind: 'folder';
10+
}
11+
12+
export interface MetaEntityCreateOptionActionFolderKind extends MetaEntityCreateOptionAction {
13+
folderRepositoryAlias: string;
14+
}
15+
16+
declare global {
17+
interface UmbExtensionManifestMap {
18+
umbManifestEntityCreateOptionActionFolderKind: ManifestEntityCreateOptionActionFolderKind;
19+
}
20+
}
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
import { manifests as modalManifests } from './modal/manifests.js';
21
import { manifests as entityActionManifests } from './entity-action/manifests.js';
2+
import { manifests as entityCreateOptionActionManifests } from './entity-create-option-action/manifests.js';
3+
import { manifests as modalManifests } from './modal/manifests.js';
34
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
45

56
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
6-
...modalManifests,
77
...entityActionManifests,
8+
...entityCreateOptionActionManifests,
9+
...modalManifests,
810
];

src/Umbraco.Web.UI.Client/src/packages/data-type/entity-actions/create/create.action.ts

Lines changed: 0 additions & 21 deletions
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { UMB_CREATE_DATA_TYPE_WORKSPACE_PATH_PATTERN } from '../../../paths.js';
2+
import type { UmbDataTypeFolderEntityType, UmbDataTypeRootEntityType } from '../../../entity.js';
3+
import { UmbEntityCreateOptionActionBase } from '@umbraco-cms/backoffice/entity-create-option-action';
4+
import type { MetaEntityCreateOptionAction } from '@umbraco-cms/backoffice/entity-create-option-action';
5+
6+
export class UmbDefaultDataTypeCreateOptionAction extends UmbEntityCreateOptionActionBase<MetaEntityCreateOptionAction> {
7+
override async getHref() {
8+
const parentEntityType = this.args.entityType as UmbDataTypeRootEntityType | UmbDataTypeFolderEntityType;
9+
if (!parentEntityType) throw new Error('Entity type is required to create a document type');
10+
11+
const parentUnique = this.args.unique ?? null;
12+
13+
return UMB_CREATE_DATA_TYPE_WORKSPACE_PATH_PATTERN.generateAbsolute({
14+
parentEntityType,
15+
parentUnique,
16+
});
17+
}
18+
}
19+
20+
export { UmbDefaultDataTypeCreateOptionAction as api };
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE, UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../../../entity.js';
2+
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
3+
4+
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
5+
{
6+
type: 'entityCreateOptionAction',
7+
alias: 'Umb.EntityCreateOptionAction.DataType.Default',
8+
name: 'Default Data Type Entity Create Option Action',
9+
weight: 1000,
10+
api: () => import('./default-data-type-create-option-action.js'),
11+
forEntityTypes: [UMB_DATA_TYPE_ROOT_ENTITY_TYPE, UMB_DATA_TYPE_FOLDER_ENTITY_TYPE],
12+
meta: {
13+
icon: 'icon-autofill',
14+
label: '#create_newDataType',
15+
},
16+
},
17+
];
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE, UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../../../entity.js';
2+
import { UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS } from '../../../tree/constants.js';
3+
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
4+
5+
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
6+
{
7+
type: 'entityCreateOptionAction',
8+
kind: 'folder',
9+
alias: 'Umb.EntityCreateOptionAction.DataType.Folder',
10+
name: 'Data Type Folder Entity Create Option Action',
11+
forEntityTypes: [UMB_DATA_TYPE_ROOT_ENTITY_TYPE, UMB_DATA_TYPE_FOLDER_ENTITY_TYPE],
12+
meta: {
13+
icon: 'icon-folder',
14+
label: '#create_folder',
15+
description: '#create_folderDescription',
16+
folderRepositoryAlias: UMB_DATA_TYPE_FOLDER_REPOSITORY_ALIAS,
17+
},
18+
},
19+
];
Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,24 @@
11
import { UMB_DATA_TYPE_FOLDER_ENTITY_TYPE, UMB_DATA_TYPE_ROOT_ENTITY_TYPE } from '../../entity.js';
2+
import { manifests as defaultManifests } from './default/manifests.js';
3+
import { manifests as folderManifests } from './folder/manifests.js';
4+
import type { UmbExtensionManifestKind } from '@umbraco-cms/backoffice/extension-registry';
25

3-
export const manifests: Array<UmbExtensionManifest> = [
6+
export const manifests: Array<UmbExtensionManifest | UmbExtensionManifestKind> = [
47
{
58
type: 'entityAction',
6-
kind: 'default',
9+
kind: 'create',
710
alias: 'Umb.EntityAction.DataType.Create',
811
name: 'Create Data Type Entity Action',
912
weight: 1200,
10-
api: () => import('./create.action.js'),
1113
forEntityTypes: [UMB_DATA_TYPE_ROOT_ENTITY_TYPE, UMB_DATA_TYPE_FOLDER_ENTITY_TYPE],
12-
meta: {
13-
icon: 'icon-add',
14-
label: '#actions_create',
15-
additionalOptions: true,
16-
},
1714
},
15+
// TODO: Deprecated: Will be removed in 17.0.0
1816
{
1917
type: 'modal',
2018
alias: 'Umb.Modal.DataTypeCreateOptions',
2119
name: 'Data Type Create Options Modal',
2220
element: () => import('./modal/data-type-create-options-modal.element.js'),
2321
},
22+
...defaultManifests,
23+
...folderManifests,
2424
];

0 commit comments

Comments
 (0)