clean up context

This commit is contained in:
Niels Lyngsø
2023-12-05 11:01:17 +01:00
parent b384b66364
commit 0ac48ab936
3 changed files with 1 additions and 58 deletions

View File

@@ -1,2 +1 @@
export * from './property-action-menu.context.js'
export * from './property-action-menu.element.js'
export * from './property-action-menu.element.js';

View File

@@ -1,23 +0,0 @@
import { type UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api';
import { UmbBaseController } from '@umbraco-cms/backoffice/class-api';
import { UmbBooleanState } from '@umbraco-cms/backoffice/observable-api';
export class UmbPropertyActionMenuContext extends UmbBaseController {
#isOpen = new UmbBooleanState(false);
public readonly isOpen = this.#isOpen.asObservable();
constructor(host: UmbControllerHostElement) {
super(host);
this.provideContext('umbPropertyActionMenu', this);
}
toggle() {
this.#isOpen.next(!this.#isOpen.getValue());
}
open() {
this.#isOpen.next(true);
}
close() {
this.#isOpen.next(false);
}
}

View File

@@ -1,4 +1,3 @@
import { UmbPropertyActionMenuContext } from './property-action-menu.context.js';
import {
css,
CSSResultGroup,
@@ -50,37 +49,6 @@ export class UmbPropertyActionMenuElement extends UmbLitElement {
@state()
private _actions: Array<UmbExtensionElementInitializer<ManifestPropertyAction, any>> = [];
@state()
private _open = false; //TODO: Is this still needed? now that we don't use the old popover anymore?
//TODO: What is this context used for?
//TODO: Is this still needed? now that we don't use the old popover anymore?
private _propertyActionMenuContext = new UmbPropertyActionMenuContext(this);
constructor() {
super();
this.observe(this._propertyActionMenuContext.isOpen, (isOpen) => {
this._open = isOpen;
});
this.addEventListener('close', (e) => {
this._propertyActionMenuContext.close();
e.stopPropagation();
});
}
private _toggleMenu() {
//TODO: Is this still needed? now that we don't use the old popover anymore?
this._propertyActionMenuContext.toggle();
}
private _handleClose(event: CustomEvent) {
//TODO: Is this still needed? now that we don't use the old popover anymore?
this._propertyActionMenuContext.close();
event.stopPropagation();
}
render() {
return this._actions.length > 0
? html`
@@ -89,7 +57,6 @@ export class UmbPropertyActionMenuElement extends UmbLitElement {
popovertarget="property-action-popover"
look="secondary"
label="More"
@click="${this._toggleMenu}"
compact>
<uui-symbol-more id="more-symbol"></uui-symbol-more>
</uui-button>