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

Feature: Folder workspace #2342

Merged
merged 33 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
7c79157
register folder workspace for document types
madsrasmussen Sep 25, 2024
aa89b5b
require entityType on folders
madsrasmussen Sep 25, 2024
b13fa6e
wip align folder and detail repos
madsrasmussen Sep 25, 2024
057d090
align with detail repo + detail data source
madsrasmussen Sep 25, 2024
bad73ab
add missing pieces for media type folders
madsrasmussen Sep 25, 2024
296d357
organize
madsrasmussen Sep 26, 2024
3dfd17e
render most basic folder workspace
madsrasmussen Sep 26, 2024
6bc1883
implement folder workspace for data type folders
madsrasmussen Sep 26, 2024
7611e7e
Merge branch 'main' into v15/feature/tree-folder-workspace
madsrasmussen Sep 26, 2024
a5029e9
reorganize
madsrasmussen Sep 26, 2024
c6d9a0c
rename
madsrasmussen Sep 26, 2024
2020c9e
register script folder workspace
madsrasmussen Sep 26, 2024
1ed8de8
expose observable data from base
madsrasmussen Sep 26, 2024
53d0d6c
move unique + entityType observable to the base class
madsrasmussen Sep 26, 2024
4add154
reorganize
madsrasmussen Sep 26, 2024
f343fc7
add stylesheet folder workspace
madsrasmussen Sep 26, 2024
67a610f
reorganize
madsrasmussen Sep 26, 2024
983d8e0
Merge branch 'main' into v15/feature/tree-folder-workspace
madsrasmussen Sep 26, 2024
475b300
register folder workspace
madsrasmussen Sep 26, 2024
e911aa5
Update document-blueprint-options-create-modal.element.ts
madsrasmussen Sep 26, 2024
24d7c03
organize
madsrasmussen Sep 26, 2024
cd2dea0
add workspace for document blueprint folders
madsrasmussen Sep 26, 2024
7dc4c56
remove registration
madsrasmussen Sep 26, 2024
70202cc
editable folder name
madsrasmussen Sep 27, 2024
1036ae7
reorganize
madsrasmussen Sep 27, 2024
c84b00c
add media type folder workspace
madsrasmussen Sep 27, 2024
25adb06
render editable name
madsrasmussen Sep 27, 2024
f1356c5
fix element name
madsrasmussen Sep 27, 2024
a9378da
fix duplicated alias
madsrasmussen Sep 27, 2024
3d422c1
register temp root workspaces
madsrasmussen Sep 27, 2024
b921ab6
edit document blueprint
madsrasmussen Sep 27, 2024
42ac20e
add recycle bin roots
madsrasmussen Sep 27, 2024
4ce4e6b
fix imports
madsrasmussen Sep 27, 2024
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
Expand Up @@ -7,9 +7,10 @@ import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
import type { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
import type { UmbDetailStore } from '@umbraco-cms/backoffice/store';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export abstract class UmbDetailRepositoryBase<
DetailModelType extends { unique: string; entityType: string },
DetailModelType extends UmbEntityModel,
UmbDetailDataSourceType extends UmbDetailDataSource<DetailModelType> = UmbDetailDataSource<DetailModelType>,
>
extends UmbRepositoryBase
Expand All @@ -28,6 +29,9 @@ export abstract class UmbDetailRepositoryBase<
) {
super(host);

if (!detailSource) throw new Error('Detail source is missing');
if (!detailStoreContextAlias) throw new Error('Detail store context alias is missing');

this.detailDataSource = new detailSource(host) as UmbDetailDataSourceType;

this.#init = Promise.all([
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification';
import type { UmbDetailStore } from '@umbraco-cms/backoffice/store';
import { UmbRepositoryBase } from '@umbraco-cms/backoffice/repository';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export abstract class UmbRenameServerFileRepositoryBase<
DetailModelType extends { unique: string },
DetailModelType extends UmbEntityModel,
> extends UmbRepositoryBase {
#renameSource: UmbRenameServerFileDataSource<DetailModelType>;
#detailStoreContextAlias: string | UmbContextToken<UmbDetailStore<DetailModelType>>;
Expand Down
7 changes: 4 additions & 3 deletions src/packages/core/server-file-system/rename/types.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,15 @@
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
import type { UmbDataSourceResponse } from '@umbraco-cms/backoffice/repository';

export interface UmbRenameServerFileRepository<DetailType extends { unique: string }> {
export interface UmbRenameServerFileRepository<DetailType extends UmbEntityModel> {
rename(unique: string, name: string): Promise<UmbDataSourceResponse<DetailType>>;
}

export interface UmbRenameServerFileDataSourceConstructor<DetailType extends { unique: string }> {
export interface UmbRenameServerFileDataSourceConstructor<DetailType extends UmbEntityModel> {
new (host: UmbControllerHost): UmbRenameServerFileDataSource<DetailType>;
}

export interface UmbRenameServerFileDataSource<DetailType extends { unique: string }> {
export interface UmbRenameServerFileDataSource<DetailType extends UmbEntityModel> {
rename(unique: string, name: string): Promise<UmbDataSourceResponse<DetailType>>;
}
8 changes: 5 additions & 3 deletions src/packages/core/store/detail/detail-store-base.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import { UmbStoreBase } from '../store-base.js';
import type { UmbDetailStore } from './detail-store.interface.js';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';

Expand All @@ -9,14 +10,14 @@ import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api';
* @description - Data Store for Data Type items
*/

export abstract class UmbDetailStoreBase<T extends { unique: string }>
export abstract class UmbDetailStoreBase<T extends UmbEntityModel>
extends UmbStoreBase<T>
implements UmbDetailStore<T>
{
/**
* Creates an instance of UmbDetailStoreBase.
* @param {UmbControllerHost} host - The controller host for this controller to be appended to
* @param storeAlias
* @param storeAlias - The alias of the store
* @memberof UmbDetailStoreBase
*/
constructor(host: UmbControllerHost, storeAlias: string) {
Expand All @@ -25,8 +26,9 @@ export abstract class UmbDetailStoreBase<T extends { unique: string }>

/**
* Retrieve a detail model from the store
* @param {unique} string unique
* @param {unique} string unique identifier
* @param unique
* @returns {Observable<T>}
* @memberof UmbDetailStoreBase
*/
byUnique(unique: string) {
Expand Down
3 changes: 2 additions & 1 deletion src/packages/core/store/detail/detail-store.interface.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import type { UmbStore } from '../store.interface.js';
import type { Observable } from '@umbraco-cms/backoffice/external/rxjs';
import type { UmbApi } from '@umbraco-cms/backoffice/extension-api';
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export interface UmbDetailStore<T extends { unique: string }> extends UmbStore<T>, UmbApi {
export interface UmbDetailStore<T extends UmbEntityModel> extends UmbStore<T>, UmbApi {
byUnique: (unique: string) => Observable<T | undefined>;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import type { UmbFolderRepository } from '../../folder-repository.interface.js';
import type { UmbFolderModel } from '../../types.js';
import { UMB_ACTION_EVENT_CONTEXT } from '@umbraco-cms/backoffice/action';
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
import type { UmbEntityActionArgs } from '@umbraco-cms/backoffice/entity-action';
Expand All @@ -7,10 +7,11 @@ import { UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-ap
import type { MetaEntityActionFolderKind } from '@umbraco-cms/backoffice/extension-registry';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { umbConfirmModal } from '@umbraco-cms/backoffice/modal';
import type { UmbDetailRepository } from '@umbraco-cms/backoffice/repository';

export class UmbDeleteFolderEntityAction extends UmbEntityActionBase<MetaEntityActionFolderKind> {
// TODO: make base type for item and detail models
#folderRepository?: UmbFolderRepository;
#folderRepository?: UmbDetailRepository<UmbFolderModel>;
#init: Promise<unknown>;

constructor(host: UmbControllerHost, args: UmbEntityActionArgs<MetaEntityActionFolderKind>) {
Expand All @@ -25,7 +26,7 @@ export class UmbDeleteFolderEntityAction extends UmbEntityActionBase<MetaEntityA
this.args.meta.folderRepositoryAlias,
[this._host],
(permitted, ctrl) => {
this.#folderRepository = permitted ? (ctrl.api as UmbFolderRepository) : undefined;
this.#folderRepository = permitted ? (ctrl.api as UmbDetailRepository<UmbFolderModel>) : undefined;
},
).asPromise(),
]);
Expand All @@ -35,7 +36,7 @@ export class UmbDeleteFolderEntityAction extends UmbEntityActionBase<MetaEntityA
if (!this.args.unique) throw new Error('Unique is not available');
await this.#init;

const { data: folder } = await this.#folderRepository!.request(this.args.unique);
const { data: folder } = await this.#folderRepository!.requestByUnique(this.args.unique);

if (folder) {
// TODO: maybe we can show something about how many items are part of the folder?
Expand Down
14 changes: 0 additions & 14 deletions src/packages/core/tree/folder/folder-data-source.interface.ts

This file was deleted.

115 changes: 0 additions & 115 deletions src/packages/core/tree/folder/folder-repository-base.ts

This file was deleted.

10 changes: 0 additions & 10 deletions src/packages/core/tree/folder/folder-repository.interface.ts

This file was deleted.

4 changes: 0 additions & 4 deletions src/packages/core/tree/folder/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,3 @@
export { type UmbFolderRepository } from './folder-repository.interface.js';
export { type UmbFolderDataSource } from './folder-data-source.interface.js';
export { UmbFolderRepositoryBase } from './folder-repository-base.js';

export * from './types.js';
export * from './modal/index.js';
export * from './entity-action/index.js';
Original file line number Diff line number Diff line change
@@ -1,11 +1,6 @@
import { UmbFolderModalElementBase } from './folder-modal-element-base.js';
import { customElement, state } from '@umbraco-cms/backoffice/external/lit';
import type {
UmbCreateFolderModel,
UmbFolderCreateModalData,
UmbFolderCreateModalValue,
UmbFolderModel,
} from '@umbraco-cms/backoffice/tree';
import type { UmbFolderCreateModalData, UmbFolderCreateModalValue, UmbFolderModel } from '@umbraco-cms/backoffice/tree';

@customElement('umb-folder-create-modal')
export class UmbFolderCreateModalElement extends UmbFolderModalElementBase<
Expand Down Expand Up @@ -35,13 +30,12 @@ export class UmbFolderCreateModalElement extends UmbFolderModalElementBase<
if (!this._folderScaffold) throw new Error('The folder scaffold was not initialized correctly');
if (!this.data?.parent) throw new Error('A parent is required to create folder');

const createFolderModel: UmbCreateFolderModel = {
const folder: UmbFolderModel = {
...this._folderScaffold,
parentUnique: this.data.parent.unique,
name,
};

const { data: createdFolder } = await this.folderRepository.create(createFolderModel);
const { data: createdFolder } = await this.folderRepository.create(folder, this.data.parent.unique);

if (createdFolder) {
this.value = { folder: createdFolder };
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { css, html, state } from '@umbraco-cms/backoffice/external/lit';
import { UmbTextStyles } from '@umbraco-cms/backoffice/style';
import { UmbModalBaseElement } from '@umbraco-cms/backoffice/modal';
import type { UmbFolderModel, UmbFolderRepository } from '@umbraco-cms/backoffice/tree';
import type { UmbFolderModel } from '@umbraco-cms/backoffice/tree';
import { UmbExtensionApiInitializer } from '@umbraco-cms/backoffice/extension-api';
import { umbExtensionsRegistry } from '@umbraco-cms/backoffice/extension-registry';
import { umbFocus } from '@umbraco-cms/backoffice/lit-element';
import type { UmbDetailRepository } from '@umbraco-cms/backoffice/repository';

export abstract class UmbFolderModalElementBase<
FolderModalDataType extends { folderRepositoryAlias: string },
Expand All @@ -13,7 +14,7 @@ export abstract class UmbFolderModalElementBase<
@state()
_isNew = false;

folderRepository?: UmbFolderRepository;
folderRepository?: UmbDetailRepository<UmbFolderModel>;

override connectedCallback(): void {
super.connectedCallback();
Expand All @@ -29,7 +30,7 @@ export abstract class UmbFolderModalElementBase<
this.data.folderRepositoryAlias,
[this],
(permitted, ctrl) => {
this.folderRepository = permitted ? (ctrl.api as UmbFolderRepository) : undefined;
this.folderRepository = permitted ? (ctrl.api as UmbDetailRepository<UmbFolderModel>) : undefined;
if (this.folderRepository) {
this.init();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export class UmbFolderModalElement extends UmbFolderModalElementBase<
if (!this.folderRepository) throw new Error('A folder repository is required to load a folder');
if (!this.data?.unique) throw new Error('A unique is required to load folder');

const { data } = await this.folderRepository.request(this.data.unique);
const { data } = await this.folderRepository.requestByUnique(this.data.unique);

if (data) {
this.value = { folder: data };
Expand All @@ -22,7 +22,7 @@ export class UmbFolderModalElement extends UmbFolderModalElementBase<
if (!this.folderRepository) throw new Error('A folder repository is required to update a folder');
if (this.value.folder === undefined) throw new Error('The folder was not initialized correctly');

const { data } = await this.folderRepository.update({
const { data } = await this.folderRepository.save({
...this.value.folder,
name,
});
Expand Down
14 changes: 2 additions & 12 deletions src/packages/core/tree/folder/types.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
export interface UmbFolderModel {
unique: string;
name: string;
}

export interface UmbCreateFolderModel {
unique: string;
parentUnique: string | null;
name: string;
}
import type { UmbEntityModel } from '@umbraco-cms/backoffice/entity';

export interface UmbUpdateFolderModel {
unique: string;
export interface UmbFolderModel extends UmbEntityModel {
name: string;
}
Loading
Loading