= data;
@state()
_section?: string;
- @state()
- _currentNodeId?: number;
-
- private _router?: UmbRouter;
- private _location?: UmbRouteLocation;
- private _locationSubscription?: Subscription;
-
- constructor() {
- super();
-
- // TODO: implement correct tree data
- this._tree = data;
-
- this.consumeContext('umbRouter', (router: UmbRouter) => {
- this._router = router;
- this._useLocation();
- });
- }
-
- private _useLocation() {
- this._locationSubscription?.unsubscribe();
-
- this._locationSubscription = this._router?.location.subscribe((location) => {
- this._location = location;
- this._section = location.params.section;
- this._currentNodeId = parseInt(location.params.nodeId);
- });
- }
-
- disconnectedCallback(): void {
- super.disconnectedCallback();
- this._locationSubscription?.unsubscribe();
- }
-
- /* TODO: there are some problems with menu items and click events. They can happen on element inside and outside of the shadow dom
- which makes it difficult to find the right href in the router.
- It might make sense to make it possible to use your own anchor tag or button inside a label slot instead.
- This is a temp solution to get the href from the menu item and overwrite the router hijacking.
- */
- private _handleMenuItemClick(e: PointerEvent) {
- e.preventDefault();
- e.stopPropagation();
-
- const target = e.target as UUIMenuItemElement;
- if (!target) return;
-
- const href = target.href;
- if (!href) return;
-
- this._router?.push(href);
- }
-
render() {
return html`
-
+
Content
-
${this._tree.map(
(item) => html`
+ href="/section/content/node/${item.id}">
`
diff --git a/src/Umbraco.Web.UI.Client/src/core/extension/create-extension-element.function.ts b/src/Umbraco.Web.UI.Client/src/core/extension/create-extension-element.function.ts
index 0db61a8b6e..9d9b2d76bd 100644
--- a/src/Umbraco.Web.UI.Client/src/core/extension/create-extension-element.function.ts
+++ b/src/Umbraco.Web.UI.Client/src/core/extension/create-extension-element.function.ts
@@ -2,16 +2,14 @@ import { UmbExtensionManifest } from './extension.registry';
import { loadExtension } from './load-extension.function';
export function createExtensionElement(manifest: UmbExtensionManifest): Promise | Promise {
-
//TODO: Write tests for these extension options:
return loadExtension(manifest).then((js) => {
-
if (manifest.elementName) {
console.log('-- created by elementName', manifest.elementName);
return document.createElement(manifest.elementName as any);
}
- console.log(js)
+ console.log(js);
if (js) {
if (js instanceof HTMLElement) {
@@ -24,11 +22,11 @@ export function createExtensionElement(manifest: UmbExtensionManifest): Promise<
}
if ((js as any).default) {
console.log('-- created by default class', (js as any).default);
- return new ((js as any).default) as HTMLElement;
+ return new (js as any).default() as HTMLElement;
}
}
console.error('-- Extension did not succeed creating an element');
return Promise.resolve(undefined);
});
-}
\ No newline at end of file
+}
diff --git a/src/Umbraco.Web.UI.Client/src/core/extension/index.ts b/src/Umbraco.Web.UI.Client/src/core/extension/index.ts
index dd24563803..2f96a3abcd 100644
--- a/src/Umbraco.Web.UI.Client/src/core/extension/index.ts
+++ b/src/Umbraco.Web.UI.Client/src/core/extension/index.ts
@@ -1 +1,3 @@
export * from './extension.registry';
+export * from './create-extension-element.function';
+export * from './load-extension.function';
diff --git a/src/Umbraco.Web.UI.Client/src/core/extension/load-extension.function.ts b/src/Umbraco.Web.UI.Client/src/core/extension/load-extension.function.ts
index 39cd523f42..ff834b04cc 100644
--- a/src/Umbraco.Web.UI.Client/src/core/extension/load-extension.function.ts
+++ b/src/Umbraco.Web.UI.Client/src/core/extension/load-extension.function.ts
@@ -1,14 +1,13 @@
import { UmbExtensionManifest } from './extension.registry';
-export function loadExtension(manifest: UmbExtensionManifest): Promise
`;
diff --git a/src/Umbraco.Web.UI.Client/src/section.context.ts b/src/Umbraco.Web.UI.Client/src/section.context.ts
deleted file mode 100644
index d4c669a16c..0000000000
--- a/src/Umbraco.Web.UI.Client/src/section.context.ts
+++ /dev/null
@@ -1,32 +0,0 @@
-import { firstValueFrom, map, ReplaySubject } from 'rxjs';
-
-import { UmbExtensionManifestSection, UmbExtensionRegistry } from './core/extension';
-
-export class UmbSectionContext {
- private _extensionRegistry!: UmbExtensionRegistry;
-
- private _current = new ReplaySubject(1);
- public readonly current = this._current.asObservable();
-
- constructor(_extensionRegistry: UmbExtensionRegistry) {
- this._extensionRegistry = _extensionRegistry;
- }
-
- getSections() {
- return this._extensionRegistry
- .extensionsOfType('section')
- .pipe(map((extensions) => extensions.sort((a, b) => b.meta.weight - a.meta.weight)));
- }
-
- getCurrent() {
- return this.current;
- }
-
- async setCurrent(sectionAlias: string) {
- const sections = await firstValueFrom(this.getSections());
- const matchedSection = sections.find((section) => section.alias === sectionAlias);
- if (matchedSection) {
- this._current.next(matchedSection);
- }
- }
-}