name prop for workspace context

This commit is contained in:
Niels Lyngsø
2023-01-10 13:26:01 +01:00
parent f2c70e6c4a
commit 27d37b1c79
2 changed files with 7 additions and 6 deletions

View File

@@ -1,7 +1,6 @@
import { css, html } from 'lit';
import { UUITextStyles } from '@umbraco-ui/uui-css/lib';
import { customElement, state } from 'lit/decorators.js';
import { distinctUntilChanged } from 'rxjs';
import type { UmbWorkspaceContentContext } from '../../workspace-content.context';
import type { DocumentDetails, MediaDetails } from '@umbraco-cms/models';
import { UmbLitElement } from '@umbraco-cms/element';
@@ -36,8 +35,8 @@ export class UmbWorkspaceViewContentInfoElement extends UmbLitElement {
private _observeContent() {
if (!this._workspaceContext) return;
this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (node) => {
this._nodeName = node.name as string;
this.observe(this._workspaceContext.name, (name) => {
this._nodeName = name || '';
});
}

View File

@@ -8,7 +8,7 @@ import { UmbContextConsumerController } from 'src/core/context-api/consume/conte
import { UmbObserverController } from '@umbraco-cms/observable-api';
import { UmbContextProviderController } from 'src/core/context-api/provide/context-provider.controller';
import { EntityTreeItem } from '@umbraco-cms/backend-api';
import { UniqueBehaviorSubject } from 'src/core/observable-api/unique-behavior-subject';
import { CreateObservablePart, UniqueBehaviorSubject } from 'src/core/observable-api/unique-behavior-subject';
// TODO: Consider if its right to have this many class-inheritance of WorkspaceContext
// TODO: Could we extract this code into a 'Manager' of its own, which will be instantiated by the concrete Workspace Context. This will be more transparent and 'reuseable'
@@ -21,8 +21,9 @@ export abstract class UmbWorkspaceContentContext<
// TODO: figure out how fine grained we want to make our observables.
// TODO: add interface
protected _data!:UniqueBehaviorSubject<ContentTypeType>;
public readonly data: Observable<ContentTypeType>;
protected _data;
public readonly data;
public readonly name;
protected _notificationService?: UmbNotificationService;
@@ -45,6 +46,7 @@ export abstract class UmbWorkspaceContentContext<
this._data = new UniqueBehaviorSubject<ContentTypeType>(defaultData);
this.data = this._data.asObservable();
this.name = CreateObservablePart(this._data, data => data.name);
this.entityType = entityType;