remove current tree store interface

This commit is contained in:
Mads Rasmussen
2023-03-24 10:44:04 +01:00
parent 23664f7499
commit baebfb55de
4 changed files with 6 additions and 39 deletions

View File

@@ -9,33 +9,7 @@ export interface UmbDataStore {
readonly storeAlias: string;
}
export interface UmbTreeStore<T> extends UmbDataStore {
getTreeRoot(): Observable<Array<T>>;
getTreeItemChildren(key: string): Observable<Array<T>>;
// Notice: this might not be right to put here as only some content items has ability to be trashed.
/**
* @description - Trash data.
* @param {string[]} keys
* @return {*} {(Promise<void>)}
* @memberof UmbTreeStore
*/
trash(keys: string[]): Promise<void>;
// Notice: this might not be right to put here as only some content items has ability to be moved.
/**
* @description - Move data.
* @param {string[]} keys
* @return {*} {(Promise<void>)}
* @memberof UmbTreeStore
*/
move(keys: string[], destination: string): Promise<void>;
}
export interface UmbEntityDetailStore<T> extends UmbDataStore {
/**
* @description - Request scaffold data by entityType and . The data is added to the store and is returned as an Observable.
* @param {string} key
@@ -61,10 +35,7 @@ export interface UmbEntityDetailStore<T> extends UmbDataStore {
save(data: T[]): Promise<void>;
}
export interface UmbContentStore<T> extends UmbEntityDetailStore<T> {
// TODO: make something that is specific for UmbContentStore, or then we should get rid of it. But for now i kept it as we might want this for rollback or other things specific to Content types.
save(data: T[]): Promise<void>;
}

View File

@@ -1,6 +1,5 @@
import { Observable } from 'rxjs';
import type { EntityTreeItemResponseModel } from '@umbraco-cms/backoffice/backend-api';
import type { UmbTreeStore } from '@umbraco-cms/backoffice/store';
import type { UmbControllerHostInterface } from '@umbraco-cms/backoffice/controller';
import { UmbContextToken, UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api';
import { ArrayState, UmbObserverController } from '@umbraco-cms/backoffice/observable-api';
@@ -9,17 +8,14 @@ import { createExtensionClass } from 'libs/extensions-api/create-extension-class
import { UmbTreeRepository } from '@umbraco-cms/backoffice/repository';
// TODO: Clean up the need for store as Media has switched to use Repositories(repository).
export class UmbCollectionContext<
DataType extends EntityTreeItemResponseModel = EntityTreeItemResponseModel,
StoreType extends UmbTreeStore<DataType> = UmbTreeStore<DataType>
> {
export class UmbCollectionContext<DataType extends EntityTreeItemResponseModel = EntityTreeItemResponseModel> {
private _host: UmbControllerHostInterface;
private _entityType: string | null;
private _entityKey: string | null;
#repository?: UmbTreeRepository;
private _store?: StoreType;
private _store?: any;
protected _dataObserver?: UmbObserverController<DataType[]>;
#data = new ArrayState(<Array<DataType>>[]);
@@ -46,7 +42,7 @@ export class UmbCollectionContext<
this._entityKey = entityKey;
if (storeAlias) {
new UmbContextConsumerController(this._host, storeAlias, (_instance: StoreType) => {
new UmbContextConsumerController(this._host, storeAlias, (_instance) => {
this._store = _instance;
if (!this._store) {
// TODO: if we keep the type assumption of _store existing, then we should here make sure to break the application in a good way.
@@ -175,4 +171,4 @@ export class UmbCollectionContext<
}
}
export const UMB_COLLECTION_CONTEXT_TOKEN = new UmbContextToken<UmbCollectionContext<any, any>>('UmbCollectionContext');
export const UMB_COLLECTION_CONTEXT_TOKEN = new UmbContextToken<UmbCollectionContext<any>>('UmbCollectionContext');

View File

@@ -25,7 +25,7 @@ export class UmbDashboardCollectionElement extends UmbLitElement {
];
// TODO: Use the right type here:
private _collectionContext?: UmbCollectionContext<FolderTreeItemResponseModel, any>;
private _collectionContext?: UmbCollectionContext<FolderTreeItemResponseModel>;
public manifest!: ManifestDashboardCollection;

View File

@@ -30,7 +30,7 @@ export class UmbWorkspaceViewCollectionElement extends UmbLitElement {
private _workspaceContext?: UmbEntityWorkspaceContextInterface;
// TODO: add type for the collection context.
private _collectionContext?: UmbCollectionContext<FolderTreeItemResponseModel, any>;
private _collectionContext?: UmbCollectionContext<FolderTreeItemResponseModel>;
constructor() {
super();