usage of sections

This commit is contained in:
Niels Lyngsø
2023-04-27 10:26:36 +02:00
parent f38252940c
commit 805e7c753d
5 changed files with 5 additions and 13 deletions

View File

@@ -57,7 +57,7 @@ export class UmbBackofficeHeaderSectionsElement extends UmbLitElement {
private _observeSections() {
if (!this._backofficeContext) return;
this.observe(this._backofficeContext.getAllowedSections(), (allowedSections) => {
this.observe(this._backofficeContext.allowedSections, (allowedSections) => {
this._sections = allowedSections;
this._visibleSections = this._sections;
});

View File

@@ -37,7 +37,7 @@ export class UmbBackofficeMainElement extends UmbLitElement {
private async _observeBackoffice() {
if (this._backofficeContext) {
this.observe(
this._backofficeContext.getAllowedSections(),
this._backofficeContext.allowedSections,
(sections) => {
this._sections = sections;
this._createRoutes();

View File

@@ -5,15 +5,7 @@ import { UmbStringState } from '@umbraco-cms/backoffice/observable-api';
export class UmbBackofficeContext {
#activeSectionAlias = new UmbStringState(undefined);
public readonly activeSectionAlias = this.#activeSectionAlias.asObservable();
public getAllowedSections() {
// TODO: implemented allowed filtering based on user, maybe this will be a general need and solved else where so this might not be needed in the end.
/*
const { data } = await getUserSections({});
this._allowedSection = data.sections;
*/
return umbExtensionsRegistry.extensionsOfType('section');
}
public readonly allowedSections = umbExtensionsRegistry.extensionsOfType('section');
public setActiveSectionAlias(alias: string) {
this.#activeSectionAlias.next(alias);

View File

@@ -21,7 +21,7 @@ export class UmbInputPickerSectionElement extends UmbInputListBaseElement {
private _observeSections() {
if (this.value.length > 0) {
umbExtensionsRegistry.extensionsOfType('section').subscribe((sections: Array<ManifestSection>) => {
this.observe(umbExtensionsRegistry.extensionsOfType('section'), (sections: Array<ManifestSection>) => {
this._sections = sections.filter((section) => this.value.includes(section.alias));
});
} else {

View File

@@ -14,7 +14,7 @@ export class UmbSectionPickerModalElement extends UmbModalElementPickerBase<Mani
connectedCallback(): void {
super.connectedCallback();
umbExtensionsRegistry.extensionsOfType('section').subscribe((sections: Array<ManifestSection>) => {
this.observe(umbExtensionsRegistry.extensionsOfType('section'), (sections: Array<ManifestSection>) => {
this._sections = sections;
});
}