From 71c60eaa5908f77ab6e83a09bba702788c18f2e2 Mon Sep 17 00:00:00 2001 From: Mads Rasmussen Date: Wed, 1 Mar 2023 18:07:14 +0100 Subject: [PATCH] rename notication service to notification context --- .../notification/notification.context.test.ts | 16 +++--- .../libs/notification/notification.context.ts | 4 +- .../notification/stories/notification.mdx | 52 +++++++++---------- .../stories/notification.stories.ts | 4 +- ...ry-notification-default-example.element.ts | 10 ++-- .../libs/resources/resource.controller.ts | 12 ++--- .../src/backoffice/backoffice.element.ts | 4 +- .../repository/document-type.repository.ts | 14 ++--- .../repository/document.repository.ts | 14 ++--- .../repository/media-type.repository.ts | 12 ++--- .../media/repository/media.repository.ts | 14 ++--- .../repository/member-group.repository.ts | 14 ++--- .../repository/member-type.repository.ts | 14 ++--- .../members/repository/member.repository.ts | 10 ++-- .../cultures/repository/culture.repository.ts | 8 +-- .../repository/data-type.repository.ts | 14 ++--- .../repository/language.repository.ts | 14 ++--- ...ckoffice-notification-container.element.ts | 12 ++--- .../entity-manager-controller.ts | 12 ++--- .../copy/property-action-copy.element.ts | 10 ++-- .../repository/template.repository.ts | 14 ++--- .../data/template.detail.repository.ts | 16 +++--- .../repository/dictionary.repository.ts | 12 ++--- .../workspace-view-users-create.element.ts | 10 ++-- 24 files changed, 157 insertions(+), 159 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/libs/notification/notification.context.test.ts b/src/Umbraco.Web.UI.Client/libs/notification/notification.context.test.ts index 9dd850f5f1..6d0f32b897 100644 --- a/src/Umbraco.Web.UI.Client/libs/notification/notification.context.test.ts +++ b/src/Umbraco.Web.UI.Client/libs/notification/notification.context.test.ts @@ -2,27 +2,27 @@ import { expect } from '@open-wc/testing'; import { UmbNotificationHandler, UmbNotificationContext } from '.'; -describe('UCPNotificationService', () => { - let notificationService: UmbNotificationContext; +describe('UmbNotificationContext', () => { + let notificationContext: UmbNotificationContext; beforeEach(async () => { - notificationService = new UmbNotificationContext(); + notificationContext = new UmbNotificationContext(); }); describe('Public API', () => { describe('properties', () => { it('has a dialog property', () => { - expect(notificationService).to.have.property('notifications'); + expect(notificationContext).to.have.property('notifications'); }); }); describe('methods', () => { it('has a peek method', () => { - expect(notificationService).to.have.property('peek').that.is.a('function'); + expect(notificationContext).to.have.property('peek').that.is.a('function'); }); it('has a stay method', () => { - expect(notificationService).to.have.property('stay').that.is.a('function'); + expect(notificationContext).to.have.property('stay').that.is.a('function'); }); }); }); @@ -36,7 +36,7 @@ describe('UCPNotificationService', () => { data: { headline: 'Peek notification headline', message: 'Peek notification message' }, }; - peekNotificationHandler = notificationService.peek('positive', peekOptions); + peekNotificationHandler = notificationContext.peek('positive', peekOptions); layoutElement = peekNotificationHandler.element.querySelector('umb-notification-layout-default'); }); @@ -64,7 +64,7 @@ describe('UCPNotificationService', () => { data: { headline: 'Stay notification headline', message: 'Stay notification message' }, }; - stayNotificationHandler = notificationService.stay('danger', stayOptions); + stayNotificationHandler = notificationContext.stay('danger', stayOptions); layoutElement = stayNotificationHandler.element.querySelector('umb-notification-layout-default'); }); diff --git a/src/Umbraco.Web.UI.Client/libs/notification/notification.context.ts b/src/Umbraco.Web.UI.Client/libs/notification/notification.context.ts index 95b3822bdb..785aa93ad4 100644 --- a/src/Umbraco.Web.UI.Client/libs/notification/notification.context.ts +++ b/src/Umbraco.Web.UI.Client/libs/notification/notification.context.ts @@ -86,6 +86,4 @@ export class UmbNotificationContext { } } -export const UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN = new UmbContextToken( - UmbNotificationContext.name -); +export const UMB_NOTIFICATION_CONTEXT_TOKEN = new UmbContextToken(UmbNotificationContext.name); diff --git a/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.mdx b/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.mdx index 9543ac4b32..5d60846fc4 100644 --- a/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.mdx +++ b/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.mdx @@ -14,24 +14,24 @@ Stays on the screen until dismissed by the user or custom code. Stay notificatio ## Basic usage -### Consume UmbNotificationService from an element +### Consume UmbNotificationContext from an element -The UmbNotification service can be used to open notifications. +The UmbNotification context can be used to open notifications. ```typescript import { html, LitElement } from 'lit'; import { UmbLitElement } from '@umbraco-cms/element'; -import type { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from './core/services/notification'; +import type { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_ALIAS } from '@umbraco-cms/notification'; class MyElement extends UmbLitElement { - private _notificationService?: UmbNotificationService; + private _notificationContext?: UmbNotificationContext; constructor() { super(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { - this._notificationService = notificationService; - // notificationService is now ready to be used + this.consumeContext(UMB_NOTIFICATION_CONTEXT_ALIAS, (instance) => { + this._notificationContext = notificationContext; + // notificationContext is now ready to be used }); } } @@ -39,33 +39,33 @@ class MyElement extends UmbLitElement { ### Open a notification -A notification is opened by calling one of the helper methods on the UmbNotificationService. The methods will return an instance of UmbNotificationHandler. +A notification is opened by calling one of the helper methods on the UmbNotificationContext. The methods will return an instance of UmbNotificationHandler. ```typescript import { html, LitElement } from 'lit'; import { state } from 'lit/decorators.js'; import { UmbLitElement } from '@umbraco-cms/element'; import type { - UmbNotificationService, + UmbNotificationContext, UmbNotificationDefaultData, - UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, -} from './core/services/notification'; + UMB_NOTIFICATION_CONTEXT_ALIAS, +} from '@umbraco-cms/notification'; class MyElement extends UmbLitElement { - private _notificationService?: UmbNotificationService; + private _notificationContext?: UmbNotificationContext; constructor() { super(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { - this._notificationService = notificationService; - // notificationService is now ready to be used + this.consumeContext(UMB_NOTIFICATION_CONTEXT_ALIAS, (notificationContext) => { + this._notificationContext = notificationContext; + // notificationContext is now ready to be used }); } private _handleClick() { const data: UmbNotificationDefaultData = { headline: 'Look at this', message: 'Something good happened' }; - const notificationHandler = this._notificationService?.peek('positive', { data }); + const notificationHandler = this._notificationContext?.peek('positive', { data }); notificationHandler.onClose().then(() => { // if you need any logic when the notification is closed you can run it here @@ -88,7 +88,7 @@ The default layout will cover most cases, but there might be situations where we import { html, LitElement } from 'lit'; import { property } from 'lit/decorators.js'; import { UUITextStyles } from '@umbraco-ui/uui-css'; -import type { UmbNotificationHandler } from './core/services/notification'; +import type { UmbNotificationHandler } from '@umbraco-cms/notification'; export interface UmbNotificationCustomData { headline: string; @@ -127,21 +127,21 @@ export class UmbNotificationLayoutCustom extends LitElement { import { html, LitElement } from 'lit'; import { UmbContextInjectMixin } from '@umbraco-cms/context-api'; import type { - UmbNotificationService, + UmbNotificationContext, UmbNotificationOptions, - UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, -} from './core/services/notification'; + UMB_NOTIFICATION_CONTEXT_ALIAS, +} from '@umbraco-cms/notification'; import type { UmbNotificationCustomData } from './custom-notification-layout'; class MyElement extends LitElement { - private _notificationService?: UmbNotificationService; + private _notificationContext?: UmbNotificationContext; constructor() { super(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { - this._notificationService = notificationService; - // notificationService is now ready to be used + this.consumeContext(UMB_NOTIFICATION_CONTEXT_ALIAS, (instance) => { + this._notificationContext = instance; + // notificationContext is now ready to be used }); } @@ -154,7 +154,7 @@ class MyElement extends LitElement { }, }; - const notificationHandler = this._notificationService?.stay('default', options); + const notificationHandler = this._notificationContext?.stay('default', options); notificationHandler.onClose().then((result) => { if (result) { @@ -174,4 +174,4 @@ class MyElement extends LitElement { - Keep messages in notifications short and friendly. - Only use headlines when you need extra attention to the notification - If a custom notification layout is only used in one module keep the files layout files local to that module. -- If a custom notification will be used across the project. Create it as a layout in the notification folder and add a helper method to the UmbNotificationService. +- If a custom notification will be used across the project. Create it as a layout in the notification folder and add a helper method to the UmbNotificationContext. diff --git a/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.stories.ts b/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.stories.ts index 87556cde8d..16872f9f7d 100644 --- a/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.stories.ts +++ b/src/Umbraco.Web.UI.Client/libs/notification/stories/notification.stories.ts @@ -10,7 +10,7 @@ export default { component: 'ucp-notification-layout-default', decorators: [ (story) => - html` + html` ${story()} `, ], @@ -31,7 +31,7 @@ const options: UmbNotificationOptions = { } }; -this._notificationService?.peek('positive', options); +this._notificationContext?.peek('positive', options); `, }, }, diff --git a/src/Umbraco.Web.UI.Client/libs/notification/stories/story-notification-default-example.element.ts b/src/Umbraco.Web.UI.Client/libs/notification/stories/story-notification-default-example.element.ts index b208fcc921..4b965c60f2 100644 --- a/src/Umbraco.Web.UI.Client/libs/notification/stories/story-notification-default-example.element.ts +++ b/src/Umbraco.Web.UI.Client/libs/notification/stories/story-notification-default-example.element.ts @@ -5,19 +5,19 @@ import { UmbNotificationColor, UmbNotificationOptions, UmbNotificationContext, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_CONTEXT_TOKEN, } from '..'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('story-notification-default-example') export class StoryNotificationDefaultExampleElement extends UmbLitElement { - private _notificationService?: UmbNotificationContext; + private _notificationContext?: UmbNotificationContext; connectedCallback(): void { super.connectedCallback(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (notificationService) => { - this._notificationService = notificationService; + this.consumeContext(UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this._notificationContext = instance; }); } @@ -28,7 +28,7 @@ export class StoryNotificationDefaultExampleElement extends UmbLitElement { message: 'Lorem ipsum dolor sit amet, consectetur adipiscing elit', }, }; - this._notificationService?.peek(color, options); + this._notificationContext?.peek(color, options); }; render() { diff --git a/src/Umbraco.Web.UI.Client/libs/resources/resource.controller.ts b/src/Umbraco.Web.UI.Client/libs/resources/resource.controller.ts index f1f8d138ba..d0ac8ed130 100644 --- a/src/Umbraco.Web.UI.Client/libs/resources/resource.controller.ts +++ b/src/Umbraco.Web.UI.Client/libs/resources/resource.controller.ts @@ -3,7 +3,7 @@ import { UmbNotificationOptions, UmbNotificationContext, UmbNotificationDefaultData, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_CONTEXT_TOKEN, } from '@umbraco-cms/notification'; import { ApiError, CancelablePromise, ProblemDetailsModel } from '@umbraco-cms/backend-api'; import { UmbController, UmbControllerHostInterface } from '@umbraco-cms/controller'; @@ -13,15 +13,15 @@ import type { DataSourceResponse } from '@umbraco-cms/models'; export class UmbResourceController extends UmbController { #promise: Promise; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface, promise: Promise, alias?: string) { super(host, alias); this.#promise = promise; - new UmbContextConsumerController(host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (_instance) => { - this.#notificationService = _instance; + new UmbContextConsumerController(host, UMB_NOTIFICATION_CONTEXT_TOKEN, (_instance) => { + this.#notificationContext = _instance; }); } @@ -76,8 +76,8 @@ export class UmbResourceController extends UmbController { message: error.detail ?? 'Something went wrong', }; - if (this.#notificationService) { - this.#notificationService?.peek('danger', { data, ...options }); + if (this.#notificationContext) { + this.#notificationContext?.peek('danger', { data, ...options }); } else { console.group('UmbResourceController'); console.error(error); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts index b23a7bf3af..636c5dcb5a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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 UmbNotificationContext()); + this.provideContext(UMB_NOTIFICATION_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()); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/repository/document-type.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/repository/document-type.repository.ts index bb0cf6517f..683880d36e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/repository/document-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/repository/document-type.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; type ItemType = DocumentTypeModel; @@ -27,7 +27,7 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe #detailDataSource: UmbDocumentTypeServerDataSource; #detailStore?: UmbDocumentTypeStore; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -45,8 +45,8 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe this.#detailStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -159,7 +159,7 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe if (!error) { const notification = { data: { message: `Document created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -181,7 +181,7 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe if (!error) { const notification = { data: { message: `Document saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -207,7 +207,7 @@ export class UmbDocumentTypeRepository implements UmbTreeRepository, UmbDetailRe if (!error) { const notification = { data: { message: `Document deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/repository/document.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/repository/document.repository.ts index d20caf2f14..42b9f407c9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/repository/document.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/repository/document.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; type ItemType = DocumentModel; @@ -27,7 +27,7 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi #detailDataSource: UmbDocumentServerDataSource; #detailStore?: UmbDocumentStore; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -45,8 +45,8 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi this.#detailStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -154,7 +154,7 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -176,7 +176,7 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -202,7 +202,7 @@ export class UmbDocumentRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/repository/media-type.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/repository/media-type.repository.ts index 3dc3adde0b..1ded02b0fe 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/repository/media-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/repository/media-type.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -38,8 +38,8 @@ export class UmbMediaTypeRepository implements UmbTreeRepository { this.#treeStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -144,7 +144,7 @@ export class UmbMediaTypeRepository implements UmbTreeRepository { if (!error) { const notification = { data: { message: `Media type '${mediaType.name}' saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -169,7 +169,7 @@ export class UmbMediaTypeRepository implements UmbTreeRepository { if (!error) { const notification = { data: { message: `Media type '${mediaType.name}' created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { data, error }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/repository/media.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/repository/media.repository.ts index e31c97110a..c5fd5107e7 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/repository/media.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/repository/media.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; type ItemDetailType = MediaDetails; @@ -28,7 +28,7 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor #detailDataSource: UmbMediaDetailServerDataSource; #detailStore?: UmbMediaDetailStore; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -46,8 +46,8 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor this.#detailStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -152,7 +152,7 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor if (!error) { const notification = { data: { message: `Media created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -174,7 +174,7 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor if (!error) { const notification = { data: { message: `Document saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -200,7 +200,7 @@ export class UmbMediaRepository implements UmbTreeRepository, UmbDetailRepositor if (!error) { const notification = { data: { message: `Document deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/repository/member-group.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/repository/member-group.repository.ts index 805b9f2b06..80e323c25e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/repository/member-group.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/repository/member-group.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -37,8 +37,8 @@ export class UmbMemberGroupRepository implements UmbTreeRepository, UmbDetailRep this.#detailStore = instance; }); - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }); } @@ -123,7 +123,7 @@ export class UmbMemberGroupRepository implements UmbTreeRepository, UmbDetailRep if (!error) { const notification = { data: { message: `Member group '${detail.name}' created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { data, error }; @@ -141,7 +141,7 @@ export class UmbMemberGroupRepository implements UmbTreeRepository, UmbDetailRep if (!error) { const notification = { data: { message: `Member group '${memberGroup.name} saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } this.#detailStore?.append(memberGroup); @@ -162,7 +162,7 @@ export class UmbMemberGroupRepository implements UmbTreeRepository, UmbDetailRep if (!error) { const notification = { data: { message: `Document deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/repository/member-type.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/repository/member-type.repository.ts index 0fb69656e0..ec294e6ee6 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/repository/member-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/repository/member-type.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -41,8 +41,8 @@ export class UmbMemberTypeRepository implements UmbTreeRepository, UmbDetailRepo this.#treeStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -140,7 +140,7 @@ export class UmbMemberTypeRepository implements UmbTreeRepository, UmbDetailRepo if (!error) { const notification = { data: { message: `Member type deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -167,7 +167,7 @@ export class UmbMemberTypeRepository implements UmbTreeRepository, UmbDetailRepo if (!error) { const notification = { data: { message: `Member type '${detail.name}' saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -192,7 +192,7 @@ export class UmbMemberTypeRepository implements UmbTreeRepository, UmbDetailRepo if (!error) { const notification = { data: { message: `Member type '${detail.name}' created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { data, error }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/members/repository/member.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/members/repository/member.repository.ts index 1518857860..db2744a5ed 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/members/repository/member.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/members/repository/member.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; #initResolver?: () => void; #initialized = false; @@ -24,8 +24,8 @@ export class UmbMemberRepository implements UmbTreeRepository { this.#checkIfInitialized(); }); - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; this.#checkIfInitialized(); }); } @@ -35,7 +35,7 @@ export class UmbMemberRepository implements UmbTreeRepository { }); #checkIfInitialized() { - if (this.#treeStore && this.#notificationService) { + if (this.#treeStore && this.#notificationContext) { this.#initialized = true; this.#initResolver?.(); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/cultures/repository/culture.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/cultures/repository/culture.repository.ts index b0ce3dec34..8e68ea40b5 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/cultures/repository/culture.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/cultures/repository/culture.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; export class UmbCultureRepository { #init!: Promise; @@ -9,7 +9,7 @@ export class UmbCultureRepository { #dataSource: UmbCultureServerDataSource; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -17,8 +17,8 @@ export class UmbCultureRepository { this.#dataSource = new UmbCultureServerDataSource(this.#host); this.#init = Promise.all([ - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/repository/data-type.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/repository/data-type.repository.ts index cf3593ef05..e440812256 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/repository/data-type.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/repository/data-type.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; type ItemType = DataTypeModel; @@ -27,7 +27,7 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi #detailDataSource: UmbDataTypeServerDataSource; #detailStore?: UmbDataTypeStore; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -45,8 +45,8 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi this.#detailStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -159,7 +159,7 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -181,7 +181,7 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -207,7 +207,7 @@ export class UmbDataTypeRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Document deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/repository/language.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/repository/language.repository.ts index 44673f1781..07d8b00a97 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/repository/language.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/repository/language.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -21,8 +21,8 @@ export class UmbLanguageRepository { this.#dataSource = new UmbLanguageServerDataSource(this.#host); this.#init = Promise.all([ - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), new UmbContextConsumerController(this.#host, UMB_LANGUAGE_STORE_CONTEXT_TOKEN, (instance) => { @@ -92,7 +92,7 @@ export class UmbLanguageRepository { if (!error) { this.#languageStore?.append(language); const notification = { data: { message: `Language created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { error }; @@ -111,7 +111,7 @@ export class UmbLanguageRepository { if (!error) { const notification = { data: { message: `Language saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); this.#languageStore?.append(language); } @@ -137,7 +137,7 @@ export class UmbLanguageRepository { if (!error) { this.#languageStore?.remove([isoCode]); const notification = { data: { message: `Language deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { error }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-notification-container.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-notification-container.element.ts index 7a3d44f0a0..eb5268301e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-notification-container.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-notification-container.element.ts @@ -5,7 +5,7 @@ import { repeat } from 'lit/directives/repeat.js'; import { UmbNotificationHandler, UmbNotificationContext, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_CONTEXT_TOKEN, } from '@umbraco-cms/notification'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -29,21 +29,21 @@ export class UmbBackofficeNotificationContainer extends UmbLitElement { @state() private _notifications?: UmbNotificationHandler[]; - private _notificationService?: UmbNotificationContext; + private _notificationContext?: UmbNotificationContext; constructor() { super(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (notificationService) => { - this._notificationService = notificationService; + this.consumeContext(UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this._notificationContext = instance; this._observeNotifications(); }); } private _observeNotifications() { - if (!this._notificationService) return; + if (!this._notificationContext) return; - this.observe(this._notificationService.notifications, (notifications) => { + this.observe(this._notificationContext.notifications, (notifications) => { this._notifications = notifications; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/entity-manager-controller.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/entity-manager-controller.ts index d37bb44918..62c920a95a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/entity-manager-controller.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-context/entity-manager-controller.ts @@ -4,7 +4,7 @@ import { UmbControllerHostInterface } from '@umbraco-cms/controller'; import { UmbNotificationDefaultData, UmbNotificationContext, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_CONTEXT_TOKEN, } from '@umbraco-cms/notification'; import { ObjectState, UmbObserverController } from '@umbraco-cms/observable-api'; import type { EntityTreeItemModel } from '@umbraco-cms/backend-api'; @@ -22,7 +22,7 @@ export class UmbEntityWorkspaceManager< protected _storeSubscription?: UmbObserverController; - private _notificationService?: UmbNotificationContext; + private _notificationContext?: UmbNotificationContext; private _store?: StoreType; #isNew = false; @@ -35,8 +35,8 @@ export class UmbEntityWorkspaceManager< this._host = host; this._entityType = entityType; - new UmbContextConsumerController(this._host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (_instance) => { - this._notificationService = _instance; + new UmbContextConsumerController(this._host, UMB_NOTIFICATION_CONTEXT_TOKEN, (_instance) => { + this._notificationContext = _instance; }); // Create controller holding Token? @@ -111,11 +111,11 @@ export class UmbEntityWorkspaceManager< .save([documentData]) .then(() => { const data: UmbNotificationDefaultData = { message: 'Document Saved' }; - this._notificationService?.peek('positive', { data }); + this._notificationContext?.peek('positive', { data }); }) .catch(() => { const data: UmbNotificationDefaultData = { message: 'Failed to save Document' }; - this._notificationService?.peek('danger', { data }); + this._notificationContext?.peek('danger', { data }); }); }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/copy/property-action-copy.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/copy/property-action-copy.element.ts index 6f328015c9..874c535eaf 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/copy/property-action-copy.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-actions/copy/property-action-copy.element.ts @@ -4,7 +4,7 @@ import type { UmbPropertyAction } from '../shared/property-action/property-actio import { UmbNotificationDefaultData, UmbNotificationContext, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_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?: UmbNotificationContext; + private _notificationContext?: UmbNotificationContext; constructor() { super(); @@ -23,14 +23,14 @@ export class UmbPropertyActionCopyElement extends UmbLitElement implements UmbPr console.log('PROPERTY', property); }); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (notificationService) => { - this._notificationService = notificationService; + this.consumeContext(UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this._notificationContext = instance; }); } private _handleLabelClick() { const data: UmbNotificationDefaultData = { message: 'Copied to clipboard' }; - this._notificationService?.peek('positive', { data }); + this._notificationContext?.peek('positive', { data }); // TODO: how do we want to close the menu? Testing an event based approach this.dispatchEvent(new CustomEvent('close', { bubbles: true, composed: true })); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/repository/template.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/repository/template.repository.ts index 75d596ea3c..46a8c1fd19 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/repository/template.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/repository/template.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -44,8 +44,8 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi this.#detailStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -153,7 +153,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Template created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -175,7 +175,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Template saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -201,7 +201,7 @@ export class UmbTemplateRepository implements UmbTreeRepository, UmbDetailReposi if (!error) { const notification = { data: { message: `Template deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.repository.ts index 17cd602fd6..3971b37f8a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/templating/templates/workspace/data/template.detail.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_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?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; #initResolver?: () => void; #initialized = false; @@ -36,8 +36,8 @@ export class UmbTemplateDetailRepository { this.#checkIfInitialized(); }); - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; this.#checkIfInitialized(); }); } @@ -50,7 +50,7 @@ export class UmbTemplateDetailRepository { } #checkIfInitialized() { - if (this.#detailStore && this.#detailStore && this.#notificationService) { + if (this.#detailStore && this.#detailStore && this.#notificationContext) { this.#initialized = true; this.#initResolver?.(); } @@ -98,7 +98,7 @@ export class UmbTemplateDetailRepository { if (!error) { const notification = { data: { message: `Template created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -125,7 +125,7 @@ export class UmbTemplateDetailRepository { if (!error) { const notification = { data: { message: `Template saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -151,7 +151,7 @@ export class UmbTemplateDetailRepository { if (!error) { const notification = { data: { message: `Template deleted` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/repository/dictionary.repository.ts b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/repository/dictionary.repository.ts index 0f28a507e4..745e1ad8b4 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/repository/dictionary.repository.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/repository/dictionary.repository.ts @@ -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 { UmbNotificationContext, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN } from '@umbraco-cms/notification'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/notification'; import type { DictionaryDetails } from '@umbraco-cms/models'; export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepository { @@ -20,7 +20,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo #detailSource: UmbDictionaryDetailServerDataSource; #detailStore?: UmbDictionaryDetailStore; - #notificationService?: UmbNotificationContext; + #notificationContext?: UmbNotificationContext; constructor(host: UmbControllerHostInterface) { this.#host = host; @@ -38,8 +38,8 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo this.#treeStore = instance; }), - new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (instance) => { - this.#notificationService = instance; + new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationContext = instance; }), ]); } @@ -155,7 +155,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo if (!error) { const notification = { data: { message: `Dictionary '${dictionary.name}' saved` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } // TODO: we currently don't use the detail store for anything. @@ -180,7 +180,7 @@ export class UmbDictionaryRepository implements UmbTreeRepository, UmbDetailRepo if (!error) { const notification = { data: { message: `Dictionary '${detail.name}' created` } }; - this.#notificationService?.peek('positive', notification); + this.#notificationContext?.peek('positive', notification); } return { data, error }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-create.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-create.element.ts index c02cd567dd..d5aa8702e4 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-create.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-create.element.ts @@ -9,7 +9,7 @@ import type { UserDetails } from '@umbraco-cms/models'; import { UmbNotificationDefaultData, UmbNotificationContext, - UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, + UMB_NOTIFICATION_CONTEXT_TOKEN, } from '@umbraco-cms/notification'; export type UsersViewType = 'list' | 'grid'; @@ -61,13 +61,13 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement { private _createdUser?: UserDetails; protected _userStore?: UmbUserStore; - private _notificationService?: UmbNotificationContext; + private _notificationContext?: UmbNotificationContext; connectedCallback(): void { super.connectedCallback(); - this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_TOKEN, (_instance) => { - this._notificationService = _instance; + this.consumeContext(UMB_NOTIFICATION_CONTEXT_TOKEN, (_instance) => { + this._notificationContext = _instance; }); this.consumeContext(UMB_USER_STORE_CONTEXT_TOKEN, (_instance) => { @@ -107,7 +107,7 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement { navigator.clipboard.writeText(passwordInput.value); const data: UmbNotificationDefaultData = { message: 'Password copied' }; - this._notificationService?.peek('positive', { data }); + this._notificationContext?.peek('positive', { data }); } private _submitForm() {