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 bc1d2db112..9d24e132ab 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 @@ -11,6 +11,7 @@ import { loadExtension } from '../load-extension.function'; import { hasInitExport } from '../has-init-export.function'; import type { UmbControllerHostInterface } from '@umbraco-cms/controller'; import { UmbContextToken } from '@umbraco-cms/context-api'; +import { createObservablePart } from '@umbraco-cms/observable-api'; export class UmbExtensionRegistry { // TODO: Use UniqueBehaviorSubject, as we don't want someone to edit data of extensions. @@ -147,27 +148,6 @@ export class UmbExtensionRegistry { // // TODO: DisctinctUntilChanged by using aliases? } - - // TODO: consider ust having the a.type.localeCompare(b.type); in the extension view, to then be able to use other existing observables? - /** - * Gets all the extensions registrations, but does not merge with kinds. - * @returns - */ - extensionRegistrationsSortedByTypeAndWeight(): 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 (b.weight || 0) - (a.weight || 0); - } - - // Otherwise sort by type - return a.type.localeCompare(b.type); - }) - ) - ) as Observable>; - } } export const UMB_EXTENSION_REGISTRY_TOKEN = new UmbContextToken('UmbExtensionRegistry'); 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 f401899358..218da0a48f 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,5 +1,6 @@ import { html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; +import { map } from 'rxjs'; import { UMB_CONFIRM_MODAL_TOKEN } from '../../../shared/modals/confirm'; import { isManifestElementNameType, umbExtensionsRegistry } from '@umbraco-cms/extensions-api'; import type { ManifestBase } from '@umbraco-cms/models'; @@ -23,9 +24,23 @@ export class UmbExtensionRootWorkspaceElement extends UmbLitElement { } private _observeExtensions() { - this.observe(umbExtensionsRegistry.extensionRegistrationsSortedByTypeAndWeight(), (extensions) => { - this._extensions = extensions || undefined; - }); + this.observe( + umbExtensionsRegistry.extensions.pipe( + map((exts) => + exts.sort((a, b) => { + // If type is the same, sort by weight + if (a.type === b.type) { + return (b.weight || 0) - (a.weight || 0); + } + // Otherwise sort by type + return a.type.localeCompare(b.type); + }) + ) + ), + (extensions) => { + this._extensions = extensions || undefined; + } + ); } async #removeExtension(extension: ManifestBase) {