Skip to content

Commit e3d2001

Browse files
SectionSidebarContextMenu: Delete element and methods for interaction (#20399)
Delete sction-sidebar-context-menu element + context methods
1 parent 7c0b5b7 commit e3d2001

File tree

8 files changed

+7
-230
lines changed

8 files changed

+7
-230
lines changed

src/Umbraco.Web.UI.Client/src/packages/core/section/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ export * from './constants.js';
33
export * from './default/default-section.element.js';
44
export * from './section-main/index.js';
55
export * from './section-picker-modal/section-picker-modal.token.js';
6-
export * from './section-sidebar-context-menu/index.js';
76
export * from './section-sidebar/index.js';
87
export * from './section.context.js';
98
export * from './section.context.token.js';

src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/index.ts

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/Umbraco.Web.UI.Client/src/packages/core/section/section-sidebar-context-menu/section-sidebar-context-menu.element.ts

Lines changed: 0 additions & 163 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './section-sidebar.context.js';
21
export * from './section-sidebar.element.js';
2+
export * from './section-sidebar.context.token.js';
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
import type { UmbSectionSidebarContext } from './section-sidebar.context.js';
2+
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
3+
4+
export const UMB_SECTION_SIDEBAR_CONTEXT = new UmbContextToken<UmbSectionSidebarContext>('UmbSectionSidebarContext');
Lines changed: 1 addition & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,53 +1,9 @@
1-
import type { UmbOpenContextMenuArgs } from './types.js';
2-
import { UmbContextToken } from '@umbraco-cms/backoffice/context-api';
1+
import { UMB_SECTION_SIDEBAR_CONTEXT } from './section-sidebar.context.token.js';
32
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
43
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
5-
import { UmbStringState, UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
64

75
export class UmbSectionSidebarContext extends UmbContextBase {
8-
#contextMenuIsOpen = new UmbBooleanState(false);
9-
contextMenuIsOpen = this.#contextMenuIsOpen.asObservable();
10-
11-
#entityType = new UmbStringState<undefined>(undefined);
12-
entityType = this.#entityType.asObservable();
13-
14-
#unique = new UmbStringState<null | undefined>(undefined);
15-
unique = this.#unique.asObservable();
16-
17-
#headline = new UmbStringState<undefined>(undefined);
18-
headline = this.#headline.asObservable();
19-
20-
#contextElement: Element | undefined = undefined;
21-
226
constructor(host: UmbControllerHost) {
237
super(host, UMB_SECTION_SIDEBAR_CONTEXT);
248
}
25-
26-
toggleContextMenu(host: Element, args: UmbOpenContextMenuArgs) {
27-
this.openContextMenu(host, args);
28-
}
29-
30-
// TODO: we wont get notified about tree item name changes because we don't have a subscription
31-
// we need to figure out how we best can handle this when we only know the entity and unique id
32-
openContextMenu(host: Element, args: UmbOpenContextMenuArgs) {
33-
this.#entityType.setValue(args.entityType);
34-
this.#unique.setValue(args.unique);
35-
this.#headline.setValue(args.headline);
36-
this.#contextMenuIsOpen.setValue(true);
37-
this.#contextElement = host;
38-
}
39-
40-
closeContextMenu() {
41-
this.#contextMenuIsOpen.setValue(false);
42-
this.#entityType.setValue(undefined);
43-
this.#unique.setValue(undefined);
44-
this.#headline.setValue(undefined);
45-
this.#contextElement = undefined;
46-
}
47-
48-
getContextElement() {
49-
return this.#contextElement;
50-
}
519
}
52-
53-
export const UMB_SECTION_SIDEBAR_CONTEXT = new UmbContextToken<UmbSectionSidebarContext>('UmbSectionSidebarContext');

src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-item/tree-item-base/tree-item-context-base.ts

Lines changed: 1 addition & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { UmbBooleanState, UmbObjectState, UmbStringState } from '@umbraco-cms/ba
1212
import { UmbContextBase } from '@umbraco-cms/backoffice/class-api';
1313
import { UmbDeprecation, debounce } from '@umbraco-cms/backoffice/utils';
1414
import { UmbParentEntityContext } from '@umbraco-cms/backoffice/entity';
15-
import { UMB_SECTION_CONTEXT, UMB_SECTION_SIDEBAR_CONTEXT } from '@umbraco-cms/backoffice/section';
15+
import { UMB_SECTION_CONTEXT } from '@umbraco-cms/backoffice/section';
1616
import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api';
1717
import type { UmbEntityModel, UmbEntityUnique } from '@umbraco-cms/backoffice/entity';
1818

@@ -69,7 +69,6 @@ export abstract class UmbTreeItemContextBase<
6969
public treeContext?: typeof UMB_TREE_CONTEXT.TYPE;
7070

7171
#sectionContext?: typeof UMB_SECTION_CONTEXT.TYPE;
72-
#sectionSidebarContext?: typeof UMB_SECTION_SIDEBAR_CONTEXT.TYPE;
7372

7473
#parentContext = new UmbParentEntityContext(this);
7574

@@ -172,18 +171,6 @@ export abstract class UmbTreeItemContextBase<
172171
*/
173172
public loadNextItems = (): Promise<void> => this.#treeItemChildrenManager.loadNextChildren();
174173

175-
public toggleContextMenu() {
176-
if (!this.getTreeItem() || !this.entityType || this.unique === undefined) {
177-
throw new Error('Could not request children, tree item is not set');
178-
}
179-
180-
this.#sectionSidebarContext?.toggleContextMenu(this.getHostElement(), {
181-
entityType: this.entityType,
182-
unique: this.unique,
183-
headline: this.getTreeItem()?.name || '',
184-
});
185-
}
186-
187174
/**
188175
* Selects the tree item
189176
* @memberof UmbTreeItemContextBase
@@ -241,10 +228,6 @@ export abstract class UmbTreeItemContextBase<
241228
this.#observeSectionPath();
242229
});
243230

244-
this.consumeContext(UMB_SECTION_SIDEBAR_CONTEXT, (instance) => {
245-
this.#sectionSidebarContext = instance;
246-
});
247-
248231
this.consumeContext(UMB_TREE_CONTEXT, (treeContext) => {
249232
this.treeContext = treeContext;
250233
this.#observeIsSelectable();

src/Umbraco.Web.UI.Client/src/packages/core/tree/tree-item/tree-item-context.interface.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ export interface UmbTreeItemContext<TreeItemType extends UmbTreeItemModel = UmbT
2525
targetPagination: UmbTargetPaginationManager;
2626
getTreeItem(): TreeItemType | undefined;
2727
setTreeItem(treeItem: TreeItemType | undefined): void;
28-
toggleContextMenu(): void;
2928
select(): void;
3029
deselect(): void;
3130
constructPath(pathname: string, entityType: string, unique: string): string;

0 commit comments

Comments
 (0)