Bugfix: Workspace breadcrumbs, error when new at root
This commit is contained in:
@@ -58,28 +58,31 @@ export abstract class UmbMenuTreeStructureWorkspaceContextBase extends UmbContex
|
||||
}
|
||||
|
||||
const isNew = this.#workspaceContext?.getIsNew();
|
||||
const uniqueObservable = isNew ? this.#workspaceContext?.parentUnique : this.#workspaceContext?.unique;
|
||||
|
||||
const entityTypeObservable = isNew ? this.#workspaceContext?.parentEntityType : this.#workspaceContext?.entityType;
|
||||
|
||||
const unique = (await this.observe(uniqueObservable, () => {})?.asPromise()) as string;
|
||||
if (!unique) throw new Error('Unique is not available');
|
||||
|
||||
const entityType = (await this.observe(entityTypeObservable, () => {})?.asPromise()) as string;
|
||||
if (!entityType) throw new Error('Entity type is not available');
|
||||
|
||||
const { data } = await treeRepository.requestTreeItemAncestors({ treeItem: { unique, entityType } });
|
||||
// If the entity type is different from the root entity type, then we can request the ancestors.
|
||||
if (entityType !== root?.entityType) {
|
||||
const uniqueObservable = isNew ? this.#workspaceContext?.parentUnique : this.#workspaceContext?.unique;
|
||||
const unique = (await this.observe(uniqueObservable, () => {})?.asPromise()) as string;
|
||||
if (!unique) throw new Error('Unique is not available');
|
||||
|
||||
if (data) {
|
||||
const ancestorItems = data.map((treeItem) => {
|
||||
return {
|
||||
unique: treeItem.unique,
|
||||
entityType: treeItem.entityType,
|
||||
name: treeItem.name,
|
||||
isFolder: treeItem.isFolder,
|
||||
};
|
||||
});
|
||||
const { data } = await treeRepository.requestTreeItemAncestors({ treeItem: { unique, entityType } });
|
||||
|
||||
structureItems.push(...ancestorItems);
|
||||
if (data) {
|
||||
const ancestorItems = data.map((treeItem) => {
|
||||
return {
|
||||
unique: treeItem.unique,
|
||||
entityType: treeItem.entityType,
|
||||
name: treeItem.name,
|
||||
isFolder: treeItem.isFolder,
|
||||
};
|
||||
});
|
||||
|
||||
structureItems.push(...ancestorItems);
|
||||
}
|
||||
}
|
||||
|
||||
const parent = structureItems[structureItems.length - 2];
|
||||
|
||||
Reference in New Issue
Block a user