From bc5a37fc9fca09acfd783dc8f7f1a411b636ddcb Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 14 Feb 2024 21:50:40 +0100 Subject: [PATCH] remove outdated half implementation of tree + workspace --- .../src/mocks/data/document-blueprint.data.ts | 35 ------ .../document-blueprint.detail.store.ts | 101 ------------------ .../document-blueprint.tree.store.ts | 19 ---- .../document-blueprints/manifests.ts | 22 +--- .../documents/document-blueprints/types.ts | 11 -- 5 files changed, 1 insertion(+), 187 deletions(-) delete mode 100644 src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint.data.ts delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.detail.store.ts delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.tree.store.ts delete mode 100644 src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/types.ts diff --git a/src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint.data.ts b/src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint.data.ts deleted file mode 100644 index 47aa466b55..0000000000 --- a/src/Umbraco.Web.UI.Client/src/mocks/data/document-blueprint.data.ts +++ /dev/null @@ -1,35 +0,0 @@ -import type { DocumentBlueprintDetails } from '../../packages/documents/document-blueprints/types.js'; -import { UmbEntityData } from './entity.data.js'; - -export const data: Array = [ - { - name: 'Document Blueprint 1', - type: 'document-blueprint', - id: '3fa85f64-5717-4562-b3fc-2c963f66afa6', - icon: 'icon-blueprint', - documentTypeKey: 'd81c7957-153c-4b5a-aa6f-b434a4964624', - properties: [], - data: [], - }, - { - name: 'Document Blueprint 2', - type: 'document-blueprint', - id: '3fa85f64-5717-4562-b3qc-2c963f66afa6', - icon: 'icon-blueprint', - documentTypeKey: 'a99e4018-3ffc-486b-aa76-eecea9593d17', - properties: [], - data: [], - }, -]; - -// Temp mocked database -// TODO: all properties are optional in the server schema. I don't think this is correct. -// eslint-disable-next-line @typescript-eslint/ban-ts-comment -// @ts-ignore -class UmbDocumentBlueprintData extends UmbEntityData { - constructor() { - super(data); - } -} - -export const umbDocumentBlueprintData = new UmbDocumentBlueprintData(); diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.detail.store.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.detail.store.ts deleted file mode 100644 index 885329dd0c..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.detail.store.ts +++ /dev/null @@ -1,101 +0,0 @@ -import type { DocumentBlueprintDetails } from './types.js'; -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import { UmbArrayState } from '@umbraco-cms/backoffice/observable-api'; -import { UmbStoreBase } from '@umbraco-cms/backoffice/store'; -import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; - -/** - * @export - * @class UmbDocumentBlueprintStore - * @extends {UmbStoreBase} - * @description - Data Store for Document Blueprints - */ -export class UmbDocumentBlueprintStore extends UmbStoreBase { - constructor(host: UmbControllerHostElement) { - super( - host, - UMB_DOCUMENT_BLUEPRINT_STORE_CONTEXT.toString(), - // TODO: use the right type: - - new UmbArrayState([], (x) => x.id), - ); - } - - /** - * @description - Request a Data Type by id. The Data Type is added to the store and is returned as an Observable. - * @param {string} id - * @return {*} {(Observable)} - * @memberof UmbDocumentBlueprintStore - */ - getById(id: string) { - // TODO: use backend cli when available. - fetch(`/umbraco/management/api/v1/document-blueprint/details/${id}`) - .then((res) => res.json()) - .then((data) => { - this._data.append(data); - }); - - return this._data.asObservablePart((documents) => documents.find((document) => document.id === id)); - } - - getScaffold(entityType: string, parentId: string | null) { - return {} as DocumentBlueprintDetails; - } - - // TODO: make sure UI somehow can follow the status of this action. - /** - * @description - Save a DocumentBlueprint. - * @param {Array} Dictionaries - * @memberof UmbDocumentBlueprintStore - * @return {*} {Promise} - */ - save(data: DocumentBlueprintDetails[]) { - // fetch from server and update store - // TODO: use Fetcher API. - let body: string; - - try { - body = JSON.stringify(data); - } catch (error) { - console.error(error); - return Promise.reject(); - } - - // TODO: use backend cli when available. - return fetch('/umbraco/management/api/v1/document-blueprint/save', { - method: 'POST', - body: body, - headers: { - 'Content-Type': 'application/json', - }, - }) - .then((res) => res.json()) - .then((data: Array) => { - this._data.append(data); - }); - } - - // TODO: How can we avoid having this in both stores? - /** - * @description - Delete a Data Type. - * @param {string[]} ids - * @memberof UmbDocumentBlueprintStore - * @return {*} {Promise} - */ - async delete(ids: string[]) { - // TODO: use backend cli when available. - await fetch('/umbraco/backoffice/document-blueprint/delete', { - method: 'POST', - body: JSON.stringify(ids), - headers: { - 'Content-Type': 'application/json', - }, - }); - - this._data.remove(ids); - } -} - -export const UMB_DOCUMENT_BLUEPRINT_STORE_CONTEXT = new UmbContextToken( - 'UmbDocumentBlueprintStore', -); diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.tree.store.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.tree.store.ts deleted file mode 100644 index 4443072992..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/document-blueprint.tree.store.ts +++ /dev/null @@ -1,19 +0,0 @@ -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import { UmbEntityTreeStore } from '@umbraco-cms/backoffice/tree'; -import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; - -export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT = new UmbContextToken( - 'UmbDocumentBlueprintTreeStore', -); - -/** - * @export - * @class UmbDocumentBlueprintTreeStore - * @extends {UmbStoreBase} - * @description - Tree Data Store for Document Blueprints - */ -export class UmbDocumentBlueprintTreeStore extends UmbEntityTreeStore { - constructor(host: UmbControllerHostElement) { - super(host, UMB_DOCUMENT_BLUEPRINT_TREE_STORE_CONTEXT.toString()); - } -} diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/manifests.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/manifests.ts index d065efe4b3..ea4e6d7613 100644 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/manifests.ts @@ -1,24 +1,4 @@ -import { UmbDocumentBlueprintStore } from './document-blueprint.detail.store.js'; -import { UmbDocumentBlueprintTreeStore } from './document-blueprint.tree.store.js'; import { manifests as menuItemManifests } from './menu-item/manifests.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; -import type { ManifestStore, ManifestTreeStore } from '@umbraco-cms/backoffice/extension-registry'; -export const UMB_DOCUMENT_BLUEPRINT_STORE_ALIAS = 'Umb.Store.DocumentBlueprint'; -export const UMB_DOCUMENT_BLUEPRINT_TREE_STORE_ALIAS = 'Umb.Store.DocumentBlueprintTree'; - -const store: ManifestStore = { - type: 'store', - alias: UMB_DOCUMENT_BLUEPRINT_STORE_ALIAS, - name: 'Document Blueprint Store', - api: UmbDocumentBlueprintStore, -}; - -const treeStore: ManifestTreeStore = { - type: 'treeStore', - alias: UMB_DOCUMENT_BLUEPRINT_TREE_STORE_ALIAS, - name: 'Document Blueprint Tree Store', - api: UmbDocumentBlueprintTreeStore, -}; - -export const manifests = [store, treeStore, ...menuItemManifests, ...workspaceManifests]; +export const manifests = [...menuItemManifests, ...workspaceManifests]; diff --git a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/types.ts b/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/types.ts deleted file mode 100644 index 6a7b8c2fbb..0000000000 --- a/src/Umbraco.Web.UI.Client/src/packages/documents/document-blueprints/types.ts +++ /dev/null @@ -1,11 +0,0 @@ -// Document Blueprint - -export interface DocumentBlueprintDetails { - id: string; - name: string; - type: 'document-blueprint'; - properties: Array; - data: Array; - icon: string; - documentTypeKey: string; -}