rename class
This commit is contained in:
committed by
Jacob Overgaard
parent
3b6161c85b
commit
1ab4230b6b
@@ -1,12 +1,12 @@
|
||||
import { expect } from '@open-wc/testing';
|
||||
|
||||
import { UmbNotificationHandler, UmbNotificationService } from '.';
|
||||
import { UmbNotificationHandler, UmbNotificationContext } from '.';
|
||||
|
||||
describe('UCPNotificationService', () => {
|
||||
let notificationService: UmbNotificationService;
|
||||
let notificationService: UmbNotificationContext;
|
||||
|
||||
beforeEach(async () => {
|
||||
notificationService = new UmbNotificationService();
|
||||
notificationService = new UmbNotificationContext();
|
||||
});
|
||||
|
||||
describe('Public API', () => {
|
||||
|
||||
@@ -18,7 +18,7 @@ export interface UmbNotificationOptions<UmbNotificationData> {
|
||||
|
||||
export type UmbNotificationColor = '' | 'default' | 'positive' | 'warning' | 'danger';
|
||||
|
||||
export class UmbNotificationService {
|
||||
export class UmbNotificationContext {
|
||||
// Notice this cannot use UniqueBehaviorSubject as it holds a HTML Element. which cannot be Serialized to JSON (it has some circular references)
|
||||
private _notifications = new BehaviorSubject(<Array<UmbNotificationHandler>>[]);
|
||||
public readonly notifications = this._notifications.asObservable();
|
||||
@@ -27,7 +27,7 @@ export class UmbNotificationService {
|
||||
* @private
|
||||
* @param {UmbNotificationOptions<UmbNotificationData>} options
|
||||
* @return {*} {UmbNotificationHandler}
|
||||
* @memberof UmbNotificationService
|
||||
* @memberof UmbNotificationContext
|
||||
*/
|
||||
private _open(options: UmbNotificationOptions<UmbNotificationData>): UmbNotificationHandler {
|
||||
const notificationHandler = new UmbNotificationHandler(options);
|
||||
@@ -41,7 +41,7 @@ export class UmbNotificationService {
|
||||
/**
|
||||
* @private
|
||||
* @param {string} key
|
||||
* @memberof UmbNotificationService
|
||||
* @memberof UmbNotificationContext
|
||||
*/
|
||||
private _close(key: string) {
|
||||
this._notifications.next(this._notifications.getValue().filter((notification) => notification.key !== key));
|
||||
@@ -50,7 +50,7 @@ export class UmbNotificationService {
|
||||
/**
|
||||
* @private
|
||||
* @param {string} key
|
||||
* @memberof UmbNotificationService
|
||||
* @memberof UmbNotificationContext
|
||||
*/
|
||||
private _handleClosed(notificationHandler: UmbNotificationHandler) {
|
||||
notificationHandler.element.removeEventListener('closed', () => this._handleClosed(notificationHandler));
|
||||
@@ -62,7 +62,7 @@ export class UmbNotificationService {
|
||||
* @param {UmbNotificationColor} color
|
||||
* @param {UmbNotificationOptions<UmbNotificationData>} options
|
||||
* @return {*}
|
||||
* @memberof UmbNotificationService
|
||||
* @memberof UmbNotificationContext
|
||||
*/
|
||||
public peek(
|
||||
color: UmbNotificationColor,
|
||||
@@ -76,7 +76,7 @@ export class UmbNotificationService {
|
||||
* @param {UmbNotificationColor} color
|
||||
* @param {UmbNotificationOptions<UmbNotificationData>} options
|
||||
* @return {*}
|
||||
* @memberof UmbNotificationService
|
||||
* @memberof UmbNotificationContext
|
||||
*/
|
||||
public stay(
|
||||
color: UmbNotificationColor,
|
||||
@@ -86,6 +86,6 @@ export class UmbNotificationService {
|
||||
}
|
||||
}
|
||||
|
||||
export const UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN = new UmbContextToken<UmbNotificationService>(
|
||||
UmbNotificationService.name
|
||||
export const UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN = new UmbContextToken<UmbNotificationContext>(
|
||||
UmbNotificationContext.name
|
||||
);
|
||||
|
||||
@@ -3,14 +3,14 @@ import '../layouts/default';
|
||||
import { Meta, Story } from '@storybook/web-components';
|
||||
import { html } from 'lit';
|
||||
|
||||
import { UmbNotificationService } from '..';
|
||||
import { UmbNotificationContext } from '..';
|
||||
|
||||
export default {
|
||||
title: 'API/Notifications/Overview',
|
||||
component: 'ucp-notification-layout-default',
|
||||
decorators: [
|
||||
(story) =>
|
||||
html`<umb-context-provider key="umbNotificationService" .value=${new UmbNotificationService()}>
|
||||
html`<umb-context-provider key="umbNotificationService" .value=${new UmbNotificationContext()}>
|
||||
${story()}
|
||||
</umb-context-provider>`,
|
||||
],
|
||||
|
||||
@@ -4,15 +4,14 @@ import { UmbNotificationDefaultData } from '../layouts/default';
|
||||
import {
|
||||
UmbNotificationColor,
|
||||
UmbNotificationOptions,
|
||||
UmbNotificationService,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN
|
||||
UmbNotificationContext,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '..';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
|
||||
|
||||
@customElement('story-notification-default-example')
|
||||
export class StoryNotificationDefaultExampleElement extends UmbLitElement {
|
||||
private _notificationService?: UmbNotificationService;
|
||||
private _notificationService?: UmbNotificationContext;
|
||||
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
/* eslint-disable @typescript-eslint/no-explicit-any */
|
||||
import {
|
||||
UmbNotificationOptions,
|
||||
UmbNotificationService,
|
||||
UmbNotificationContext,
|
||||
UmbNotificationDefaultData,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
@@ -13,7 +13,7 @@ import type { DataSourceResponse } from '@umbraco-cms/models';
|
||||
export class UmbResourceController extends UmbController {
|
||||
#promise: Promise<any>;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface, promise: Promise<any>, alias?: string) {
|
||||
super(host, alias);
|
||||
|
||||
@@ -45,7 +45,7 @@ import {
|
||||
} from './settings/languages/app-language-select/app-language.context';
|
||||
import { UmbPackageStore } from './packages/repository/package.store';
|
||||
import { UmbServerExtensionController } from './packages/repository/server-extension.controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
import { umbExtensionsRegistry } from '@umbraco-cms/extensions-api';
|
||||
|
||||
@@ -84,7 +84,7 @@ export class UmbBackofficeElement extends UmbLitElement {
|
||||
super();
|
||||
|
||||
this.provideContext(UMB_MODAL_SERVICE_CONTEXT_TOKEN, new UmbModalService());
|
||||
this.provideContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, new UmbNotificationService());
|
||||
this.provideContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, new UmbNotificationContext());
|
||||
|
||||
// TODO: find a way this is possible outside this element. It needs to be possible to register stores in extensions
|
||||
this.provideContext(UMB_CURRENT_USER_STORE_CONTEXT_TOKEN, new UmbCurrentUserStore());
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { ProblemDetailsModel, DocumentTypeModel } from '@umbraco-cms/backend-api';
|
||||
import type { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||
import { UmbDetailRepository } from '@umbraco-cms/repository';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
type ItemType = DocumentTypeModel;
|
||||
|
||||
@@ -27,7 +27,7 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe
|
||||
#detailDataSource: UmbDocumentTypeServerDataSource;
|
||||
#detailStore?: UmbDocumentTypeStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { ProblemDetailsModel, DocumentModel } from '@umbraco-cms/backend-api';
|
||||
import type { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||
import { UmbDetailRepository } from '@umbraco-cms/repository';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
type ItemType = DocumentModel;
|
||||
|
||||
@@ -27,7 +27,7 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi
|
||||
#detailDataSource: UmbDocumentServerDataSource;
|
||||
#detailStore?: UmbDocumentStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import type { MediaTypeDetails } from '@umbraco-cms/models';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbTreeRepository, RepositoryTreeDataSource } from '@umbraco-cms/repository';
|
||||
|
||||
export class UmbMediaTypeRepository implements UmbTreeRepository {
|
||||
@@ -20,7 +20,7 @@ export class UmbMediaTypeRepository implements UmbTreeRepository {
|
||||
#detailSource: UmbMediaTypeDetailServerDataSource;
|
||||
#detailStore?: UmbMediaTypeDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -9,7 +9,7 @@ import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import type { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||
import { UmbDetailRepository } from '@umbraco-cms/repository';
|
||||
import type { MediaDetails } from '@umbraco-cms/models';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
type ItemDetailType = MediaDetails;
|
||||
|
||||
@@ -28,7 +28,7 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor
|
||||
#detailDataSource: UmbMediaDetailServerDataSource;
|
||||
#detailStore?: UmbMediaDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -3,7 +3,7 @@ import { UmbMemberGroupDetailServerDataSource } from './sources/member-group.det
|
||||
import { UmbMemberGroupDetailStore, UMB_MEMBER_GROUP_DETAIL_STORE_CONTEXT_TOKEN } from './member-group.detail.store';
|
||||
import { MemberGroupTreeServerDataSource } from './sources/member-group.tree.server.data';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import type { MemberGroupDetails } from '@umbraco-cms/models';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
@@ -21,7 +21,7 @@ export class UmbMemberGroupRepository implements UmbTreeRepository, UmbDetailRep
|
||||
#detailSource: UmbMemberGroupDetailServerDataSource;
|
||||
#detailStore?: UmbMemberGroupDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -6,7 +6,7 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { RepositoryTreeDataSource, UmbDetailRepository, UmbTreeRepository } from '@umbraco-cms/repository';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import type { MemberTypeDetails } from '@umbraco-cms/models';
|
||||
|
||||
// TODO => use correct type when available
|
||||
@@ -23,7 +23,7 @@ export class UmbMemberTypeRepository implements UmbTreeRepository, UmbDetailRepo
|
||||
#detailSource: UmbMemberTypeDetailServerDataSource;
|
||||
#detailStore?: UmbMemberTypeDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UmbMemberTreeStore, UMB_MEMBER_TREE_STORE_CONTEXT_TOKEN } from './member.tree.store';
|
||||
import { MemberTreeServerDataSource } from './sources/member.tree.server.data';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { UmbTreeRepository } from '@umbraco-cms/repository';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
@@ -10,7 +10,7 @@ export class UmbMemberRepository implements UmbTreeRepository {
|
||||
#host: UmbControllerHostInterface;
|
||||
#dataSource: MemberTreeServerDataSource;
|
||||
#treeStore?: UmbMemberTreeStore;
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
#initResolver?: () => void;
|
||||
#initialized = false;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { UmbCultureServerDataSource } from './sources/culture.server.data';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
export class UmbCultureRepository {
|
||||
#init!: Promise<unknown>;
|
||||
@@ -9,7 +9,7 @@ export class UmbCultureRepository {
|
||||
|
||||
#dataSource: UmbCultureServerDataSource;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { ProblemDetailsModel, DataTypeModel } from '@umbraco-cms/backend-api';
|
||||
import type { UmbTreeRepository } from 'libs/repository/tree-repository.interface';
|
||||
import { UmbDetailRepository } from '@umbraco-cms/repository';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
type ItemType = DataTypeModel;
|
||||
|
||||
@@ -27,7 +27,7 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi
|
||||
#detailDataSource: UmbDataTypeServerDataSource;
|
||||
#detailStore?: UmbDataTypeStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -2,7 +2,7 @@ import { UmbLanguageServerDataSource } from './sources/language.server.data';
|
||||
import { UmbLanguageStore, UMB_LANGUAGE_STORE_CONTEXT_TOKEN } from './language.store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { LanguageModel, ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
|
||||
export class UmbLanguageRepository {
|
||||
@@ -13,7 +13,7 @@ export class UmbLanguageRepository {
|
||||
#dataSource: UmbLanguageServerDataSource;
|
||||
#languageStore?: UmbLanguageStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { customElement, state } from 'lit/decorators.js';
|
||||
import { repeat } from 'lit/directives/repeat.js';
|
||||
import {
|
||||
UmbNotificationHandler,
|
||||
UmbNotificationService,
|
||||
UmbNotificationContext,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
@@ -29,7 +29,7 @@ export class UmbBackofficeNotificationContainer extends UmbLitElement {
|
||||
@state()
|
||||
private _notifications?: UmbNotificationHandler[];
|
||||
|
||||
private _notificationService?: UmbNotificationService;
|
||||
private _notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -1,41 +1,37 @@
|
||||
import { v4 as uuidv4 } from 'uuid';
|
||||
import { UmbContextConsumerController, UmbContextToken } from "@umbraco-cms/context-api";
|
||||
import { UmbControllerHostInterface } from "@umbraco-cms/controller";
|
||||
import { UmbNotificationDefaultData, UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from "@umbraco-cms/notification";
|
||||
import { ObjectState, UmbObserverController } from "@umbraco-cms/observable-api";
|
||||
import { UmbContextConsumerController, UmbContextToken } from '@umbraco-cms/context-api';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import {
|
||||
UmbNotificationDefaultData,
|
||||
UmbNotificationContext,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
import { ObjectState, UmbObserverController } from '@umbraco-cms/observable-api';
|
||||
import type { EntityTreeItemModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbEntityDetailStore } from '@umbraco-cms/store';
|
||||
|
||||
|
||||
// Extend entityType base type?, so we are sure to have parentKey?
|
||||
// TODO: switch to use EntityDetailItem ? if we can have such type?
|
||||
export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<EntityDetailsType>, EntityDetailsType extends EntityTreeItemModel = ReturnType<StoreType['getScaffold']>> {
|
||||
|
||||
|
||||
export class UmbEntityWorkspaceManager<
|
||||
StoreType extends UmbEntityDetailStore<EntityDetailsType>,
|
||||
EntityDetailsType extends EntityTreeItemModel = ReturnType<StoreType['getScaffold']>
|
||||
> {
|
||||
private _host;
|
||||
|
||||
state = new ObjectState<EntityDetailsType | undefined>(undefined);
|
||||
|
||||
|
||||
|
||||
protected _storeSubscription?: UmbObserverController;
|
||||
|
||||
private _notificationService?: UmbNotificationService;
|
||||
private _notificationService?: UmbNotificationContext;
|
||||
private _store?: StoreType;
|
||||
|
||||
|
||||
#isNew = false;
|
||||
private _entityType;
|
||||
private _entityKey!: string;
|
||||
|
||||
private _createAtParentKey?: string | null;
|
||||
|
||||
|
||||
constructor(
|
||||
host: UmbControllerHostInterface,
|
||||
entityType:string,
|
||||
storeToken: UmbContextToken<StoreType>
|
||||
) {
|
||||
constructor(host: UmbControllerHostInterface, entityType: string, storeToken: UmbContextToken<StoreType>) {
|
||||
this._host = host;
|
||||
this._entityType = entityType;
|
||||
|
||||
@@ -73,33 +69,32 @@ export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<En
|
||||
|
||||
getEntityType = () => {
|
||||
return this._entityType;
|
||||
}
|
||||
};
|
||||
getEntityKey = (): string => {
|
||||
return this._entityKey;
|
||||
}
|
||||
};
|
||||
|
||||
getStore = () => {
|
||||
return this._store;
|
||||
}
|
||||
};
|
||||
|
||||
getData = () => {
|
||||
return this.state.getValue();
|
||||
}
|
||||
};
|
||||
|
||||
load = (entityKey: string) => {
|
||||
this.#isNew = false;
|
||||
this._entityKey = entityKey;
|
||||
this._observeStore();
|
||||
}
|
||||
};
|
||||
|
||||
create = (parentKey: string | null) => {
|
||||
this.#isNew = true;
|
||||
this._entityKey = uuidv4();
|
||||
this._createAtParentKey = parentKey;
|
||||
}
|
||||
};
|
||||
|
||||
save = (): Promise<void> => {
|
||||
|
||||
if (!this._store) {
|
||||
// TODO: add a more beautiful error:
|
||||
console.error('Could not save cause workspace context has no store.');
|
||||
@@ -107,7 +102,7 @@ export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<En
|
||||
}
|
||||
|
||||
const documentData = this.getData();
|
||||
if(!documentData) {
|
||||
if (!documentData) {
|
||||
console.error('Could not save cause workspace context has no data.');
|
||||
return Promise.resolve();
|
||||
}
|
||||
@@ -122,12 +117,9 @@ export class UmbEntityWorkspaceManager<StoreType extends UmbEntityDetailStore<En
|
||||
const data: UmbNotificationDefaultData = { message: 'Failed to save Document' };
|
||||
this._notificationService?.peek('danger', { data });
|
||||
});
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
public destroy = (): void => {
|
||||
this.state.unsubscribe();
|
||||
}
|
||||
|
||||
|
||||
};
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ import { customElement, property } from 'lit/decorators.js';
|
||||
import type { UmbPropertyAction } from '../shared/property-action/property-action.model';
|
||||
import {
|
||||
UmbNotificationDefaultData,
|
||||
UmbNotificationService,
|
||||
UmbNotificationContext,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
import { UmbLitElement } from '@umbraco-cms/element';
|
||||
@@ -13,7 +13,7 @@ export class UmbPropertyActionCopyElement extends UmbLitElement implements UmbPr
|
||||
@property()
|
||||
value = '';
|
||||
|
||||
private _notificationService?: UmbNotificationService;
|
||||
private _notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor() {
|
||||
super();
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from '../workspace/data/template.detail.store';
|
||||
import { UmbTemplateTreeStore, UMB_TEMPLATE_TREE_STORE_CONTEXT_TOKEN } from '../tree/data/template.tree.store';
|
||||
import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { ProblemDetailsModel, TemplateModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbDetailRepository } from 'libs/repository/detail-repository.interface';
|
||||
@@ -26,7 +26,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi
|
||||
#treeStore?: UmbTemplateTreeStore;
|
||||
#detailStore?: UmbTemplateDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -4,7 +4,7 @@ import { UmbTemplateDetailServerDataSource } from './sources/template.detail.ser
|
||||
import type { ProblemDetailsModel, TemplateModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import type { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
|
||||
// Move to documentation / JSdoc
|
||||
/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */
|
||||
@@ -15,7 +15,7 @@ export class UmbTemplateDetailRepository {
|
||||
#dataSource: UmbTemplateDetailServerDataSource;
|
||||
#detailStore?: UmbTemplateDetailStore;
|
||||
#treeStore?: UmbTemplateTreeStore;
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
#initResolver?: () => void;
|
||||
#initialized = false;
|
||||
|
||||
|
||||
@@ -6,7 +6,7 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller';
|
||||
import { UmbContextConsumerController } from '@umbraco-cms/context-api';
|
||||
import { RepositoryTreeDataSource, UmbDetailRepository, UmbTreeRepository } from '@umbraco-cms/repository';
|
||||
import { ProblemDetailsModel } from '@umbraco-cms/backend-api';
|
||||
import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification';
|
||||
import type { DictionaryDetails } from '@umbraco-cms/models';
|
||||
|
||||
export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepository<DictionaryDetails> {
|
||||
@@ -20,7 +20,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo
|
||||
#detailSource: UmbDictionaryDetailServerDataSource;
|
||||
#detailStore?: UmbDictionaryDetailStore;
|
||||
|
||||
#notificationService?: UmbNotificationService;
|
||||
#notificationService?: UmbNotificationContext;
|
||||
|
||||
constructor(host: UmbControllerHostInterface) {
|
||||
this.#host = host;
|
||||
|
||||
@@ -8,7 +8,7 @@ import { UmbUserStore, UMB_USER_STORE_CONTEXT_TOKEN } from '../../../users/user.
|
||||
import type { UserDetails } from '@umbraco-cms/models';
|
||||
import {
|
||||
UmbNotificationDefaultData,
|
||||
UmbNotificationService,
|
||||
UmbNotificationContext,
|
||||
UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN,
|
||||
} from '@umbraco-cms/notification';
|
||||
|
||||
@@ -61,7 +61,7 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement {
|
||||
private _createdUser?: UserDetails;
|
||||
|
||||
protected _userStore?: UmbUserStore;
|
||||
private _notificationService?: UmbNotificationService;
|
||||
private _notificationService?: UmbNotificationContext;
|
||||
|
||||
connectedCallback(): void {
|
||||
super.connectedCallback();
|
||||
|
||||
Reference in New Issue
Block a user