Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
export * from './entity-actions/constants.js';
export * from './media-type-root/constants.js';
export * from './paths.js';
export * from './repository/constants.js';
export * from './tree/constants.js';
export * from './workspace/constants.js';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export const UMB_MEDIA_TYPE_ROOT_WORKSPACE_ALIAS = 'Umb.Workspace.MediaType.Root';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './constants.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE } from '../entity.js';

export const manifests: Array<UmbExtensionManifest> = [
{
type: 'workspace',
kind: 'default',
alias: 'Umb.Workspace.MediaType.Root',
name: 'Media Type Root Workspace',
meta: {
entityType: UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE,
headline: '#treeHeaders_mediaTypes',
},
},
];
25 changes: 25 additions & 0 deletions src/Umbraco.Web.UI.Client/src/packages/media/media-types/paths.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
import { UMB_MEDIA_TYPE_ENTITY_TYPE, UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE } from './entity.js';
import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace';
import { UMB_SETTINGS_SECTION_PATHNAME } from '@umbraco-cms/backoffice/settings';
import { UmbPathPattern } from '@umbraco-cms/backoffice/router';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export const UMB_MEDIA_TYPE_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({
sectionName: UMB_SETTINGS_SECTION_PATHNAME,
entityType: UMB_MEDIA_TYPE_ENTITY_TYPE,
});

export const UMB_MEDIA_TYPE_ROOT_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({
sectionName: UMB_SETTINGS_SECTION_PATHNAME,
entityType: UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE,
});

export const UMB_CREATE_MEDIA_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{
parentEntityType: UmbEntityModel['entityType'];
parentUnique: UmbEntityModel['unique'];
}>('create/parent/:parentEntityType/:parentUnique', UMB_MEDIA_TYPE_WORKSPACE_PATH);

export const UMB_EDIT_MEDIA_TYPE_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>(
'edit/:unique',
UMB_MEDIA_TYPE_WORKSPACE_PATH,
);
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
export * from './folder/constants.js';
export * from './tree-item-children/constants.js';

export const UMB_MEDIA_TYPE_TREE_REPOSITORY_ALIAS = 'Umb.Repository.MediaType.Tree';
export const UMB_MEDIA_TYPE_TREE_STORE_ALIAS = 'Umb.Store.MediaType.Tree';
export const UMB_MEDIA_TYPE_TREE_ALIAS = 'Umb.Tree.MediaType';
export { UMB_MEDIA_TYPE_PICKER_MODAL } from './media-type-picker-modal.token.js';
export { UMB_MEDIA_TYPE_TREE_STORE_CONTEXT } from './media-type-tree.store.context-token.js';
export * from './folder/constants.js';
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
export const UMB_MEDIA_TYPE_FOLDER_WORKSPACE_ALIAS = 'Umb.Workspace.MediaType.Folder';
export * from './media-type-folder.workspace.context-token.js';
export * from './paths.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE } from '../../../entity.js';
import { UmbPathPattern } from '@umbraco-cms/backoffice/router';
import { UMB_SETTINGS_SECTION_PATHNAME } from '@umbraco-cms/backoffice/settings';
import { UMB_WORKSPACE_PATH_PATTERN } from '@umbraco-cms/backoffice/workspace';

export const UMB_MEDIA_TYPE_FOLDER_WORKSPACE_PATH = UMB_WORKSPACE_PATH_PATTERN.generateAbsolute({
sectionName: UMB_SETTINGS_SECTION_PATHNAME,
entityType: UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE,
});

export const UMB_EDIT_MEDIA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN = new UmbPathPattern<{ unique: string }>(
'edit/:unique',
UMB_MEDIA_TYPE_FOLDER_WORKSPACE_PATH,
);
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
UMB_MEDIA_TYPE_TREE_STORE_ALIAS,
} from './constants.js';
import { manifests as folderManifests } from './folder/manifests.js';
import { manifests as reloadTreeItemChildrenManifest } from './reload-tree-item-children/manifests.js';
import { manifests as treeItemChildrenManifest } from './tree-item-children/manifests.js';

export const manifests: Array<UmbExtensionManifest> = [
{
Expand Down Expand Up @@ -51,5 +51,5 @@ export const manifests: Array<UmbExtensionManifest> = [
},
},
...folderManifests,
...reloadTreeItemChildrenManifest,
...treeItemChildrenManifest,
];

