From 69a9e783b3177639b3921ba4afa123ad442d1351 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 6 Feb 2023 10:06:24 +0000 Subject: [PATCH 1/9] Add new method to extension registry to get a sorted list of extensions by type and then weight --- .../extensions-api/registry/extension.registry.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/libs/extensions-api/registry/extension.registry.ts b/src/Umbraco.Web.UI.Client/libs/extensions-api/registry/extension.registry.ts index 7e562cb17b..df0e30cca2 100644 --- a/src/Umbraco.Web.UI.Client/libs/extensions-api/registry/extension.registry.ts +++ b/src/Umbraco.Web.UI.Client/libs/extensions-api/registry/extension.registry.ts @@ -80,4 +80,19 @@ export class UmbExtensionRegistry { ) ) as Observable>; } + + extensionsSortedByTypeAndWeight(): Observable> { + return this.extensions.pipe( + map((exts) => exts + .sort((a, b) => { + // If type is the same, sort by weight + if (a.type === b.type) { + return (a.weight || 0) - (b.weight || 0); + } + + // Otherwise sort by type + return a.type.localeCompare(b.type); + })) + ) as Observable>; + } } From 651458186de48faf39dc7aa9423431ae74468a96 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Mon, 6 Feb 2023 10:07:41 +0000 Subject: [PATCH 2/9] Improve the extensions list to be sorted by type & weight along with confirm dialog --- .../extension-root-workspace.element.ts | 37 ++++++++++++++++--- 1 file changed, 32 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts index 26bcf43f2a..c501718527 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts @@ -3,31 +3,53 @@ import { customElement, state } from 'lit/decorators.js'; import { isManifestElementNameType , umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; import type { ManifestBase } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; +import { UMB_MODAL_SERVICE_CONTEXT_TOKEN } from 'src/core/modal/modal.service'; @customElement('umb-extension-root-workspace') export class UmbExtensionRootWorkspaceElement extends UmbLitElement { @state() private _extensions?: Array = undefined; + private _modalService: UmbModalService; + connectedCallback(): void { super.connectedCallback(); this._observeExtensions(); + + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_TOKEN, (modalService) => { + this._modalService = modalService; + }); } private _observeExtensions() { - this.observe(umbExtensionsRegistry.extensions, (extensions) => { + this.observe(umbExtensionsRegistry.extensionsSortedByTypeAndWeight(), (extensions) => { this._extensions = extensions || undefined; }); } + #removeExtension(extension: ManifestBase) { + const modalHandler = this._modalService.confirm({ + headline: 'Unload extension', + confirmLabel: 'Unload', + content: html`

Are you sure you want to unload the extension ${extension.alias}?

`, + color: 'danger' + }); + + modalHandler?.onClose().then(({ confirmed }: any) => { + if (confirmed) { + umbExtensionsRegistry.unregister(extension.alias); + } + }); + } + render() { return html` -

List of currently loaded extensions

Type + Weight Name Alias Actions @@ -37,14 +59,19 @@ export class UmbExtensionRootWorkspaceElement extends UmbLitElement { (extension) => html` ${extension.type} + ${extension.weight ? extension.weight : 'Not Set'} - ${isManifestElementNameType(extension) ? extension.name : 'Custom extension'} + ${isManifestElementNameType(extension) ? extension.name : `[Custom extension] ${extension.name}`} ${extension.alias} umbExtensionsRegistry.unregister(extension.alias)}> + label="Unload" + color="danger" + look="primary" + @click=${() => this.#removeExtension(extension)}> + + ` From 51573ece41af63ebcafdfc00deda943c531e8bae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 11:16:23 +0100 Subject: [PATCH 3/9] use umb-router-slot --- src/Umbraco.Web.UI.Client/src/app.ts | 2 +- .../views/created/created-packages-section-view.element.ts | 2 +- .../installed/installed-packages-section-view.element.ts | 2 +- .../dashboard-examine-management.element.ts | 2 +- .../dashboards/health-check/dashboard-health-check.element.ts | 2 +- .../src/backoffice/shared/collection/collection.element.ts | 2 +- .../section/section-dashboards/section-dashboards.element.ts | 2 +- .../backoffice/shared/components/section/section.element.ts | 2 +- .../user-section/views/users/section-view-users.element.ts | 4 ++-- .../views/users/workspace-view-users-overview.element.ts | 2 +- 10 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/app.ts b/src/Umbraco.Web.UI.Client/src/app.ts index 1b27d767ff..fe282b328e 100644 --- a/src/Umbraco.Web.UI.Client/src/app.ts +++ b/src/Umbraco.Web.UI.Client/src/app.ts @@ -151,7 +151,7 @@ export class UmbApp extends UmbLitElement { } render() { - return html``; + return html``; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/created/created-packages-section-view.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/created/created-packages-section-view.element.ts index be18117d20..24d577c5be 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/created/created-packages-section-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/created/created-packages-section-view.element.ts @@ -54,7 +54,7 @@ export class UmbCreatedPackagesSectionViewElement extends UmbLitElement { } render() { - return html``; + return html``; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/installed-packages-section-view.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/installed-packages-section-view.element.ts index f1b8d80ddc..d9eced75e2 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/installed-packages-section-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/installed-packages-section-view.element.ts @@ -54,7 +54,7 @@ export class UmbInstalledPackagesSectionViewElement extends UmbLitElement { } render() { - return html``; + return html``; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts index 3ad1c32254..bb535df29f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts @@ -67,7 +67,7 @@ export class UmbDashboardExamineManagementElement extends UmbLitElement { return html` ${this.backbutton ? html` ← Back to overview ` : nothing} - `; + `; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/health-check/dashboard-health-check.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/health-check/dashboard-health-check.element.ts index 91fb021085..93ea82a6f0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/health-check/dashboard-health-check.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/health-check/dashboard-health-check.element.ts @@ -76,7 +76,7 @@ export class UmbDashboardHealthCheckElement extends UmbLitElement { } render() { - return html` `; + return html` `; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts index d9a52420ca..81e529e706 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts @@ -103,7 +103,7 @@ export class UmbCollectionElement extends UmbLitElement { return html` - + ${this._selection && this._selection.length > 0 ? html`` : nothing} diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts index 90379166a8..246928fb34 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts @@ -150,7 +150,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { return html` ${this._renderNavigation()} - + `; } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts index b4565ccee2..9f19e4ee06 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts @@ -199,7 +199,7 @@ export class UmbSectionElement extends UmbLitElement { ${this._views && this._views.length > 0 ? html`` : nothing} ${this._routes && this._routes.length > 0 - ? html`` + ? html`` : nothing} diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts index c383ee2e05..2412500318 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts @@ -2,6 +2,7 @@ import { css, html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, state } from 'lit/decorators.js'; import type { IRoute, IRoutingInfo } from 'router-slot'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_TOKEN } from '../../../users/user.store'; import { umbExtensionsRegistry , createExtensionElement } from '@umbraco-cms/extensions-api'; import './list-view-layouts/table/workspace-view-users-table.element'; @@ -9,7 +10,6 @@ import './list-view-layouts/grid/workspace-view-users-grid.element'; import './workspace-view-users-selection.element'; import './workspace-view-users-invite.element'; import type { ManifestWorkspace, UserDetails } from '@umbraco-cms/models'; -import { UmbUserStore, UMB_USER_STORE_CONTEXT_TOKEN } from 'src/backoffice/users/users/user.store'; import { UmbLitElement } from '@umbraco-cms/element'; import { DeepState } from '@umbraco-cms/observable-api'; @@ -128,7 +128,7 @@ export class UmbSectionViewUsersElement extends UmbLitElement { } render() { - return html``; + return html``; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts index 474931b49f..16669f6dad 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts @@ -220,7 +220,7 @@ export class UmbWorkspaceViewUsersOverviewElement extends UmbLitElement { - + ${this._renderSelection()} `; From 279f82ae26b269e8365938e06a41e94d0a2d9396 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 12:57:02 +0100 Subject: [PATCH 4/9] implement router-slot --- .../libs/router/router-slot.element.ts | 7 +++++ src/Umbraco.Web.UI.Client/src/app.ts | 3 +- .../dashboard-examine-management.element.ts | 31 ++++++++----------- 3 files changed, 22 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/libs/router/router-slot.element.ts b/src/Umbraco.Web.UI.Client/libs/router/router-slot.element.ts index 26fbbfd9bb..fa5c50fc39 100644 --- a/src/Umbraco.Web.UI.Client/libs/router/router-slot.element.ts +++ b/src/Umbraco.Web.UI.Client/libs/router/router-slot.element.ts @@ -1,3 +1,4 @@ +import 'router-slot'; import { LitElement, PropertyValueMap } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import { IRoute, RouterSlot } from 'router-slot'; @@ -7,6 +8,8 @@ import { UmbRouterSlotChangeEvent, UmbRouterSlotInitEvent } from '@umbraco-cms/r * @element umb-router-slot-element * @description - Component for wrapping Router Slot element, providing some local events for implementation. * @extends UmbRouterSlotElement + * @fires {UmbRouterSlotInitEvent} init - fires when the media card is selected + * @fires {UmbRouterSlotChangeEvent} change - fires when the media card is unselected */ @customElement('umb-router-slot') export class UmbRouterSlotElement extends LitElement { @@ -38,8 +41,11 @@ export class UmbRouterSlotElement extends LitElement { constructor() { super(); this.#router = document.createElement('router-slot'); + // Note: I decided not to use the local changestate event, because it is not fired when the route is changed from any router-slot. And for now I wanted to keep it local. + //this.#router.addEventListener('changestate', this._onNavigationChanged); } + connectedCallback() { super.connectedCallback(); if (this.#listening === false) { @@ -54,6 +60,7 @@ export class UmbRouterSlotElement extends LitElement { this.#listening = false; } + protected firstUpdated(_changedProperties: PropertyValueMap | Map): void { super.firstUpdated(_changedProperties); this._routerPath = this.#router.constructAbsolutePath('') || ''; diff --git a/src/Umbraco.Web.UI.Client/src/app.ts b/src/Umbraco.Web.UI.Client/src/app.ts index fe282b328e..4d2cd611e0 100644 --- a/src/Umbraco.Web.UI.Client/src/app.ts +++ b/src/Umbraco.Web.UI.Client/src/app.ts @@ -9,7 +9,7 @@ import '@umbraco-ui/uui-modal-container'; import '@umbraco-ui/uui-modal-dialog'; import '@umbraco-ui/uui-modal-sidebar'; import 'element-internals-polyfill'; -import 'router-slot'; +import '@umbraco-cms/router'; import type { Guard, IRoute } from 'router-slot/model'; @@ -17,6 +17,7 @@ import { UUIIconRegistryEssential } from '@umbraco-ui/uui'; import { css, html } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; + import { UmbLitElement } from '@umbraco-cms/element'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; import { OpenAPI, RuntimeLevel, ServerResource } from '@umbraco-cms/backend-api'; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts index bb535df29f..55879ccc21 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts @@ -6,6 +6,7 @@ import { UmbDashboardExamineIndexElement } from './views/section-view-examine-in import { UmbDashboardExamineSearcherElement } from './views/section-view-examine-searchers'; import { UmbLitElement } from '@umbraco-cms/element'; +import { UmbRouterSlotChangeEvent, UmbRouterSlotInitEvent } from '@umbraco-cms/router'; @customElement('umb-dashboard-examine-management') export class UmbDashboardExamineManagementElement extends UmbLitElement { @@ -46,28 +47,22 @@ export class UmbDashboardExamineManagementElement extends UmbLitElement { ]; @state() - private _currentPath?: string; + private _routerPath?: string; + private _activePath?: string; - /** - * - */ - constructor() { - super(); - } - - private _onRouteChange() { - this._currentPath = path(); - } - - private get backbutton(): boolean { - return !(this._currentPath?.endsWith('examine-management/')); - } render() { - return html` ${this.backbutton - ? html` ← Back to overview ` + return html` ${this._activePath !== '' + ? html` ← Back to overview ` : nothing} - `; + { + this._routerPath = event.target.absoluteRouterPath; + }} + @change=${(event: UmbRouterSlotChangeEvent) => { + this._activePath = event.target.localActiveViewPath; + }}>`; } } From c95e3854be09fbd8f7e24695f2b01f909082da76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 13:33:36 +0100 Subject: [PATCH 5/9] implement usage of umb-router-slot --- .../dashboard-examine-management.element.ts | 11 +++++++---- .../backoffice-frame/backoffice-main.element.ts | 15 ++++++++------- 2 files changed, 15 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts index 55879ccc21..b561c18a76 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts @@ -48,20 +48,23 @@ export class UmbDashboardExamineManagementElement extends UmbLitElement { @state() private _routerPath?: string; - private _activePath?: string; + + @state() + private _activePath = ''; render() { - return html` ${this._activePath !== '' - ? html` ← Back to overview ` + return html` ${this._routerPath && this._activePath !== '' + ? html` ← Back to overview ` : nothing} { + console.log("init", event.target.absoluteRouterPath) this._routerPath = event.target.absoluteRouterPath; }} @change=${(event: UmbRouterSlotChangeEvent) => { - this._activePath = event.target.localActiveViewPath; + this._activePath = event.target.localActiveViewPath || ''; }}>`; } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts index e2c04a8cfe..1bc842424b 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts @@ -2,12 +2,12 @@ import { defineElement } from '@umbraco-ui/uui-base/lib/registration'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { state } from 'lit/decorators.js'; -import { IRoutingInfo } from 'router-slot'; import { UmbSectionContext, UMB_SECTION_CONTEXT_TOKEN } from '../section/section.context'; import { UmbBackofficeContext, UMB_BACKOFFICE_CONTEXT_TOKEN } from './backoffice.context'; import type { ManifestSection } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; import { createExtensionElementOrFallback } from '@umbraco-cms/extensions-api'; +import { UmbRouterSlotChangeEvent } from '@umbraco-cms/router'; @defineElement('umb-backoffice-main') export class UmbBackofficeMain extends UmbLitElement { @@ -67,9 +67,6 @@ export class UmbBackofficeMain extends UmbLitElement { return { path: this._routePrefix + section.meta.pathname, component: () => createExtensionElementOrFallback(section, 'umb-section'), - setup: this._onRouteSetup, - // TODO: sometimes we can end up in a state where this callback doesn't get called. It could look like a bug in the router-slot. - // Niels: Could this be because _backofficeContext is not available at that state? }; }); @@ -79,8 +76,8 @@ export class UmbBackofficeMain extends UmbLitElement { }); } - private _onRouteSetup = (_component: HTMLElement, info: IRoutingInfo) => { - const currentPath = info.match.route.path; + private _onRouteChange = (event: UmbRouterSlotChangeEvent) => { + const currentPath = event.target.localActiveViewPath || '' const section = this._sections.find((s) => this._routePrefix + s.meta.pathname === currentPath); if (!section) return; this._backofficeContext?.setActiveSectionAlias(section.alias); @@ -97,7 +94,11 @@ export class UmbBackofficeMain extends UmbLitElement { } render() { - return html``; + return html` + `; } } From b762f0236a8d80cece9ffc235bf23aa7c73cd21d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 13:47:20 +0100 Subject: [PATCH 6/9] implement section --- .../shared/components/section/section.element.ts | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts index 9f19e4ee06..6c63ea29ae 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts @@ -11,6 +11,7 @@ import { UmbLitElement } from '@umbraco-cms/element'; import './section-sidebar-menu/section-sidebar-menu.element.ts'; import './section-views/section-views.element.ts'; +import { UmbRouterSlotChangeEvent } from '@umbraco-cms/router'; @customElement('umb-section') export class UmbSectionElement extends UmbLitElement { @@ -173,9 +174,6 @@ export class UmbSectionElement extends UmbLitElement { return { path: 'view/' + view.meta.pathname, component: () => createExtensionElement(view), - setup: () => { - this._sectionContext?.setActiveView(view); - }, }; }) ?? []; @@ -187,6 +185,13 @@ export class UmbSectionElement extends UmbLitElement { } } + private _onRouteChange = (event: UmbRouterSlotChangeEvent) => { + const currentPath = event.target.localActiveViewPath; + const view = this._views?.find((view) => 'view/' + view.meta.pathname === currentPath); + if (!view) return; + this._sectionContext?.setActiveView(view); + } + render() { return html` ${this._menuItems && this._menuItems.length > 0 @@ -199,7 +204,7 @@ export class UmbSectionElement extends UmbLitElement { ${this._views && this._views.length > 0 ? html`` : nothing} ${this._routes && this._routes.length > 0 - ? html`` + ? html`` : nothing} From 2fb728692e3b6663d3ff367ae83e571d55d4411a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 13:56:02 +0100 Subject: [PATCH 7/9] remove console.log --- .../examine-management/dashboard-examine-management.element.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts index b561c18a76..753b15908f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/dashboard-examine-management.element.ts @@ -60,7 +60,6 @@ export class UmbDashboardExamineManagementElement extends UmbLitElement { { - console.log("init", event.target.absoluteRouterPath) this._routerPath = event.target.absoluteRouterPath; }} @change=${(event: UmbRouterSlotChangeEvent) => { From 06c718d543f92e41ffdd0f7f4ec138a69a894208 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Niels=20Lyngs=C3=B8?= Date: Mon, 6 Feb 2023 13:56:12 +0100 Subject: [PATCH 8/9] implement router-slot for dashboards --- .../section-dashboards.element.ts | 28 +++++++++++-------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts index 246928fb34..ca5442d022 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts @@ -8,6 +8,7 @@ import { createExtensionElement, umbExtensionsRegistry } from '@umbraco-cms/exte import type { ManifestDashboard, ManifestDashboardCollection, ManifestWithMeta } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; +import { UmbRouterSlotChangeEvent, UmbRouterSlotInitEvent } from '@umbraco-cms/router'; @customElement('umb-section-dashboards') export class UmbSectionDashboardsElement extends UmbLitElement { @@ -41,14 +42,14 @@ export class UmbSectionDashboardsElement extends UmbLitElement { @state() private _dashboards?: Array; - @state() - private _currentDashboardPathname = ''; - @state() private _routes: Array = []; @state() - private _currentSectionPathname = ''; + private _routerPath?: string; + + @state() + private _activePath?: string; private _currentSectionAlias?: string; private _sectionContext?: UmbSectionContext; @@ -69,9 +70,6 @@ export class UmbSectionDashboardsElement extends UmbLitElement { this._currentSectionAlias = alias; this._observeDashboards(); }); - this.observe(this._sectionContext.pathname.pipe(first()), (pathname) => { - this._currentSectionPathname = pathname || ''; - }); } private _observeDashboards() { @@ -108,7 +106,6 @@ export class UmbSectionDashboardsElement extends UmbLitElement { return createExtensionElement(dashboard); }, setup: (component: Promise | HTMLElement, info: IRoutingInfo) => { - this._currentDashboardPathname = info.match.route.path; // When its using import, we get an element, when using createExtensionElement we get a Promise. // TODO: this is a bit hacky, can we do it in a more appropriate way: if ((component as any).then) { @@ -135,9 +132,9 @@ export class UmbSectionDashboardsElement extends UmbLitElement { ${this._dashboards.map( (dashboard) => html` + ?active="${dashboard.meta.pathname === this._activePath}"> ` )} @@ -150,7 +147,16 @@ export class UmbSectionDashboardsElement extends UmbLitElement { return html` ${this._renderNavigation()} - + { + this._routerPath = event.target.absoluteRouterPath; + }} + @change=${(event: UmbRouterSlotChangeEvent) => { + this._activePath = event.target.localActiveViewPath; + }} + > `; } From da8aab733b9d6d754796eb4e1c8ebd7451180ff8 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Mon, 6 Feb 2023 15:12:08 +0100 Subject: [PATCH 9/9] fix imports --- .../workspace/extension-root-workspace.element.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts index c501718527..563af4962a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/extensions/workspace/extension-root-workspace.element.ts @@ -1,16 +1,16 @@ import { html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { isManifestElementNameType , umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; +import { isManifestElementNameType, umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; import type { ManifestBase } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; -import { UMB_MODAL_SERVICE_CONTEXT_TOKEN } from 'src/core/modal/modal.service'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/modal'; @customElement('umb-extension-root-workspace') export class UmbExtensionRootWorkspaceElement extends UmbLitElement { @state() private _extensions?: Array = undefined; - private _modalService: UmbModalService; + private _modalService?: UmbModalService; connectedCallback(): void { super.connectedCallback(); @@ -28,11 +28,11 @@ export class UmbExtensionRootWorkspaceElement extends UmbLitElement { } #removeExtension(extension: ManifestBase) { - const modalHandler = this._modalService.confirm({ + const modalHandler = this._modalService?.confirm({ headline: 'Unload extension', confirmLabel: 'Unload', content: html`

Are you sure you want to unload the extension ${extension.alias}?

`, - color: 'danger' + color: 'danger', }); modalHandler?.onClose().then(({ confirmed }: any) => { @@ -40,7 +40,7 @@ export class UmbExtensionRootWorkspaceElement extends UmbLitElement { umbExtensionsRegistry.unregister(extension.alias); } }); - } + } render() { return html`