fixes registration of data types repository (#521)
* fixes registration of data types repository removes old tree * fix for pr-first-response? * that was pointless - first run won't run again * add repository to extensions registry --------- Co-authored-by: Mads Rasmussen <madsr@hey.com>
This commit is contained in:
@@ -34,7 +34,7 @@ import { UmbDictionaryTreeStore } from './translation/dictionary/repository/dict
|
||||
import { UmbDocumentBlueprintDetailStore } from './documents/document-blueprints/document-blueprint.detail.store';
|
||||
import { UmbDocumentBlueprintTreeStore } from './documents/document-blueprints/document-blueprint.tree.store';
|
||||
import { UmbDataTypeStore } from './settings/data-types/repository/data-type.store';
|
||||
import { UmbDataTypeTreeStore } from './settings/data-types/tree/data-type.tree.store';
|
||||
import { UmbDataTypeTreeStore } from './settings/data-types/repository/data-type.tree.store';
|
||||
import { UmbTemplateTreeStore } from './templating/templates/tree/data/template.tree.store';
|
||||
import { UmbTemplateDetailStore } from './templating/templates/workspace/data/template.detail.store';
|
||||
import { UmbThemeContext } from './themes/theme.context';
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
import { manifests as sidebarMenuItemManifests } from './sidebar-menu-item/manifests';
|
||||
import { manifests as treeManifests } from './tree/manifests';
|
||||
import { manifests as workspaceManifests } from './workspace/manifests';
|
||||
import { manifests as repositoryManifests } from './repository/manifests';
|
||||
|
||||
export const manifests = [...sidebarMenuItemManifests, ...treeManifests, ...workspaceManifests];
|
||||
export const manifests = [...sidebarMenuItemManifests, ...treeManifests, ...repositoryManifests, ...workspaceManifests];
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
import { UmbDataTypeRepository } from './data-type.repository';
|
||||
import { ManifestRepository } from 'libs/extensions-registry/repository.models';
|
||||
|
||||
export const DATA_TYPE_REPOSITORY_ALIAS = 'Umb.Repository.DataTypes';
|
||||
|
||||
const repository: ManifestRepository = {
|
||||
type: 'repository',
|
||||
alias: DATA_TYPE_REPOSITORY_ALIAS,
|
||||
name: 'Data Types Repository',
|
||||
class: UmbDataTypeRepository,
|
||||
};
|
||||
|
||||
export const manifests = [repository];
|
||||
@@ -1,91 +0,0 @@
|
||||
import { DataTypeResource, DocumentTreeItemModel } from '@umbraco-cms/backend-api';
|
||||
import { tryExecuteAndNotify } from '@umbraco-cms/resources';
|
||||
import { UmbContextToken } from '@umbraco-cms/context-api';
|
||||
import { ArrayState } from '@umbraco-cms/observable-api';
|
||||
import { UmbStoreBase } from '@umbraco-cms/store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
|
||||
export const UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN = new UmbContextToken<UmbDataTypeTreeStore>('UmbDataTypeTreeStore');
|
||||
|
||||
/**
|
||||
* @export
|
||||
* @class UmbDataTypeTreeStore
|
||||
* @extends {UmbStoreBase}
|
||||
* @description - Tree Data Store for Data Types
|
||||
*/
|
||||
export class UmbDataTypeTreeStore extends UmbStoreBase {
|
||||
#data = new ArrayState<DocumentTreeItemModel>([], (x) => x.key);
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
super(host, UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN.toString());
|
||||
}
|
||||
|
||||
// TODO: How can we avoid having this in both stores?
|
||||
/**
|
||||
* @description - Delete a Data Type.
|
||||
* @param {string[]} keys
|
||||
* @memberof UmbDataTypesStore
|
||||
* @return {*} {Promise<void>}
|
||||
*/
|
||||
async delete(keys: string[]) {
|
||||
// TODO: use backend cli when available.
|
||||
await fetch('/umbraco/backoffice/data-type/delete', {
|
||||
method: 'POST',
|
||||
body: JSON.stringify(keys),
|
||||
headers: {
|
||||
'Content-Type': 'application/json',
|
||||
},
|
||||
});
|
||||
|
||||
this.#data.remove(keys);
|
||||
}
|
||||
|
||||
getTreeRoot() {
|
||||
tryExecuteAndNotify(this._host, DataTypeResource.getTreeDataTypeRoot({})).then(({ data }) => {
|
||||
if (data) {
|
||||
// TODO: how do we handle if an item has been removed during this session(like in another tab or by another user)?
|
||||
this.#data.append(data.items);
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: how do we handle trashed items?
|
||||
// TODO: remove ignore when we know how to handle trashed items.
|
||||
return this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === null && !item.isTrashed));
|
||||
}
|
||||
|
||||
getTreeItemChildren(key: string) {
|
||||
tryExecuteAndNotify(
|
||||
this._host,
|
||||
DataTypeResource.getTreeDataTypeChildren({
|
||||
parentKey: key,
|
||||
})
|
||||
).then(({ data }) => {
|
||||
if (data) {
|
||||
// TODO: how do we handle if an item has been removed during this session(like in another tab or by another user)?
|
||||
this.#data.append(data.items);
|
||||
}
|
||||
});
|
||||
|
||||
// TODO: how do we handle trashed items?
|
||||
// TODO: remove ignore when we know how to handle trashed items.
|
||||
return this.#data.getObservablePart((items) => items.filter((item) => item.parentKey === key && !item.isTrashed));
|
||||
}
|
||||
|
||||
getTreeItems(keys: Array<string>) {
|
||||
if (keys?.length > 0) {
|
||||
tryExecuteAndNotify(
|
||||
this._host,
|
||||
DataTypeResource.getTreeDataTypeItem({
|
||||
key: keys,
|
||||
})
|
||||
).then(({ data }) => {
|
||||
if (data) {
|
||||
// TODO: how do we handle if an item has been removed during this session(like in another tab or by another user)?
|
||||
this.#data.append(data);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
return this.#data.getObservablePart((items) => items.filter((item) => keys.includes(item.key ?? '')));
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
import { UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN } from './data-type.tree.store';
|
||||
import { UmbDataTypeRepository } from '../repository/data-type.repository';
|
||||
import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models';
|
||||
|
||||
const tree: ManifestTree = {
|
||||
@@ -6,7 +6,7 @@ const tree: ManifestTree = {
|
||||
alias: 'Umb.Tree.DataTypes',
|
||||
name: 'Data Types Tree',
|
||||
meta: {
|
||||
storeAlias: UMB_DATA_TYPE_TREE_STORE_CONTEXT_TOKEN.toString(),
|
||||
repository: UmbDataTypeRepository,
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user