This file was deleted.

Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './repository/constants.js';
export const UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS = 'Umb.Collection.MediaType.TreeItemChildren';
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './constants.js';
export * from './repository/index.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { manifests as viewManifests } from './views/manifests.js';
import { manifests as repositoryManifests } from './repository/manifests.js';
import { UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS } from './constants.js';
import { UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS } from './repository/index.js';

export const manifests: Array<UmbExtensionManifest> = [
{
type: 'collection',
kind: 'default',
alias: UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS,
name: 'Media Type Tree Item Children Collection',
meta: {
repositoryAlias: UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS,
},
},
...viewManifests,
...repositoryManifests,
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export const UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS =
'Umb.Repository.MediaType.TreeItemChildrenCollection';
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './constants.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS } from './constants.js';

export const manifests: Array<UmbExtensionManifest> = [
{
type: 'repository',
alias: UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS,
name: 'Media Type Tree Item Children Collection Repository',
api: () => import('./media-type-tree-item-children-collection.repository.js'),
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
import UmbMediaTypeTreeRepository from '../../../media-type-tree.repository.js';
import type { UmbCollectionFilterModel, UmbCollectionRepository } from '@umbraco-cms/backoffice/collection';
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
import { UMB_ENTITY_CONTEXT, type UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export class UmbMediaTypeTreeItemChildrenCollectionRepository
extends UmbRepositoryBase
implements UmbCollectionRepository
{
#treeRepository = new UmbMediaTypeTreeRepository(this);

async requestCollection(filter: UmbCollectionFilterModel) {
// TODO: get parent from args
const entityContext = await this.getContext(UMB_ENTITY_CONTEXT);
if (!entityContext) throw new Error('Entity context not found');

const entityType = entityContext.getEntityType();
const unique = entityContext.getUnique();

if (!entityType) throw new Error('Entity type not found');
if (unique === undefined) throw new Error('Unique not found');

const parent: UmbEntityModel = { entityType, unique };

if (parent.unique === null) {
return this.#treeRepository.requestTreeRootItems({ skip: filter.skip, take: filter.take });
} else {
return this.#treeRepository.requestTreeItemsOf({ parent, skip: filter.skip, take: filter.take });
}
}
}

export { UmbMediaTypeTreeItemChildrenCollectionRepository as api };
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
import type { UmbCollectionFilterModel } from '@umbraco-cms/backoffice/collection';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export interface UmbMediaTypeTreeItemChildrenCollectionFilterModel extends UmbCollectionFilterModel {
parent: UmbEntityModel;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import { UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS } from '../constants.js';
import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection';

export const manifests: Array<UmbExtensionManifest> = [
{
type: 'collectionView',
alias: 'Umb.CollectionView.MediaType.TreeItem.Table',
name: 'Media Type Tree Item Table Collection View',
element: () => import('./media-type-tree-item-table-collection-view.element.js'),
weight: 300,
meta: {
label: 'Table',
icon: 'icon-list',
pathName: 'table',
},
conditions: [
{
alias: UMB_COLLECTION_ALIAS_CONDITION,
match: UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS,
},
],
},
];
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
import type { UmbMediaTypeTreeItemModel } from '../../../types.js';
import { UMB_EDIT_MEDIA_TYPE_WORKSPACE_PATH_PATTERN } from '../../../../paths.js';
import { UMB_EDIT_MEDIA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN } from '../../../folder/workspace/paths.js';
import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection';
import { UMB_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection';
import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components';
import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element';
import { UmbModalRouteRegistrationController, type UmbModalRouteBuilder } from '@umbraco-cms/backoffice/router';
import { UMB_WORKSPACE_MODAL } from '@umbraco-cms/backoffice/workspace';

@customElement('umb-media-type-tree-item-table-collection-view')
export class UmbMediaTypeTreeItemTableCollectionViewElement extends UmbLitElement {
@state()
private _tableConfig: UmbTableConfig = {
allowSelection: false,
};

@state()
private _tableColumns: Array<UmbTableColumn> = [
{
name: 'Name',
alias: 'name',
},
{
name: '',
alias: 'entityActions',
},
];

@state()
private _tableItems: Array<UmbTableItem> = [];

#collectionContext?: UmbDefaultCollectionContext<any>;
#routeBuilder?: UmbModalRouteBuilder;

constructor() {
super();

this.consumeContext(UMB_COLLECTION_CONTEXT, (instance) => {
this.#collectionContext = instance;
});

this.#registerModalRoute();
}

#registerModalRoute() {
new UmbModalRouteRegistrationController(this, UMB_WORKSPACE_MODAL)
.addAdditionalPath(':entityType')
.onSetup((params) => {
return { data: { entityType: params.entityType, preset: {} } };
})
.observeRouteBuilder((routeBuilder) => {
this.#routeBuilder = routeBuilder;

// NOTE: Configuring the observations AFTER the route builder is ready,
// otherwise there is a race condition and `#collectionContext.items` tends to win. [LK]
this.#observeCollectionItems();
});
}

#observeCollectionItems() {
if (!this.#collectionContext) return;
this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver');
}

#createTableItems(items: Array<UmbMediaTypeTreeItemModel>) {
const routeBuilder = this.#routeBuilder;
if (!routeBuilder) throw new Error('Route builder not ready');

this._tableItems = items.map((item) => {
const modalEditPath =
routeBuilder({ entityType: item.entityType }) +
UMB_EDIT_MEDIA_TYPE_WORKSPACE_PATH_PATTERN.generateLocal({ unique: item.unique });
const inlineEditPath = UMB_EDIT_MEDIA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN.generateAbsolute({
unique: item.unique,
});

return {
id: item.unique,
icon: item.isFolder && !item.icon ? 'icon-folder' : item.icon,
data: [
{
columnAlias: 'name',
value: html`<uui-button
href=${item.isFolder ? inlineEditPath : modalEditPath}
label=${item.name}></uui-button>`,
},
{
columnAlias: 'entityActions',
value: html`<umb-entity-actions-table-column-view
.value=${{
entityType: item.entityType,
unique: item.unique,
}}></umb-entity-actions-table-column-view>`,
},
],
};
});
}

override render() {
return html`
<umb-table .config=${this._tableConfig} .columns=${this._tableColumns} .items=${this._tableItems}></umb-table>
`;
}

static override styles = [
UmbTextStyles,
css`
:host {
display: flex;
flex-direction: column;
}
`,
];
}

export { UmbMediaTypeTreeItemTableCollectionViewElement as element };

declare global {
interface HTMLElementTagNameMap {
'umb-media-type-tree-item-table-collection-view': UmbMediaTypeTreeItemTableCollectionViewElement;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './collection/constants.js';
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import {
UMB_MEDIA_TYPE_ENTITY_TYPE,
UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE,
UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE,
} from '../../entity.js';
import { UMB_MEDIA_TYPE_ROOT_WORKSPACE_ALIAS } from '../../media-type-root/constants.js';
import { UMB_MEDIA_TYPE_FOLDER_WORKSPACE_ALIAS } from '../folder/constants.js';
import { manifests as collectionManifests } from './collection/manifests.js';

export const manifests: Array<UmbExtensionManifest> = [
{
type: 'entityAction',
kind: 'reloadTreeItemChildren',
alias: 'Umb.EntityAction.MediaType.Tree.ReloadChildrenOf',
name: 'Reload Media Type Tree Item Children Entity Action',
forEntityTypes: [UMB_MEDIA_TYPE_ENTITY_TYPE, UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE, UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE],
},
{
type: 'workspaceView',
kind: 'collection',
alias: 'Umb.WorkspaceView.MediaType.TreeItemChildrenCollection',
name: 'Media Type Tree Item Children Collection Workspace View',
meta: {
label: 'Folder',
pathname: 'folder',
icon: 'icon-folder',
collectionAlias: 'Umb.Collection.MediaType.TreeItemChildren',
},
conditions: [
{
alias: 'Umb.Condition.WorkspaceAlias',
oneOf: [UMB_MEDIA_TYPE_ROOT_WORKSPACE_ALIAS, UMB_MEDIA_TYPE_FOLDER_WORKSPACE_ALIAS],
},
],
},
...collectionManifests,
];
2 changes: 1 addition & 1 deletion src/Umbraco.Web.UI.Client/utils/all-umb-consts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -208,7 +208,7 @@ export const foundConsts = [{
},
{
path: '@umbraco-cms/backoffice/media-type',
consts: ["UMB_MEDIA_TYPE_CREATE_OPTIONS_MODAL","UMB_DUPLICATE_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_EXPORT_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_IMPORT_MODAL","UMB_MEDIA_TYPE_IMPORT_REPOSITORY_ALIAS","UMB_MOVE_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_ENTITY_TYPE","UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE","UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE","UMB_MEDIA_TYPE_COMPOSITION_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_DETAIL_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_DETAIL_STORE_ALIAS","UMB_MEDIA_TYPE_DETAIL_STORE_CONTEXT","UMB_MEDIA_TYPE_ITEM_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_ITEM_STORE_ALIAS","UMB_MEDIA_TYPE_ITEM_STORE_CONTEXT","UMB_MEDIA_TYPE_STRUCTURE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_TREE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_TREE_STORE_ALIAS","UMB_MEDIA_TYPE_TREE_ALIAS","UMB_MEDIA_TYPE_FOLDER_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_FOLDER_STORE_ALIAS","UMB_MEDIA_TYPE_FOLDER_STORE_CONTEXT","UMB_MEDIA_TYPE_FOLDER_WORKSPACE_ALIAS","UMB_MEDIA_TYPE_FOLDER_WORKSPACE_CONTEXT","UMB_MEDIA_TYPE_PICKER_MODAL","UMB_MEDIA_TYPE_TREE_STORE_CONTEXT","UMB_MEDIA_TYPE_WORKSPACE_ALIAS","UMB_MEDIA_TYPE_WORKSPACE_CONTEXT"]
consts: ["UMB_MEDIA_TYPE_CREATE_OPTIONS_MODAL","UMB_DUPLICATE_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_EXPORT_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_IMPORT_MODAL","UMB_MEDIA_TYPE_IMPORT_REPOSITORY_ALIAS","UMB_MOVE_MEDIA_TYPE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_ENTITY_TYPE","UMB_MEDIA_TYPE_ROOT_ENTITY_TYPE","UMB_MEDIA_TYPE_FOLDER_ENTITY_TYPE","UMB_MEDIA_TYPE_ROOT_WORKSPACE_ALIAS","UMB_MEDIA_TYPE_WORKSPACE_PATH","UMB_MEDIA_TYPE_ROOT_WORKSPACE_PATH","UMB_CREATE_MEDIA_TYPE_WORKSPACE_PATH_PATTERN","UMB_EDIT_MEDIA_TYPE_WORKSPACE_PATH_PATTERN","UMB_MEDIA_TYPE_COMPOSITION_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_DETAIL_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_DETAIL_STORE_ALIAS","UMB_MEDIA_TYPE_DETAIL_STORE_CONTEXT","UMB_MEDIA_TYPE_ITEM_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_ITEM_STORE_ALIAS","UMB_MEDIA_TYPE_ITEM_STORE_CONTEXT","UMB_MEDIA_TYPE_STRUCTURE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_TREE_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_TREE_STORE_ALIAS","UMB_MEDIA_TYPE_TREE_ALIAS","UMB_MEDIA_TYPE_FOLDER_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_FOLDER_STORE_ALIAS","UMB_MEDIA_TYPE_FOLDER_STORE_CONTEXT","UMB_MEDIA_TYPE_FOLDER_WORKSPACE_ALIAS","UMB_MEDIA_TYPE_FOLDER_WORKSPACE_CONTEXT","UMB_MEDIA_TYPE_FOLDER_WORKSPACE_PATH","UMB_EDIT_MEDIA_TYPE_FOLDER_WORKSPACE_PATH_PATTERN","UMB_MEDIA_TYPE_PICKER_MODAL","UMB_MEDIA_TYPE_TREE_STORE_CONTEXT","UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_ALIAS","UMB_MEDIA_TYPE_TREE_ITEM_CHILDREN_COLLECTION_REPOSITORY_ALIAS","UMB_MEDIA_TYPE_WORKSPACE_ALIAS","UMB_MEDIA_TYPE_WORKSPACE_CONTEXT"]
},
{
path: '@umbraco-cms/backoffice/media',
Expand Down