From 0a9868eec1de01d8c74df79495b38b21698d1b69 Mon Sep 17 00:00:00 2001 From: Nathan Woulfe Date: Thu, 12 Jan 2023 12:44:36 +1000 Subject: [PATCH 01/75] show/hide checkbox/icon in table rows based on config --- .../shared/components/table/table.element.ts | 74 ++++++++++++------- .../shared/components/table/table.stories.ts | 1 + 2 files changed, 48 insertions(+), 27 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.element.ts index 2f3c4c15f1..722377a020 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.element.ts @@ -1,5 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; -import { css, html, LitElement, nothing } from 'lit'; +import { css, html, LitElement } from 'lit'; +import { ifDefined } from 'lit-html/directives/if-defined.js'; +import { when } from 'lit-html/directives/when.js'; import { customElement, property, state } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; @@ -22,6 +24,7 @@ export interface UmbTableColumn { export interface UmbTableConfig { allowSelection: boolean; + hideIcon?: boolean; } export class UmbTableSelectedEvent extends Event { @@ -77,16 +80,16 @@ export class UmbTableElement extends LitElement { display: none; } - uui-table-row:focus uui-icon, - uui-table-row:focus-within uui-icon, - uui-table-row:hover uui-icon, + uui-table-row[selectable]:focus uui-icon, + uui-table-row[selectable]:focus-within uui-icon, + uui-table-row[selectable]:hover uui-icon, uui-table-row[select-only] uui-icon { display: none; } - uui-table-row:focus uui-checkbox, - uui-table-row:focus-within uui-checkbox, - uui-table-row:hover uui-checkbox, + uui-table-row[selectable]:focus uui-checkbox, + uui-table-row[selectable]:focus-within uui-checkbox, + uui-table-row[selectable]:hover uui-checkbox, uui-table-row[select-only] uui-checkbox { display: inline-block; } @@ -137,6 +140,7 @@ export class UmbTableElement extends LitElement { @property({ type: Object, attribute: false }) public config: UmbTableConfig = { allowSelection: false, + hideIcon: false, }; /** @@ -201,18 +205,10 @@ export class UmbTableElement extends LitElement { } render() { - return html` + return html` - - - - - ${this.columns.map((column) => this._renderHeaderCell(column))} + ${this._renderHeaderCheckboxCell()} ${this.columns.map((column) => this._renderHeaderCell(column))} ${repeat(this.items, (item) => item.key, this._renderRow)} `; @@ -231,28 +227,52 @@ export class UmbTableElement extends LitElement { `; } + private _renderHeaderCheckboxCell() { + if (this.config.hideIcon && !this.config.allowSelection) return; + + return html` + ${when( + this.config.allowSelection, + () => html` + ` + )} + `; + } + private _renderRow = (item: UmbTableItem) => { return html` this._selectRow(item.key)} @unselected=${() => this._deselectRow(item.key)}> - - ${item.icon ? html`` : nothing} - this._renderRowCell(column, item))} + `; + }; + + private _renderRowCheckboxCell(item: UmbTableItem) { + if (this.config.hideIcon && !this.config.allowSelection) return; + + return html` + ${when(!this.config.hideIcon, () => html``)} + ${when( + this.config.allowSelection, + () => html` e.stopPropagation()} @change=${(event: Event) => this._handleRowCheckboxChange(event, item)} ?checked="${this._isSelected(item.key)}"> - - - ${this.columns.map((column) => this._renderRowCell(column, item))} - `; - }; + ` + )} + `; + } private _renderRowCell(column: UmbTableColumn, item: UmbTableItem) { - return html`${this._renderCellContent(column, item)} `; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.stories.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.stories.ts index 329ae94aea..b26be13e10 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.stories.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/table/table.stories.ts @@ -72,6 +72,7 @@ const items: Array = [ const config: UmbTableConfig = { allowSelection: true, + hideIcon: false, }; export const AAAOverview: Story = () => From 5528ca2fbe7abeb0ba6d857adba308c417971ef8 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Thu, 12 Jan 2023 12:08:27 +0000 Subject: [PATCH 02/75] Adds padding/breathing room to dashboard content like we have today --- .../section/section-dashboards/section-dashboards.element.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts index bc1bfa484f..49bacb5ef4 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts @@ -41,6 +41,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { height: 100%; box-sizing: border-box; display: block; + padding:var(--uui-size-5); } `, ]; From 9e2c68b6038c5ab202836ca0f82a1aa70594e3a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 00:30:23 +0100 Subject: [PATCH 03/75] added table --- .../collection-view-media-table.element.ts | 100 +++++++++++++++--- 1 file changed, 88 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index 069e3c8c9e..5029713536 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -4,16 +4,56 @@ import { customElement, state } from 'lit/decorators.js'; import type { UmbCollectionContext } from '../collection.context'; import type { MediaDetails } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; +import { + UmbTableColumn, + UmbTableConfig, + UmbTableDeselectedEvent, + UmbTableElement, + UmbTableItem, + UmbTableOrderedEvent, + UmbTableSelectedEvent, +} from '../../components/table'; @customElement('umb-collection-view-media-table') export class UmbCollectionViewMediaTableElement extends UmbLitElement { - static styles = [UUITextStyles, css``]; + static styles = [ + UUITextStyles, + css` + :host { + display: block; + box-sizing: border-box; + height: 100%; + width: 100%; + padding: var(--uui-size-space-3) var(--uui-size-space-6); + } + + umb-table { + padding: 0; /* To fix the embedded padding in the table component. */ + } + `, + ]; @state() private _mediaItems?: Array; @state() - private _selection?: Array; + private _tableConfig: UmbTableConfig = { + allowSelection: true, + }; + + @state() + private _tableColumns: Array = [ + { + name: 'Name', + alias: 'mediaName', + }, + ]; + + @state() + private _tableItems: Array = []; + + @state() + private _selection: Array = []; private _collectionContext?: UmbCollectionContext; @@ -30,6 +70,7 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { this.observe(this._collectionContext.data, (nodes) => { this._mediaItems = nodes; + this._createTableItems(this._mediaItems); }); this.observe(this._collectionContext.selection, (selection) => { @@ -37,17 +78,52 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { }); } + private _createTableItems(mediaItems: Array) { + // TODO: I guess the type error below will go away when we get an entity based MediaDetails model instead of tree based. + // @ts-ignore // TODO: Remove ts-ignore when Media type gets fixed. + this._tableItems = mediaItems.map((item) => { + return { + key: item.key, + icon: item.icon, + data: [ + { + columnAlias: 'mediaName', + value: item.name || 'Untitled', + }, + ], + }; + }); + console.log('NAME??', this._tableColumns); + } + + private _handleSelected(event: UmbTableSelectedEvent) { + event.stopPropagation(); + console.log('HANDLE SELECT'); + } + + private _handleDeselected(event: UmbTableDeselectedEvent) { + event.stopPropagation(); + console.log('HANDLE DESELECT'); + } + + private _handleOrdering(event: UmbTableOrderedEvent) { + const table = event.target as UmbTableElement; + const orderingColumn = table.orderingColumn; + const orderingDesc = table.orderingDesc; + console.log(`fetch media items, order column: ${orderingColumn}, desc: ${orderingDesc}`); + } + render() { - return html`

umb-collection-view-media-table

-
-

Selected Media Items:

-
    - ${this._selection?.map((key) => { - const mediaItem = this._mediaItems?.find((item) => item.key === key); - return html`
  • ${mediaItem?.name}
  • `; - })} -
-
`; + return html` + + `; } } From 5b59cd21ea0543531500964c607cdcd6c42651fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 02:36:54 +0100 Subject: [PATCH 04/75] handle select/deselect --- .../collection-view-media-table.element.ts | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index 5029713536..f08578bcdb 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -93,17 +93,20 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { ], }; }); - console.log('NAME??', this._tableColumns); } - private _handleSelected(event: UmbTableSelectedEvent) { + private _handleSelect(event: UmbTableSelectedEvent) { event.stopPropagation(); - console.log('HANDLE SELECT'); + const table = event.target as UmbTableElement; + const selection = table.selection; + this._collectionContext?.setSelection(selection); } - private _handleDeselected(event: UmbTableDeselectedEvent) { + private _handleDeselect(event: UmbTableDeselectedEvent) { event.stopPropagation(); - console.log('HANDLE DESELECT'); + const table = event.target as UmbTableElement; + const selection = table.selection; + this._collectionContext?.setSelection(selection); } private _handleOrdering(event: UmbTableOrderedEvent) { @@ -120,8 +123,8 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { .columns=${this._tableColumns} .items=${this._tableItems} .selection=${this._selection} - @selected="${this._handleSelected}" - @deselected="${this._handleDeselected}" + @selected="${this._handleSelect}" + @deselected="${this._handleDeselect}" @ordered="${this._handleOrdering}"> `; } From 8bad278d82d1b6e5948fe75c9364ee29008f2b9e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 02:43:53 +0100 Subject: [PATCH 05/75] added columns --- .../views/collection-view-media-table.element.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index f08578bcdb..a18e00f3a3 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -47,6 +47,14 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { name: 'Name', alias: 'mediaName', }, + { + name: 'Last edited', + alias: 'mediaLastEdited', + }, + { + name: 'Created by', + alias: 'mediaCreatedBy', + }, ]; @state() @@ -90,6 +98,14 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { columnAlias: 'mediaName', value: item.name || 'Untitled', }, + { + columnAlias: 'mediaLastEdited', + value: 'not implemented', + }, + { + columnAlias: 'mediaCreatedBy', + value: 'not implemented', + }, ], }; }); From 50dc0f525d63826f69217b9c14bfba8e4c55d355 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 02:48:03 +0100 Subject: [PATCH 06/75] added comments --- .../collection/views/collection-view-media-table.element.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index a18e00f3a3..8c4ef9c5af 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -27,6 +27,7 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { padding: var(--uui-size-space-3) var(--uui-size-space-6); } + /* TODO: Should we have embedded padding in the table component? */ umb-table { padding: 0; /* To fix the embedded padding in the table component. */ } From a3d218e494d5cb3c9a668c6677db3e87d5d2bdf9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 02:55:54 +0100 Subject: [PATCH 07/75] remove ts-ignore --- .../collection/views/collection-view-media-table.element.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index 8c4ef9c5af..b0a622f966 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -87,9 +87,9 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { }); } - private _createTableItems(mediaItems: Array) { - // TODO: I guess the type error below will go away when we get an entity based MediaDetails model instead of tree based. - // @ts-ignore // TODO: Remove ts-ignore when Media type gets fixed. + private _createTableItems(mediaItems: Array) { + // TODO: this should use the MediaDetails type, but for now that results in type errors. + // TODO: I guess the type error will go away when we get an entity based MediaDetails model instead of tree based. this._tableItems = mediaItems.map((item) => { return { key: item.key, From 85a7868cac5aef207bbcfb05654d93b6c246c1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jesper=20M=C3=B8ller=20Jensen?= <26099018+JesmoDev@users.noreply.github.com> Date: Fri, 13 Jan 2023 03:02:34 +0100 Subject: [PATCH 08/75] removed unused columns --- .../views/collection-view-media-table.element.ts | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index b0a622f966..ae733a0b8d 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -48,14 +48,6 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { name: 'Name', alias: 'mediaName', }, - { - name: 'Last edited', - alias: 'mediaLastEdited', - }, - { - name: 'Created by', - alias: 'mediaCreatedBy', - }, ]; @state() @@ -99,14 +91,6 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { columnAlias: 'mediaName', value: item.name || 'Untitled', }, - { - columnAlias: 'mediaLastEdited', - value: 'not implemented', - }, - { - columnAlias: 'mediaCreatedBy', - value: 'not implemented', - }, ], }; }); From 678c3cdc12e5302a8946b4021ced497b929f4dc8 Mon Sep 17 00:00:00 2001 From: Nathan Woulfe Date: Fri, 13 Jan 2023 16:53:59 +1000 Subject: [PATCH 09/75] Update workspace-layout.element.ts flex: 0 on router-outlet to collapse when empty --- .../workspace/workspace-layout/workspace-layout.element.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-layout/workspace-layout.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-layout/workspace-layout.element.ts index 59ca7e8672..72917fb40d 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-layout/workspace-layout.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-layout/workspace-layout.element.ts @@ -46,6 +46,7 @@ export class UmbWorkspaceLayout extends UmbLitElement { } router-slot { height: 100%; + flex:0; } umb-extension-slot[slot='actions'] { From e31e777f90fe2eba51cc7675a9abd99a899b40c7 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:57:22 +0000 Subject: [PATCH 10/75] Bump eslint from 8.31.0 to 8.32.0 Bumps [eslint](https://github.com/eslint/eslint) from 8.31.0 to 8.32.0. - [Release notes](https://github.com/eslint/eslint/releases) - [Changelog](https://github.com/eslint/eslint/blob/main/CHANGELOG.md) - [Commits](https://github.com/eslint/eslint/compare/v8.31.0...v8.32.0) --- updated-dependencies: - dependency-name: eslint dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- src/Umbraco.Web.UI.Client/package-lock.json | 14 +++++++------- src/Umbraco.Web.UI.Client/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 2a9a0b9d6c..6e60a33137 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -47,7 +47,7 @@ "@web/test-runner": "^0.15.0", "@web/test-runner-playwright": "^0.9.0", "babel-loader": "^9.1.2", - "eslint": "^8.31.0", + "eslint": "^8.32.0", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.3", "eslint-plugin-import": "^2.27.4", @@ -13515,9 +13515,9 @@ } }, "node_modules/eslint": { - "version": "8.31.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz", - "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==", + "version": "8.32.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz", + "integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==", "dev": true, "dependencies": { "@eslint/eslintrc": "^1.4.1", @@ -39702,9 +39702,9 @@ "dev": true }, "eslint": { - "version": "8.31.0", - "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.31.0.tgz", - "integrity": "sha512-0tQQEVdmPZ1UtUKXjX7EMm9BlgJ08G90IhWh0PKDCb3ZLsgAOHI8fYSIzYVZej92zsgq+ft0FGsxhJ3xo2tbuA==", + "version": "8.32.0", + "resolved": "https://registry.npmjs.org/eslint/-/eslint-8.32.0.tgz", + "integrity": "sha512-nETVXpnthqKPFyuY2FNjz/bEd6nbosRgKbkgS/y1C7LJop96gYHWpiguLecMHQ2XCPxn77DS0P+68WzG6vkZSQ==", "dev": true, "requires": { "@eslint/eslintrc": "^1.4.1", diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 40e63e164e..8d3af5470d 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -93,7 +93,7 @@ "@web/test-runner": "^0.15.0", "@web/test-runner-playwright": "^0.9.0", "babel-loader": "^9.1.2", - "eslint": "^8.31.0", + "eslint": "^8.32.0", "eslint-config-prettier": "^8.6.0", "eslint-import-resolver-typescript": "^3.5.3", "eslint-plugin-import": "^2.27.4", From 0cc08785ad29b93956ab1a63aa2ea07de63204c4 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:58:16 +0000 Subject: [PATCH 11/75] Bump element-internals-polyfill from 1.1.18 to 1.1.19 Bumps [element-internals-polyfill](https://github.com/calebdwilliams/element-internals-polyfill) from 1.1.18 to 1.1.19. - [Release notes](https://github.com/calebdwilliams/element-internals-polyfill/releases) - [Changelog](https://github.com/calebdwilliams/element-internals-polyfill/blob/main/CHANGELOG.md) - [Commits](https://github.com/calebdwilliams/element-internals-polyfill/compare/v1.1.18...v1.1.19) --- updated-dependencies: - dependency-name: element-internals-polyfill dependency-type: direct:production update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Umbraco.Web.UI.Client/package-lock.json | 14 +++++++------- src/Umbraco.Web.UI.Client/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 2a9a0b9d6c..012c877110 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -17,7 +17,7 @@ "@umbraco-ui/uui-modal-container": "file:umbraco-ui-uui-modal-container-0.0.0.tgz", "@umbraco-ui/uui-modal-dialog": "file:umbraco-ui-uui-modal-dialog-0.0.0.tgz", "@umbraco-ui/uui-modal-sidebar": "file:umbraco-ui-uui-modal-sidebar-0.0.0.tgz", - "element-internals-polyfill": "^1.1.18", + "element-internals-polyfill": "^1.1.19", "lit": "^2.6.1", "lodash": "^4.17.21", "router-slot": "^1.5.5", @@ -12887,9 +12887,9 @@ "dev": true }, "node_modules/element-internals-polyfill": { - "version": "1.1.18", - "resolved": "https://registry.npmjs.org/element-internals-polyfill/-/element-internals-polyfill-1.1.18.tgz", - "integrity": "sha512-ULyzpzblTZfMPEt83NphWeREajgaKQBNSTXvNBcjTeriIy7GsuAHFUZ0CpHnlDIVdvPlWcewfu7n7vVfiifZlQ==" + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/element-internals-polyfill/-/element-internals-polyfill-1.1.19.tgz", + "integrity": "sha512-deGDqTkxXtYAQl/VSH5xXWfCe4zEVCkWCYrVeNOPtg3F6W1i0JYRjqPU+MZO9mS1P2UxkkD2vPH+Mb6W/CDicA==" }, "node_modules/element-resize-detector": { "version": "1.2.4", @@ -39302,9 +39302,9 @@ "dev": true }, "element-internals-polyfill": { - "version": "1.1.18", - "resolved": "https://registry.npmjs.org/element-internals-polyfill/-/element-internals-polyfill-1.1.18.tgz", - "integrity": "sha512-ULyzpzblTZfMPEt83NphWeREajgaKQBNSTXvNBcjTeriIy7GsuAHFUZ0CpHnlDIVdvPlWcewfu7n7vVfiifZlQ==" + "version": "1.1.19", + "resolved": "https://registry.npmjs.org/element-internals-polyfill/-/element-internals-polyfill-1.1.19.tgz", + "integrity": "sha512-deGDqTkxXtYAQl/VSH5xXWfCe4zEVCkWCYrVeNOPtg3F6W1i0JYRjqPU+MZO9mS1P2UxkkD2vPH+Mb6W/CDicA==" }, "element-resize-detector": { "version": "1.2.4", diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 40e63e164e..41686db7f5 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -63,7 +63,7 @@ "@umbraco-ui/uui-modal-container": "file:umbraco-ui-uui-modal-container-0.0.0.tgz", "@umbraco-ui/uui-modal-dialog": "file:umbraco-ui-uui-modal-dialog-0.0.0.tgz", "@umbraco-ui/uui-modal-sidebar": "file:umbraco-ui-uui-modal-sidebar-0.0.0.tgz", - "element-internals-polyfill": "^1.1.18", + "element-internals-polyfill": "^1.1.19", "lit": "^2.6.1", "lodash": "^4.17.21", "router-slot": "^1.5.5", From 117e88d595a6f31a04a071c71f2e1fe0ea7353df Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:59:13 +0000 Subject: [PATCH 12/75] Bump prettier from 2.8.2 to 2.8.3 Bumps [prettier](https://github.com/prettier/prettier) from 2.8.2 to 2.8.3. - [Release notes](https://github.com/prettier/prettier/releases) - [Changelog](https://github.com/prettier/prettier/blob/main/CHANGELOG.md) - [Commits](https://github.com/prettier/prettier/compare/2.8.2...2.8.3) --- updated-dependencies: - dependency-name: prettier dependency-type: direct:development update-type: version-update:semver-patch ... Signed-off-by: dependabot[bot] --- src/Umbraco.Web.UI.Client/package-lock.json | 14 +++++++------- src/Umbraco.Web.UI.Client/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 2a9a0b9d6c..81de64a89a 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -62,7 +62,7 @@ "openapi-typescript-codegen": "^0.23.0", "playwright-msw": "^2.1.0", "plop": "^3.1.1", - "prettier": "2.8.2", + "prettier": "2.8.3", "tiny-glob": "^0.2.9", "typescript": "^4.9.4", "vite": "^4.0.4", @@ -22455,9 +22455,9 @@ } }, "node_modules/prettier": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.2.tgz", - "integrity": "sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", "dev": true, "bin": { "prettier": "bin-prettier.js" @@ -46464,9 +46464,9 @@ "dev": true }, "prettier": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.2.tgz", - "integrity": "sha512-BtRV9BcncDyI2tsuS19zzhzoxD8Dh8LiCx7j7tHzrkz8GFXAexeWFdi22mjE1d16dftH2qNaytVxqiRTGlMfpw==", + "version": "2.8.3", + "resolved": "https://registry.npmjs.org/prettier/-/prettier-2.8.3.tgz", + "integrity": "sha512-tJ/oJ4amDihPoufT5sM0Z1SKEuKay8LfVAMlbbhnnkvt6BUserZylqo2PN+p9KeljLr0OHa2rXHU1T8reeoTrw==", "dev": true }, "pretty-error": { diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 40e63e164e..0f1c25a4e9 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -108,7 +108,7 @@ "openapi-typescript-codegen": "^0.23.0", "playwright-msw": "^2.1.0", "plop": "^3.1.1", - "prettier": "2.8.2", + "prettier": "2.8.3", "tiny-glob": "^0.2.9", "typescript": "^4.9.4", "vite": "^4.0.4", From 60a2d348e14a8174c0d952651005997608293eb8 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 16 Jan 2023 09:59:54 +0000 Subject: [PATCH 13/75] Bump msw-storybook-addon from 1.6.3 to 1.7.0 Bumps [msw-storybook-addon](https://github.com/mswjs/msw-storybook-addon/tree/HEAD/packages/msw-addon) from 1.6.3 to 1.7.0. - [Release notes](https://github.com/mswjs/msw-storybook-addon/releases) - [Commits](https://github.com/mswjs/msw-storybook-addon/commits/v1.7.0/packages/msw-addon) --- updated-dependencies: - dependency-name: msw-storybook-addon dependency-type: direct:development update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- src/Umbraco.Web.UI.Client/package-lock.json | 14 +++++++------- src/Umbraco.Web.UI.Client/package.json | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index 2a9a0b9d6c..c1aca1b614 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -58,7 +58,7 @@ "eslint-plugin-wc": "^1.4.0", "lit-html": "^2.6.1", "msw": "^0.49.2", - "msw-storybook-addon": "^1.6.3", + "msw-storybook-addon": "^1.7.0", "openapi-typescript-codegen": "^0.23.0", "playwright-msw": "^2.1.0", "plop": "^3.1.1", @@ -20444,9 +20444,9 @@ } }, "node_modules/msw-storybook-addon": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/msw-storybook-addon/-/msw-storybook-addon-1.6.3.tgz", - "integrity": "sha512-Ps80WdRmXsmenoTwfrgKMNpQD8INUUFyUFyZOecx8QjuqSlL++UYrLaGyACXN2goOn+/VS6rb0ZapbjrasPClg==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/msw-storybook-addon/-/msw-storybook-addon-1.7.0.tgz", + "integrity": "sha512-G/cYj7Z8NuyFbMsdVJRr17flWed8J7CmKTSPNXmuK65W6uILpqNDpXJC7KVRhOg7lUFR5Hmqwcq6z8Mow/wu5A==", "dev": true, "dependencies": { "@storybook/addons": "^6.0.0", @@ -44983,9 +44983,9 @@ } }, "msw-storybook-addon": { - "version": "1.6.3", - "resolved": "https://registry.npmjs.org/msw-storybook-addon/-/msw-storybook-addon-1.6.3.tgz", - "integrity": "sha512-Ps80WdRmXsmenoTwfrgKMNpQD8INUUFyUFyZOecx8QjuqSlL++UYrLaGyACXN2goOn+/VS6rb0ZapbjrasPClg==", + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/msw-storybook-addon/-/msw-storybook-addon-1.7.0.tgz", + "integrity": "sha512-G/cYj7Z8NuyFbMsdVJRr17flWed8J7CmKTSPNXmuK65W6uILpqNDpXJC7KVRhOg7lUFR5Hmqwcq6z8Mow/wu5A==", "dev": true, "requires": { "@storybook/addons": "^6.0.0", diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 40e63e164e..06ffbd65e2 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -104,7 +104,7 @@ "eslint-plugin-wc": "^1.4.0", "lit-html": "^2.6.1", "msw": "^0.49.2", - "msw-storybook-addon": "^1.6.3", + "msw-storybook-addon": "^1.7.0", "openapi-typescript-codegen": "^0.23.0", "playwright-msw": "^2.1.0", "plop": "^3.1.1", From 7ad9dd5784785ab9b7e103f99b89d17741ef68d0 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 09:59:55 +0100 Subject: [PATCH 14/75] add shortcut to controllers --- src/Umbraco.Web.UI.Client/tsconfig.json | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/tsconfig.json b/src/Umbraco.Web.UI.Client/tsconfig.json index 3b5a74a536..79f21ed985 100644 --- a/src/Umbraco.Web.UI.Client/tsconfig.json +++ b/src/Umbraco.Web.UI.Client/tsconfig.json @@ -33,7 +33,8 @@ "@umbraco-cms/services": ["src/core/services"], "@umbraco-cms/components/*": ["src/backoffice/components/*"], "@umbraco-cms/stores/*": ["src/core/stores/*"], - "@umbraco-cms/sections/*": ["src/backoffice/sections/*"] + "@umbraco-cms/sections/*": ["src/backoffice/sections/*"], + "@umbraco-cms/controllers": ["src/core/controller"] } }, "include": ["src/**/*.ts", "e2e/**/*.ts"], From 2151097a26466c7e810ca8187058685ea271c44a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:00:14 +0100 Subject: [PATCH 15/75] add controller index --- src/Umbraco.Web.UI.Client/src/core/controller/index.ts | 3 +++ 1 file changed, 3 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/core/controller/index.ts diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/index.ts b/src/Umbraco.Web.UI.Client/src/core/controller/index.ts new file mode 100644 index 0000000000..c683d1e658 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/controller/index.ts @@ -0,0 +1,3 @@ +export * from './controller-host.mixin'; +export * from './controller.class'; +export * from './controller.interface'; From 87f2881a8f4dd9c8db3366fb58b11bee2e8219b3 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:00:22 +0100 Subject: [PATCH 16/75] add ContextToken --- .../src/core/context-api/context-token.ts | 19 +++++++++++++++++++ .../src/core/context-api/index.ts | 1 + 2 files changed, 20 insertions(+) create mode 100644 src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts new file mode 100644 index 0000000000..5f3086d211 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts @@ -0,0 +1,19 @@ +export class ContextToken { + /** + * @param _desc Description for the token, + * used only for debugging purposes, + * it should but does not need to be unique + */ + constructor(protected _desc: string) {} + + /** + * @internal + */ + get multi(): ContextToken> { + return this as ContextToken>; + } + + toString(): string { + return `${ContextToken.name} ${this._desc}`; + } +} diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts index c9bc27c68a..4cb2fa0b29 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts @@ -2,3 +2,4 @@ export * from './consume/context-consumer'; export * from './consume/context-request.event'; export * from './provide/context-provider'; export * from './provide/context-provide.event'; +export * from './context-token'; From 000f7cd54d90a2196d01e36f23b08173161e2f44 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:01:15 +0100 Subject: [PATCH 17/75] allow ContextToken as provide and consume alias --- .../consume/context-consumer.controller.ts | 17 +++++++++++------ .../context-api/consume/context-consumer.ts | 15 +++++++++------ .../consume/context-request.event.ts | 19 ++++++++++++------- .../core/controller/controller.interface.ts | 6 ++++-- 4 files changed, 36 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index ecf921af17..5c44c3aff6 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -1,16 +1,22 @@ +import { ContextToken } from '../context-token'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextCallback } from './context-request.event'; -import type { UmbControllerInterface } from 'src/core/controller/controller.interface'; -import { UmbControllerHostInterface } from 'src/core/controller/controller-host.mixin'; +import { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controllers'; -export class UmbContextConsumerController extends UmbContextConsumer implements UmbControllerInterface { - +export class UmbContextConsumerController + extends UmbContextConsumer + implements UmbControllerInterface +{ public get unique() { return this._contextAlias; } - constructor(host:UmbControllerHostInterface, contextAlias: string, callback: UmbContextCallback) { + constructor( + host: UmbControllerHostInterface, + contextAlias: string | ContextToken, + callback: UmbContextCallback + ) { super(host, contextAlias, callback); host.addController(this); } @@ -20,5 +26,4 @@ export class UmbContextConsumerController extends UmbContextConsumer { - +export class UmbContextConsumer { private _instance?: unknown; get instance(): unknown | undefined { return this._instance; @@ -23,13 +23,16 @@ export class UmbContextConsumer { * @param {UmbContextCallback} _callback * @memberof UmbContextConsumer */ - constructor(protected host: HostType, protected _contextAlias: string, private _callback: UmbContextCallback) {} + constructor( + protected host: HostType, + protected _contextAlias: string | ContextToken, + private _callback: UmbContextCallback + ) {} - - private _onResponse = (instance: unknown) => { + private _onResponse = (instance: ContextType) => { this._instance = instance; this._callback(instance); - } + }; /** * @memberof UmbContextConsumer diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index ad1baad5c2..bc9e86dc62 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -1,14 +1,16 @@ +import { ContextToken } from '../injectionToken'; + export const umbContextRequestEventType = 'umb:context-request'; -export type UmbContextCallback = (instance: any) => void; +export type UmbContextCallback = (instance: T) => void; /** * @export * @interface UmbContextRequestEvent */ -export interface UmbContextRequestEvent extends Event { - readonly contextAlias: string; - readonly callback: UmbContextCallback; +export interface UmbContextRequestEvent extends Event { + readonly contextAlias: string | ContextToken; + readonly callback: UmbContextCallback; } /** @@ -17,12 +19,15 @@ export interface UmbContextRequestEvent extends Event { * @extends {Event} * @implements {UmbContextRequestEvent} */ -export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { - public constructor(public readonly contextAlias: string, public readonly callback: UmbContextCallback) { +export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { + public constructor( + public readonly contextAlias: string | ContextToken, + public readonly callback: UmbContextCallback + ) { super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true }); } } -export const isUmbContextRequestEvent = (event: Event): event is UmbContextRequestEventImplementation => { +export const isUmbContextRequestEvent = (event: Event): event is UmbContextRequestEventImplementation => { return event.type === umbContextRequestEventType; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts index f8feb3ff9c..7c0f44db11 100644 --- a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts @@ -1,5 +1,7 @@ -export interface UmbControllerInterface { - get unique(): string | undefined; +import { ContextToken } from '@umbraco-cms/context-api'; + +export interface UmbControllerInterface { + get unique(): string | ContextToken; hostConnected(): void; hostDisconnected(): void; destroy(): void; From 1b265c499cfe773157f1fdc4071e13e87d44dd61 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:01:41 +0100 Subject: [PATCH 18/75] rename to contextToken --- .../src/core/context-api/consume/context-consumer.ts | 2 +- .../src/core/context-api/consume/context-request.event.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index 246941d6b0..5af6274d8b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../injectionToken'; +import { ContextToken } from '../context-token'; import { isUmbContextProvideEventType, umbContextProvideEventType } from '../provide/context-provide.event'; import { UmbContextRequestEventImplementation, UmbContextCallback } from './context-request.event'; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index bc9e86dc62..fca575eb45 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../injectionToken'; +import { ContextToken } from '../context-token'; export const umbContextRequestEventType = 'umb:context-request'; From f04b152d2d20ed397fa22d7b59aac073f421fba7 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 10:30:19 +0100 Subject: [PATCH 19/75] remove duplicate shortcut --- src/Umbraco.Web.UI.Client/tsconfig.json | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/tsconfig.json b/src/Umbraco.Web.UI.Client/tsconfig.json index 49154942f3..36aecaf703 100644 --- a/src/Umbraco.Web.UI.Client/tsconfig.json +++ b/src/Umbraco.Web.UI.Client/tsconfig.json @@ -33,8 +33,7 @@ "@umbraco-cms/resources": ["src/core/resources"], "@umbraco-cms/components/*": ["src/backoffice/components/*"], "@umbraco-cms/stores/*": ["src/core/stores/*"], - "@umbraco-cms/sections/*": ["src/backoffice/sections/*"], - "@umbraco-cms/controllers": ["src/core/controller"] + "@umbraco-cms/sections/*": ["src/backoffice/sections/*"] } }, "include": ["src/**/*.ts", "e2e/**/*.ts"], From 14e63f7abbbefd75ac06a847e803cd37e0a475f2 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:05:40 +0100 Subject: [PATCH 20/75] mark contextToken as default type = unknown --- .../consume/context-consumer.controller.ts | 10 +++++----- .../core/context-api/consume/context-consumer.ts | 8 ++++---- .../context-api/consume/context-request.event.ts | 16 ++++++++-------- .../src/core/context-api/context-token.ts | 2 +- .../context-api/provide/context-provide.event.ts | 6 ++++-- .../provide/context-provider.controller.ts | 16 ++++++++-------- .../core/context-api/provide/context-provider.ts | 8 ++++---- 7 files changed, 34 insertions(+), 32 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index 1d4188c99c..9d1633840a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -2,14 +2,14 @@ import { ContextToken } from '../context-token'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextCallback } from './context-request.event'; -import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controllers'; +import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controller'; -export class UmbContextConsumerController - extends UmbContextConsumer - implements UmbControllerInterface +export class UmbContextConsumerController + extends UmbContextConsumer + implements UmbControllerInterface { public get unique() { - return this._contextAlias; + return this._contextAlias?.toString(); } constructor( diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index 5af6274d8b..006690cf9c 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -6,7 +6,7 @@ import { UmbContextRequestEventImplementation, UmbContextCallback } from './cont * @export * @class UmbContextConsumer */ -export class UmbContextConsumer { +export class UmbContextConsumer { private _instance?: unknown; get instance(): unknown | undefined { return this._instance; @@ -25,11 +25,11 @@ export class UmbContextConsumer, - private _callback: UmbContextCallback + protected _contextAlias: string | ContextToken, + private _callback: UmbContextCallback ) {} - private _onResponse = (instance: ContextType) => { + private _onResponse = (instance: any) => { this._instance = instance; this._callback(instance); }; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index fca575eb45..52e44d8257 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -2,15 +2,15 @@ import { ContextToken } from '../context-token'; export const umbContextRequestEventType = 'umb:context-request'; -export type UmbContextCallback = (instance: T) => void; +export type UmbContextCallback = (instance: T) => void; /** * @export * @interface UmbContextRequestEvent */ -export interface UmbContextRequestEvent extends Event { - readonly contextAlias: string | ContextToken; - readonly callback: UmbContextCallback; +export interface UmbContextRequestEvent extends Event { + readonly contextAlias: string | ContextToken; + readonly callback: UmbContextCallback; } /** @@ -19,15 +19,15 @@ export interface UmbContextRequestEvent extends Event { * @extends {Event} * @implements {UmbContextRequestEvent} */ -export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { +export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { public constructor( - public readonly contextAlias: string | ContextToken, - public readonly callback: UmbContextCallback + public readonly contextAlias: string | ContextToken, + public readonly callback: UmbContextCallback ) { super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true }); } } -export const isUmbContextRequestEvent = (event: Event): event is UmbContextRequestEventImplementation => { +export const isUmbContextRequestEvent = (event: Event): event is UmbContextRequestEventImplementation => { return event.type === umbContextRequestEventType; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts index 5f3086d211..060206316e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts @@ -1,4 +1,4 @@ -export class ContextToken { +export class ContextToken { /** * @param _desc Description for the token, * used only for debugging purposes, diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts index c6c38a80e7..763c2d5a06 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts @@ -1,3 +1,5 @@ +import { ContextToken } from '../context-token'; + export const umbContextProvideEventType = 'umb:context-provide'; /** @@ -5,7 +7,7 @@ export const umbContextProvideEventType = 'umb:context-provide'; * @interface UmbContextProvideEvent */ export interface UmbContextProvideEvent extends Event { - readonly contextAlias: string; + readonly contextAlias: string | ContextToken; } /** @@ -15,7 +17,7 @@ export interface UmbContextProvideEvent extends Event { * @implements {UmbContextProvideEvent} */ export class UmbContextProvideEventImplementation extends Event implements UmbContextProvideEvent { - public constructor(public readonly contextAlias: string) { + public constructor(public readonly contextAlias: string | ContextToken) { super(umbContextProvideEventType, { bubbles: true, composed: true }); } } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts index 17afb97861..d7e35c992a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts @@ -1,15 +1,16 @@ +import { ContextToken } from '../context-token'; import { UmbContextProvider } from './context-provider'; -import type { UmbControllerInterface } from 'src/core/controller/controller.interface'; -import { UmbControllerHostInterface } from '@umbraco-cms/controller'; - - -export class UmbContextProviderController extends UmbContextProvider implements UmbControllerInterface { +import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controller'; +export class UmbContextProviderController + extends UmbContextProvider + implements UmbControllerInterface +{ public get unique() { - return this._contextAlias; + return this._contextAlias.toString(); } - constructor(host:UmbControllerHostInterface, contextAlias: string, instance: unknown) { + constructor(host: UmbControllerHostInterface, contextAlias: string | ContextToken, instance: T) { super(host, contextAlias, instance); // TODO: What if this API is already provided with this alias? maybe handle this in the controller: @@ -23,5 +24,4 @@ export class UmbContextProviderController extends UmbContextProvider { - +export class UmbContextProvider { protected host: HostType; - protected _contextAlias: string; + protected _contextAlias: string | ContextToken; #instance: unknown; /** @@ -19,7 +19,7 @@ export class UmbContextProvider { * @param {*} instance * @memberof UmbContextProvider */ - constructor(host: HostType, contextAlias: string, instance: unknown) { + constructor(host: HostType, contextAlias: string | ContextToken, instance: unknown) { this.host = host; this._contextAlias = contextAlias; this.#instance = instance; From 21b37f303eab7e905c1d41b2f58a9bd4feaf1f7b Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:06:17 +0100 Subject: [PATCH 21/75] rename ContextToken to ContextAlias --- .../context-api/consume/context-consumer.controller.ts | 4 ++-- .../src/core/context-api/consume/context-consumer.ts | 4 ++-- .../src/core/context-api/consume/context-request.event.ts | 6 +++--- .../src/core/context-api/context-token.ts | 8 ++++---- .../src/core/context-api/provide/context-provide.event.ts | 6 +++--- .../context-api/provide/context-provider.controller.ts | 4 ++-- .../src/core/context-api/provide/context-provider.ts | 6 +++--- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index 9d1633840a..d2a264a7df 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextCallback } from './context-request.event'; @@ -14,7 +14,7 @@ export class UmbContextConsumerController constructor( host: UmbControllerHostInterface, - contextAlias: string | ContextToken, + contextAlias: string | ContextAlias, callback: UmbContextCallback ) { super(host, contextAlias, callback); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index 006690cf9c..b37c798657 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; import { isUmbContextProvideEventType, umbContextProvideEventType } from '../provide/context-provide.event'; import { UmbContextRequestEventImplementation, UmbContextCallback } from './context-request.event'; @@ -25,7 +25,7 @@ export class UmbContextConsumer ) {} diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index 52e44d8257..4d25b0f317 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; export const umbContextRequestEventType = 'umb:context-request'; @@ -9,7 +9,7 @@ export type UmbContextCallback = (instance: T) => void; * @interface UmbContextRequestEvent */ export interface UmbContextRequestEvent extends Event { - readonly contextAlias: string | ContextToken; + readonly contextAlias: string | ContextAlias; readonly callback: UmbContextCallback; } @@ -21,7 +21,7 @@ export interface UmbContextRequestEvent extends Event { */ export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { public constructor( - public readonly contextAlias: string | ContextToken, + public readonly contextAlias: string | ContextAlias, public readonly callback: UmbContextCallback ) { super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true }); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts index 060206316e..59b00c092f 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts @@ -1,4 +1,4 @@ -export class ContextToken { +export class ContextAlias { /** * @param _desc Description for the token, * used only for debugging purposes, @@ -9,11 +9,11 @@ export class ContextToken { /** * @internal */ - get multi(): ContextToken> { - return this as ContextToken>; + get multi(): ContextAlias> { + return this as ContextAlias>; } toString(): string { - return `${ContextToken.name} ${this._desc}`; + return `${ContextAlias.name} ${this._desc}`; } } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts index 763c2d5a06..69bbecabb2 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; export const umbContextProvideEventType = 'umb:context-provide'; @@ -7,7 +7,7 @@ export const umbContextProvideEventType = 'umb:context-provide'; * @interface UmbContextProvideEvent */ export interface UmbContextProvideEvent extends Event { - readonly contextAlias: string | ContextToken; + readonly contextAlias: string | ContextAlias; } /** @@ -17,7 +17,7 @@ export interface UmbContextProvideEvent extends Event { * @implements {UmbContextProvideEvent} */ export class UmbContextProvideEventImplementation extends Event implements UmbContextProvideEvent { - public constructor(public readonly contextAlias: string | ContextToken) { + public constructor(public readonly contextAlias: string | ContextAlias) { super(umbContextProvideEventType, { bubbles: true, composed: true }); } } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts index d7e35c992a..643d2f82e2 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts @@ -1,4 +1,4 @@ -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; import { UmbContextProvider } from './context-provider'; import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controller'; @@ -10,7 +10,7 @@ export class UmbContextProviderController return this._contextAlias.toString(); } - constructor(host: UmbControllerHostInterface, contextAlias: string | ContextToken, instance: T) { + constructor(host: UmbControllerHostInterface, contextAlias: string | ContextAlias, instance: T) { super(host, contextAlias, instance); // TODO: What if this API is already provided with this alias? maybe handle this in the controller: diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts index 5c4b235d3b..8776066ad1 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts @@ -1,5 +1,5 @@ import { umbContextRequestEventType, isUmbContextRequestEvent } from '../consume/context-request.event'; -import { ContextToken } from '../context-token'; +import { ContextAlias } from '../context-token'; import { UmbContextProvideEventImplementation } from './context-provide.event'; /** @@ -9,7 +9,7 @@ import { UmbContextProvideEventImplementation } from './context-provide.event'; export class UmbContextProvider { protected host: HostType; - protected _contextAlias: string | ContextToken; + protected _contextAlias: string | ContextAlias; #instance: unknown; /** @@ -19,7 +19,7 @@ export class UmbContextProvider { * @param {*} instance * @memberof UmbContextProvider */ - constructor(host: HostType, contextAlias: string | ContextToken, instance: unknown) { + constructor(host: HostType, contextAlias: string | ContextAlias, instance: unknown) { this.host = host; this._contextAlias = contextAlias; this.#instance = instance; From ef68d61ac0a67908606d56d14e2d04a8ae89633c Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:06:55 +0100 Subject: [PATCH 22/75] unique alias should only be a string --- .../src/core/controller/controller.interface.ts | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts index 7c0f44db11..5ab80dd0a1 100644 --- a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts @@ -1,7 +1,5 @@ -import { ContextToken } from '@umbraco-cms/context-api'; - -export interface UmbControllerInterface { - get unique(): string | ContextToken; +export interface UmbControllerInterface { + get unique(): string; hostConnected(): void; hostDisconnected(): void; destroy(): void; From f5a407a7b600d62859fa3dbf175b798eca16c425 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:07:19 +0100 Subject: [PATCH 23/75] fix issue where alias should be a string --- .../src/core/controller/controller.class.ts | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts b/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts index 02235df414..757dc4cb89 100644 --- a/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts +++ b/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts @@ -4,10 +4,9 @@ import { UmbControllerInterface } from './controller.interface'; export abstract class UmbController implements UmbControllerInterface { protected host?: UmbControllerHostInterface; - private _alias?: string; public get unique() { - return this._alias; + return this._alias ?? UmbController.name; } constructor(host: UmbControllerHostInterface, alias?: string) { From 59fddec43e50dfee8febcba7eb13710bb98f9f86 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:07:35 +0100 Subject: [PATCH 24/75] implement contextAlias for element mixin --- .../src/core/element/element.mixin.ts | 59 +++++++++++-------- 1 file changed, 33 insertions(+), 26 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts index d4bcaf7d3b..d83a56c6ef 100644 --- a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts +++ b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts @@ -1,10 +1,15 @@ import { Observable } from 'rxjs'; -import { UmbContextConsumerController } from '../context-api/consume/context-consumer.controller'; -import { UmbContextCallback } from '../context-api/consume/context-request.event'; -import { UmbContextProviderController } from '../context-api/provide/context-provider.controller'; -import { UmbControllerHostInterface, UmbControllerHostMixin } from '../controller/controller-host.mixin'; + import type { HTMLElementConstructor } from '../models'; -import { UmbObserverController } from '../observable-api/observer.controller'; + +import { UmbControllerHostInterface, UmbControllerHostMixin } from '@umbraco-cms/controller'; +import { + ContextAlias, + UmbContextCallback, + UmbContextConsumerController, + UmbContextProviderController, +} from '@umbraco-cms/context-api'; +import { UmbObserverController } from '@umbraco-cms/observable-api'; // TODO: can we use this aliases to generate the key of this type interface ResolvedContexts { @@ -13,14 +18,16 @@ interface ResolvedContexts { export declare class UmbElementMixinInterface extends UmbControllerHostInterface { observe(source: Observable, callback: (_value: T) => void, unique?: string): UmbObserverController; - provideContext(alias: string, instance: unknown): UmbContextProviderController; - consumeContext(alias: string, callback: UmbContextCallback): UmbContextConsumerController; + provideContext(alias: string | ContextAlias, instance: R): UmbContextProviderController; + consumeContext( + alias: string | ContextAlias, + callback: UmbContextCallback + ): UmbContextConsumerController; consumeAllContexts(contextAliases: string[], callback: (_instances: ResolvedContexts) => void): void; } export const UmbElementMixin = (superClass: T) => { - class UmbElementMixinClass extends UmbControllerHostMixin(superClass) { - + class UmbElementMixinClass extends UmbControllerHostMixin(superClass) implements UmbElementMixinInterface { /** * @description Observe a RxJS source of choice. * @param {Observable} source RxJS source @@ -39,7 +46,7 @@ export const UmbElementMixin = (superClass: T) * @return {UmbContextProviderController} Reference to a Context Provider Controller instance * @memberof UmbElementMixin */ - provideContext(alias: string, instance: unknown): UmbContextProviderController { + provideContext(alias: string | ContextAlias, instance: R): UmbContextProviderController { return new UmbContextProviderController(this, alias, instance); } @@ -50,7 +57,10 @@ export const UmbElementMixin = (superClass: T) * @return {UmbContextConsumerController} Reference to a Context Consumer Controller instance * @memberof UmbElementMixin */ - consumeContext(alias: string, callback: UmbContextCallback): UmbContextConsumerController { + consumeContext( + alias: string | ContextAlias, + callback: UmbContextCallback + ): UmbContextConsumerController { return new UmbContextConsumerController(this, alias, callback); } @@ -62,26 +72,23 @@ export const UmbElementMixin = (superClass: T) */ consumeAllContexts(_contextAliases: Array, callback: (_instances: ResolvedContexts) => void) { let resolvedAmount = 0; - const controllers = _contextAliases.map((alias) => - new UmbContextConsumerController(this, alias, () => { + const controllers = _contextAliases.map( + (alias) => + new UmbContextConsumerController(this, alias, () => { + resolvedAmount++; - resolvedAmount++; + if (resolvedAmount === _contextAliases.length) { + const result: ResolvedContexts = {}; - if (resolvedAmount === _contextAliases.length) { + controllers.forEach((contextCtrl: UmbContextConsumerController) => { + result[contextCtrl.consumerAlias?.toString()] = contextCtrl.instance; + }); - const result: ResolvedContexts = {}; - - controllers.forEach((contextCtrl: UmbContextConsumerController) => { - result[contextCtrl.consumerAlias] = contextCtrl.instance; - }); - - callback(result); - } - }) + callback(result); + } + }) ); } - - } return UmbElementMixinClass as unknown as HTMLElementConstructor & T; From 542ead29f47031db466518897298b323a08d0b17 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:08:00 +0100 Subject: [PATCH 25/75] create context alias for notification service --- src/Umbraco.Web.UI.Client/src/core/notification/index.ts | 1 + .../src/core/notification/notification.service.ts | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/notification/index.ts b/src/Umbraco.Web.UI.Client/src/core/notification/index.ts index 544360a565..7ea5fe1cbe 100644 --- a/src/Umbraco.Web.UI.Client/src/core/notification/index.ts +++ b/src/Umbraco.Web.UI.Client/src/core/notification/index.ts @@ -1,2 +1,3 @@ export * from './notification.service'; export * from './notification-handler'; +export * from './layouts/default'; diff --git a/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts b/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts index c93c0d724b..96143af559 100644 --- a/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts +++ b/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts @@ -1,5 +1,6 @@ import { BehaviorSubject } from 'rxjs'; import { UmbNotificationHandler } from '.'; +import { ContextAlias } from '@umbraco-cms/context-api'; export type UmbNotificationData = any; @@ -18,7 +19,6 @@ export interface UmbNotificationOptions { export type UmbNotificationColor = '' | 'default' | 'positive' | 'warning' | 'danger'; export class UmbNotificationService { - // 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(>[]); public readonly notifications = this._notifications.asObservable(); @@ -85,3 +85,7 @@ export class UmbNotificationService { return this._open({ ...options, color, duration: null }); } } + +export const UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS = new ContextAlias( + UmbNotificationService.name +); From 2d9d630f6d1fd96ea509e5aa579bd5913c443eb7 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:08:21 +0100 Subject: [PATCH 26/75] provide notification service with alias --- .../src/backoffice/backoffice.element.ts | 4 ++-- ...ckoffice-notification-container.element.ts | 20 ++++++++++++------- 2 files changed, 15 insertions(+), 9 deletions(-) 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 8a56c75eb5..b9ba923f12 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -3,7 +3,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { UmbModalService } from '../core/modal'; -import { UmbNotificationService } from '../core/notification'; +import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../core/notification'; import { UmbUserStore } from './users/users/user.store'; import { UmbUserGroupStore } from './users/user-groups/user-group.store'; import { UmbCurrentUserStore } from './users/current-user/current-user.store'; @@ -54,7 +54,7 @@ export class UmbBackofficeElement extends UmbLitElement { super(); this.provideContext('umbModalService', new UmbModalService()); - this.provideContext('umbNotificationService', new UmbNotificationService()); + this.provideContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, new UmbNotificationService()); // TODO: find a way this is possible outside this element. It needs to be possible to register stores in extensions this.provideContext('umbCurrentUserStore', new UmbCurrentUserStore()); 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 7540e565bf..2b259de012 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 @@ -2,7 +2,11 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; -import type { UmbNotificationHandler, UmbNotificationService } from '../../../../core/notification'; +import { + UmbNotificationHandler, + UmbNotificationService, + UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, +} from '../../../../core/notification'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-backoffice-notification-container') @@ -30,7 +34,7 @@ export class UmbBackofficeNotificationContainer extends UmbLitElement { constructor() { super(); - this.consumeContext('umbNotificationService', (notificationService: UmbNotificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; this._observeNotifications(); }); @@ -47,11 +51,13 @@ export class UmbBackofficeNotificationContainer extends UmbLitElement { render() { return html` - ${this._notifications ? repeat( - this._notifications, - (notification: UmbNotificationHandler) => notification.key, - (notification) => html`${notification.element}` - ) : ''} + ${this._notifications + ? repeat( + this._notifications, + (notification: UmbNotificationHandler) => notification.key, + (notification) => html`${notification.element}` + ) + : ''} `; } From c2ed6296f0d9d734014289130fd4019758543b1c Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:13:29 +0100 Subject: [PATCH 27/75] migrate umbNotificationService to context alias --- .../language/language-workspace.element.ts | 14 ++++- .../workspace-content.context.ts | 58 ++++++++----------- .../copy/property-action-copy.element.ts | 5 +- .../workspace-view-users-create.element.ts | 9 ++- .../notification/notification.stories.mdx | 20 +++++-- .../core/notification/notification.stories.ts | 9 ++- .../src/core/resources/resource.controller.ts | 11 ++-- 7 files changed, 72 insertions(+), 54 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts index 06a4912dbb..5c9106baa6 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts @@ -1,8 +1,20 @@ +import { UmbLitElement } from '@umbraco-cms/element'; import { html, LitElement } from 'lit'; import { customElement } from 'lit/decorators.js'; +import { UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from 'src/core/notification'; @customElement('umb-language-workspace') -export class UmbLanguageWorkspaceElement extends LitElement { +export class UmbLanguageWorkspaceElement extends UmbLitElement { + constructor() { + super(); + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (service) => { + console.log( + '🚀 ~ file: language-workspace.element.ts:11 ~ UmbLanguageWorkspaceElement ~ this.consumeContext ~ service', + service + ); + service.peek('positive', { data: { message: 'Language Workspace' } }); + }); + } render() { return html`
Language Workspace
`; } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/workspace-content.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/workspace-content.context.ts index 8acc609eb3..e0d67ad974 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/workspace-content.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/workspace-content.context.ts @@ -1,5 +1,5 @@ import { v4 as uuidv4 } from 'uuid'; -import { UmbNotificationService } from '../../../../../core/notification'; +import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../../../../../core/notification'; import { UmbNotificationDefaultData } from '../../../../../core/notification/layouts/default'; import { UmbNodeStoreBase } from '@umbraco-cms/stores/store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; @@ -13,7 +13,6 @@ export abstract class UmbWorkspaceContentContext< ContentTypeType extends EntityTreeItem = EntityTreeItem, StoreType extends UmbNodeStoreBase = UmbNodeStoreBase > { - protected _host: UmbControllerHostInterface; // TODO: figure out how fine grained we want to make our observables. @@ -24,7 +23,7 @@ export abstract class UmbWorkspaceContentContext< protected _notificationService?: UmbNotificationService; - protected _store: StoreType|null = null; + protected _store: StoreType | null = null; protected _storeSubscription?: UmbObserverController; #isNew = true; @@ -32,29 +31,18 @@ export abstract class UmbWorkspaceContentContext< public entityKey?: string; public entityType: string; - constructor( - host: UmbControllerHostInterface, - defaultData: ContentTypeType, - storeAlias: string, - entityType: string - ) { - + constructor(host: UmbControllerHostInterface, defaultData: ContentTypeType, storeAlias: string, entityType: string) { this._host = host; this._data = new UniqueBehaviorSubject(defaultData); this.data = this._data.asObservable(); - this.name = createObservablePart(this._data, data => data.name); - + this.name = createObservablePart(this._data, (data) => data.name); this.entityType = entityType; - new UmbContextConsumerController( - host, - 'umbNotificationService', - (_instance: UmbNotificationService) => { - this._notificationService = _instance; - } - ); + new UmbContextConsumerController(host, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._notificationService = _instance; + }); new UmbContextConsumerController(host, storeAlias, (_instance: StoreType) => { this._store = _instance; @@ -69,7 +57,6 @@ export abstract class UmbWorkspaceContentContext< }); } - public getData() { return this._data.getValue(); } @@ -86,21 +73,24 @@ export abstract class UmbWorkspaceContentContext< create(parentKey: string | null) { this.#isNew = true; this.entityKey = uuidv4(); - console.log("I'm new, and I will be created under ", parentKey) + console.log("I'm new, and I will be created under ", parentKey); } protected _observeStore(): void { - if(!this._store || !this.entityKey) { + if (!this._store || !this.entityKey) { return; } - if(!this.#isNew) { + if (!this.#isNew) { this._storeSubscription?.destroy(); - this._storeSubscription = new UmbObserverController(this._host, this._store.getByKey(this.entityKey), - (content) => { - if (!content) return; // TODO: Handle nicely if there is no content data. - this.update(content as any); - }); + this._storeSubscription = new UmbObserverController( + this._host, + this._store.getByKey(this.entityKey), + (content) => { + if (!content) return; // TODO: Handle nicely if there is no content data. + this.update(content as any); + } + ); } } @@ -108,17 +98,17 @@ export abstract class UmbWorkspaceContentContext< return this._store; } - abstract setPropertyValue(alias: string, value: unknown):void; - + abstract setPropertyValue(alias: string, value: unknown): void; // TODO: consider turning this into an abstract so each context implement this them selfs. public save(): Promise { - if(!this._store) { + if (!this._store) { // TODO: more beautiful error: - console.error("Could not save cause workspace context has no store."); + console.error('Could not save cause workspace context has no store.'); return Promise.resolve(); } - return this._store.save([this.getData()]) + return this._store + .save([this.getData()]) .then(() => { const data: UmbNotificationDefaultData = { message: 'Document Saved' }; this._notificationService?.peek('positive', { data }); @@ -129,8 +119,6 @@ export abstract class UmbWorkspaceContentContext< }); } - - // TODO: how can we make sure to call this. public destroy(): void { this._data.unsubscribe(); 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 6182985fa7..a02ae6475b 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 @@ -1,13 +1,12 @@ import { html } from 'lit'; import { customElement, property } from 'lit/decorators.js'; import type { UmbNotificationDefaultData } from '../../../../core/notification/layouts/default'; -import type { UmbNotificationService } from '../../../../core/notification'; +import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../../../../core/notification'; import type { UmbPropertyAction } from '../shared/property-action/property-action.model'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-property-action-copy') export class UmbPropertyActionCopyElement extends UmbLitElement implements UmbPropertyAction { - @property() value = ''; @@ -21,7 +20,7 @@ export class UmbPropertyActionCopyElement extends UmbLitElement implements UmbPr console.log('PROPERTY', property); }); - this.consumeContext('umbNotificationService', (notificationService: UmbNotificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; }); } 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 173df0fc7a..1feea1bda5 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 @@ -4,7 +4,7 @@ import { customElement, query, state } from 'lit/decorators.js'; import { UUIInputPasswordElement } from '@umbraco-ui/uui'; import { UmbInputPickerUserGroupElement } from 'src/auth/components/input-user-group/input-user-group.element'; import type { UserDetails } from '@umbraco-cms/models'; -import { UmbNotificationService } from 'src/core/notification'; +import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from 'src/core/notification'; import { UmbNotificationDefaultData } from 'src/core/notification/layouts/default'; import { UmbModalLayoutElement } from 'src/core/modal'; import { UmbUserStore } from 'src/backoffice/users/users/user.store'; @@ -63,9 +63,12 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement { connectedCallback(): void { super.connectedCallback(); - this.consumeAllContexts(['umbUserStore', 'umbNotificationService'], (instances) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._notificationService = _instance; + }); + + this.consumeAllContexts(['umbUserStore'], (instances) => { this._userStore = instances['umbUserStore']; - this._notificationService = instances['umbNotificationService']; }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.mdx b/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.mdx index 1809a23ce2..3dcf56a53c 100644 --- a/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.mdx +++ b/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.mdx @@ -21,7 +21,7 @@ The UmbNotification service can be used to open notifications. ```ts import { html, LitElement } from 'lit'; import { UmbLitElement } from '@umbraco-cms/element'; -import type { UmbNotificationService } from './core/services/notification'; +import type { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from './core/services/notification'; class MyElement extends UmbLitElement { private _notificationService?: UmbNotificationService; @@ -29,7 +29,7 @@ class MyElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbNotificationService', (notificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; // notificationService is now ready to be used }); @@ -45,7 +45,11 @@ A notification is opened by calling one of the helper methods on the UmbNotifica import { html, LitElement } from 'lit'; import { state } from 'lit/decorators.js'; import { UmbLitElement } from '@umbraco-cms/element'; -import type { UmbNotificationService, UmbNotificationDefaultData } from './core/services/notification'; +import type { + UmbNotificationService, + UmbNotificationDefaultData, + UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, +} from './core/services/notification'; class MyElement extends UmbLitElement { private _notificationService?: UmbNotificationService; @@ -53,7 +57,7 @@ class MyElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbNotificationService', (notificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; // notificationService is now ready to be used }); @@ -122,7 +126,11 @@ export class UmbNotificationLayoutCustom extends LitElement { ```ts import { html, LitElement } from 'lit'; import { UmbContextInjectMixin } from '@umbraco-cms/context-api'; -import type { UmbNotificationService, UmbNotificationOptions } from './core/services/notification'; +import type { + UmbNotificationService, + UmbNotificationOptions, + UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, +} from './core/services/notification'; import type { UmbNotificationCustomData } from './custom-notification-layout'; class MyElement extends LitElement { @@ -131,7 +139,7 @@ class MyElement extends LitElement { constructor() { super(); - this.consumeContext('umbNotificationService', (notificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; // notificationService is now ready to be used }); diff --git a/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.ts b/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.ts index 4f7c424035..7d2ce069a6 100644 --- a/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.ts +++ b/src/Umbraco.Web.UI.Client/src/core/notification/notification.stories.ts @@ -7,7 +7,12 @@ import { html } from 'lit'; import { customElement } from 'lit/decorators.js'; import type { UmbNotificationDefaultData } from './layouts/default'; -import { UmbNotificationColor, UmbNotificationOptions, UmbNotificationService } from '.'; +import { + UmbNotificationColor, + UmbNotificationOptions, + UmbNotificationService, + UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, +} from '.'; import { UmbLitElement } from '@umbraco-cms/element'; export default { @@ -28,7 +33,7 @@ export class StoryNotificationDefaultExampleElement extends UmbLitElement { connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbNotificationService', (notificationService) => { + this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (notificationService) => { this._notificationService = notificationService; }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/resources/resource.controller.ts b/src/Umbraco.Web.UI.Client/src/core/resources/resource.controller.ts index ae3776f47d..efa10c9060 100644 --- a/src/Umbraco.Web.UI.Client/src/core/resources/resource.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/resources/resource.controller.ts @@ -2,12 +2,15 @@ import { UmbController } from '../controller/controller.class'; import { UmbControllerHostInterface } from '../controller/controller-host.mixin'; import { UmbContextConsumerController } from '../context-api/consume/context-consumer.controller'; +import { + UmbNotificationOptions, + UmbNotificationService, + UmbNotificationDefaultData, + UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, +} from '../notification'; import { ApiError, CancelablePromise, ProblemDetails } from '@umbraco-cms/backend-api'; -import { UmbNotificationOptions, UmbNotificationService } from 'src/core/notification'; -import { UmbNotificationDefaultData } from 'src/core/notification/layouts/default'; export class UmbResourceController extends UmbController { - #promise: Promise; #notificationService?: UmbNotificationService; @@ -17,7 +20,7 @@ export class UmbResourceController extends UmbController { this.#promise = promise; - new UmbContextConsumerController(host, 'umbNotificationService', (_instance: UmbNotificationService) => { + new UmbContextConsumerController(host, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (_instance) => { this.#notificationService = _instance; }); } From 5c2e92e94ff1e7b3f7c10670774dfd7370bc4194 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:20:58 +0100 Subject: [PATCH 28/75] migrate umbModalService to ContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../workspace/document-type-workspace.element.ts | 6 +++--- .../tree/actions/action-document-delete.element.ts | 4 ++-- .../views/installed/packages-installed-item.element.ts | 4 ++-- .../views/section-view-examine-indexers.ts | 6 +++--- .../views/section-view-examine-searchers.ts | 6 +++--- .../dashboard-published-status.element.ts | 6 +++--- .../actions/delete/action-data-type-delete.element.ts | 4 ++-- .../edit/data-type-workspace-view-edit.element.ts | 9 ++++++--- .../backoffice-modal-container.element.ts | 4 ++-- .../input-document-picker.element.ts | 6 +++--- .../components/input-list-base/input-list-base.ts | 5 ++--- .../property-editor-ui-icon-picker.element.ts | 4 ++-- .../current-user/current-user-header-app.element.ts | 10 +++++++--- .../users/workspace-view-users-overview.element.ts | 6 +++--- .../modal/layouts/modal-layout-current-user.element.ts | 10 +++++++--- .../src/core/modal/modal.service.ts | 4 +++- .../src/core/modal/modal.stories.mdx | 10 +++++----- .../src/core/modal/modal.stories.ts | 4 ++-- 19 files changed, 62 insertions(+), 50 deletions(-) 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 b9ba923f12..25518c4b62 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -2,7 +2,7 @@ import { defineElement } from '@umbraco-ui/uui-base/lib/registration'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; -import { UmbModalService } from '../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../core/modal'; import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../core/notification'; import { UmbUserStore } from './users/users/user.store'; import { UmbUserGroupStore } from './users/user-groups/user-group.store'; @@ -53,7 +53,7 @@ export class UmbBackofficeElement extends UmbLitElement { constructor() { super(); - this.provideContext('umbModalService', new UmbModalService()); + this.provideContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, new UmbModalService()); this.provideContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, new UmbNotificationService()); // TODO: find a way this is possible outside this element. It needs to be possible to register stores in extensions diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.element.ts index 4ab87c39f5..ebea212444 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.element.ts @@ -5,7 +5,7 @@ import { customElement, property, state } from 'lit/decorators.js'; import { distinctUntilChanged } from 'rxjs'; import { UmbWorkspaceDocumentTypeContext } from './document-type-workspace.context'; import type { DocumentTypeDetails } from '@umbraco-cms/models'; -import { UmbModalService } from 'src/core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; import type { UmbWorkspaceEntityElement } from 'src/backoffice/shared/components/workspace/workspace-entity-element.interface'; @@ -73,13 +73,13 @@ export class UmbDocumentTypeWorkspaceElement extends UmbLitElement implements Um constructor() { super(); - this.consumeContext('umbModalService', (instance) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (instance) => { this._modalService = instance; }); this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (data) => { // TODO: make method to identify if data is of type DocumentTypeDetails - this._documentType = (data as DocumentTypeDetails); + this._documentType = data as DocumentTypeDetails; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts index 59bbc856c6..ca25c2c798 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; -import { UmbModalService } from '../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; import { UmbDocumentStore } from '../../document.store'; import UmbTreeItemActionElement from '../../../../shared/components/tree/action/tree-item-action.element'; @@ -15,7 +15,7 @@ export default class UmbTreeActionDocumentDeleteElement extends UmbTreeItemActio connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/packages-installed-item.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/packages-installed-item.element.ts index 05353b06cd..3d3527e312 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/packages-installed-item.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/installed/packages-installed-item.element.ts @@ -2,7 +2,7 @@ import { html, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import { firstValueFrom, map } from 'rxjs'; -import type { UmbModalService } from '../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; @@ -22,7 +22,7 @@ export class UmbPackagesInstalledItem extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._umbModalService = modalService; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts index 9a48b508cb..89ead70bc1 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-indexers.ts @@ -4,7 +4,7 @@ import { customElement, property, state } from 'lit/decorators.js'; import { UUIButtonState } from '@umbraco-ui/uui-button'; -import { UmbModalService } from '../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; import './section-view-examine-searchers'; @@ -97,8 +97,8 @@ export class UmbDashboardExamineIndexElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbModalService'], (instances) => { - this._modalService = instances['umbModalService']; + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._modalService = _instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts index 2a4f399099..5e8008b163 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/examine-management/views/section-view-examine-searchers.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html, nothing } from 'lit'; import { customElement, state, query, property } from 'lit/decorators.js'; -import { UmbModalService } from '../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; import { SearchResult, SearcherResource, Field } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -120,13 +120,13 @@ export class UmbDashboardExamineSearcherElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (instance) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (instance) => { this._modalService = instance; }); } private _onNameClick() { - // TODO: + // TODO: alert('TODO: Open workspace for ' + this.searcherName); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts index 5995c9aea8..48147dfc43 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/published-status/dashboard-published-status.element.ts @@ -3,7 +3,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbModalService } from '../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../core/modal'; import { PublishedCacheResource } from '@umbraco-cms/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; @@ -43,8 +43,8 @@ export class UmbDashboardPublishedStatusElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbModalService'], (instances) => { - this._modalService = instances['umbModalService']; + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._modalService = _instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts index 7bd5b8270e..ef044b1e84 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; -import { UmbModalService } from '../../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../../core/modal'; import { UmbDataTypeStore } from '../../../data-type.store'; import UmbTreeItemActionElement from '../../../../../shared/components/tree/action/tree-item-action.element'; @@ -15,7 +15,7 @@ export default class UmbTreeActionDataTypeDeleteElement extends UmbTreeItemActio connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts index c4eb4ee119..61e538a7f7 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbModalService } from '../../../../../../core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../../core/modal'; import { UmbWorkspaceDataTypeContext } from '../../data-type-workspace.context'; import { UmbLitElement } from '@umbraco-cms/element'; import type { DataTypeDetails } from '@umbraco-cms/models'; @@ -46,9 +46,12 @@ export class UmbDataTypeWorkspaceViewEditElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbWorkspaceContext', 'umbModalService'], (result) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._modalService = _instance; + }); + + this.consumeAllContexts(['umbWorkspaceContext'], (result) => { this._workspaceContext = result['umbWorkspaceContext']; - this._modalService = result['umbModalService']; this._observeDataType(); }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-modal-container.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-modal-container.element.ts index a216a45f2d..2300cf3f7c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-modal-container.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-modal-container.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; -import { UmbModalHandler, UmbModalService } from '../../../../core/modal'; +import { UmbModalHandler, UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-backoffice-modal-container') @@ -24,7 +24,7 @@ export class UmbBackofficeModalContainer extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; this._observeModals(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts index 47ae5ecaad..39dd4fa81a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts @@ -3,7 +3,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, property, state } from 'lit/decorators.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import { FormControlMixin } from '@umbraco-ui/uui-base/lib/mixins'; -import type { UmbModalService } from 'src/core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import type { FolderTreeItem } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; import type { UmbObserverController } from '@umbraco-cms/observable-api'; @@ -94,11 +94,11 @@ export class UmbInputDocumentPickerElement extends FormControlMixin(UmbLitElemen () => !!this.max && this._selectedKeys.length > this.max ); - this.consumeContext('umbDocumentStore', (instance) => { + this.consumeContext('umbDocumentStore', (instance: UmbDocumentStore) => { this._documentStore = instance; this._observePickedDocuments(); }); - this.consumeContext('umbModalService', (instance) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (instance) => { this._modalService = instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts index 2ee8808dce..344fc8a61f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-list-base/input-list-base.ts @@ -2,7 +2,7 @@ import { html } from 'lit'; import { property } from 'lit/decorators.js'; import { UUIModalSidebarSize } from '@umbraco-ui/uui-modal-sidebar'; import { UmbPickerData } from '../../../../core/modal/layouts/modal-layout-picker-base'; -import { UmbModalService, UmbModalType } from '../../../../core/modal'; +import { UmbModalService, UmbModalType, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../core/modal'; //TODO: These should probably be imported dynamically. import '../../../../core/modal/layouts/picker-section/picker-layout-section.element'; @@ -12,7 +12,6 @@ import { UmbLitElement } from '@umbraco-cms/element'; /** TODO: Make use of UUI FORM Mixin, to make it easily take part of a form. */ export class UmbInputListBase extends UmbLitElement { - @property({ type: Array }) public value: Array = []; @@ -30,7 +29,7 @@ export class UmbInputListBase extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts index 2fb03c08e8..11b5eb2641 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts @@ -1,7 +1,7 @@ import { html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, property } from 'lit/decorators.js'; -import type { UmbModalService } from 'src/core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; /** @@ -21,7 +21,7 @@ export class UmbPropertyEditorUIIconPickerElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts index 2cbc66df2c..bf67fc141e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts @@ -3,7 +3,7 @@ import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbCurrentUserStore } from './current-user.store'; import type { UserDetails } from '@umbraco-cms/models'; -import { UmbModalService } from 'src/core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-current-user-header-app') @@ -25,9 +25,13 @@ export class UmbCurrentUserHeaderApp extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbCurrentUserStore', 'umbModalService'], (instances) => { + + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._modalService = _instance; + }); + + this.consumeAllContexts(['umbCurrentUserStore'], (instances) => { this._currentUserStore = instances['umbCurrentUserStore']; - this._modalService = instances['umbModalService']; this._observeCurrentUser(); }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts index cfc5518a70..99617801c1 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-overview.element.ts @@ -5,8 +5,8 @@ import { IRoute } from 'router-slot'; import { UUIPopoverElement } from '@umbraco-ui/uui'; import type { UmbSectionViewUsersElement } from './section-view-users.element'; -import { UmbLitElement } from '@umbraco-cms/element'; -import { UmbModalService } from 'src/core/modal'; +import { UmbLitElement } from '@umbraco-cms/element'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import './list-view-layouts/table/workspace-view-users-table.element'; import './list-view-layouts/grid/workspace-view-users-grid.element'; @@ -114,7 +114,7 @@ export class UmbWorkspaceViewUsersOverviewElement extends UmbLitElement { this._observeSelection(); }); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts index 2cc868caca..129d47221f 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; -import { UmbModalHandler, UmbModalService } from '..'; +import { UmbModalHandler, UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '..'; import type { UserDetails } from '@umbraco-cms/models'; import { UmbCurrentUserHistoryStore, @@ -89,8 +89,12 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbModalService', 'umbCurrentUserStore', 'umbCurrentUserHistoryStore'], (instances) => { - this._modalService = instances['umbModalService']; + + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (_instance) => { + this._modalService = _instance; + }); + + this.consumeAllContexts(['umbCurrentUserStore', 'umbCurrentUserHistoryStore'], (instances) => { this._currentUserStore = instances['umbCurrentUserStore']; this._currentUserHistoryStore = instances['umbCurrentUserHistoryStore']; this._observeHistory(); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts index 40b6667e6e..018a7282fa 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts @@ -15,6 +15,7 @@ import type { UmbModalConfirmData } from './layouts/confirm/modal-layout-confirm import type { UmbModalContentPickerData } from './layouts/content-picker/modal-layout-content-picker.element'; import type { UmbModalPropertyEditorUIPickerData } from './layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element'; import { UmbModalHandler } from '.'; +import { ContextAlias } from '../context-api/context-token'; export type UmbModalType = 'dialog' | 'sidebar'; @@ -26,7 +27,6 @@ export interface UmbModalOptions { // TODO: Should this be called UmbModalContext ? as we don't have 'services' as a term. export class UmbModalService { - #modals = new BehaviorSubject(>[]); public readonly modals = this.#modals.asObservable(); @@ -132,3 +132,5 @@ export class UmbModalService { this._close(modalHandler.key); } } + +export const UMB_MODAL_SERVICE_CONTEXT_ALIAS = new ContextAlias(UmbModalService.name); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.mdx b/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.mdx index f150e2be2a..69ad42fa30 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.mdx +++ b/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.mdx @@ -25,12 +25,12 @@ The UmbModal service can be used to open modals. ```ts import { html, LitElement } from 'lit'; import { UmbLitElement } from '@umbraco-cms/element'; -import type { UmbModalService } from './core/services/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from './core/services/modal'; class MyElement extends UmbLitElement { private _modalService_?: UmbModalService; constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; // modalService is now ready to be used. }); @@ -45,13 +45,13 @@ A modal is opened by calling one of the helper methods on the UmbModalService. T ```ts import { html, LitElement } from 'lit'; import { UmbLitElement } from '@umbraco-cms/element'; -import type { UmbModalService } from './core/services/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from './core/services/modal'; class MyElement extends UmbLitElement { private _modalService?: UmbModalService; constructor() { super(); - this.consumeContext('umbModalService', (modalService) => { - this._modalService = modalService.; + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { + this._modalService = modalService; // modalService is now ready to be used }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.ts b/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.ts index 891322ce64..d22fa03015 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/modal.stories.ts @@ -2,7 +2,7 @@ import { Meta, Story } from '@storybook/web-components'; import { html } from 'lit-html'; import { customElement, property, state } from 'lit/decorators.js'; -import { UmbModalService } from '.'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '.'; import { UmbLitElement } from '@umbraco-cms/element'; export default { @@ -28,7 +28,7 @@ export class StoryModalServiceExampleElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbModalService', (modalService: UmbModalService) => { + this.consumeContext(UMB_MODAL_SERVICE_CONTEXT_ALIAS, (modalService) => { this._modalService = modalService; }); } From 450ca9b638948ef57b9e03092965d2ddcbca8b08 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:21:51 +0100 Subject: [PATCH 29/75] clean imports --- .../workspace/language/language-workspace.element.ts | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts index 5c9106baa6..72a759a89c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/languages/workspace/language/language-workspace.element.ts @@ -1,17 +1,14 @@ -import { UmbLitElement } from '@umbraco-cms/element'; -import { html, LitElement } from 'lit'; +import { html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from 'src/core/notification'; +import { UmbLitElement } from '@umbraco-cms/element'; + @customElement('umb-language-workspace') export class UmbLanguageWorkspaceElement extends UmbLitElement { constructor() { super(); this.consumeContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, (service) => { - console.log( - '🚀 ~ file: language-workspace.element.ts:11 ~ UmbLanguageWorkspaceElement ~ this.consumeContext ~ service', - service - ); service.peek('positive', { data: { message: 'Language Workspace' } }); }); } From f7fc73b2d4b52e10a4579f0c49e14232f993d76e Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 11:25:58 +0100 Subject: [PATCH 30/75] allow alias to be undefined --- .../src/core/context-api/consume/context-consumer.controller.ts | 2 +- .../src/core/controller/controller.class.ts | 2 +- .../src/core/controller/controller.interface.ts | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index d2a264a7df..77e07e74b7 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -9,7 +9,7 @@ export class UmbContextConsumerController implements UmbControllerInterface { public get unique() { - return this._contextAlias?.toString(); + return this._contextAlias.toString(); } constructor( diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts b/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts index 757dc4cb89..c34be538a7 100644 --- a/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts +++ b/src/Umbraco.Web.UI.Client/src/core/controller/controller.class.ts @@ -6,7 +6,7 @@ export abstract class UmbController implements UmbControllerInterface { private _alias?: string; public get unique() { - return this._alias ?? UmbController.name; + return this._alias; } constructor(host: UmbControllerHostInterface, alias?: string) { diff --git a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts index 5ab80dd0a1..f8feb3ff9c 100644 --- a/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts +++ b/src/Umbraco.Web.UI.Client/src/core/controller/controller.interface.ts @@ -1,5 +1,5 @@ export interface UmbControllerInterface { - get unique(): string; + get unique(): string | undefined; hostConnected(): void; hostDisconnected(): void; destroy(): void; From e10c443aaa58d95d3e50a5a7bb62d89632e52582 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 13:38:15 +0100 Subject: [PATCH 31/75] add + fix tests --- .../consume/context-consumer.test.ts | 20 ++++++++++++++++++- .../context-api/consume/context-consumer.ts | 8 ++++---- .../consume/context-request.event.ts | 14 ++++++------- .../provide/context-provider.test.ts | 14 +++++++++++++ 4 files changed, 44 insertions(+), 12 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts index 07d32cf870..bb44fdcf89 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts @@ -1,4 +1,5 @@ import { expect, oneEvent } from '@open-wc/testing'; +import { ContextAlias } from '../context-token'; import { UmbContextProvider } from '../provide/context-provider'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextRequestEventImplementation, umbContextRequestEventType } from './context-request.event'; @@ -45,7 +46,24 @@ describe('UmbContextConsumer', () => { const element = document.createElement('div'); document.body.appendChild(element); - const localConsumer = new UmbContextConsumer(element, testContextAlias, (_instance) => { + const localConsumer = new UmbContextConsumer(element, testContextAlias, (_instance: MyClass) => { + expect(_instance.prop).to.eq('value from provider'); + done(); + }); + localConsumer.hostConnected(); + + provider.hostDisconnected(); + }); + + it('works with ContextAlias', (done) => { + const CONTEXT_ALIAS = new ContextAlias(testContextAlias); + const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); + provider.hostConnected(); + + const element = document.createElement('div'); + document.body.appendChild(element); + + const localConsumer = new UmbContextConsumer(element, CONTEXT_ALIAS, (_instance) => { expect(_instance.prop).to.eq('value from provider'); done(); }); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index b37c798657..a8281d557b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -7,8 +7,8 @@ import { UmbContextRequestEventImplementation, UmbContextCallback } from './cont * @class UmbContextConsumer */ export class UmbContextConsumer { - private _instance?: unknown; - get instance(): unknown | undefined { + private _instance?: T; + get instance() { return this._instance; } @@ -25,11 +25,11 @@ export class UmbContextConsumer, private _callback: UmbContextCallback ) {} - private _onResponse = (instance: any) => { + private _onResponse = (instance: T) => { this._instance = instance; this._callback(instance); }; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index 4d25b0f317..9074259368 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -2,15 +2,15 @@ import { ContextAlias } from '../context-token'; export const umbContextRequestEventType = 'umb:context-request'; -export type UmbContextCallback = (instance: T) => void; +export type UmbContextCallback = (instance: T) => void; /** * @export * @interface UmbContextRequestEvent */ -export interface UmbContextRequestEvent extends Event { - readonly contextAlias: string | ContextAlias; - readonly callback: UmbContextCallback; +export interface UmbContextRequestEvent extends Event { + readonly contextAlias: string | ContextAlias; + readonly callback: UmbContextCallback; } /** @@ -19,10 +19,10 @@ export interface UmbContextRequestEvent extends Event { * @extends {Event} * @implements {UmbContextRequestEvent} */ -export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { +export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { public constructor( - public readonly contextAlias: string | ContextAlias, - public readonly callback: UmbContextCallback + public readonly contextAlias: string | ContextAlias, + public readonly callback: UmbContextCallback ) { super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts index 0d864cd608..d053ed97fe 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts @@ -1,6 +1,7 @@ import { expect } from '@open-wc/testing'; import { UmbContextConsumer } from '../consume/context-consumer'; import { UmbContextRequestEventImplementation } from '../consume/context-request.event'; +import { ContextAlias } from '../context-token'; import { UmbContextProvider } from './context-provider'; class MyClass { @@ -57,4 +58,17 @@ describe('UmbContextProvider', () => { }); localConsumer.hostConnected(); }); + + it('works with ContextAlias', (done) => { + const CONTEXT_ALIAS = new ContextAlias(MyClass.name); + const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); + provider.hostConnected(); + + const localConsumer = new UmbContextConsumer(document.body, CONTEXT_ALIAS, (_instance: MyClass) => { + expect(_instance.prop).to.eq('value from provider'); + localConsumer.hostDisconnected(); + done(); + }); + localConsumer.hostConnected(); + }); }); From 08ffc547d8ef303c7918c55639cfd85e1480ab37 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 13:39:37 +0100 Subject: [PATCH 32/75] rename ContextAlias to UmbContextAlias --- .../context-api/consume/context-consumer.controller.ts | 4 ++-- .../core/context-api/consume/context-consumer.test.ts | 4 ++-- .../src/core/context-api/consume/context-consumer.ts | 4 ++-- .../core/context-api/consume/context-request.event.ts | 6 +++--- .../context-api/{context-token.ts => context-alias.ts} | 8 ++++---- .../src/core/context-api/index.ts | 2 +- .../core/context-api/provide/context-provide.event.ts | 6 +++--- .../context-api/provide/context-provider.controller.ts | 4 ++-- .../core/context-api/provide/context-provider.test.ts | 4 ++-- .../src/core/context-api/provide/context-provider.ts | 6 +++--- .../src/core/element/element.mixin.ts | 10 +++++----- .../src/core/modal/modal.service.ts | 4 ++-- .../src/core/notification/notification.service.ts | 4 ++-- 13 files changed, 33 insertions(+), 33 deletions(-) rename src/Umbraco.Web.UI.Client/src/core/context-api/{context-token.ts => context-alias.ts} (59%) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index 77e07e74b7..5cbb4aa2a0 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -1,4 +1,4 @@ -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextCallback } from './context-request.event'; @@ -14,7 +14,7 @@ export class UmbContextConsumerController constructor( host: UmbControllerHostInterface, - contextAlias: string | ContextAlias, + contextAlias: string | UmbContextAlias, callback: UmbContextCallback ) { super(host, contextAlias, callback); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts index bb44fdcf89..1bd94e9352 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts @@ -1,5 +1,5 @@ import { expect, oneEvent } from '@open-wc/testing'; -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { UmbContextProvider } from '../provide/context-provider'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextRequestEventImplementation, umbContextRequestEventType } from './context-request.event'; @@ -56,7 +56,7 @@ describe('UmbContextConsumer', () => { }); it('works with ContextAlias', (done) => { - const CONTEXT_ALIAS = new ContextAlias(testContextAlias); + const CONTEXT_ALIAS = new UmbContextAlias(testContextAlias); const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); provider.hostConnected(); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index a8281d557b..db88b7cfc5 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -1,4 +1,4 @@ -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { isUmbContextProvideEventType, umbContextProvideEventType } from '../provide/context-provide.event'; import { UmbContextRequestEventImplementation, UmbContextCallback } from './context-request.event'; @@ -25,7 +25,7 @@ export class UmbContextConsumer, + protected _contextAlias: string | UmbContextAlias, private _callback: UmbContextCallback ) {} diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts index 9074259368..4dfc6d1127 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-request.event.ts @@ -1,4 +1,4 @@ -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; export const umbContextRequestEventType = 'umb:context-request'; @@ -9,7 +9,7 @@ export type UmbContextCallback = (instance: T) => void; * @interface UmbContextRequestEvent */ export interface UmbContextRequestEvent extends Event { - readonly contextAlias: string | ContextAlias; + readonly contextAlias: string | UmbContextAlias; readonly callback: UmbContextCallback; } @@ -21,7 +21,7 @@ export interface UmbContextRequestEvent extends Event { */ export class UmbContextRequestEventImplementation extends Event implements UmbContextRequestEvent { public constructor( - public readonly contextAlias: string | ContextAlias, + public readonly contextAlias: string | UmbContextAlias, public readonly callback: UmbContextCallback ) { super(umbContextRequestEventType, { bubbles: true, composed: true, cancelable: true }); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts similarity index 59% rename from src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts rename to src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts index 59b00c092f..0bdc5d4495 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/context-token.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts @@ -1,4 +1,4 @@ -export class ContextAlias { +export class UmbContextAlias { /** * @param _desc Description for the token, * used only for debugging purposes, @@ -9,11 +9,11 @@ export class ContextAlias { /** * @internal */ - get multi(): ContextAlias> { - return this as ContextAlias>; + get multi(): UmbContextAlias> { + return this as UmbContextAlias>; } toString(): string { - return `${ContextAlias.name} ${this._desc}`; + return `${UmbContextAlias.name} ${this._desc}`; } } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts index 67aaa8edcf..fa0e18d989 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/index.ts @@ -4,4 +4,4 @@ export * from './consume/context-request.event'; export * from './provide/context-provider.controller'; export * from './provide/context-provider'; export * from './provide/context-provide.event'; -export * from './context-token'; +export * from './context-alias'; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts index 69bbecabb2..3b3da50808 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provide.event.ts @@ -1,4 +1,4 @@ -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; export const umbContextProvideEventType = 'umb:context-provide'; @@ -7,7 +7,7 @@ export const umbContextProvideEventType = 'umb:context-provide'; * @interface UmbContextProvideEvent */ export interface UmbContextProvideEvent extends Event { - readonly contextAlias: string | ContextAlias; + readonly contextAlias: string | UmbContextAlias; } /** @@ -17,7 +17,7 @@ export interface UmbContextProvideEvent extends Event { * @implements {UmbContextProvideEvent} */ export class UmbContextProvideEventImplementation extends Event implements UmbContextProvideEvent { - public constructor(public readonly contextAlias: string | ContextAlias) { + public constructor(public readonly contextAlias: string | UmbContextAlias) { super(umbContextProvideEventType, { bubbles: true, composed: true }); } } diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts index 643d2f82e2..dbddce98ba 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.controller.ts @@ -1,4 +1,4 @@ -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { UmbContextProvider } from './context-provider'; import type { UmbControllerHostInterface, UmbControllerInterface } from '@umbraco-cms/controller'; @@ -10,7 +10,7 @@ export class UmbContextProviderController return this._contextAlias.toString(); } - constructor(host: UmbControllerHostInterface, contextAlias: string | ContextAlias, instance: T) { + constructor(host: UmbControllerHostInterface, contextAlias: string | UmbContextAlias, instance: T) { super(host, contextAlias, instance); // TODO: What if this API is already provided with this alias? maybe handle this in the controller: diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts index d053ed97fe..be1e39480d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts @@ -1,7 +1,7 @@ import { expect } from '@open-wc/testing'; import { UmbContextConsumer } from '../consume/context-consumer'; import { UmbContextRequestEventImplementation } from '../consume/context-request.event'; -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { UmbContextProvider } from './context-provider'; class MyClass { @@ -60,7 +60,7 @@ describe('UmbContextProvider', () => { }); it('works with ContextAlias', (done) => { - const CONTEXT_ALIAS = new ContextAlias(MyClass.name); + const CONTEXT_ALIAS = new UmbContextAlias(MyClass.name); const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); provider.hostConnected(); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts index 8776066ad1..2e6afb429e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts @@ -1,5 +1,5 @@ import { umbContextRequestEventType, isUmbContextRequestEvent } from '../consume/context-request.event'; -import { ContextAlias } from '../context-token'; +import { UmbContextAlias } from '../context-alias'; import { UmbContextProvideEventImplementation } from './context-provide.event'; /** @@ -9,7 +9,7 @@ import { UmbContextProvideEventImplementation } from './context-provide.event'; export class UmbContextProvider { protected host: HostType; - protected _contextAlias: string | ContextAlias; + protected _contextAlias: string | UmbContextAlias; #instance: unknown; /** @@ -19,7 +19,7 @@ export class UmbContextProvider { * @param {*} instance * @memberof UmbContextProvider */ - constructor(host: HostType, contextAlias: string | ContextAlias, instance: unknown) { + constructor(host: HostType, contextAlias: string | UmbContextAlias, instance: unknown) { this.host = host; this._contextAlias = contextAlias; this.#instance = instance; diff --git a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts index d83a56c6ef..f041a60ffe 100644 --- a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts +++ b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts @@ -4,7 +4,7 @@ import type { HTMLElementConstructor } from '../models'; import { UmbControllerHostInterface, UmbControllerHostMixin } from '@umbraco-cms/controller'; import { - ContextAlias, + UmbContextAlias, UmbContextCallback, UmbContextConsumerController, UmbContextProviderController, @@ -18,9 +18,9 @@ interface ResolvedContexts { export declare class UmbElementMixinInterface extends UmbControllerHostInterface { observe(source: Observable, callback: (_value: T) => void, unique?: string): UmbObserverController; - provideContext(alias: string | ContextAlias, instance: R): UmbContextProviderController; + provideContext(alias: string | UmbContextAlias, instance: R): UmbContextProviderController; consumeContext( - alias: string | ContextAlias, + alias: string | UmbContextAlias, callback: UmbContextCallback ): UmbContextConsumerController; consumeAllContexts(contextAliases: string[], callback: (_instances: ResolvedContexts) => void): void; @@ -46,7 +46,7 @@ export const UmbElementMixin = (superClass: T) * @return {UmbContextProviderController} Reference to a Context Provider Controller instance * @memberof UmbElementMixin */ - provideContext(alias: string | ContextAlias, instance: R): UmbContextProviderController { + provideContext(alias: string | UmbContextAlias, instance: R): UmbContextProviderController { return new UmbContextProviderController(this, alias, instance); } @@ -58,7 +58,7 @@ export const UmbElementMixin = (superClass: T) * @memberof UmbElementMixin */ consumeContext( - alias: string | ContextAlias, + alias: string | UmbContextAlias, callback: UmbContextCallback ): UmbContextConsumerController { return new UmbContextConsumerController(this, alias, callback); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts index 018a7282fa..480a8694b3 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts @@ -6,6 +6,7 @@ import './layouts/modal-layout-current-user.element'; import { UUIModalSidebarSize } from '@umbraco-ui/uui-modal-sidebar'; import { BehaviorSubject } from 'rxjs'; +import { UmbContextAlias } from '../context-api/context-alias'; import { UmbModalChangePasswordData } from './layouts/modal-layout-change-password.element'; import type { UmbModalIconPickerData } from './layouts/icon-picker/modal-layout-icon-picker.element'; @@ -15,7 +16,6 @@ import type { UmbModalConfirmData } from './layouts/confirm/modal-layout-confirm import type { UmbModalContentPickerData } from './layouts/content-picker/modal-layout-content-picker.element'; import type { UmbModalPropertyEditorUIPickerData } from './layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element'; import { UmbModalHandler } from '.'; -import { ContextAlias } from '../context-api/context-token'; export type UmbModalType = 'dialog' | 'sidebar'; @@ -133,4 +133,4 @@ export class UmbModalService { } } -export const UMB_MODAL_SERVICE_CONTEXT_ALIAS = new ContextAlias(UmbModalService.name); +export const UMB_MODAL_SERVICE_CONTEXT_ALIAS = new UmbContextAlias(UmbModalService.name); diff --git a/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts b/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts index 96143af559..97686ccf7a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts +++ b/src/Umbraco.Web.UI.Client/src/core/notification/notification.service.ts @@ -1,6 +1,6 @@ import { BehaviorSubject } from 'rxjs'; import { UmbNotificationHandler } from '.'; -import { ContextAlias } from '@umbraco-cms/context-api'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbNotificationData = any; @@ -86,6 +86,6 @@ export class UmbNotificationService { } } -export const UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS = new ContextAlias( +export const UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS = new UmbContextAlias( UmbNotificationService.name ); From c8eafb6dc5f3ba95a5b981b02a8c5c3f23177509 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 14:01:17 +0100 Subject: [PATCH 33/75] eliminate the need for consumeAllContexts + add deprecation notice --- ...space-view-document-type-design.element.ts | 3 +- .../data-type-workspace-view-edit.element.ts | 5 ++-- .../current-user-header-app.element.ts | 4 +-- .../grid/workspace-view-users-grid.element.ts | 18 ++++++------ .../workspace-view-users-table.element.ts | 11 ++++--- .../views/users/section-view-users.element.ts | 13 ++++----- .../workspace-view-users-create.element.ts | 4 +-- .../src/core/element/element.mixin.ts | 1 + .../modal-layout-current-user.element.ts | 10 +++++-- .../src/stories/umbelement.stories.mdx | 29 ++++++++++++------- 10 files changed, 57 insertions(+), 41 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/views/design/workspace-view-document-type-design.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/views/design/workspace-view-document-type-design.element.ts index 18c2003e3f..ef831cf3c7 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/views/design/workspace-view-document-type-design.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/views/design/workspace-view-document-type-design.element.ts @@ -18,7 +18,8 @@ export class UmbWorkspaceViewDocumentTypeDesignElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (documentTypeContext) => { + // TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextAlias + this.consumeContext('umbWorkspaceContext', (documentTypeContext) => { this._workspaceContext = documentTypeContext; this._observeDocumentType(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts index 61e538a7f7..c0571e9665 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/edit/data-type-workspace-view-edit.element.ts @@ -50,8 +50,9 @@ export class UmbDataTypeWorkspaceViewEditElement extends UmbLitElement { this._modalService = _instance; }); - this.consumeAllContexts(['umbWorkspaceContext'], (result) => { - this._workspaceContext = result['umbWorkspaceContext']; + // TODO: Figure out if this is the best way to consume a context or if it could be strongly typed using UmbContextAlias + this.consumeContext('umbWorkspaceContext', (_instance) => { + this._workspaceContext = _instance; this._observeDataType(); }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts index bf67fc141e..f20f6952a5 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts @@ -30,8 +30,8 @@ export class UmbCurrentUserHeaderApp extends UmbLitElement { this._modalService = _instance; }); - this.consumeAllContexts(['umbCurrentUserStore'], (instances) => { - this._currentUserStore = instances['umbCurrentUserStore']; + this.consumeContext('umbCurrentUserStore', (_instance) => { + this._currentUserStore = _instance; this._observeCurrentUser(); }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts index 3bbe72aadc..4695ca9df8 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts @@ -5,7 +5,7 @@ import { repeat } from 'lit/directives/repeat.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import type { UmbSectionViewUsersElement } from '../../section-view-users.element'; import { getTagLookAndColor } from '../../../../../../../auth/utils'; -import type { UserDetails, UserEntity, UserGroupDetails, UserGroupEntity } from '@umbraco-cms/models'; +import type { UserDetails, UserEntity, UserGroupEntity } from '@umbraco-cms/models'; import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -54,11 +54,14 @@ export class UmbWorkspaceViewUsersGridElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbUserGroupStore', 'umbUsersContext'], (instances) => { - this._userGroupStore = instances['umbUserGroupStore']; - this._usersContext = instances['umbUsersContext']; - this._observeUsers(); + this.consumeContext('umbUserGroupStore', (instance) => { + this._userGroupStore = instance; this._observeUserGroups(); + }); + + this.consumeContext('umbUsersContext', (_instance) => { + this._usersContext = _instance; + this._observeUsers(); this._observeSelection(); }); } @@ -72,10 +75,7 @@ export class UmbWorkspaceViewUsersGridElement extends UmbLitElement { private _observeUserGroups() { if (!this._userGroupStore) return; - this.observe( - this._userGroupStore.getAll(), - (userGroups) => (this._userGroups = userGroups) - ); + this.observe(this._userGroupStore.getAll(), (userGroups) => (this._userGroups = userGroups)); } private _observeSelection() { diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts index b1529a7035..ab3cab4139 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts @@ -76,11 +76,14 @@ export class UmbWorkspaceViewUsersTableElement extends UmbLitElement { constructor() { super(); - this.consumeAllContexts(['umbUserGroupStore', 'umbUsersContext'], (instances) => { - this._userGroupStore = instances['umbUserGroupStore']; - this._usersContext = instances['umbUsersContext']; - this._observeUsers(); + this.consumeContext('umbUserGroupStore', (instance) => { + this._userGroupStore = instance; this._observeUserGroups(); + }); + + this.consumeContext('umbUsersContext', (_instance) => { + this._usersContext = _instance; + this._observeUsers(); this._observeSelection(); }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts index 56b5bd1a62..7525f525e0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts @@ -30,7 +30,6 @@ export class UmbSectionViewUsersElement extends UmbLitElement { private _workspaces: Array = []; - // TODO: This must be turned into context api: Maybe its a Collection View (SectionView Collection View)? private _userStore?: UmbUserStore; @@ -43,14 +42,14 @@ export class UmbSectionViewUsersElement extends UmbLitElement { #search = new UniqueBehaviorSubject(''); public readonly search = this.#search.asObservable(); - constructor() { super(); - this.consumeAllContexts(['umbUserStore', 'umbUserGroupStore', 'umbUsersContext'], (instances) => { - this._userStore = instances['umbUserStore']; + this.consumeContext('umbUserStore', (_instance) => { + this._userStore = _instance; this._observeUsers(); }); + // TODO: consider this context name, is it to broad? // TODO: Stop using it self as a context api. this.provideContext('umbUsersContext', this); @@ -97,9 +96,7 @@ export class UmbSectionViewUsersElement extends UmbLitElement { if (!this._userStore) return; if (this.#search.getValue()) { - this.observe(this._userStore.getByName(this.#search.getValue()), (users) => - this.#users.next(users) - ); + this.observe(this._userStore.getByName(this.#search.getValue()), (users) => this.#users.next(users)); } else { this.observe(this._userStore.getAll(), (users) => this.#users.next(users)); } @@ -119,7 +116,7 @@ export class UmbSectionViewUsersElement extends UmbLitElement { public select(key: string) { const oldSelection = this.#selection.getValue(); - if(oldSelection.indexOf(key) !== -1) return; + if (oldSelection.indexOf(key) !== -1) return; this.#selection.next([...oldSelection, key]); this.requestUpdate('selection'); 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 1feea1bda5..88d56f7a46 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 @@ -67,8 +67,8 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement { this._notificationService = _instance; }); - this.consumeAllContexts(['umbUserStore'], (instances) => { - this._userStore = instances['umbUserStore']; + this.consumeContext('umbUserStore', (_instance) => { + this._userStore = _instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts index f041a60ffe..99bd7471fc 100644 --- a/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts +++ b/src/Umbraco.Web.UI.Client/src/core/element/element.mixin.ts @@ -69,6 +69,7 @@ export const UmbElementMixin = (superClass: T) * @param {string} aliases * @param {method} callback Callback method called when all contexts are resolved. * @memberof UmbElementMixin + * @deprecated it should not be necessary to consume multiple contexts at once, use consumeContext instead with an UmbContextAlias */ consumeAllContexts(_contextAliases: Array, callback: (_instances: ResolvedContexts) => void) { let resolvedAmount = 0; diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts index 129d47221f..83a6726dad 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts @@ -94,9 +94,13 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement { this._modalService = _instance; }); - this.consumeAllContexts(['umbCurrentUserStore', 'umbCurrentUserHistoryStore'], (instances) => { - this._currentUserStore = instances['umbCurrentUserStore']; - this._currentUserHistoryStore = instances['umbCurrentUserHistoryStore']; + this.consumeContext('umbCurrentUserStore', (_instance) => { + this._currentUserStore = _instance; + this._observeCurrentUser(); + }); + + this.consumeContext('umbCurrentUserHistoryStore', (_instance) => { + this._currentUserHistoryStore = _instance; this._observeHistory(); }); diff --git a/src/Umbraco.Web.UI.Client/src/stories/umbelement.stories.mdx b/src/Umbraco.Web.UI.Client/src/stories/umbelement.stories.mdx index 65990879dd..c00203099e 100644 --- a/src/Umbraco.Web.UI.Client/src/stories/umbelement.stories.mdx +++ b/src/Umbraco.Web.UI.Client/src/stories/umbelement.stories.mdx @@ -8,23 +8,32 @@ This element can be used as the base of any Element. Do this if you need to Observe Data, Consume or Provide a Context API or use a Resource. The Element implements the Controller Host and provides a few shortcut methods for initializing some Controllers. -The methods are (*note this can be out of date, we need to look into how we can ensure this Doc originates from code.*) +The methods are (_note this can be out of date, we need to look into how we can ensure this Doc originates from code._) -```` +``` observe(source: Observable, callback: (_value: T) => void, unique?: string): UmbObserverController -provideContext(alias: string, instance: unknown): UmbContextProviderController +provideContext(alias: string | UmbContextAlias, instance: R): UmbContextProviderController -consumeContext(alias: string, callback: UmbContextCallback): UmbContextConsumerController +consumeContext(alias: string | UmbContextAlias, callback: UmbContextCallback): UmbContextConsumerController +``` -consumeAllContexts(_contextAliases: Array, callback: (_instances: ResolvedContexts) => void) -```` +Use these for an smooth consumption, like this request for a Context API using a simple string context, where the callback value is unknown -Use these for an smooth consumption, like this request for a Context API. - -```` +``` this.consumeContext('requestThisContextAlias', (context) => { // Notice this is a subscription, as context might change or a new one appears. console.log("I've got the context", context); }); -```` +``` + +Or use the UmbContextAlias type to define the type of the context, like this + +``` +const contextAlias = new UmbContextAlias('description of context for debugging purposes'); + +this.consumeContext(contextAlias, (context) => { + // Notice this is a subscription, as context might change or a new one appears, but the value is strongly typed + console.log("I've got the context", context); +}); +``` From 360b8e06276a477a7cbcc0fd44777886c7138cc7 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 14:03:29 +0100 Subject: [PATCH 34/75] add generics to workspace --- .../info/workspace-view-data-type-info.element.ts | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/info/workspace-view-data-type-info.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/info/workspace-view-data-type-info.element.ts index 5180894c9a..d532e3912f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/info/workspace-view-data-type-info.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/views/info/workspace-view-data-type-info.element.ts @@ -18,7 +18,8 @@ export class UmbWorkspaceViewDataTypeInfoElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (dataTypeContext) => { + // TODO: Figure out if this is the best way to consume the context or if it can be strongly typed with an UmbContextAlias + this.consumeContext('umbWorkspaceContext', (dataTypeContext) => { this._workspaceContext = dataTypeContext; this._observeDataType(); }); @@ -28,11 +29,11 @@ export class UmbWorkspaceViewDataTypeInfoElement extends UmbLitElement { if (!this._workspaceContext) return; this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (dataType) => { - if(!dataType) return; + if (!dataType) return; // TODO: handle if model is not of the type wanted. // TODO: Make method to identify wether data is of type DataTypeDetails - this._dataType = (dataType as DataTypeDetails); + this._dataType = dataType as DataTypeDetails; }); } @@ -46,13 +47,11 @@ export class UmbWorkspaceViewDataTypeInfoElement extends UmbLitElement {
${this._dataType?.key}
- +
${this._dataType?.propertyEditorModelAlias}
- +
${this._dataType?.propertyEditorUIAlias}
From 6fde96e49997adabb87561f9ffca9f74bc565e23 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:03:13 +0100 Subject: [PATCH 35/75] migrate umbCurrentUserStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../users/current-user/current-user-header-app.element.ts | 4 ++-- .../backoffice/users/current-user/current-user.store.ts | 3 +++ .../users/users/workspace/user-workspace.element.ts | 4 ++-- .../modal/layouts/modal-layout-current-user.element.ts | 7 +++++-- 5 files changed, 14 insertions(+), 8 deletions(-) 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 25518c4b62..481efda031 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -6,7 +6,7 @@ import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../core/modal' import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../core/notification'; import { UmbUserStore } from './users/users/user.store'; import { UmbUserGroupStore } from './users/user-groups/user-group.store'; -import { UmbCurrentUserStore } from './users/current-user/current-user.store'; +import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store'; import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store'; import { UmbDocumentTypeStore } from './documents/document-types/document-type.store'; @@ -57,7 +57,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS, new UmbNotificationService()); // TODO: find a way this is possible outside this element. It needs to be possible to register stores in extensions - this.provideContext('umbCurrentUserStore', new UmbCurrentUserStore()); + this.provideContext(UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, new UmbCurrentUserStore()); this.provideContext('umbDocumentStore', new UmbDocumentStore(this)); this.provideContext('umbMediaStore', new UmbMediaStore(this)); this.provideContext('umbDataTypeStore', new UmbDataTypeStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts index f20f6952a5..400421e19e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-header-app.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbCurrentUserStore } from './current-user.store'; +import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './current-user.store'; import type { UserDetails } from '@umbraco-cms/models'; import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -30,7 +30,7 @@ export class UmbCurrentUserHeaderApp extends UmbLitElement { this._modalService = _instance; }); - this.consumeContext('umbCurrentUserStore', (_instance) => { + this.consumeContext(UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, (_instance) => { this._currentUserStore = _instance; this._observeCurrentUser(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user.store.ts index 8acd9daea9..269678f302 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user.store.ts @@ -2,6 +2,7 @@ import { BehaviorSubject, Observable } from 'rxjs'; import { umbUsersData } from '../../../core/mocks/data/users.data'; import type { UserDetails } from '@umbraco-cms/models'; import { umbracoPath } from '@umbraco-cms/utils'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export class UmbCurrentUserStore { private _currentUser = new BehaviorSubject(umbUsersData.getAll()[0]); //TODO: Temp solution to set the first user as the current logged in user @@ -26,3 +27,5 @@ export class UmbCurrentUserStore { return this._currentUser.getValue()?.userGroups.includes(adminUserGroupKey); } } + +export const UMB_CURRENT_USER_STORE_CONTEXT_ALIAS = new UmbContextAlias(UmbCurrentUserStore.name); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.element.ts index f1f670d8ca..f6cde31ed0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.element.ts @@ -8,7 +8,7 @@ import { repeat } from 'lit/directives/repeat.js'; import { distinctUntilChanged } from 'rxjs'; import { getTagLookAndColor } from '../../../../auth/utils'; -import { UmbCurrentUserStore } from '../../current-user/current-user.store'; +import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from '../../current-user/current-user.store'; import { UmbWorkspaceUserContext } from './user-workspace.context'; import type { UserDetails } from '@umbraco-cms/models'; @@ -117,7 +117,7 @@ export class UmbUserWorkspaceElement extends UmbLitElement implements UmbWorkspa constructor() { super(); - this.consumeContext('umbCurrentUserStore', (store) => { + this.consumeContext(UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, (store) => { this._currentUserStore = store; this._observeCurrentUser(); }); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts index 83a6726dad..e647d8a2ed 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts @@ -7,7 +7,10 @@ import { UmbCurrentUserHistoryStore, UmbCurrentUserHistoryItem, } from 'src/backoffice/users/current-user/current-user-history.store'; -import { UmbCurrentUserStore } from 'src/backoffice/users/current-user/current-user.store'; +import { + UmbCurrentUserStore, + UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/current-user/current-user.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-modal-layout-current-user') @@ -94,7 +97,7 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement { this._modalService = _instance; }); - this.consumeContext('umbCurrentUserStore', (_instance) => { + this.consumeContext(UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, (_instance) => { this._currentUserStore = _instance; this._observeCurrentUser(); }); From d3b8f674cda817abe6c1f7f3b91c9dbcf9ab6747 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:36:10 +0100 Subject: [PATCH 36/75] add tests for ContextAlias --- .../core/context-api/context-alias.test.ts | 51 +++++++++++++++++++ .../src/core/context-api/context-alias.ts | 11 +++- 2 files changed, 60 insertions(+), 2 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts new file mode 100644 index 0000000000..4339baca08 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts @@ -0,0 +1,51 @@ +import { expect } from '@open-wc/testing'; +import { UmbContextConsumer } from './consume/context-consumer'; +import { UmbContextAlias } from './context-alias'; +import { UmbContextProvider } from './provide/context-provider'; + +const testContextAlias = 'my-test-context'; + +class MyClass { + prop = 'value from provider'; +} + +describe('ContextAlias', () => { + const contextAlias = new UmbContextAlias(testContextAlias); + const typedProvider = new UmbContextProvider(document.body, contextAlias, new MyClass()); + typedProvider.hostConnected(); + + after(() => { + typedProvider.hostDisconnected(); + }); + + it('toString returns the alias', () => { + expect(contextAlias.toString()).to.eq(testContextAlias); + }); + + it('can be consumed directly', (done) => { + const element = document.createElement('div'); + document.body.appendChild(element); + + const localConsumer = new UmbContextConsumer(element, contextAlias, (_instance) => { + console.log('got instance', _instance); + expect(_instance).to.be.instanceOf(MyClass); + expect(_instance.prop).to.eq('value from provider'); + done(); + }); + + localConsumer.hostConnected(); + }); + + it('can be consumed using the inner string alias', (done) => { + const element = document.createElement('div'); + document.body.appendChild(element); + + const localConsumer = new UmbContextConsumer(element, testContextAlias, (_instance: MyClass) => { + expect(_instance).to.be.instanceOf(MyClass); + expect(_instance.prop).to.eq('value from provider'); + done(); + }); + + localConsumer.hostConnected(); + }); +}); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts index 0bdc5d4495..a26741648b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.ts @@ -1,10 +1,11 @@ export class UmbContextAlias { /** + * @param alias Unique identifier for the token, * @param _desc Description for the token, * used only for debugging purposes, * it should but does not need to be unique */ - constructor(protected _desc: string) {} + constructor(protected alias: string, protected _desc?: string) {} /** * @internal @@ -13,7 +14,13 @@ export class UmbContextAlias { return this as UmbContextAlias>; } + /** + * This method must always return the unique alias of the token since that + * will be used to look up the token in the injector. + * + * @returns the unique alias of the token + */ toString(): string { - return `${UmbContextAlias.name} ${this._desc}`; + return this.alias; } } From 3c447b63744deddf273072fee2c5014e05f30acd Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:36:20 +0100 Subject: [PATCH 37/75] move tests to ContextAlias --- .../consume/context-consumer.test.ts | 18 ------------------ .../provide/context-provider.test.ts | 13 ------------- 2 files changed, 31 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts index 1bd94e9352..bc0c5f2e1e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.test.ts @@ -1,5 +1,4 @@ import { expect, oneEvent } from '@open-wc/testing'; -import { UmbContextAlias } from '../context-alias'; import { UmbContextProvider } from '../provide/context-provider'; import { UmbContextConsumer } from './context-consumer'; import { UmbContextRequestEventImplementation, umbContextRequestEventType } from './context-request.event'; @@ -54,21 +53,4 @@ describe('UmbContextConsumer', () => { provider.hostDisconnected(); }); - - it('works with ContextAlias', (done) => { - const CONTEXT_ALIAS = new UmbContextAlias(testContextAlias); - const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); - provider.hostConnected(); - - const element = document.createElement('div'); - document.body.appendChild(element); - - const localConsumer = new UmbContextConsumer(element, CONTEXT_ALIAS, (_instance) => { - expect(_instance.prop).to.eq('value from provider'); - done(); - }); - localConsumer.hostConnected(); - - provider.hostDisconnected(); - }); }); diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts index be1e39480d..6a633b7931 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.test.ts @@ -58,17 +58,4 @@ describe('UmbContextProvider', () => { }); localConsumer.hostConnected(); }); - - it('works with ContextAlias', (done) => { - const CONTEXT_ALIAS = new UmbContextAlias(MyClass.name); - const provider = new UmbContextProvider(document.body, CONTEXT_ALIAS, new MyClass()); - provider.hostConnected(); - - const localConsumer = new UmbContextConsumer(document.body, CONTEXT_ALIAS, (_instance: MyClass) => { - expect(_instance.prop).to.eq('value from provider'); - localConsumer.hostDisconnected(); - done(); - }); - localConsumer.hostConnected(); - }); }); From 8be9e8e9ba779ab09bd7c1e543ab3070cedb2562 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:37:03 +0100 Subject: [PATCH 38/75] use the string value of ContextAlias to provide and consume contexts to ensure it works in a non-static context --- .../context-api/consume/context-consumer.controller.ts | 2 +- .../src/core/context-api/consume/context-consumer.ts | 9 ++++++--- .../src/core/context-api/provide/context-provider.ts | 4 ++-- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts index 5cbb4aa2a0..c0d5cc5e7d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.controller.ts @@ -9,7 +9,7 @@ export class UmbContextConsumerController implements UmbControllerInterface { public get unique() { - return this._contextAlias.toString(); + return this.consumerAlias; } constructor( diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts index db88b7cfc5..2c0ba68cc6 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/consume/context-consumer.ts @@ -12,7 +12,8 @@ export class UmbContextConsumer, + _contextAlias: string | UmbContextAlias, private _callback: UmbContextCallback - ) {} + ) { + this._contextAlias = _contextAlias.toString(); + } private _onResponse = (instance: T) => { this._instance = instance; diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts index 2e6afb429e..1b64bb2c85 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.ts @@ -9,7 +9,7 @@ import { UmbContextProvideEventImplementation } from './context-provide.event'; export class UmbContextProvider { protected host: HostType; - protected _contextAlias: string | UmbContextAlias; + protected _contextAlias: string; #instance: unknown; /** @@ -21,7 +21,7 @@ export class UmbContextProvider { */ constructor(host: HostType, contextAlias: string | UmbContextAlias, instance: unknown) { this.host = host; - this._contextAlias = contextAlias; + this._contextAlias = contextAlias.toString(); this.#instance = instance; } From 90388b50669467377bf074d026466857457a1bf2 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:45:20 +0100 Subject: [PATCH 39/75] migrate UmbDocumentStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../src/backoffice/documents/documents/document.store.ts | 3 +++ .../documents/tree/actions/action-document-delete.element.ts | 4 ++-- .../src/backoffice/documents/documents/tree/manifests.ts | 3 ++- .../input-document-picker/input-document-picker.element.ts | 4 ++-- 5 files changed, 11 insertions(+), 7 deletions(-) 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 481efda031..ee3fcf9168 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -12,7 +12,7 @@ import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-hi import { UmbDocumentTypeStore } from './documents/document-types/document-type.store'; import { UmbMediaTypeStore } from './media/media-types/media-type.store'; import { UmbMemberTypeStore } from './members/member-types/member-type.store'; -import { UmbDocumentStore } from './documents/documents/document.store'; +import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; import { UmbMediaStore } from './media/media/media.store'; import { UmbMemberGroupStore } from './members/member-groups/member-group.store'; import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; @@ -58,7 +58,7 @@ export class UmbBackofficeElement extends UmbLitElement { // 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_ALIAS, new UmbCurrentUserStore()); - this.provideContext('umbDocumentStore', new UmbDocumentStore(this)); + this.provideContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, new UmbDocumentStore(this)); this.provideContext('umbMediaStore', new UmbMediaStore(this)); this.provideContext('umbDataTypeStore', new UmbDataTypeStore(this)); this.provideContext('umbDocumentTypeStore', new UmbDocumentTypeStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/document.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/document.store.ts index 52a62d2df4..64c894e41f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/document.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/document.store.ts @@ -3,6 +3,7 @@ import { UmbNodeStoreBase } from '../../../core/stores/store'; import type { DocumentDetails } from '@umbraco-cms/models'; import { DocumentResource, DocumentTreeItem, FolderTreeItem } from '@umbraco-cms/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export const isDocumentDetails = (document: DocumentDetails | DocumentTreeItem): document is DocumentDetails => { return (document as DocumentDetails).data !== undefined; @@ -129,3 +130,5 @@ export class UmbDocumentStore extends UmbNodeStoreBase return this.items.pipe(map((items) => items.filter((item) => keys.includes(item.key ?? '')))); } } + +export const UMB_DOCUMENT_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts index ca25c2c798..cd33ab0511 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/actions/action-document-delete.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; -import { UmbDocumentStore } from '../../document.store'; +import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from '../../document.store'; import UmbTreeItemActionElement from '../../../../shared/components/tree/action/tree-item-action.element'; @customElement('umb-tree-action-document-delete') @@ -19,7 +19,7 @@ export default class UmbTreeActionDocumentDeleteElement extends UmbTreeItemActio this._modalService = modalService; }); - this.consumeContext('umbDocumentStore', (documentStore: UmbDocumentStore) => { + this.consumeContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, (documentStore) => { this._documentStore = documentStore; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/manifests.ts index 1039c9dcc9..dd544de291 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/documents/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../document.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const treeAlias = 'Umb.Tree.Documents'; @@ -7,7 +8,7 @@ const tree: ManifestTree = { alias: treeAlias, name: 'Documents Tree', meta: { - storeAlias: 'umbDocumentStore', + storeAlias: STORE_ALIAS, }, }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts index 39dd4fa81a..b4e5591787 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/input-document-picker/input-document-picker.element.ts @@ -7,7 +7,7 @@ import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal import type { FolderTreeItem } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; import type { UmbObserverController } from '@umbraco-cms/observable-api'; -import type { UmbDocumentStore } from 'src/backoffice/documents/documents/document.store'; +import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from 'src/backoffice/documents/documents/document.store'; @customElement('umb-input-document-picker') export class UmbInputDocumentPickerElement extends FormControlMixin(UmbLitElement) { @@ -94,7 +94,7 @@ export class UmbInputDocumentPickerElement extends FormControlMixin(UmbLitElemen () => !!this.max && this._selectedKeys.length > this.max ); - this.consumeContext('umbDocumentStore', (instance: UmbDocumentStore) => { + this.consumeContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, (instance) => { this._documentStore = instance; this._observePickedDocuments(); }); From 1771836159686200171b02aadc78292af161d2bc Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:49:53 +0100 Subject: [PATCH 40/75] migrate UmbMediaStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../src/backoffice/media/media/media.store.ts | 7 ++++++- .../src/backoffice/media/media/tree/manifests.ts | 3 ++- .../src/backoffice/media/media/workspace/manifests.ts | 3 ++- .../media/media/workspace/media-workspace.context.ts | 10 +++++++--- .../src/backoffice/media/section.manifests.ts | 3 ++- 6 files changed, 21 insertions(+), 9 deletions(-) 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 ee3fcf9168..cd87ab1e28 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -13,7 +13,7 @@ import { UmbDocumentTypeStore } from './documents/document-types/document-type.s import { UmbMediaTypeStore } from './media/media-types/media-type.store'; import { UmbMemberTypeStore } from './members/member-types/member-type.store'; import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; -import { UmbMediaStore } from './media/media/media.store'; +import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; import { UmbMemberGroupStore } from './members/member-groups/member-group.store'; import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; @@ -59,7 +59,7 @@ export class UmbBackofficeElement extends UmbLitElement { // 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_ALIAS, new UmbCurrentUserStore()); this.provideContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, new UmbDocumentStore(this)); - this.provideContext('umbMediaStore', new UmbMediaStore(this)); + this.provideContext(UMB_MEDIA_STORE_CONTEXT_ALIAS, new UmbMediaStore(this)); this.provideContext('umbDataTypeStore', new UmbDataTypeStore(this)); this.provideContext('umbDocumentTypeStore', new UmbDocumentTypeStore(this)); this.provideContext('umbMediaTypeStore', new UmbMediaTypeStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/media.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/media.store.ts index 95f77c02b6..de8289ecf3 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/media.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/media.store.ts @@ -3,6 +3,7 @@ import { UmbDataStoreBase } from '../../../core/stores/store'; import type { MediaDetails } from '@umbraco-cms/models'; import { ContentTreeItem, MediaResource } from '@umbraco-cms/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; const isMediaDetails = (media: UmbMediaStoreItemType): media is MediaDetails => { return (media as MediaDetails).data !== undefined; @@ -11,6 +12,8 @@ const isMediaDetails = (media: UmbMediaStoreItemType): media is MediaDetails => // TODO: stop using ContentTreeItem. export type UmbMediaStoreItemType = MediaDetails | ContentTreeItem; +export const STORE_ALIAS = 'umbMediaStore'; + /** * @export * @class UmbMediaStore @@ -18,7 +21,7 @@ export type UmbMediaStoreItemType = MediaDetails | ContentTreeItem; * @description - Data Store for Media */ export class UmbMediaStore extends UmbDataStoreBase { - public readonly storeAlias = 'umbMediaStore'; + public readonly storeAlias = STORE_ALIAS; getByKey(key: string): Observable { // fetch from server and update store @@ -108,3 +111,5 @@ export class UmbMediaStore extends UmbDataStoreBase { return this.items.pipe(map((items) => items.filter((item) => item.parentKey === key && !item.isTrashed))); } } + +export const UMB_MEDIA_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/tree/manifests.ts index 67c7b723a5..5160b0f9cf 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../media.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const treeAlias = 'Umb.Tree.Media'; @@ -7,7 +8,7 @@ const tree: ManifestTree = { alias: treeAlias, name: 'Media Tree', meta: { - storeAlias: 'umbMediaStore', + storeAlias: STORE_ALIAS, }, }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/manifests.ts index 778371d49f..0814d0f8e9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/manifests.ts @@ -4,6 +4,7 @@ import type { ManifestWorkspaceView, ManifestWorkspaceViewCollection, } from '@umbraco-cms/models'; +import { STORE_ALIAS } from '../media.store'; const workspace: ManifestWorkspace = { type: 'workspace', @@ -58,7 +59,7 @@ const workspaceViewCollections: Array = [ pathname: 'collection', icon: 'umb:grid', entityType: 'media', - storeAlias: 'umbMediaStore', + storeAlias: STORE_ALIAS, }, }, ]; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/media-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/media-workspace.context.ts index 6083fad6d0..bc45eed01a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/media-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media/workspace/media-workspace.context.ts @@ -1,5 +1,9 @@ import { UmbWorkspaceContentContext } from '../../../shared/components/workspace/workspace-content/workspace-content.context'; -import type { UmbMediaStore, UmbMediaStoreItemType } from 'src/backoffice/media/media/media.store'; +import { + UmbMediaStore, + UmbMediaStoreItemType, + UMB_MEDIA_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/media/media/media.store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; const DefaultMediaData = { @@ -33,10 +37,10 @@ const DefaultMediaData = { export class UmbWorkspaceMediaContext extends UmbWorkspaceContentContext { constructor(host: UmbControllerHostInterface) { - super(host, DefaultMediaData, 'umbMediaStore', 'media'); + super(host, DefaultMediaData, UMB_MEDIA_STORE_CONTEXT_ALIAS.toString(), 'media'); } public setPropertyValue(alias: string, value: unknown) { - throw new Error("setPropertyValue is not implemented for UmbWorkspaceMediaContext") + throw new Error('setPropertyValue is not implemented for UmbWorkspaceMediaContext'); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/section.manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/section.manifests.ts index 46ccb96ac5..b6ae3a143c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/section.manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/section.manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from './media/media.store'; import type { ManifestDashboardCollection, ManifestSection } from '@umbraco-cms/models'; const sectionAlias = 'Umb.Section.Media'; @@ -24,7 +25,7 @@ const dashboards: Array = [ sections: [sectionAlias], pathname: 'media-management', entityType: 'media', - storeAlias: 'umbMediaStore', + storeAlias: STORE_ALIAS, }, }, ]; From e14f65f8e66431ad0b39f41ce1b28cfbfe378a95 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:54:56 +0100 Subject: [PATCH 41/75] migrate UmbDataTypeStore to UmbContextAlias --- .../.storybook/preview.js | 4 ++-- .../src/backoffice/backoffice.element.ts | 4 ++-- .../settings/data-types/data-type.store.ts | 3 +++ .../delete/action-data-type-delete.element.ts | 4 ++-- .../settings/data-types/tree/manifests.ts | 3 ++- .../workspace/data-type-workspace.context.ts | 19 +++++++++++++------ .../content-property.element.ts | 19 ++++++++----------- 7 files changed, 32 insertions(+), 24 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/.storybook/preview.js b/src/Umbraco.Web.UI.Client/.storybook/preview.js index 484ccb2c7c..8d18e492b2 100644 --- a/src/Umbraco.Web.UI.Client/.storybook/preview.js +++ b/src/Umbraco.Web.UI.Client/.storybook/preview.js @@ -9,7 +9,7 @@ import { initialize, mswDecorator } from 'msw-storybook-addon'; import { setCustomElements } from '@storybook/web-components'; import customElementManifests from '../custom-elements.json'; -import { UmbDataTypeStore } from '../src/backoffice/settings/data-types/data-type.store'; +import { STORE_ALIAS as dataTypeAlias, UmbDataTypeStore } from '../src/backoffice/settings/data-types/data-type.store'; import { UmbDocumentTypeStore } from '../src/backoffice/documents/document-types/document-type.store'; import { UmbIconStore } from '../src/core/stores/icon/icon.store'; import { onUnhandledRequest } from '../src/core/mocks/browser'; @@ -51,7 +51,7 @@ customElements.define('umb-storybook', UmbStoryBookElement); const storybookProvider = (story) => html` ${story()} `; const dataTypeStoreProvider = (story) => html` - ${story()} + ${story()} `; const documentTypeStoreProvider = (story) => html` 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 cd87ab1e28..755dd7c252 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -19,7 +19,7 @@ import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; import { UmbSectionStore } from './shared/components/section/section.store'; -import { UmbDataTypeStore } from './settings/data-types/data-type.store'; +import { UmbDataTypeStore, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS } from './settings/data-types/data-type.store'; import { UmbLitElement } from '@umbraco-cms/element'; // Domains @@ -60,7 +60,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, new UmbCurrentUserStore()); this.provideContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, new UmbDocumentStore(this)); this.provideContext(UMB_MEDIA_STORE_CONTEXT_ALIAS, new UmbMediaStore(this)); - this.provideContext('umbDataTypeStore', new UmbDataTypeStore(this)); + this.provideContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, new UmbDataTypeStore(this)); this.provideContext('umbDocumentTypeStore', new UmbDocumentTypeStore(this)); this.provideContext('umbMediaTypeStore', new UmbMediaTypeStore(this)); this.provideContext('umbMemberTypeStore', new UmbMemberTypeStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/data-type.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/data-type.store.ts index 78e5d881e6..73e886c775 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/data-type.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/data-type.store.ts @@ -3,6 +3,7 @@ import { UmbDataStoreBase } from '../../../core/stores/store'; import type { DataTypeDetails } from '@umbraco-cms/models'; import { DataTypeResource, FolderTreeItem } from '@umbraco-cms/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; const isDataTypeDetails = (dataType: DataTypeDetails | FolderTreeItem): dataType is DataTypeDetails => { return (dataType as DataTypeDetails).data !== undefined; @@ -124,3 +125,5 @@ export class UmbDataTypeStore extends UmbDataStoreBase return this.items.pipe(map((items) => items.filter((item) => item.parentKey === key))); } } + +export const UMB_DATA_TYPE_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts index ef044b1e84..9d2a90baf5 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/actions/delete/action-data-type-delete.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../../core/modal'; -import { UmbDataTypeStore } from '../../../data-type.store'; +import { UmbDataTypeStore, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS } from '../../../data-type.store'; import UmbTreeItemActionElement from '../../../../../shared/components/tree/action/tree-item-action.element'; @customElement('umb-tree-action-data-type-delete') @@ -19,7 +19,7 @@ export default class UmbTreeActionDataTypeDeleteElement extends UmbTreeItemActio this._modalService = modalService; }); - this.consumeContext('umbDataTypeStore', (dataTypeStore: UmbDataTypeStore) => { + this.consumeContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, (dataTypeStore) => { this._dataTypeStore = dataTypeStore; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/manifests.ts index 373e3bf1e9..488465a362 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../data-type.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const tree: ManifestTree = { @@ -6,7 +7,7 @@ const tree: ManifestTree = { name: 'Data Types Tree', weight: 100, meta: { - storeAlias: 'umbDataTypeStore', + storeAlias: STORE_ALIAS, }, }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/data-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/data-type-workspace.context.ts index 4cb8181c25..394c17f435 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/data-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/data-types/workspace/data-type-workspace.context.ts @@ -1,5 +1,9 @@ import { UmbWorkspaceContentContext } from '../../../shared/components/workspace/workspace-content/workspace-content.context'; -import type { UmbDataTypeStore, UmbDataTypeStoreItemType } from 'src/backoffice/settings/data-types/data-type.store'; +import { + UmbDataTypeStore, + UmbDataTypeStoreItemType, + UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/settings/data-types/data-type.store'; import type { DataTypeDetails } from '@umbraco-cms/models'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; import { appendToFrozenArray } from '@umbraco-cms/observable-api'; @@ -21,16 +25,19 @@ export class UmbWorkspaceDataTypeContext extends UmbWorkspaceContentContext< UmbDataTypeStore > { constructor(host: UmbControllerHostInterface) { - super(host, DefaultDataTypeData, 'umbDataTypeStore', 'dataType'); + super(host, DefaultDataTypeData, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS.toString(), 'dataType'); } public setPropertyValue(alias: string, value: unknown) { - // TODO: make sure to check that we have a details model? otherwise fail? 8This can be relevant if we use the same context for tree actions? - const entry = {alias: alias, value: value}; + const entry = { alias: alias, value: value }; - const newDataSet = appendToFrozenArray((this._data.getValue() as DataTypeDetails).data, entry, x => x.alias === alias); + const newDataSet = appendToFrozenArray( + (this._data.getValue() as DataTypeDetails).data, + entry, + (x) => x.alias === alias + ); - this.update({data: newDataSet}); + this.update({ data: newDataSet }); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/content-property/content-property.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/content-property/content-property.element.ts index 233e42ab64..75171d868b 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/content-property/content-property.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/content-property/content-property.element.ts @@ -3,7 +3,7 @@ import { css, html } from 'lit'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import { customElement, property, state } from 'lit/decorators.js'; -import { UmbDataTypeStore } from '../../../settings/data-types/data-type.store'; +import { UmbDataTypeStore, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS } from '../../../settings/data-types/data-type.store'; import type { ContentProperty, DataTypeDetails } from '@umbraco-cms/models'; import '../workspace-property/workspace-property.element'; @@ -30,7 +30,7 @@ export class UmbContentPropertyElement extends UmbLitElement { public set property(value: ContentProperty | undefined) { const oldProperty = this._property; this._property = value; - if(this._property?.dataTypeKey !== oldProperty?.dataTypeKey) { + if (this._property?.dataTypeKey !== oldProperty?.dataTypeKey) { this._observeDataType(this._property?.dataTypeKey); } } @@ -50,7 +50,7 @@ export class UmbContentPropertyElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbDataTypeStore', (instance) => { + this.consumeContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, (instance) => { this._dataTypeStore = instance; this._observeDataType(this._property?.dataTypeKey); }); @@ -60,14 +60,11 @@ export class UmbContentPropertyElement extends UmbLitElement { if (!this._dataTypeStore) return; this._dataTypeObserver?.destroy(); - if(dataTypeKey) { - this._dataTypeObserver = this.observe( - this._dataTypeStore.getByKey(dataTypeKey), - (dataType) => { - this._dataTypeData = dataType?.data; - this._propertyEditorUIAlias = dataType?.propertyEditorUIAlias || undefined; - } - ); + if (dataTypeKey) { + this._dataTypeObserver = this.observe(this._dataTypeStore.getByKey(dataTypeKey), (dataType) => { + this._dataTypeData = dataType?.data; + this._propertyEditorUIAlias = dataType?.propertyEditorUIAlias || undefined; + }); } } From 612ac31cc309639e201c2c5be5a27024ab0cc190 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:57:23 +0100 Subject: [PATCH 42/75] migrate UmbDocumentTypeStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 7 +++++-- .../documents/document-types/document-type.store.ts | 7 ++++++- .../backoffice/documents/document-types/tree/manifests.ts | 3 ++- .../workspace/document-type-workspace.context.ts | 6 +++--- 4 files changed, 16 insertions(+), 7 deletions(-) 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 755dd7c252..e2d6f36626 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -9,7 +9,10 @@ import { UmbUserGroupStore } from './users/user-groups/user-group.store'; import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store'; import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store'; -import { UmbDocumentTypeStore } from './documents/document-types/document-type.store'; +import { + UmbDocumentTypeStore, + UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, +} from './documents/document-types/document-type.store'; import { UmbMediaTypeStore } from './media/media-types/media-type.store'; import { UmbMemberTypeStore } from './members/member-types/member-type.store'; import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; @@ -61,7 +64,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_DOCUMENT_STORE_CONTEXT_ALIAS, new UmbDocumentStore(this)); this.provideContext(UMB_MEDIA_STORE_CONTEXT_ALIAS, new UmbMediaStore(this)); this.provideContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, new UmbDataTypeStore(this)); - this.provideContext('umbDocumentTypeStore', new UmbDocumentTypeStore(this)); + this.provideContext(UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, new UmbDocumentTypeStore(this)); this.provideContext('umbMediaTypeStore', new UmbMediaTypeStore(this)); this.provideContext('umbMemberTypeStore', new UmbMemberTypeStore(this)); this.provideContext('umbUserStore', new UmbUserStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/document-type.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/document-type.store.ts index 53f7d2a65a..cedf8a450a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/document-type.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/document-type.store.ts @@ -3,6 +3,7 @@ import { UmbDataStoreBase } from '../../../core/stores/store'; import { DocumentTypeResource, DocumentTypeTreeItem } from '@umbraco-cms/backend-api'; import type { DocumentTypeDetails } from '@umbraco-cms/models'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export const isDocumentTypeDetails = ( documentType: DocumentTypeDetails | DocumentTypeTreeItem @@ -12,6 +13,8 @@ export const isDocumentTypeDetails = ( export type UmbDocumentTypeStoreItemType = DocumentTypeDetails | DocumentTypeTreeItem; +export const STORE_ALIAS = 'umbDocumentTypeStore'; + /** * @export * @class UmbDocumentTypeStore @@ -19,7 +22,7 @@ export type UmbDocumentTypeStoreItemType = DocumentTypeDetails | DocumentTypeTre * @description - Data Store for Document Types */ export class UmbDocumentTypeStore extends UmbDataStoreBase { - public readonly storeAlias = 'umbDocumentTypeStore'; + public readonly storeAlias = STORE_ALIAS; getByKey(key: string): Observable { // TODO: use Fetcher API. @@ -82,3 +85,5 @@ export class UmbDocumentTypeStore extends UmbDataStoreBase items.filter((item) => item.parentKey === key))); } } + +export const UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/tree/manifests.ts index 576748172b..694de8a0bf 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../document-type.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const tree: ManifestTree = { @@ -5,7 +6,7 @@ const tree: ManifestTree = { alias: 'Umb.Tree.DocumentTypes', name: 'Document Types Tree', meta: { - storeAlias: 'umbDocumentTypeStore', + storeAlias: STORE_ALIAS, }, }; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.context.ts index 98c9dc073a..8b2cad3053 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-types/workspace/document-type-workspace.context.ts @@ -2,6 +2,7 @@ import { UmbWorkspaceContentContext } from '../../../shared/components/workspace import { UmbDocumentTypeStore, UmbDocumentTypeStoreItemType, + UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, } from 'src/backoffice/documents/document-types/document-type.store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; @@ -21,11 +22,10 @@ export class UmbWorkspaceDocumentTypeContext extends UmbWorkspaceContentContext< UmbDocumentTypeStore > { constructor(host: UmbControllerHostInterface) { - super(host, DefaultDocumentTypeData, 'umbDocumentTypeStore', 'documentType'); + super(host, DefaultDocumentTypeData, UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS.toString(), 'documentType'); } - public setPropertyValue(alias: string, value: unknown) { - throw new Error("setPropertyValue is not implemented for UmbWorkspaceDocumentTypeContext") + throw new Error('setPropertyValue is not implemented for UmbWorkspaceDocumentTypeContext'); } } From 2f9be927d59eee65d04159c4deacec82abfc7942 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 15:58:45 +0100 Subject: [PATCH 43/75] migrate UmbMediaTypeStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../src/backoffice/media/media-types/media-type.store.ts | 8 +++++++- .../src/backoffice/media/media-types/tree/manifests.ts | 3 ++- 3 files changed, 11 insertions(+), 4 deletions(-) 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 e2d6f36626..63c81d03d9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -13,7 +13,7 @@ import { UmbDocumentTypeStore, UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, } from './documents/document-types/document-type.store'; -import { UmbMediaTypeStore } from './media/media-types/media-type.store'; +import { UmbMediaTypeStore, UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS } from './media/media-types/media-type.store'; import { UmbMemberTypeStore } from './members/member-types/member-type.store'; import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; @@ -65,7 +65,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_MEDIA_STORE_CONTEXT_ALIAS, new UmbMediaStore(this)); this.provideContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, new UmbDataTypeStore(this)); this.provideContext(UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, new UmbDocumentTypeStore(this)); - this.provideContext('umbMediaTypeStore', new UmbMediaTypeStore(this)); + this.provideContext(UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS, new UmbMediaTypeStore(this)); this.provideContext('umbMemberTypeStore', new UmbMemberTypeStore(this)); this.provideContext('umbUserStore', new UmbUserStore(this)); this.provideContext('umbUserGroupStore', new UmbUserGroupStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/media-type.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/media-type.store.ts index ae263f61f6..f2f623d45a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/media-type.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/media-type.store.ts @@ -3,8 +3,12 @@ import { UmbNodeStoreBase } from '../../../core/stores/store'; import { MediaTypeResource, FolderTreeItem } from '@umbraco-cms/backend-api'; import type { MediaTypeDetails } from '@umbraco-cms/models'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbMediaTypeStoreItemType = MediaTypeDetails | FolderTreeItem; + +export const STORE_ALIAS = 'umbMediaTypeStore'; + /** * @export * @class UmbMediaTypeStore @@ -12,7 +16,7 @@ export type UmbMediaTypeStoreItemType = MediaTypeDetails | FolderTreeItem; * @description - Data Store for Media Types */ export class UmbMediaTypeStore extends UmbNodeStoreBase { - public readonly storeAlias = 'umbMediaTypeStore'; + public readonly storeAlias = STORE_ALIAS; /** * @description - Request a Data Type by key. The Data Type is added to the store and is returned as an Observable. @@ -85,3 +89,5 @@ export class UmbMediaTypeStore extends UmbNodeStoreBase items.filter((item) => item.parentKey === key))); } } + +export const UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/tree/manifests.ts index dcb609513d..54a406aca4 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/media/media-types/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../media-type.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const tree: ManifestTree = { @@ -5,7 +6,7 @@ const tree: ManifestTree = { alias: 'Umb.Tree.MediaTypes', name: 'Media Types Tree', meta: { - storeAlias: 'umbMediaTypeStore', + storeAlias: STORE_ALIAS, }, }; From c1a66db40334ca65118090d3f264055a42a6c6cd Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:00:07 +0100 Subject: [PATCH 44/75] migrate UmbMemberTypeStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../backoffice/members/member-types/member-type.store.ts | 7 ++++++- .../src/backoffice/members/member-types/tree/manifests.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) 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 63c81d03d9..f812503b01 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -14,7 +14,7 @@ import { UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, } from './documents/document-types/document-type.store'; import { UmbMediaTypeStore, UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS } from './media/media-types/media-type.store'; -import { UmbMemberTypeStore } from './members/member-types/member-type.store'; +import { UmbMemberTypeStore, UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS } from './members/member-types/member-type.store'; import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; import { UmbMemberGroupStore } from './members/member-groups/member-group.store'; @@ -66,7 +66,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_DATA_TYPE_STORE_CONTEXT_ALIAS, new UmbDataTypeStore(this)); this.provideContext(UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, new UmbDocumentTypeStore(this)); this.provideContext(UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS, new UmbMediaTypeStore(this)); - this.provideContext('umbMemberTypeStore', new UmbMemberTypeStore(this)); + this.provideContext(UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS, new UmbMemberTypeStore(this)); this.provideContext('umbUserStore', new UmbUserStore(this)); this.provideContext('umbUserGroupStore', new UmbUserGroupStore(this)); this.provideContext('umbMemberGroupStore', new UmbMemberGroupStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/member-type.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/member-type.store.ts index 5c54dedda7..339c58628f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/member-type.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/member-type.store.ts @@ -3,9 +3,12 @@ import { UmbDataStoreBase } from '../../../core/stores/store'; import { MemberTypeResource, EntityTreeItem } from '@umbraco-cms/backend-api'; import type { MemberTypeDetails } from '@umbraco-cms/models'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbMemberTypeStoreItemType = MemberTypeDetails | EntityTreeItem; +export const STORE_ALIAS = 'umbMemberTypeStore'; + /** * @export * @class UmbMemberTypeStore @@ -13,7 +16,7 @@ export type UmbMemberTypeStoreItemType = MemberTypeDetails | EntityTreeItem; * @description - Data Store for Member Types */ export class UmbMemberTypeStore extends UmbDataStoreBase { - public readonly storeAlias = 'umbMemberTypeStore'; + public readonly storeAlias = STORE_ALIAS; getByKey(key: string): Observable { return null as any; @@ -33,3 +36,5 @@ export class UmbMemberTypeStore extends UmbDataStoreBase items.filter((item) => item.parentKey === null))); } } + +export const UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/tree/manifests.ts index 40285dc0f7..b6607ad3e4 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-types/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../member-type.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const treeAlias = 'Umb.Tree.MemberTypes'; @@ -7,7 +8,7 @@ const tree: ManifestTree = { alias: treeAlias, name: 'Member Types Tree', meta: { - storeAlias: 'umbMemberTypeStore', + storeAlias: STORE_ALIAS, }, }; From 25374ffeb6b73e9e70ac5104ae6fe65c71b9a8f0 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:03:22 +0100 Subject: [PATCH 45/75] migrate UmbUserStore to UmbContextAlias --- .../auth/components/input-user/input-user.element.ts | 4 ++-- .../src/backoffice/backoffice.element.ts | 4 ++-- .../workspace/user-group-workspace.context.ts | 6 +++--- .../workspace/user-group-workspace.element.ts | 8 +++----- .../views/users/section-view-users.element.ts | 4 ++-- .../views/users/workspace-view-users-create.element.ts | 4 ++-- .../views/users/workspace-view-users-invite.element.ts | 4 ++-- .../users/workspace-view-users-selection.element.ts | 4 ++-- .../src/backoffice/users/users/user.store.ts | 7 ++++++- .../users/users/workspace/user-workspace.context.ts | 10 +++++++--- .../layouts/picker-user/picker-layout-user.element.ts | 4 ++-- 11 files changed, 33 insertions(+), 26 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/auth/components/input-user/input-user.element.ts b/src/Umbraco.Web.UI.Client/src/auth/components/input-user/input-user.element.ts index dd99d8520d..bc8b0fd861 100644 --- a/src/Umbraco.Web.UI.Client/src/auth/components/input-user/input-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/auth/components/input-user/input-user.element.ts @@ -3,7 +3,7 @@ import { css, html, nothing, PropertyValueMap } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbInputListBase } from '../../../backoffice/shared/components/input-list-base/input-list-base'; import type { UserEntity } from '@umbraco-cms/models'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; @customElement('umb-input-user') export class UmbPickerUserElement extends UmbInputListBase { @@ -39,7 +39,7 @@ export class UmbPickerUserElement extends UmbInputListBase { connectedCallback(): void { super.connectedCallback(); this.pickerLayout = 'umb-picker-layout-user'; - this.consumeContext('umbUserStore', (userStore: UmbUserStore) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (userStore) => { this._userStore = userStore; this._observeUser(); }); 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 f812503b01..e6a75ce074 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -4,7 +4,7 @@ import { css, html } from 'lit'; import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../core/modal'; import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../core/notification'; -import { UmbUserStore } from './users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from './users/users/user.store'; import { UmbUserGroupStore } from './users/user-groups/user-group.store'; import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store'; import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store'; @@ -67,7 +67,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_DOCUMENT_TYPE_STORE_CONTEXT_ALIAS, new UmbDocumentTypeStore(this)); this.provideContext(UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS, new UmbMediaTypeStore(this)); this.provideContext(UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS, new UmbMemberTypeStore(this)); - this.provideContext('umbUserStore', new UmbUserStore(this)); + this.provideContext(UMB_USER_STORE_CONTEXT_ALIAS, new UmbUserStore(this)); this.provideContext('umbUserGroupStore', new UmbUserGroupStore(this)); this.provideContext('umbMemberGroupStore', new UmbMemberGroupStore(this)); this.provideContext('umbSectionStore', new UmbSectionStore()); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.context.ts index 863df3b4ae..c82178cfca 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.context.ts @@ -1,4 +1,5 @@ import { UmbWorkspaceContentContext } from '../../../shared/components/workspace/workspace-content/workspace-content.context'; +import { UMB_USER_STORE_CONTEXT_ALIAS } from '../../users/user.store'; import type { UmbUserGroupStore, UmbUserGroupStoreItemType } from 'src/backoffice/users/user-groups/user-group.store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; @@ -19,11 +20,10 @@ export class UmbWorkspaceUserGroupContext extends UmbWorkspaceContentContext< UmbUserGroupStore > { constructor(host: UmbControllerHostInterface) { - super(host, DefaultDataTypeData, 'umbUserStore', 'userGroup'); + super(host, DefaultDataTypeData, UMB_USER_STORE_CONTEXT_ALIAS.toString(), 'userGroup'); } - public setPropertyValue(alias: string, value: unknown) { - throw new Error("setPropertyValue is not implemented for UmbWorkspaceUserGroupContext") + throw new Error('setPropertyValue is not implemented for UmbWorkspaceUserGroupContext'); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.element.ts index 028738c485..def60d37d1 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/user-group-workspace.element.ts @@ -7,7 +7,7 @@ import { distinctUntilChanged } from 'rxjs'; import { UmbWorkspaceUserGroupContext } from './user-group-workspace.context'; import type { ManifestWorkspaceAction, UserGroupDetails } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; -import type { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; import '../../../../auth/components/input-user/input-user.element'; import '../../../../backoffice/shared/components/input-section/input-section.element'; @@ -16,7 +16,6 @@ import { UmbWorkspaceEntityElement } from 'src/backoffice/shared/components/work @customElement('umb-user-group-workspace') export class UmbUserGroupWorkspaceElement extends UmbLitElement implements UmbWorkspaceEntityElement { - static styles = [ UUITextStyles, css` @@ -217,7 +216,7 @@ export class UmbUserGroupWorkspaceElement extends UmbLitElement implements UmbWo this._registerWorkspaceActions(); - this.consumeContext('umbUserStore', (instance) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (instance) => { this._userStore = instance; this._observeUsers(); }); @@ -233,8 +232,7 @@ export class UmbUserGroupWorkspaceElement extends UmbLitElement implements UmbWo type: 'workspaceAction', alias: 'Umb.WorkspaceAction.UserGroup.Save', name: 'Save User Group Workspace Action', - loader: () => - import('../../../shared/components/workspace/actions/save/workspace-action-node-save.element'), + loader: () => import('../../../shared/components/workspace/actions/save/workspace-action-node-save.element'), meta: { workspaces: ['Umb.Workspace.UserGroup'], look: 'primary', diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts index 7525f525e0..3081825b3a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/section-view-users.element.ts @@ -9,7 +9,7 @@ import './list-view-layouts/grid/workspace-view-users-grid.element'; import './workspace-view-users-selection.element'; import './workspace-view-users-invite.element'; import type { ManifestWorkspace, UserDetails } from '@umbraco-cms/models'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import { UmbLitElement } from '@umbraco-cms/element'; import { UniqueBehaviorSubject } from '@umbraco-cms/observable-api'; @@ -45,7 +45,7 @@ export class UmbSectionViewUsersElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbUserStore', (_instance) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (_instance) => { this._userStore = _instance; this._observeUsers(); }); 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 88d56f7a46..98400b0f06 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 @@ -7,7 +7,7 @@ import type { UserDetails } from '@umbraco-cms/models'; import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from 'src/core/notification'; import { UmbNotificationDefaultData } from 'src/core/notification/layouts/default'; import { UmbModalLayoutElement } from 'src/core/modal'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; export type UsersViewType = 'list' | 'grid'; @customElement('umb-workspace-view-users-create') @@ -67,7 +67,7 @@ export class UmbWorkspaceViewUsersCreateElement extends UmbModalLayoutElement { this._notificationService = _instance; }); - this.consumeContext('umbUserStore', (_instance) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (_instance) => { this._userStore = _instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-invite.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-invite.element.ts index 5c64294fec..5725c03299 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-invite.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-invite.element.ts @@ -4,7 +4,7 @@ import { customElement, query, state } from 'lit/decorators.js'; import { UmbInputPickerUserGroupElement } from 'src/auth/components/input-user-group/input-user-group.element'; import type { UserDetails } from '@umbraco-cms/models'; import { UmbModalLayoutElement } from 'src/core/modal'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; export type UsersViewType = 'list' | 'grid'; @customElement('umb-workspace-view-users-invite') @@ -58,7 +58,7 @@ export class UmbWorkspaceViewUsersInviteElement extends UmbModalLayoutElement { connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbUserStore', (usersContext: UmbUserStore) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (usersContext) => { this._userStore = usersContext; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-selection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-selection.element.ts index 3338fc6984..2a842046d8 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-selection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/workspace-view-users-selection.element.ts @@ -2,7 +2,7 @@ import { css, html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, state } from 'lit/decorators.js'; import { UmbSectionViewUsersElement } from './section-view-users.element'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-view-users-selection') @@ -39,7 +39,7 @@ export class UmbWorkspaceViewUsersSelectionElement extends UmbLitElement { this._observeSelection(); }); - this.consumeContext('umbUserStore', (userStore: UmbUserStore) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (userStore) => { this._userStore = userStore; this._observeTotalUsers(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/user.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/user.store.ts index cc50de40fa..b49119aa7a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/user.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/user.store.ts @@ -2,9 +2,12 @@ import { map, Observable } from 'rxjs'; import { UmbDataStoreBase } from '../../../core/stores/store'; import type { UserDetails } from '@umbraco-cms/models'; import { UniqueBehaviorSubject } from '@umbraco-cms/observable-api'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbUserStoreItemType = UserDetails; +export const STORE_ALIAS = 'umbUserStore'; + /** * @export * @class UmbUserStore @@ -12,7 +15,7 @@ export type UmbUserStoreItemType = UserDetails; * @description - Data Store for Users */ export class UmbUserStore extends UmbDataStoreBase { - public readonly storeAlias = 'umbUserStore'; + public readonly storeAlias = STORE_ALIAS; #totalUsers = new UniqueBehaviorSubject(0); public readonly totalUsers = this.#totalUsers.asObservable(); @@ -276,3 +279,5 @@ export class UmbUserStore extends UmbDataStoreBase { // this.requestUpdate('users'); // } } + +export const UMB_USER_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.context.ts index bfaf92784c..1d7e623924 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/user-workspace.context.ts @@ -1,5 +1,9 @@ import { UmbWorkspaceContentContext } from '../../../shared/components/workspace/workspace-content/workspace-content.context'; -import type { UmbUserStore, UmbUserStoreItemType } from 'src/backoffice/users/users/user.store'; +import { + UmbUserStore, + UmbUserStoreItemType, + UMB_USER_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/users/user.store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; const DefaultDataTypeData = { @@ -22,10 +26,10 @@ const DefaultDataTypeData = { export class UmbWorkspaceUserContext extends UmbWorkspaceContentContext { constructor(host: UmbControllerHostInterface) { - super(host, DefaultDataTypeData, 'umbUserStore', 'user'); + super(host, DefaultDataTypeData, UMB_USER_STORE_CONTEXT_ALIAS.toString(), 'user'); } public setPropertyValue(alias: string, value: unknown) { - throw new Error("setPropertyValue is not implemented for UmbWorkspaceUserContext") + throw new Error('setPropertyValue is not implemented for UmbWorkspaceUserContext'); } } diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user/picker-layout-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user/picker-layout-user.element.ts index f9ce297c34..a2907b0652 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user/picker-layout-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user/picker-layout-user.element.ts @@ -3,7 +3,7 @@ import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbModalLayoutPickerBase } from '../modal-layout-picker-base'; import type { UserDetails } from '@umbraco-cms/models'; -import { UmbUserStore } from 'src/backoffice/users/users/user.store'; +import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from 'src/backoffice/users/users/user.store'; @customElement('umb-picker-layout-user') export class UmbPickerLayoutUserElement extends UmbModalLayoutPickerBase { @@ -65,7 +65,7 @@ export class UmbPickerLayoutUserElement extends UmbModalLayoutPickerBase { connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbUserStore', (userStore: UmbUserStore) => { + this.consumeContext(UMB_USER_STORE_CONTEXT_ALIAS, (userStore) => { this._userStore = userStore; this._observeUsers(); }); From b9837c7992acfbcc9cbcadbda0c4f782cd19fe13 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:05:43 +0100 Subject: [PATCH 46/75] migrate UmbUserGroupStore to UmbContextAlias --- .../input-user-group/input-user-group.element.ts | 12 ++++++------ .../src/backoffice/backoffice.element.ts | 4 ++-- .../backoffice/users/user-groups/user-group.store.ts | 7 ++++++- .../workspace-view-user-groups.element.ts | 7 +++++-- .../grid/workspace-view-users-grid.element.ts | 7 +++++-- .../table/workspace-view-users-table.element.ts | 7 +++++-- .../picker-layout-user-group.element.ts | 12 ++++++------ 7 files changed, 35 insertions(+), 21 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/auth/components/input-user-group/input-user-group.element.ts b/src/Umbraco.Web.UI.Client/src/auth/components/input-user-group/input-user-group.element.ts index f1133821f4..7a4b40a431 100644 --- a/src/Umbraco.Web.UI.Client/src/auth/components/input-user-group/input-user-group.element.ts +++ b/src/Umbraco.Web.UI.Client/src/auth/components/input-user-group/input-user-group.element.ts @@ -3,7 +3,10 @@ import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbInputListBase } from '../../../backoffice/shared/components/input-list-base/input-list-base'; import type { UserGroupEntity } from '@umbraco-cms/models'; -import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; +import { + UmbUserGroupStore, + UMB_USER_GROUP_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/user-groups/user-group.store'; @customElement('umb-input-user-group') export class UmbInputPickerUserGroupElement extends UmbInputListBase { @@ -44,7 +47,7 @@ export class UmbInputPickerUserGroupElement extends UmbInputListBase { connectedCallback(): void { super.connectedCallback(); this.pickerLayout = 'umb-picker-layout-user-group'; - this.consumeContext('umbUserGroupStore', (usersContext: UmbUserGroupStore) => { + this.consumeContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, (usersContext) => { this._userGroupStore = usersContext; this._observeUserGroups(); }); @@ -52,10 +55,7 @@ export class UmbInputPickerUserGroupElement extends UmbInputListBase { private _observeUserGroups() { if (this.value.length > 0 && this._userGroupStore) { - this.observe( - this._userGroupStore.getByKeys(this.value), - (userGroups) => (this._userGroups = userGroups) - ); + this.observe(this._userGroupStore.getByKeys(this.value), (userGroups) => (this._userGroups = userGroups)); } else { this._userGroups = []; } 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 e6a75ce074..fa4eea3545 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -5,7 +5,7 @@ import { css, html } from 'lit'; import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../core/modal'; import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from '../core/notification'; import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from './users/users/user.store'; -import { UmbUserGroupStore } from './users/user-groups/user-group.store'; +import { UmbUserGroupStore, UMB_USER_GROUP_STORE_CONTEXT_ALIAS } from './users/user-groups/user-group.store'; import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store'; import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store'; @@ -68,7 +68,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS, new UmbMediaTypeStore(this)); this.provideContext(UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS, new UmbMemberTypeStore(this)); this.provideContext(UMB_USER_STORE_CONTEXT_ALIAS, new UmbUserStore(this)); - this.provideContext('umbUserGroupStore', new UmbUserGroupStore(this)); + this.provideContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, new UmbUserGroupStore(this)); this.provideContext('umbMemberGroupStore', new UmbMemberGroupStore(this)); this.provideContext('umbSectionStore', new UmbSectionStore()); this.provideContext('umbCurrentUserHistoryStore', new UmbCurrentUserHistoryStore()); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/user-group.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/user-group.store.ts index 32eb707031..d8da4ff25c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/user-group.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/user-group.store.ts @@ -1,10 +1,13 @@ import { map, Observable } from 'rxjs'; import { UmbDataStoreBase } from '../../../core/stores/store'; import type { UserGroupDetails, UserGroupEntity } from '@umbraco-cms/models'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; // TODO: get rid of this type addition & { ... }: export type UmbUserGroupStoreItemType = UserGroupDetails & { users?: Array }; +export const STORE_ALIAS = 'umbUserGroupStore'; + /** * @export * @class UmbUserGroupStore @@ -12,7 +15,7 @@ export type UmbUserGroupStoreItemType = UserGroupDetails & { users?: Array { - public readonly storeAlias = 'umbUserGroupStore'; + public readonly storeAlias = STORE_ALIAS; getAll(): Observable> { // TODO: use Fetcher API. @@ -83,3 +86,5 @@ export class UmbUserGroupStore extends UmbDataStoreBase(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/user-groups/workspace-view-user-groups.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/user-groups/workspace-view-user-groups.element.ts index 7fc29ade07..878404e4fc 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/user-groups/workspace-view-user-groups.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/user-groups/workspace-view-user-groups.element.ts @@ -14,7 +14,10 @@ import type { UserGroupDetails } from '@umbraco-cms/models'; import './user-group-table-name-column-layout.element'; import './user-group-table-sections-column-layout.element'; -import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; +import { + UmbUserGroupStore, + UMB_USER_GROUP_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/user-groups/user-group.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-view-user-groups') @@ -71,7 +74,7 @@ export class UmbWorkspaceViewUserGroupsElement extends UmbLitElement { connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbUserGroupStore', (userGroupStore: UmbUserGroupStore) => { + this.consumeContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, (userGroupStore) => { this._userGroupStore = userGroupStore; this._observeUserGroups(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts index 4695ca9df8..611c20f5f6 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts @@ -6,7 +6,10 @@ import { ifDefined } from 'lit-html/directives/if-defined.js'; import type { UmbSectionViewUsersElement } from '../../section-view-users.element'; import { getTagLookAndColor } from '../../../../../../../auth/utils'; import type { UserDetails, UserEntity, UserGroupEntity } from '@umbraco-cms/models'; -import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; +import { + UmbUserGroupStore, + UMB_USER_GROUP_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/user-groups/user-group.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-view-users-grid') @@ -54,7 +57,7 @@ export class UmbWorkspaceViewUsersGridElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbUserGroupStore', (instance) => { + this.consumeContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, (instance) => { this._userGroupStore = instance; this._observeUserGroups(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts index ab3cab4139..3096d3f6e0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/table/workspace-view-users-table.element.ts @@ -15,7 +15,10 @@ import type { UserDetails, UserGroupEntity } from '@umbraco-cms/models'; import './column-layouts/name/user-table-name-column-layout.element'; import './column-layouts/status/user-table-status-column-layout.element'; -import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; +import { + UmbUserGroupStore, + UMB_USER_GROUP_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/user-groups/user-group.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-view-users-table') @@ -76,7 +79,7 @@ export class UmbWorkspaceViewUsersTableElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbUserGroupStore', (instance) => { + this.consumeContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, (instance) => { this._userGroupStore = instance; this._observeUserGroups(); }); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user-group/picker-layout-user-group.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user-group/picker-layout-user-group.element.ts index bec3735aa7..a9930d851b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user-group/picker-layout-user-group.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/picker-user-group/picker-layout-user-group.element.ts @@ -3,7 +3,10 @@ import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UmbModalLayoutPickerBase } from '../modal-layout-picker-base'; import type { UserGroupDetails } from '@umbraco-cms/models'; -import { UmbUserGroupStore } from 'src/backoffice/users/user-groups/user-group.store'; +import { + UmbUserGroupStore, + UMB_USER_GROUP_STORE_CONTEXT_ALIAS, +} from 'src/backoffice/users/user-groups/user-group.store'; @customElement('umb-picker-layout-user-group') export class UmbPickerLayoutUserGroupElement extends UmbModalLayoutPickerBase { @@ -60,7 +63,7 @@ export class UmbPickerLayoutUserGroupElement extends UmbModalLayoutPickerBase { connectedCallback(): void { super.connectedCallback(); - this.consumeContext('umbUserGroupStore', (userGroupStore: UmbUserGroupStore) => { + this.consumeContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, (userGroupStore) => { this._userGroupStore = userGroupStore; this._observeUserGroups(); }); @@ -68,10 +71,7 @@ export class UmbPickerLayoutUserGroupElement extends UmbModalLayoutPickerBase { private _observeUserGroups() { if (!this._userGroupStore) return; - this.observe( - this._userGroupStore.getAll(), - (userGroups) => (this._userGroups = userGroups) - ); + this.observe(this._userGroupStore.getAll(), (userGroups) => (this._userGroups = userGroups)); } render() { From e83eed9ec0739a4af30348bff3f900ae1d9fdc27 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:07:00 +0100 Subject: [PATCH 47/75] migrate UmbMemberGroupStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../backoffice/members/member-groups/member-group.store.ts | 7 ++++++- .../src/backoffice/members/member-groups/tree/manifests.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) 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 fa4eea3545..4af20458ac 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -17,7 +17,7 @@ import { UmbMediaTypeStore, UMB_MEDIA_TYPE_STORE_CONTEXT_ALIAS } from './media/m import { UmbMemberTypeStore, UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS } from './members/member-types/member-type.store'; import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; -import { UmbMemberGroupStore } from './members/member-groups/member-group.store'; +import { UmbMemberGroupStore, UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS } from './members/member-groups/member-group.store'; import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; @@ -69,7 +69,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS, new UmbMemberTypeStore(this)); this.provideContext(UMB_USER_STORE_CONTEXT_ALIAS, new UmbUserStore(this)); this.provideContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, new UmbUserGroupStore(this)); - this.provideContext('umbMemberGroupStore', new UmbMemberGroupStore(this)); + this.provideContext(UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS, new UmbMemberGroupStore(this)); this.provideContext('umbSectionStore', new UmbSectionStore()); this.provideContext('umbCurrentUserHistoryStore', new UmbCurrentUserHistoryStore()); this.provideContext('umbDictionaryStore', new UmbDictionaryStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/member-group.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/member-group.store.ts index 25d092a20e..f24285a9f5 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/member-group.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/member-group.store.ts @@ -3,9 +3,12 @@ import { UmbNodeStoreBase } from '../../../core/stores/store'; import { EntityTreeItem, MemberGroupResource } from '@umbraco-cms/backend-api'; import type { MemberGroupDetails } from '@umbraco-cms/models'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbMemberGroupStoreItemType = MemberGroupDetails | EntityTreeItem; +export const STORE_ALIAS = 'umbMemberGroupStore'; + /** * @export * @class UmbMemberGroupStore @@ -13,7 +16,7 @@ export type UmbMemberGroupStoreItemType = MemberGroupDetails | EntityTreeItem; * @description - Data Store for Member Groups */ export class UmbMemberGroupStore extends UmbNodeStoreBase { - public readonly storeAlias = 'umbMemberGroupStore'; + public readonly storeAlias = STORE_ALIAS; getByKey(key: string): Observable { return null as any; @@ -33,3 +36,5 @@ export class UmbMemberGroupStore extends UmbNodeStoreBase items.filter((item) => item.parentKey === null))); } } + +export const UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/tree/manifests.ts index d6605f11ff..45b2878951 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/members/member-groups/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../member-group.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const treeAlias = 'Umb.Tree.MemberGroups'; @@ -7,7 +8,7 @@ const tree: ManifestTree = { alias: treeAlias, name: 'Member Groups Tree', meta: { - storeAlias: 'umbMemberGroupStore', + storeAlias: STORE_ALIAS, }, }; From 05b623cad9a43c52ea8686af47fc1dc8c064d599 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:09:17 +0100 Subject: [PATCH 48/75] migrate UmbSectionStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../backoffice-frame/backoffice-header-sections.element.ts | 4 ++-- .../components/backoffice-frame/backoffice-main.element.ts | 4 ++-- .../src/backoffice/shared/components/section/section.store.ts | 3 +++ 4 files changed, 9 insertions(+), 6 deletions(-) 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 4af20458ac..14fdd57669 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -21,7 +21,7 @@ import { UmbMemberGroupStore, UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS } from './mem import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; -import { UmbSectionStore } from './shared/components/section/section.store'; +import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from './shared/components/section/section.store'; import { UmbDataTypeStore, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS } from './settings/data-types/data-type.store'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -70,7 +70,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_USER_STORE_CONTEXT_ALIAS, new UmbUserStore(this)); this.provideContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, new UmbUserGroupStore(this)); this.provideContext(UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS, new UmbMemberGroupStore(this)); - this.provideContext('umbSectionStore', new UmbSectionStore()); + this.provideContext(UMB_SECTION_STORE_CONTEXT_ALIAS, new UmbSectionStore()); this.provideContext('umbCurrentUserHistoryStore', new UmbCurrentUserHistoryStore()); this.provideContext('umbDictionaryStore', new UmbDictionaryStore(this)); this.provideContext('umbDocumentBlueprintStore', new UmbDocumentBlueprintStore(this)); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-header-sections.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-header-sections.element.ts index 7cd6c21bed..e3a7ad5f04 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-header-sections.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-header-sections.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { when } from 'lit/directives/when.js'; -import { UmbSectionStore } from '../section/section.store'; +import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from '../section/section.store'; import type { ManifestSection } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -54,7 +54,7 @@ export class UmbBackofficeHeaderSections extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionStore', (sectionStore: UmbSectionStore) => { + this.consumeContext(UMB_SECTION_STORE_CONTEXT_ALIAS, (sectionStore) => { this._sectionStore = sectionStore; this._observeSections(); this._observeCurrentSection(); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts index 820b6c6050..03082520d2 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts @@ -3,7 +3,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { state } from 'lit/decorators.js'; import { IRoutingInfo } from 'router-slot'; -import { UmbSectionStore } from '../section/section.store'; +import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from '../section/section.store'; import { UmbSectionContext } from '../section/section.context'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import type { ManifestSection } from '@umbraco-cms/models'; @@ -41,7 +41,7 @@ export class UmbBackofficeMain extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionStore', (_instance: UmbSectionStore) => { + this.consumeContext(UMB_SECTION_STORE_CONTEXT_ALIAS, (_instance) => { this._sectionStore = _instance; this._observeSections(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.store.ts index ac710a3a2e..800030f4e3 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.store.ts @@ -1,5 +1,6 @@ import { Observable, ReplaySubject } from 'rxjs'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; // TODO: maybe this should be named something else than store? export class UmbSectionStore { @@ -20,3 +21,5 @@ export class UmbSectionStore { this._currentAlias.next(alias); } } + +export const UMB_SECTION_STORE_CONTEXT_ALIAS = new UmbContextAlias(UmbSectionStore.name); From eb8982a2ee4287e9b39563a45337eb0b516943e8 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:13:31 +0100 Subject: [PATCH 49/75] migrate UmbCollectionContext to generic UmbContextAlias --- ...ection-bulk-action-media-delete.element.ts | 4 ++-- .../collection-selection-actions.element.ts | 4 ++-- .../shared/collection/collection.context.ts | 21 ++++++++++++------- .../shared/collection/collection.element.ts | 6 +++--- .../dashboard-collection.element.ts | 7 +++++-- .../collection-view-media-grid.element.ts | 5 ++--- .../collection-view-media-table.element.ts | 4 ++-- .../workspace-view-collection.element.ts | 7 +++++-- 8 files changed, 35 insertions(+), 23 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/bulk-actions/collection-bulk-action-media-delete.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/bulk-actions/collection-bulk-action-media-delete.element.ts index 6cf38a66e0..31f7d08428 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/bulk-actions/collection-bulk-action-media-delete.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/bulk-actions/collection-bulk-action-media-delete.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement } from 'lit/decorators.js'; import { ifDefined } from 'lit/directives/if-defined.js'; -import type { UmbCollectionContext } from '../collection.context'; +import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS } from '../collection.context'; import type { ManifestCollectionBulkAction } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -18,7 +18,7 @@ export class UmbCollectionBulkActionDeleteElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbCollectionContext', (context) => { + this.consumeContext(UMB_COLLECTION_CONTEXT_ALIAS, (context) => { this._collectionContext = context; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection-selection-actions.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection-selection-actions.element.ts index 83121e2ee2..37c367f249 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection-selection-actions.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection-selection-actions.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; -import type { UmbCollectionContext } from './collection.context'; +import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS } from './collection.context'; import type { MediaDetails } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -36,7 +36,7 @@ export class UmbCollectionSelectionActionsElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbCollectionContext', (instance) => { + this.consumeContext(UMB_COLLECTION_CONTEXT_ALIAS, (instance) => { this._collectionContext = instance; this._observeCollectionContext(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.context.ts index a312ccadf0..a84ce349f9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.context.ts @@ -1,13 +1,12 @@ import { ContentTreeItem } from '@umbraco-cms/backend-api'; import { UmbTreeDataStore } from '@umbraco-cms/stores/store'; import { UmbControllerHostInterface } from '@umbraco-cms/controller'; -import { UmbContextConsumerController } from '@umbraco-cms/context-api'; +import { UmbContextAlias, UmbContextConsumerController } from '@umbraco-cms/context-api'; import { UniqueBehaviorSubject, UmbObserverController } from '@umbraco-cms/observable-api'; export class UmbCollectionContext< DataType extends ContentTreeItem, StoreType extends UmbTreeDataStore = UmbTreeDataStore > { - private _host: UmbControllerHostInterface; private _entityKey: string | null; @@ -60,14 +59,18 @@ export class UmbCollectionContext< this._dataObserver?.destroy(); if (this._entityKey) { - this._dataObserver = new UmbObserverController(this._host, this._store.getTreeItemChildren(this._entityKey), (nodes) => { - if(nodes) { - this.#data.next(nodes); + this._dataObserver = new UmbObserverController( + this._host, + this._store.getTreeItemChildren(this._entityKey), + (nodes) => { + if (nodes) { + this.#data.next(nodes); + } } - }); + ); } else { this._dataObserver = new UmbObserverController(this._host, this._store.getTreeRoot(), (nodes) => { - if(nodes) { + if (nodes) { this.#data.next(nodes); } }); @@ -107,3 +110,7 @@ export class UmbCollectionContext< this.#data.unsubscribe(); } } + +export const UMB_COLLECTION_CONTEXT_ALIAS = new UmbContextAlias>( + UmbCollectionContext.name +); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts index 20bf799c50..5c9f89572a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/collection.element.ts @@ -4,7 +4,7 @@ import { customElement, state, property } from 'lit/decorators.js'; import { map } from 'rxjs'; import './collection-selection-actions.element'; import './collection-toolbar.element'; -import type { UmbCollectionContext } from './collection.context'; +import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS } from './collection.context'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import type { ManifestCollectionView, MediaDetails } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; @@ -53,7 +53,7 @@ export class UmbCollectionElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbCollectionContext', (instance) => { + this.consumeContext(UMB_COLLECTION_CONTEXT_ALIAS, (instance) => { this._collectionContext = instance; this._observeCollectionContext(); }); @@ -85,7 +85,7 @@ export class UmbCollectionElement extends UmbLitElement { private _createRoutes(views: ManifestCollectionView[] | null) { this._routes = []; - if(views) { + if (views) { this._routes = views.map((view) => { return { path: `${view.meta.pathName}`, diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/dashboards/dashboard-collection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/dashboards/dashboard-collection.element.ts index 697fa88192..772b8b22d9 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/dashboards/dashboard-collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/dashboards/dashboard-collection.element.ts @@ -4,7 +4,10 @@ import { customElement, state } from 'lit/decorators.js'; import '../collection.element'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import { UmbMediaStore, UmbMediaStoreItemType } from 'src/backoffice/media/media/media.store'; -import { UmbCollectionContext } from 'src/backoffice/shared/collection/collection.context'; +import { + UmbCollectionContext, + UMB_COLLECTION_CONTEXT_ALIAS, +} from 'src/backoffice/shared/collection/collection.context'; import type { ManifestDashboardCollection } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -37,7 +40,7 @@ export class UmbDashboardCollectionElement extends UmbLitElement { const manifestMeta = this.manifest.meta as any; this._entityType = manifestMeta.entityType as string; this._collectionContext = new UmbCollectionContext(this, null, manifestMeta.storeAlias); - this.provideContext('umbCollectionContext', this._collectionContext); + this.provideContext(UMB_COLLECTION_CONTEXT_ALIAS, this._collectionContext); } } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-grid.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-grid.element.ts index 52d943758a..f0cd85277a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-grid.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-grid.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; -import type { UmbCollectionContext } from '../collection.context'; +import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS } from '../collection.context'; import type { MediaDetails } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -77,8 +77,7 @@ export class UmbCollectionViewsMediaGridElement extends UmbLitElement { document.addEventListener('dragenter', this._handleDragEnter.bind(this)); document.addEventListener('dragleave', this._handleDragLeave.bind(this)); document.addEventListener('drop', this._handleDrop.bind(this)); - this.consumeContext('umbCollectionContext', (instance) => { - console.log('umbCollectionContext', instance); + this.consumeContext(UMB_COLLECTION_CONTEXT_ALIAS, (instance) => { this._collectionContext = instance; this._observeCollectionContext(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts index 069e3c8c9e..3de3932012 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/collection/views/collection-view-media-table.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import type { UmbCollectionContext } from '../collection.context'; +import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS } from '../collection.context'; import type { MediaDetails } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -19,7 +19,7 @@ export class UmbCollectionViewMediaTableElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbCollectionContext', (instance) => { + this.consumeContext(UMB_COLLECTION_CONTEXT_ALIAS, (instance) => { this._collectionContext = instance; this._observeCollectionContext(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts index 3ea12bc01c..75bc9db40e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts @@ -3,7 +3,10 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement } from 'lit/decorators.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import type { UmbWorkspaceContentContext } from '../../workspace-content.context'; -import { UmbCollectionContext } from 'src/backoffice/shared/collection/collection.context'; +import { + UmbCollectionContext, + UMB_COLLECTION_CONTEXT_ALIAS, +} from 'src/backoffice/shared/collection/collection.context'; import { UmbMediaStore, UmbMediaStoreItemType } from 'src/backoffice/media/media/media.store'; import '../../../../../../shared/components/content-property/content-property.element'; @@ -42,7 +45,7 @@ export class UmbWorkspaceViewCollectionElement extends UmbLitElement { this._workspaceContext.entityKey, this._workspaceContext.getStore()?.storeAlias || '' // The store is available when the context is available. ); - this.provideContext('umbCollectionContext', this._collectionContext); + this.provideContext(UMB_COLLECTION_CONTEXT_ALIAS, this._collectionContext); } } From 7b6a79a8abb99c17a602f5db85284edc9fde9cf8 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Tue, 17 Jan 2023 15:14:49 +0000 Subject: [PATCH 50/75] Adds the marketplace iframe --- ...kages-market-place-section-view.element.ts | 35 +++++++++++++++++-- 1 file changed, 32 insertions(+), 3 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts index 7b8b760c5a..b5c8e7b12d 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts @@ -1,10 +1,39 @@ -import { html, LitElement } from 'lit'; -import { customElement } from 'lit/decorators.js'; +import { css, html, LitElement } from 'lit'; +import { customElement, property } from 'lit/decorators.js'; @customElement('umb-packages-market-place-section-view') export class UmbPackagesMarketPlaceSectionViewElement extends LitElement { + static styles = [css` + #container { + height: 100%; + display: flex; + align-items: stretch; + } + + + iframe { + width: 100%; + height: 100%; + overflow: hidden; + border: none; + } + `]; + + // TODO: This URL comes from the server + // Was previously found in 'Umbraco.Sys.ServerVariables.umbracoUrls.marketplaceUrl' + @property() + marketplaceUrl: string = 'https://marketplace.umbraco.com/?umbversion=11.1.0&style=backoffice'; + render() { - return html`
Render Marketplace
`; + return html` +
+ +
`; } } From f93f320b5f560fd50ad3443e85eb2181b0c6d82e Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:20:30 +0100 Subject: [PATCH 51/75] migrate UmbInstallerContext to UmbContextAlias --- .../installer/consent/installer-consent.element.ts | 4 ++-- .../installer/database/installer-database.element.ts | 11 +++-------- .../src/installer/error/installer-error.element.ts | 4 ++-- .../src/installer/installer.context.ts | 3 +++ .../src/installer/installer.element.ts | 4 ++-- .../src/installer/user/installer-user.element.ts | 5 ++--- 6 files changed, 14 insertions(+), 17 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/installer/consent/installer-consent.element.ts b/src/Umbraco.Web.UI.Client/src/installer/consent/installer-consent.element.ts index f42628e2b1..112979b3d6 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/consent/installer-consent.element.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/consent/installer-consent.element.ts @@ -2,7 +2,7 @@ import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { unsafeHTML } from 'lit/directives/unsafe-html.js'; -import { UmbInstallerContext } from '../installer.context'; +import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_ALIAS } from '../installer.context'; import { ConsentLevel, Telemetry, TelemetryLevel } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -55,7 +55,7 @@ export class UmbInstallerConsentElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbInstallerContext', (installerContext: UmbInstallerContext) => { + this.consumeContext(UMB_INSTALLER_CONTEXT_ALIAS, (installerContext) => { this._installerContext = installerContext; this._observeInstallerSettings(); this._observeInstallerData(); diff --git a/src/Umbraco.Web.UI.Client/src/installer/database/installer-database.element.ts b/src/Umbraco.Web.UI.Client/src/installer/database/installer-database.element.ts index e63ad4a617..39b330fb68 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/database/installer-database.element.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/database/installer-database.element.ts @@ -2,13 +2,8 @@ import { UUIButtonElement } from '@umbraco-ui/uui'; import { css, CSSResultGroup, html, nothing } from 'lit'; import { customElement, property, query, state } from 'lit/decorators.js'; -import { UmbInstallerContext } from '../installer.context'; -import { - DatabaseInstall, - DatabaseSettings, - InstallResource, - ProblemDetails, -} from '@umbraco-cms/backend-api'; +import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_ALIAS } from '../installer.context'; +import { DatabaseInstall, DatabaseSettings, InstallResource, ProblemDetails } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; import { tryExecute } from '@umbraco-cms/resources'; @@ -101,7 +96,7 @@ export class UmbInstallerDatabaseElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbInstallerContext', (installerContext: UmbInstallerContext) => { + this.consumeContext(UMB_INSTALLER_CONTEXT_ALIAS, (installerContext) => { this._installerContext = installerContext; this._observeInstallerSettings(); this._observeInstallerData(); diff --git a/src/Umbraco.Web.UI.Client/src/installer/error/installer-error.element.ts b/src/Umbraco.Web.UI.Client/src/installer/error/installer-error.element.ts index 832669ef46..fb73dac318 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/error/installer-error.element.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/error/installer-error.element.ts @@ -1,7 +1,7 @@ import { css, CSSResultGroup, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbInstallerContext } from '../installer.context'; +import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_ALIAS } from '../installer.context'; import { ProblemDetails } from '@umbraco-cms/backend-api'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -34,7 +34,7 @@ export class UmbInstallerErrorElement extends UmbLitElement { connectedCallback() { super.connectedCallback(); - this.consumeContext('umbInstallerContext', (installerContext) => { + this.consumeContext(UMB_INSTALLER_CONTEXT_ALIAS, (installerContext) => { this._installerContext = installerContext; this._observeInstallStatus(); }); diff --git a/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts b/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts index 2a0db363fa..6c5a8a9f7f 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/installer.context.ts @@ -1,6 +1,7 @@ import { BehaviorSubject, Observable, ReplaySubject } from 'rxjs'; import { Install, InstallResource, InstallSettings, ProblemDetails, TelemetryLevel } from '@umbraco-cms/backend-api'; import { tryExecute } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; /** * Context API for the installer @@ -121,3 +122,5 @@ export class UmbInstallerContext { } } } + +export const UMB_INSTALLER_CONTEXT_ALIAS = new UmbContextAlias(UmbInstallerContext.name); diff --git a/src/Umbraco.Web.UI.Client/src/installer/installer.element.ts b/src/Umbraco.Web.UI.Client/src/installer/installer.element.ts index 4739205ed6..326f7643c3 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/installer.element.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/installer.element.ts @@ -1,6 +1,6 @@ import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbInstallerContext } from './installer.context'; +import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_ALIAS } from './installer.context'; import { UmbLitElement } from '@umbraco-cms/element'; import './consent/installer-consent.element'; @@ -21,7 +21,7 @@ export class UmbInstallerElement extends UmbLitElement { constructor() { super(); - this.provideContext('umbInstallerContext', this._umbInstallerContext); + this.provideContext(UMB_INSTALLER_CONTEXT_ALIAS, this._umbInstallerContext); } connectedCallback(): void { diff --git a/src/Umbraco.Web.UI.Client/src/installer/user/installer-user.element.ts b/src/Umbraco.Web.UI.Client/src/installer/user/installer-user.element.ts index 68df375741..eeaa612d86 100644 --- a/src/Umbraco.Web.UI.Client/src/installer/user/installer-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/installer/user/installer-user.element.ts @@ -1,9 +1,8 @@ import { css, CSSResultGroup, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbInstallerContext } from '../installer.context'; +import { UmbInstallerContext, UMB_INSTALLER_CONTEXT_ALIAS } from '../installer.context'; import { UmbLitElement } from '@umbraco-cms/element'; - @customElement('umb-installer-user') export class UmbInstallerUserElement extends UmbLitElement { static styles: CSSResultGroup = [ @@ -64,7 +63,7 @@ export class UmbInstallerUserElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbInstallerContext', (installerContext: UmbInstallerContext) => { + this.consumeContext(UMB_INSTALLER_CONTEXT_ALIAS, (installerContext) => { this._installerContext = installerContext; this._observeInstallerData(); }); From e00116c9aa867240b430ef54ac280b1773c93650 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:20:39 +0100 Subject: [PATCH 52/75] fix test --- .../core/context-api/provide/context-provider.element.test.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.element.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.element.test.ts index a200c4ebf5..b2f6c44311 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.element.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/provide/context-provider.element.test.ts @@ -8,7 +8,7 @@ export class ContextTestElement extends UmbLitElement { public value: string | null = null; constructor() { super(); - this.consumeContext('test-context', (value) => { + this.consumeContext('test-context', (value) => { this.value = value; }); } From 0c22b4ee5f7b6ab6444d331112dd54d8c6fa74e9 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:21:41 +0100 Subject: [PATCH 53/75] add types to workspace contexts consumers since it is not easily migrated to UmbContextAlias --- .../workspace-property.context.ts | 62 +++++++------------ .../workspace-action-node-save.element.ts | 24 +++---- .../workspace-view-collection.element.ts | 5 +- .../workspace-view-content-edit.element.ts | 34 +++++----- .../workspace-view-content-info.element.ts | 17 ++--- ...orkspace-action-user-group-save.element.ts | 5 +- .../workspace-action-user-save.element.ts | 3 +- 7 files changed, 70 insertions(+), 80 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace-property/workspace-property.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace-property/workspace-property.context.ts index 37e20d25ff..4bf94b6d3c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace-property/workspace-property.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace-property/workspace-property.context.ts @@ -1,19 +1,9 @@ -import { UmbWorkspaceContentContext } from "../workspace/workspace-content/workspace-content.context"; -import type { DataTypeDetails } from "@umbraco-cms/models"; -import { UmbControllerHostInterface } from "src/core/controller/controller-host.mixin"; -import { createObservablePart, UniqueBehaviorSubject } from "src/core/observable-api/unique-behavior-subject"; -import { UmbContextProviderController } from "src/core/context-api/provide/context-provider.controller"; -import { UmbContextConsumerController } from "src/core/context-api/consume/context-consumer.controller"; - - - - - - - - - - +import { UmbWorkspaceContentContext } from '../workspace/workspace-content/workspace-content.context'; +import type { DataTypeDetails } from '@umbraco-cms/models'; +import { UmbControllerHostInterface } from 'src/core/controller/controller-host.mixin'; +import { createObservablePart, UniqueBehaviorSubject } from 'src/core/observable-api/unique-behavior-subject'; +import { UmbContextProviderController } from 'src/core/context-api/provide/context-provider.controller'; +import { UmbContextConsumerController } from 'src/core/context-api/consume/context-consumer.controller'; // If we get this from the server then we can consider using TypeScripts Partial<> around the model from the Management-API. export type WorkspacePropertyData = { @@ -21,62 +11,56 @@ export type WorkspacePropertyData = { label?: string; description?: string; value?: ValueType | null; - config?: DataTypeDetails['data'];// This could potentially then come from hardcoded JS object and not the DataType store. + config?: DataTypeDetails['data']; // This could potentially then come from hardcoded JS object and not the DataType store. }; export class UmbWorkspacePropertyContext { - - private _providerController: UmbContextProviderController; private _data = new UniqueBehaviorSubject>({}); - public readonly alias = createObservablePart(this._data, data => data.alias); - public readonly label = createObservablePart(this._data, data => data.label); - public readonly description = createObservablePart(this._data, data => data.description); - public readonly value = createObservablePart(this._data, data => data.value); - public readonly config = createObservablePart(this._data, data => data.config); + public readonly alias = createObservablePart(this._data, (data) => data.alias); + public readonly label = createObservablePart(this._data, (data) => data.label); + public readonly description = createObservablePart(this._data, (data) => data.description); + public readonly value = createObservablePart(this._data, (data) => data.value); + public readonly config = createObservablePart(this._data, (data) => data.config); private _workspaceContext?: UmbWorkspaceContentContext; - - constructor(host:UmbControllerHostInterface) { - - new UmbContextConsumerController(host, 'umbWorkspaceContext', (workspaceContext) => { + constructor(host: UmbControllerHostInterface) { + // TODO: Figure out how to get the magic string in a better way. + new UmbContextConsumerController(host, 'umbWorkspaceContext', (workspaceContext) => { this._workspaceContext = workspaceContext; }); this._providerController = new UmbContextProviderController(host, 'umbPropertyContext', this); - - } public setAlias(alias: WorkspacePropertyData['alias']) { - this._data.update({alias: alias}); + this._data.update({ alias: alias }); } public setLabel(label: WorkspacePropertyData['label']) { - this._data.update({label: label}); + this._data.update({ label: label }); } public setDescription(description: WorkspacePropertyData['description']) { - this._data.update({description: description}); + this._data.update({ description: description }); } public setValue(value: WorkspacePropertyData['value']) { - // Note: Do not try to compare new / old value, as it can of any type. We trust the UniqueBehaviorSubject in doing such. - this._data.update({value: value}); + this._data.update({ value: value }); const alias = this._data.getValue().alias; - if(alias) { + if (alias) { this._workspaceContext?.setPropertyValue(alias, value); } } public setConfig(config: WorkspacePropertyData['config']) { - this._data.update({config: config}); + this._data.update({ config: config }); } public resetValue() { - this.setValue(null);// TODO: Consider if this can be configured/provided from Property Editor or DataType Configuration or even locally specified in DocumentType. + this.setValue(null); // TODO: Consider if this can be configured/provided from Property Editor or DataType Configuration or even locally specified in DocumentType. } // TODO: how can we make sure to call this. @@ -84,6 +68,4 @@ export class UmbWorkspacePropertyContext { this._data.unsubscribe(); this._providerController.destroy(); // This would also be handled by the controller host, but if someone wanted to replace/remove this context without the host being destroyed. Then we have clean up out selfs here. } - } - diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/actions/save/workspace-action-node-save.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/actions/save/workspace-action-node-save.element.ts index 2e22762721..733eb1d661 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/actions/save/workspace-action-node-save.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/actions/save/workspace-action-node-save.element.ts @@ -2,13 +2,12 @@ import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import type { UUIButtonState } from '@umbraco-ui/uui'; -import type { UmbWorkspaceContentContext } from '../../workspace-content/workspace-content.context'; +import { UmbWorkspaceContentContext } from '../../workspace-content/workspace-content.context'; import { UmbLitElement } from '@umbraco-cms/element'; import type { ManifestWorkspaceAction } from '@umbraco-cms/models'; @customElement('umb-workspace-action-node-save') export class UmbWorkspaceActionNodeSaveElement extends UmbLitElement { - static styles = [UUITextStyles, css``]; @state() @@ -21,21 +20,24 @@ export class UmbWorkspaceActionNodeSaveElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (instance) => { - this._workspaceContext = instance; - } - ); + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext('umbWorkspaceContext', (instance) => { + this._workspaceContext = instance; + }); } private async _onSave() { if (!this._workspaceContext) return; this._saveButtonState = 'waiting'; - await this._workspaceContext.save().then(() => { - this._saveButtonState = 'success'; - }).catch(() => { - this._saveButtonState = 'failed'; - }) + await this._workspaceContext + .save() + .then(() => { + this._saveButtonState = 'success'; + }) + .catch(() => { + this._saveButtonState = 'failed'; + }); } render() { diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts index 75bc9db40e..4f5a31b59a 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/collection/workspace-view-collection.element.ts @@ -2,7 +2,7 @@ import { css, html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement } from 'lit/decorators.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; -import type { UmbWorkspaceContentContext } from '../../workspace-content.context'; +import { UmbWorkspaceContentContext } from '../../workspace-content.context'; import { UmbCollectionContext, UMB_COLLECTION_CONTEXT_ALIAS, @@ -32,7 +32,8 @@ export class UmbWorkspaceViewCollectionElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (nodeContext) => { + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext('umbWorkspaceContext', (nodeContext) => { this._workspaceContext = nodeContext; this._provideWorkspace(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/edit/workspace-view-content-edit.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/edit/workspace-view-content-edit.element.ts index e004fa983a..d10cf56215 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/edit/workspace-view-content-edit.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/edit/workspace-view-content-edit.element.ts @@ -3,7 +3,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, state } from 'lit/decorators.js'; import { distinctUntilChanged } from 'rxjs'; import { repeat } from 'lit/directives/repeat.js'; -import type { UmbWorkspaceContentContext } from '../../workspace-content.context'; +import { UmbWorkspaceContentContext } from '../../workspace-content.context'; import type { ContentProperty, ContentPropertyData, DocumentDetails, MediaDetails } from '@umbraco-cms/models'; import '../../../../content-property/content-property.element'; @@ -32,10 +32,14 @@ export class UmbWorkspaceViewContentEditElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (workspaceContext) => { - this._workspaceContext = workspaceContext; - this._observeContent(); - }); + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext>( + 'umbWorkspaceContext', + (workspaceContext) => { + this._workspaceContext = workspaceContext; + this._observeContent(); + } + ); } private _observeContent() { @@ -43,22 +47,19 @@ export class UmbWorkspaceViewContentEditElement extends UmbLitElement { /* TODO: Property-Context: This observer gets all changes, We need to fix this. it should be simpler. - It should look at length and aliases? as long as they are identical nothing should change. + It should look at length and aliases? as long as they are identical nothing should change. As they would update them selfs? Should use a Observable for this._workspaceContext.properties */ - this.observe( - this._workspaceContext.data.pipe(distinctUntilChanged()), - (content) => { - this._properties = content.properties; - this._data = content.data; - /* + this.observe(this._workspaceContext.data.pipe(distinctUntilChanged()), (content) => { + this._properties = content.properties; + this._data = content.data; + /* Maybe we should not give the value, but the umb-content-property should get the context and observe its own data. This would become a more specific Observer therefor better performance?.. Note to self: Debate with Mads how he sees this perspective. */ - } - ); + }); } render() { @@ -67,11 +68,10 @@ export class UmbWorkspaceViewContentEditElement extends UmbLitElement { ${repeat( this._properties, (property) => property.alias, - (property) => + (property) => html` data.alias === property.alias)?.value}> - ` + .value=${this._data.find((data) => data.alias === property.alias)?.value}> ` )} `; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/info/workspace-view-content-info.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/info/workspace-view-content-info.element.ts index 56fd69160c..ae148d8937 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/info/workspace-view-content-info.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/workspace/workspace-content/views/info/workspace-view-content-info.element.ts @@ -11,10 +11,10 @@ export class UmbWorkspaceViewContentInfoElement extends UmbLitElement { UUITextStyles, css` :host { - display:block; + display: block; margin: var(--uui-size-layout-1); } - ` + `, ]; @state() @@ -25,13 +25,16 @@ export class UmbWorkspaceViewContentInfoElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (nodeContext) => { - this._workspaceContext = nodeContext; - this._observeContent(); - }); + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext>( + 'umbWorkspaceContext', + (nodeContext) => { + this._workspaceContext = nodeContext; + this._observeContent(); + } + ); } - private _observeContent() { if (!this._workspaceContext) return; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/actions/workspace-action-user-group-save.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/actions/workspace-action-user-group-save.element.ts index 6aa5d8f09a..3977037d08 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/actions/workspace-action-user-group-save.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-groups/workspace/actions/workspace-action-user-group-save.element.ts @@ -2,7 +2,7 @@ import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import type { UUIButtonState } from '@umbraco-ui/uui'; -import type { UmbWorkspaceUserContext } from '../../../users/workspace/user-workspace.context'; +import { UmbWorkspaceUserContext } from '../../../users/workspace/user-workspace.context'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-action-user-group-save') @@ -17,7 +17,8 @@ export class UmbWorkspaceActionUserGroupSaveElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (instance) => { + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext('umbWorkspaceContext', (instance) => { this._workspaceContext = instance; }); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/actions/workspace-action-user-save.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/actions/workspace-action-user-save.element.ts index 43370e5c02..000e11c34d 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/actions/workspace-action-user-save.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/users/workspace/actions/workspace-action-user-save.element.ts @@ -17,7 +17,8 @@ export class UmbWorkspaceActionUserSaveElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (instance) => { + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext('umbWorkspaceContext', (instance) => { this._workspaceContext = instance; }); } From 8f389a217dd7f2afe913eda9496b3e7789674f46 Mon Sep 17 00:00:00 2001 From: Warren Buckley Date: Tue, 17 Jan 2023 15:22:13 +0000 Subject: [PATCH 54/75] Updated to pass linter on GitHub Actions CI - type is inferred by default value --- .../market-place/packages-market-place-section-view.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts index b5c8e7b12d..fb4eb3af97 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/packages/package-section/views/market-place/packages-market-place-section-view.element.ts @@ -22,7 +22,7 @@ export class UmbPackagesMarketPlaceSectionViewElement extends LitElement { // TODO: This URL comes from the server // Was previously found in 'Umbraco.Sys.ServerVariables.umbracoUrls.marketplaceUrl' @property() - marketplaceUrl: string = 'https://marketplace.umbraco.com/?umbversion=11.1.0&style=backoffice'; + marketplaceUrl = 'https://marketplace.umbraco.com/?umbversion=11.1.0&style=backoffice'; render() { return html` From fbc8928ecd22c2b049bb9ad8c202ed5a7281ea84 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:24:47 +0100 Subject: [PATCH 55/75] migrate UmbSectionContext to UmbContextAlias --- .../backoffice-main.element.ts | 4 ++-- .../section-dashboards.element.ts | 10 ++++----- .../section-dashboards.stories.ts | 6 +++-- .../section-sidebar-menu.element.ts | 4 ++-- .../section-sidebar.element.ts | 4 ++-- .../section-views/section-views.element.ts | 4 ++-- .../components/section/section.context.ts | 6 ++--- .../components/section/section.element.ts | 22 ++++++++----------- .../tree/action/tree-item-action.element.ts | 4 ++-- ...e-context-menu-page-action-list.element.ts | 4 ++-- .../components/tree/tree-item.element.ts | 4 ++-- 11 files changed, 35 insertions(+), 37 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts index 03082520d2..c262fd10bc 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/backoffice-frame/backoffice-main.element.ts @@ -4,7 +4,7 @@ import { css, html } from 'lit'; import { state } from 'lit/decorators.js'; import { IRoutingInfo } from 'router-slot'; import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from '../section/section.store'; -import { UmbSectionContext } from '../section/section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section/section.context'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import type { ManifestSection } from '@umbraco-cms/models'; import { UmbSectionElement } from 'src/backoffice/shared/components/section/section.element'; @@ -93,7 +93,7 @@ export class UmbBackofficeMain extends UmbLitElement { private _provideSectionContext(section: ManifestSection) { if (!this._sectionContext) { this._sectionContext = new UmbSectionContext(section); - this.provideContext('umbSectionContext', this._sectionContext); + this.provideContext(UMB_SECTION_CONTEXT_ALIAS, this._sectionContext); } else { this._sectionContext.setManifest(section); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts index bc1bfa484f..2fae73b1f5 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.element.ts @@ -3,7 +3,7 @@ import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { IRoutingInfo } from 'router-slot'; import { first, map } from 'rxjs'; -import { UmbSectionContext } from '../section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section.context'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import type { ManifestDashboard, @@ -63,7 +63,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (context: UmbSectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (context) => { this._sectionContext = context; this._observeSectionContext(); }); @@ -73,7 +73,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { if (!this._sectionContext) return; this.observe(this._sectionContext.manifest.pipe(first()), (section) => { - if(section) { + if (section) { this._currentSectionAlias = section.alias; this._currentSectionPathname = section.meta.pathname; this._observeDashboards(); @@ -86,7 +86,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { this.observe( umbExtensionsRegistry - ?.extensionsOfTypes<(ManifestDashboard | ManifestDashboardCollection)>(['dashboard', 'dashboardCollection']) + ?.extensionsOfTypes(['dashboard', 'dashboardCollection']) .pipe( map((extensions) => extensions.filter((extension) => @@ -104,7 +104,7 @@ export class UmbSectionDashboardsElement extends UmbLitElement { private _createRoutes() { this._routes = []; - if(this._dashboards) { + if (this._dashboards) { this._routes = this._dashboards.map((dashboard) => { return { path: `${dashboard.meta.pathname}`, diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.stories.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.stories.ts index c54f0dbf59..8d2b69df27 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.stories.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-dashboards/section-dashboards.stories.ts @@ -1,7 +1,7 @@ import { Meta, Story } from '@storybook/web-components'; import { html } from 'lit-html'; import { manifests } from '../../../../documents/section.manifests'; -import { UmbSectionContext } from '../section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section.context'; import type { UmbSectionDashboardsElement } from './section-dashboards.element'; import type { ManifestSection } from '@umbraco-cms/models'; import './section-dashboards.element'; @@ -14,7 +14,9 @@ export default { id: 'umb-section-dashboards', decorators: [ (story) => - html` + html` ${story()} `, ], diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar-menu/section-sidebar-menu.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar-menu/section-sidebar-menu.element.ts index 47977ede17..90140a5aa1 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar-menu/section-sidebar-menu.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar-menu/section-sidebar-menu.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbSectionContext } from '../section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section.context'; import { ManifestSidebarMenuItem } from '@umbraco-cms/extensions-registry'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -19,7 +19,7 @@ export class UmbSectionSidebarMenuElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (instance) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (instance) => { this._sectionContext = instance; this._observeCurrentSection(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar/section-sidebar.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar/section-sidebar.element.ts index b339344abd..b2adba6084 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar/section-sidebar.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-sidebar/section-sidebar.element.ts @@ -1,7 +1,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, html } from 'lit'; import { customElement, state } from 'lit/decorators.js'; -import { UmbSectionContext } from '../section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section.context'; import type { ManifestSection } from '@umbraco-cms/models'; import '../../tree/context-menu/tree-context-menu.service'; @@ -39,7 +39,7 @@ export class UmbSectionSidebarElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (sectionContext: UmbSectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (sectionContext) => { this._sectionContext = sectionContext; this._observeSectionContext(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-views/section-views.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-views/section-views.element.ts index 9773e7d1b7..06b7dd27de 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-views/section-views.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section-views/section-views.element.ts @@ -2,7 +2,7 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { EMPTY, map, of, Subscription, switchMap } from 'rxjs'; -import { UmbSectionContext } from '../section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section.context'; import type { ManifestSectionView } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -44,7 +44,7 @@ export class UmbSectionViewsElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (sectionContext: UmbSectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (sectionContext) => { this._sectionContext = sectionContext; this._observeViews(); this._observeActiveView(); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.context.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.context.ts index 8ce461f91a..ab2a382154 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.context.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.context.ts @@ -1,10 +1,9 @@ import { BehaviorSubject } from 'rxjs'; import type { Entity, ManifestSection, ManifestSectionView, ManifestTree } from '@umbraco-cms/models'; import { UniqueBehaviorSubject } from '@umbraco-cms/observable-api'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export class UmbSectionContext { - - #manifest; public readonly manifest; @@ -25,7 +24,6 @@ export class UmbSectionContext { this.manifest = this.#manifest.asObservable(); } - public setManifest(data: ManifestSection) { this.#manifest.next({ ...data }); } @@ -46,3 +44,5 @@ export class UmbSectionContext { this._activeView.next(view); } } + +export const UMB_SECTION_CONTEXT_ALIAS = new UmbContextAlias(UmbSectionContext.name); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts index e975845712..012142be63 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/section/section.element.ts @@ -4,7 +4,7 @@ import { customElement, state } from 'lit/decorators.js'; import { map, switchMap, EMPTY, of } from 'rxjs'; import { IRoutingInfo } from 'router-slot'; import type { UmbWorkspaceEntityElement } from '../workspace/workspace-entity-element.interface'; -import { UmbSectionContext } from './section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from './section.context'; import { createExtensionElement } from '@umbraco-cms/extensions-api'; import type { ManifestSectionView, ManifestWorkspace, ManifestSidebarMenuItem } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; @@ -48,7 +48,7 @@ export class UmbSectionElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (instance) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (instance) => { this._sectionContext = instance; // TODO: currently they don't corporate, as they overwrite each other... @@ -60,11 +60,9 @@ export class UmbSectionElement extends UmbLitElement { private _observeMenuItems() { if (!this._sectionContext) return; - this.observe(this._sectionContext?.manifest, - (section) => { - this._observeSidebarMenuItem(section?.alias); - } - ); + this.observe(this._sectionContext?.manifest, (section) => { + this._observeSidebarMenuItem(section?.alias); + }); this.observe(umbExtensionsRegistry.extensionsOfType('workspace'), (workspaceExtensions) => { this._workspaces = workspaceExtensions; @@ -72,14 +70,12 @@ export class UmbSectionElement extends UmbLitElement { }); } - private _observeSidebarMenuItem(sectionAlias?:string) { - if(sectionAlias) { + private _observeSidebarMenuItem(sectionAlias?: string) { + if (sectionAlias) { this.observe( umbExtensionsRegistry - ?.extensionsOfType('sidebarMenuItem') - .pipe( - map((manifests) => manifests.filter((manifest) => manifest.meta.sections.includes(sectionAlias))) - ), + ?.extensionsOfType('sidebarMenuItem') + .pipe(map((manifests) => manifests.filter((manifest) => manifest.meta.sections.includes(sectionAlias)))), (manifests) => { this._menuItems = manifests; this._createMenuRoutes(); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts index 773916db86..02c504c965 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts @@ -1,5 +1,5 @@ import { customElement, property, state } from 'lit/decorators.js'; -import { UmbSectionContext } from '../../section/section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../../section/section.context'; import { UmbTreeContextMenuPageService } from '../context-menu/tree-context-menu-page.service'; import { UmbTreeContextMenuService } from '../context-menu/tree-context-menu.service'; import type { Entity, ManifestTreeItemAction, ManifestTree } from '@umbraco-cms/models'; @@ -28,7 +28,7 @@ export default class UmbTreeItemActionElement extends UmbLitElement { connectedCallback() { super.connectedCallback(); - this.consumeContext('umbSectionContext', (sectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (sectionContext) => { this._sectionContext = sectionContext; this._observeActiveTree(); this._observeActiveTreeItem(); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page-action-list.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page-action-list.element.ts index 59a5991fa4..4107927fec 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page-action-list.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page-action-list.element.ts @@ -2,7 +2,7 @@ import { css, html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, state } from 'lit/decorators.js'; import { map } from 'rxjs'; -import { UmbSectionContext } from '../../section/section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../../section/section.context'; import type { Entity, ManifestTreeItemAction, ManifestTree } from '@umbraco-cms/models'; import { umbExtensionsRegistry } from '@umbraco-cms/extensions-registry'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -41,7 +41,7 @@ export class UmbTreeContextMenuPageActionListElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbSectionContext', (sectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (sectionContext) => { this._sectionContext = sectionContext; this._observeActiveTree(); this._observeActiveTreeItem(); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts index 8ec0dffd7e..828841b360 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts @@ -4,7 +4,7 @@ import { customElement, property, state } from 'lit/decorators.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import { map, Observable } from 'rxjs'; import { repeat } from 'lit/directives/repeat.js'; -import { UmbSectionContext } from '../section/section.context'; +import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section/section.context'; import type { UmbTreeContextBase } from './tree.context'; import { UmbTreeContextMenuService } from './context-menu/tree-context-menu.service'; import type { Entity } from '@umbraco-cms/models'; @@ -82,7 +82,7 @@ export class UmbTreeItem extends UmbLitElement { this._store = store; }); - this.consumeContext('umbSectionContext', (sectionContext: UmbSectionContext) => { + this.consumeContext(UMB_SECTION_CONTEXT_ALIAS, (sectionContext) => { this._sectionContext = sectionContext; this._observeSection(); this._observeActiveTreeItem(); From 3f45be8b0a30729730f138a51ba9054fd5d625c4 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:25:18 +0100 Subject: [PATCH 56/75] set type for workspace --- .../variant-selector.element.ts | 63 ++++++++++--------- 1 file changed, 35 insertions(+), 28 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/variant-selector/variant-selector.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/variant-selector/variant-selector.element.ts index 11a83671bf..dc605c8d92 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/variant-selector/variant-selector.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/variant-selector/variant-selector.element.ts @@ -54,10 +54,14 @@ export class UmbVariantSelectorElement extends UmbLitElement { constructor() { super(); - this.consumeContext('umbWorkspaceContext', (instance) => { - this._workspaceContext = instance; - this._observeWorkspace(); - }); + // TODO: Figure out how to get the magic string for the workspace context. + this.consumeContext>>( + 'umbWorkspaceContext', + (instance) => { + this._workspaceContext = instance; + this._observeWorkspace(); + } + ); } private async _observeWorkspace() { @@ -68,7 +72,6 @@ export class UmbVariantSelectorElement extends UmbLitElement { }); } - // TODO. find a way where we don't have to do this for all workspaces. private _handleInput(event: UUIInputEvent) { if (event instanceof UUIInputEvent) { @@ -95,31 +98,35 @@ export class UmbVariantSelectorElement extends UmbLitElement { return html` - ${this._content && this._content.variants?.length > 0 - ? html` -
- - English (United States) - - -
- ` - : nothing} + ${ + this._content && this._content.variants?.length > 0 + ? html` +
+ + English (United States) + + +
+ ` + : nothing + }
- ${this._content && this._content.variants?.length > 0 - ? html` - -
- -
    -
  • Implement variants
  • -
-
-
-
- ` - : nothing} + ${ + this._content && this._content.variants?.length > 0 + ? html` + +
+ +
    +
  • Implement variants
  • +
+
+
+
+ ` + : nothing + } `; } From de3ea8b791245a4e5cbdea91c9103be0aab5e545 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:27:17 +0100 Subject: [PATCH 57/75] migrate UmbCurrentUserHistoryStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 7 +++++-- .../current-user/current-user-history.store.ts | 13 +++++++------ .../layouts/modal-layout-current-user.element.ts | 3 ++- 3 files changed, 14 insertions(+), 9 deletions(-) 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 14fdd57669..d7b1b6b3d8 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -7,7 +7,10 @@ import { UmbNotificationService, UMB_NOTIFICATION_SERVICE_CONTEXT_ALIAS } from ' import { UmbUserStore, UMB_USER_STORE_CONTEXT_ALIAS } from './users/users/user.store'; import { UmbUserGroupStore, UMB_USER_GROUP_STORE_CONTEXT_ALIAS } from './users/user-groups/user-group.store'; import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS } from './users/current-user/current-user.store'; -import { UmbCurrentUserHistoryStore } from './users/current-user/current-user-history.store'; +import { + UmbCurrentUserHistoryStore, + UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, +} from './users/current-user/current-user-history.store'; import { UmbDocumentTypeStore, @@ -71,7 +74,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_USER_GROUP_STORE_CONTEXT_ALIAS, new UmbUserGroupStore(this)); this.provideContext(UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS, new UmbMemberGroupStore(this)); this.provideContext(UMB_SECTION_STORE_CONTEXT_ALIAS, new UmbSectionStore()); - this.provideContext('umbCurrentUserHistoryStore', new UmbCurrentUserHistoryStore()); + this.provideContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, new UmbCurrentUserHistoryStore()); this.provideContext('umbDictionaryStore', new UmbDictionaryStore(this)); this.provideContext('umbDocumentBlueprintStore', new UmbDocumentBlueprintStore(this)); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-history.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-history.store.ts index 76f6651277..e2558a5eba 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-history.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/current-user/current-user-history.store.ts @@ -1,3 +1,4 @@ +import { UmbContextAlias } from '@umbraco-cms/context-api'; import { createObservablePart, UniqueBehaviorSubject } from '@umbraco-cms/observable-api'; export type UmbModelType = 'dialog' | 'sidebar'; @@ -9,14 +10,10 @@ export type UmbCurrentUserHistoryItem = { }; export class UmbCurrentUserHistoryStore { - - #history = new UniqueBehaviorSubject( - >[] - ); + #history = new UniqueBehaviorSubject(>[]); public readonly history = this.#history.asObservable(); - public readonly latestHistory = createObservablePart(this.#history, historyItems => historyItems.slice(-10)); - + public readonly latestHistory = createObservablePart(this.#history, (historyItems) => historyItems.slice(-10)); constructor() { if (!('navigation' in window)) return; @@ -52,3 +49,7 @@ export class UmbCurrentUserHistoryStore { this.#history.next([]); } } + +export const UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS = new UmbContextAlias( + UmbCurrentUserHistoryStore.name +); diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts index e647d8a2ed..e3fad1ac29 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts @@ -6,6 +6,7 @@ import type { UserDetails } from '@umbraco-cms/models'; import { UmbCurrentUserHistoryStore, UmbCurrentUserHistoryItem, + UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, } from 'src/backoffice/users/current-user/current-user-history.store'; import { UmbCurrentUserStore, @@ -102,7 +103,7 @@ export class UmbModalLayoutCurrentUserElement extends UmbLitElement { this._observeCurrentUser(); }); - this.consumeContext('umbCurrentUserHistoryStore', (_instance) => { + this.consumeContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, (_instance) => { this._currentUserHistoryStore = _instance; this._observeHistory(); }); From 0c5d4e225ab03b706e8ba8fd93a48121942c60cf Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:28:32 +0100 Subject: [PATCH 58/75] migrate UmbDictionaryStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 4 ++-- .../backoffice/translation/dictionary/dictionary.store.ts | 7 ++++++- .../backoffice/translation/dictionary/tree/manifests.ts | 3 ++- 3 files changed, 10 insertions(+), 4 deletions(-) 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 d7b1b6b3d8..9b1d6e8823 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -21,7 +21,7 @@ import { UmbMemberTypeStore, UMB_MEMBER_TYPE_STORE_CONTEXT_ALIAS } from './membe import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/documents/document.store'; import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; import { UmbMemberGroupStore, UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS } from './members/member-groups/member-group.store'; -import { UmbDictionaryStore } from './translation/dictionary/dictionary.store'; +import { UmbDictionaryStore, UMB_DICTIONARY_STORE_CONTEXT_ALIAS } from './translation/dictionary/dictionary.store'; import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from './shared/components/section/section.store'; @@ -75,7 +75,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS, new UmbMemberGroupStore(this)); this.provideContext(UMB_SECTION_STORE_CONTEXT_ALIAS, new UmbSectionStore()); this.provideContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, new UmbCurrentUserHistoryStore()); - this.provideContext('umbDictionaryStore', new UmbDictionaryStore(this)); + this.provideContext(UMB_DICTIONARY_STORE_CONTEXT_ALIAS, new UmbDictionaryStore(this)); this.provideContext('umbDocumentBlueprintStore', new UmbDocumentBlueprintStore(this)); } diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/dictionary.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/dictionary.store.ts index 6b056b7c07..dae11fae8f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/dictionary.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/dictionary.store.ts @@ -2,6 +2,9 @@ import { map, Observable } from 'rxjs'; import { UmbDataStoreBase } from '../../../core/stores/store'; import { DictionaryResource, EntityTreeItem } from '@umbraco-cms/backend-api'; import { tryExecuteAndNotify } from '@umbraco-cms/resources'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; + +export const STORE_ALIAS = 'umbDictionaryStore'; /** * @export @@ -10,7 +13,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/resources'; * @description - Data Store for Dictionary Items. */ export class UmbDictionaryStore extends UmbDataStoreBase { - public readonly storeAlias = 'umbDictionaryStore'; + public readonly storeAlias = STORE_ALIAS; /** * @description - Get the root of the tree. @@ -48,3 +51,5 @@ export class UmbDictionaryStore extends UmbDataStoreBase { return this.items.pipe(map((items) => items.filter((item) => item.parentKey === key))); } } + +export const UMB_DICTIONARY_STORE_CONTEXT_ALIAS = new UmbContextAlias(STORE_ALIAS); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/tree/manifests.ts b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/tree/manifests.ts index 398b5bb5b0..f399178b43 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/tree/manifests.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/translation/dictionary/tree/manifests.ts @@ -1,3 +1,4 @@ +import { STORE_ALIAS } from '../dictionary.store'; import type { ManifestTree, ManifestTreeItemAction } from '@umbraco-cms/models'; const treeAlias = 'Umb.Tree.Dictionary'; @@ -7,7 +8,7 @@ const tree: ManifestTree = { alias: treeAlias, name: 'Dictionary Tree', meta: { - storeAlias: 'umbDictionaryStore', + storeAlias: STORE_ALIAS, }, }; From 372f3e028a672be7a4667b7a99055a90da6547a8 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:29:54 +0100 Subject: [PATCH 59/75] migrate UmbDocumentBlueprintStore to UmbContextAlias --- .../src/backoffice/backoffice.element.ts | 7 +++++-- .../document-blueprints/document-blueprint.store.ts | 7 ++++++- 2 files changed, 11 insertions(+), 3 deletions(-) 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 9b1d6e8823..d08811f67f 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/backoffice.element.ts @@ -22,7 +22,10 @@ import { UmbDocumentStore, UMB_DOCUMENT_STORE_CONTEXT_ALIAS } from './documents/ import { UmbMediaStore, UMB_MEDIA_STORE_CONTEXT_ALIAS } from './media/media/media.store'; import { UmbMemberGroupStore, UMB_MEMBER_GROUP_STORE_CONTEXT_ALIAS } from './members/member-groups/member-group.store'; import { UmbDictionaryStore, UMB_DICTIONARY_STORE_CONTEXT_ALIAS } from './translation/dictionary/dictionary.store'; -import { UmbDocumentBlueprintStore } from './documents/document-blueprints/document-blueprint.store'; +import { + UmbDocumentBlueprintStore, + UMB_DOCUMENT_BLULEPRINT_STORE_CONTEXT_ALIAS, +} from './documents/document-blueprints/document-blueprint.store'; import { UmbSectionStore, UMB_SECTION_STORE_CONTEXT_ALIAS } from './shared/components/section/section.store'; import { UmbDataTypeStore, UMB_DATA_TYPE_STORE_CONTEXT_ALIAS } from './settings/data-types/data-type.store'; @@ -76,7 +79,7 @@ export class UmbBackofficeElement extends UmbLitElement { this.provideContext(UMB_SECTION_STORE_CONTEXT_ALIAS, new UmbSectionStore()); this.provideContext(UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, new UmbCurrentUserHistoryStore()); this.provideContext(UMB_DICTIONARY_STORE_CONTEXT_ALIAS, new UmbDictionaryStore(this)); - this.provideContext('umbDocumentBlueprintStore', new UmbDocumentBlueprintStore(this)); + this.provideContext(UMB_DOCUMENT_BLULEPRINT_STORE_CONTEXT_ALIAS, new UmbDocumentBlueprintStore(this)); } render() { diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-blueprints/document-blueprint.store.ts b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-blueprints/document-blueprint.store.ts index ca12e0b964..9eaca6f39e 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-blueprints/document-blueprint.store.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/documents/document-blueprints/document-blueprint.store.ts @@ -2,9 +2,12 @@ import { map, Observable } from 'rxjs'; import { UmbNodeStoreBase } from '../../../core/stores/store'; import type { DocumentBlueprintDetails, DocumentDetails } from '@umbraco-cms/models'; import { DocumentBlueprintTreeItem } from '@umbraco-cms/backend-api'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbDocumentStoreItemType = DocumentBlueprintDetails | DocumentBlueprintTreeItem; +export const STORE_ALIAS = 'umbDocumentBlueprintStore'; + const isDocumentBlueprintDetails = ( documentBlueprint: DocumentBlueprintDetails | DocumentBlueprintTreeItem ): documentBlueprint is DocumentBlueprintDetails => { @@ -18,7 +21,7 @@ const isDocumentBlueprintDetails = ( * @description - Data Store for Documents */ export class UmbDocumentBlueprintStore extends UmbNodeStoreBase { - public readonly storeAlias = 'umbDocumentBlueprintStore'; + public readonly storeAlias = STORE_ALIAS; getByKey(key: string): Observable { // TODO: implement call to end point @@ -37,3 +40,5 @@ export class UmbDocumentBlueprintStore extends UmbNodeStoreBase(STORE_ALIAS); From 880c6056d7d7534e7a605753dac5809a63ce6dc5 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Tue, 17 Jan 2023 16:33:16 +0100 Subject: [PATCH 60/75] migrate tree context services to UmbContextAlias --- .../tree/action/tree-item-action.element.ts | 14 ++++++++++---- .../context-menu/tree-context-menu-page.service.ts | 8 +++++++- .../tree/context-menu/tree-context-menu.service.ts | 7 ++++++- .../shared/components/tree/tree-item.element.ts | 7 +++++-- 4 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts index 02c504c965..964777c6f0 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/action/tree-item-action.element.ts @@ -1,7 +1,13 @@ import { customElement, property, state } from 'lit/decorators.js'; import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../../section/section.context'; -import { UmbTreeContextMenuPageService } from '../context-menu/tree-context-menu-page.service'; -import { UmbTreeContextMenuService } from '../context-menu/tree-context-menu.service'; +import { + UmbTreeContextMenuPageService, + UMB_TREE_CONTEXT_MENU_PAGE_SERVICE_CONTEXT_ALIAS, +} from '../context-menu/tree-context-menu-page.service'; +import { + UmbTreeContextMenuService, + UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS, +} from '../context-menu/tree-context-menu.service'; import type { Entity, ManifestTreeItemAction, ManifestTree } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -34,11 +40,11 @@ export default class UmbTreeItemActionElement extends UmbLitElement { this._observeActiveTreeItem(); }); - this.consumeContext('umbTreeContextMenuService', (treeContextMenuService: UmbTreeContextMenuService) => { + this.consumeContext(UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS, (treeContextMenuService) => { this._treeContextMenuService = treeContextMenuService; }); - this.consumeContext('umbTreeContextMenuPageService', (actionPageService: UmbTreeContextMenuPageService) => { + this.consumeContext(UMB_TREE_CONTEXT_MENU_PAGE_SERVICE_CONTEXT_ALIAS, (actionPageService) => { this._actionPageService = actionPageService; this._observeEntity(); }); diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page.service.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page.service.ts index 5804c1b483..4f799de30c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page.service.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu-page.service.ts @@ -2,8 +2,10 @@ import { UUITextStyles } from '@umbraco-ui/uui-css'; import { css, nothing, PropertyValueMap } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import UmbTreeItemActionElement, { ActionPageEntity } from '../action/tree-item-action.element'; +import { UmbTreeContextMenuService } from './tree-context-menu.service'; import { UmbLitElement } from '@umbraco-cms/element'; import { UniqueBehaviorSubject } from '@umbraco-cms/observable-api'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; // TODO: Refactor this, its not a service and the data should be handled by a context api. @customElement('umb-tree-context-menu-page-service') @@ -21,7 +23,7 @@ export class UmbTreeContextMenuPageService extends UmbLitElement { connectedCallback() { super.connectedCallback(); - this.provideContext('umbTreeContextMenuPageService', this); + this.provideContext(UMB_TREE_CONTEXT_MENU_PAGE_SERVICE_CONTEXT_ALIAS, this); this.openFreshPage('umb-tree-context-menu-page-action-list'); } @@ -64,6 +66,10 @@ export class UmbTreeContextMenuPageService extends UmbLitElement { } } +export const UMB_TREE_CONTEXT_MENU_PAGE_SERVICE_CONTEXT_ALIAS = new UmbContextAlias( + UmbTreeContextMenuService.name +); + declare global { interface HTMLElementTagNameMap { 'umb-tree-context-menu-page-service': UmbTreeContextMenuPageService; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu.service.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu.service.ts index f21f2d833a..aaed6a96aa 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu.service.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/context-menu/tree-context-menu.service.ts @@ -3,6 +3,7 @@ import { css, html, nothing } from 'lit'; import { customElement, state } from 'lit/decorators.js'; import { ActionPageEntity } from '../action/tree-item-action.element'; import { UmbLitElement } from '@umbraco-cms/element'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; @customElement('umb-tree-context-menu-service') export class UmbTreeContextMenuService extends UmbLitElement { @@ -56,7 +57,7 @@ export class UmbTreeContextMenuService extends UmbLitElement { connectedCallback() { super.connectedCallback(); - this.provideContext('umbTreeContextMenuService', this); + this.provideContext(UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS, this); } public open(entity: ActionPageEntity) { @@ -92,6 +93,10 @@ export class UmbTreeContextMenuService extends UmbLitElement { } } +export const UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS = new UmbContextAlias( + UmbTreeContextMenuService.name +); + declare global { interface HTMLElementTagNameMap { 'umb-tree-context-menu-service': UmbTreeContextMenuService; diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts index 828841b360..767fa4721c 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/components/tree/tree-item.element.ts @@ -6,7 +6,10 @@ import { map, Observable } from 'rxjs'; import { repeat } from 'lit/directives/repeat.js'; import { UmbSectionContext, UMB_SECTION_CONTEXT_ALIAS } from '../section/section.context'; import type { UmbTreeContextBase } from './tree.context'; -import { UmbTreeContextMenuService } from './context-menu/tree-context-menu.service'; +import { + UmbTreeContextMenuService, + UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS, +} from './context-menu/tree-context-menu.service'; import type { Entity } from '@umbraco-cms/models'; import { UmbTreeDataStore } from '@umbraco-cms/stores/store'; import { UmbLitElement } from '@umbraco-cms/element'; @@ -88,7 +91,7 @@ export class UmbTreeItem extends UmbLitElement { this._observeActiveTreeItem(); }); - this.consumeContext('umbTreeContextMenuService', (treeContextMenuService: UmbTreeContextMenuService) => { + this.consumeContext(UMB_TREE_CONTEXT_MENU_SERVICE_CONTEXT_ALIAS, (treeContextMenuService) => { this._treeContextMenuService = treeContextMenuService; }); } From 6c6abe23942d0acdaf74eb2c8d22d8f69a536d22 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 09:01:19 +0100 Subject: [PATCH 61/75] make import path relative --- .../grid/workspace-view-users-grid.element.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts index 611c20f5f6..6e84aae4bb 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/users/user-section/views/users/list-view-layouts/grid/workspace-view-users-grid.element.ts @@ -5,11 +5,8 @@ import { repeat } from 'lit/directives/repeat.js'; import { ifDefined } from 'lit-html/directives/if-defined.js'; import type { UmbSectionViewUsersElement } from '../../section-view-users.element'; import { getTagLookAndColor } from '../../../../../../../auth/utils'; +import { UmbUserGroupStore, UMB_USER_GROUP_STORE_CONTEXT_ALIAS } from '../../../../../user-groups/user-group.store'; import type { UserDetails, UserEntity, UserGroupEntity } from '@umbraco-cms/models'; -import { - UmbUserGroupStore, - UMB_USER_GROUP_STORE_CONTEXT_ALIAS, -} from 'src/backoffice/users/user-groups/user-group.store'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-workspace-view-users-grid') From 904ac0a8d63a77ca927f4db432d700093df61dfb Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 09:12:26 +0100 Subject: [PATCH 62/75] make import path relative --- .../uis/icon-picker/property-editor-ui-icon-picker.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts index 11b5eb2641..adee00c697 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/shared/property-editors/uis/icon-picker/property-editor-ui-icon-picker.element.ts @@ -1,7 +1,7 @@ import { html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, property } from 'lit/decorators.js'; -import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from 'src/core/modal'; +import { UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '../../../../../core/modal'; import { UmbLitElement } from '@umbraco-cms/element'; /** From 5a50a7028704f306a973ae513a1b1b310bde5719 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 09:13:39 +0100 Subject: [PATCH 63/75] remove css import since it pollutes the test output and doesn't work at the moment --- src/Umbraco.Web.UI.Client/web-test-runner.config.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs index b893e88699..1edfdcd438 100644 --- a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs +++ b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs @@ -39,7 +39,8 @@ export default { testRunnerHtml: (testFramework) => ` - + + From f6a8dd94e657e1a1d159e90d1df6412c267dee17 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:17:43 +0100 Subject: [PATCH 64/75] remove console.log --- .../src/core/context-api/context-alias.test.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts index 4339baca08..81b2f4623a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts +++ b/src/Umbraco.Web.UI.Client/src/core/context-api/context-alias.test.ts @@ -27,7 +27,6 @@ describe('ContextAlias', () => { document.body.appendChild(element); const localConsumer = new UmbContextConsumer(element, contextAlias, (_instance) => { - console.log('got instance', _instance); expect(_instance).to.be.instanceOf(MyClass); expect(_instance.prop).to.eq('value from provider'); done(); From e0ae629f83197436b7d7faa56d8a452a87a6ec0d Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:18:38 +0100 Subject: [PATCH 65/75] use lodash-es instead of lodash to fix failing test (and enable better treeshaking) --- src/Umbraco.Web.UI.Client/devops/plop/plop.js | 3 +-- src/Umbraco.Web.UI.Client/package-lock.json | 18 +++++++++++++++--- src/Umbraco.Web.UI.Client/package.json | 2 +- ...layout-property-editor-ui-picker.element.ts | 13 +++++-------- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/devops/plop/plop.js b/src/Umbraco.Web.UI.Client/devops/plop/plop.js index f6662b30b4..1345d25b26 100644 --- a/src/Umbraco.Web.UI.Client/devops/plop/plop.js +++ b/src/Umbraco.Web.UI.Client/devops/plop/plop.js @@ -1,5 +1,4 @@ -import lodash from 'lodash'; -const { kebabCase, camelCase, startCase } = lodash; +import { kebabCase, camelCase, startCase } from 'lodash-es'; const pascalCase = (str) => startCase(str).replace(/ /g, ''); const tagNamePrefix = 'umb-'; diff --git a/src/Umbraco.Web.UI.Client/package-lock.json b/src/Umbraco.Web.UI.Client/package-lock.json index c0ac33a197..714173e565 100644 --- a/src/Umbraco.Web.UI.Client/package-lock.json +++ b/src/Umbraco.Web.UI.Client/package-lock.json @@ -19,7 +19,7 @@ "@umbraco-ui/uui-modal-sidebar": "file:umbraco-ui-uui-modal-sidebar-0.0.0.tgz", "element-internals-polyfill": "^1.1.19", "lit": "^2.6.1", - "lodash": "^4.17.21", + "lodash-es": "4.17.21", "router-slot": "^1.5.5", "rxjs": "^7.8.0", "uuid": "^9.0.0" @@ -18461,7 +18461,13 @@ "node_modules/lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "node_modules/lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" }, "node_modules/lodash.camelcase": { "version": "4.3.0", @@ -43494,7 +43500,13 @@ "lodash": { "version": "4.17.21", "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==" + "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", + "dev": true + }, + "lodash-es": { + "version": "4.17.21", + "resolved": "https://registry.npmjs.org/lodash-es/-/lodash-es-4.17.21.tgz", + "integrity": "sha512-mKnC+QJ9pWVzv+C4/U3rRsHapFfHvQFoFB92e52xeyGMcX6/OlIl78je1u8vePzYZSkkogMPJ2yjxxsb89cxyw==" }, "lodash.camelcase": { "version": "4.3.0", diff --git a/src/Umbraco.Web.UI.Client/package.json b/src/Umbraco.Web.UI.Client/package.json index 7d3a1c3973..4a11ab1255 100644 --- a/src/Umbraco.Web.UI.Client/package.json +++ b/src/Umbraco.Web.UI.Client/package.json @@ -65,7 +65,7 @@ "@umbraco-ui/uui-modal-sidebar": "file:umbraco-ui-uui-modal-sidebar-0.0.0.tgz", "element-internals-polyfill": "^1.1.19", "lit": "^2.6.1", - "lodash": "^4.17.21", + "lodash-es": "4.17.21", "router-slot": "^1.5.5", "rxjs": "^7.8.0", "uuid": "^9.0.0" diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element.ts index 4df01afad1..fc1a76799d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element.ts @@ -2,7 +2,7 @@ import { css, html } from 'lit'; import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { customElement, property, state } from 'lit/decorators.js'; import { repeat } from 'lit/directives/repeat.js'; -import { groupBy } from 'lodash'; +import { groupBy } from 'lodash-es'; import type { UUIInputEvent } from '@umbraco-ui/uui'; import type { UmbModalHandler } from '../../modal-handler'; import type { ManifestPropertyEditorUI } from '@umbraco-cms/models'; @@ -115,13 +115,10 @@ export class UmbModalLayoutPropertyEditorUIPickerElement extends UmbLitElement { private _usePropertyEditorUIs() { if (!this.data) return; - this.observe( - umbExtensionsRegistry.extensionsOfType('propertyEditorUI'), - (propertyEditorUIs) => { - this._propertyEditorUIs = propertyEditorUIs; - this._groupedPropertyEditorUIs = groupBy(propertyEditorUIs, 'meta.group'); - } - ); + this.observe(umbExtensionsRegistry.extensionsOfType('propertyEditorUI'), (propertyEditorUIs) => { + this._propertyEditorUIs = propertyEditorUIs; + this._groupedPropertyEditorUIs = groupBy(propertyEditorUIs, 'meta.group'); + }); } private _handleClick(propertyEditorUI: ManifestPropertyEditorUI) { From e78ccfb523c0618106ed5e111954ba934caa85b2 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:19:51 +0100 Subject: [PATCH 66/75] import uui-css directly in app.ts, preview.js and web-test-runner.mjs to avoid 404 on the web-test-runner --- src/Umbraco.Web.UI.Client/.storybook/preview.js | 4 +++- src/Umbraco.Web.UI.Client/src/app.ts | 1 + .../src/core/css/custom-properties.css | 2 -- src/Umbraco.Web.UI.Client/web-test-runner.config.mjs | 9 +++++++-- 4 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/.storybook/preview.js b/src/Umbraco.Web.UI.Client/.storybook/preview.js index 8d18e492b2..9eb279f45b 100644 --- a/src/Umbraco.Web.UI.Client/.storybook/preview.js +++ b/src/Umbraco.Web.UI.Client/.storybook/preview.js @@ -1,3 +1,6 @@ +import '../src/core/css/custom-properties.css'; +import '@umbraco-ui/uui-css/dist/uui-css.css'; + import '@umbraco-ui/uui'; import '@umbraco-ui/uui-modal'; import '@umbraco-ui/uui-modal-container'; @@ -22,7 +25,6 @@ import { UmbModalService } from '../src/core/modal'; import { umbExtensionsRegistry } from '../src/core/extensions-registry'; import '../src/core/context-api/provide/context-provider.element'; -import '../src/core/css/custom-properties.css'; import '../src/backoffice/shared/components/backoffice-frame/backoffice-modal-container.element'; import '../src/backoffice/shared/components/code-block/code-block.element'; diff --git a/src/Umbraco.Web.UI.Client/src/app.ts b/src/Umbraco.Web.UI.Client/src/app.ts index deac04fcb6..8cbb6f7bb0 100644 --- a/src/Umbraco.Web.UI.Client/src/app.ts +++ b/src/Umbraco.Web.UI.Client/src/app.ts @@ -1,3 +1,4 @@ +import '@umbraco-ui/uui-css/dist/uui-css.css'; import './core/css/custom-properties.css'; // TODO: remove these imports when they are part of UUI diff --git a/src/Umbraco.Web.UI.Client/src/core/css/custom-properties.css b/src/Umbraco.Web.UI.Client/src/core/css/custom-properties.css index 43f24a9590..4f728ed1fd 100644 --- a/src/Umbraco.Web.UI.Client/src/core/css/custom-properties.css +++ b/src/Umbraco.Web.UI.Client/src/core/css/custom-properties.css @@ -1,5 +1,3 @@ -@import '@umbraco-ui/uui-css/dist/uui-css.css'; - :root { --uui-color-positive: #1c874c; } diff --git a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs index 1edfdcd438..36107c2ec4 100644 --- a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs +++ b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs @@ -39,8 +39,13 @@ export default { testRunnerHtml: (testFramework) => ` - - + + + + Umbraco + + + From 8de68c2d4813609378abbcf9c2d74567621403c3 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:20:20 +0100 Subject: [PATCH 67/75] ensure web-test-runner importmaps and tsconfig.json have the same paths --- src/Umbraco.Web.UI.Client/web-test-runner.config.mjs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs index 36107c2ec4..32cccd6044 100644 --- a/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs +++ b/src/Umbraco.Web.UI.Client/web-test-runner.config.mjs @@ -18,11 +18,11 @@ export default { '@umbraco-cms/controller': './src/core/controller/index.ts', '@umbraco-cms/element': './src/core/element/index.ts', '@umbraco-cms/extensions-api': './src/core/extensions-api/index.ts', + '@umbraco-cms/extensions-registry': './src/core/extensions-registry/index.ts', '@umbraco-cms/observable-api': './src/core/observable-api/index.ts', '@umbraco-cms/utils': './src/core/utils/index.ts', '@umbraco-cms/test-utils': './src/core/test-utils/index.ts', - '@umbraco-cms/resources': './src/core/resources/index.ts', - '@umbraco-cms/extensions-registry': './src/core/extensions-registry/index.ts', + '@umbraco-cms/resources': './src/core/resources/index.ts' }, }, }, From e55b61de02c1999e46ca8e0dd4717aa4248a123b Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:20:48 +0100 Subject: [PATCH 68/75] move initial call to ensure its only being run once --- .../dashboards/telemetry/dashboard-telemetry.element.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts index 140e3b94f7..81f1eee017 100644 --- a/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts +++ b/src/Umbraco.Web.UI.Client/src/backoffice/settings/dashboards/telemetry/dashboard-telemetry.element.ts @@ -32,11 +32,7 @@ export class UmbDashboardTelemetryElement extends UmbLitElement { constructor() { super(); - } - - async connectedCallback() { - super.connectedCallback(); - await this._setup(); + this._setup(); } private async _setup() { From 84df0ec91371c9197521c4423ef43d59a2af3275 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 11:21:05 +0100 Subject: [PATCH 69/75] use relative imports to fix failing tests --- .../core/modal/layouts/modal-layout-current-user.element.ts | 6 +++--- src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts index e3fad1ac29..8784989da5 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/layouts/modal-layout-current-user.element.ts @@ -2,16 +2,16 @@ import { UUITextStyles } from '@umbraco-ui/uui-css/lib'; import { css, CSSResultGroup, html, nothing } from 'lit'; import { customElement, property, state } from 'lit/decorators.js'; import { UmbModalHandler, UmbModalService, UMB_MODAL_SERVICE_CONTEXT_ALIAS } from '..'; -import type { UserDetails } from '@umbraco-cms/models'; import { UmbCurrentUserHistoryStore, UmbCurrentUserHistoryItem, UMB_CURRENT_USER_HISTORY_STORE_CONTEXT_ALIAS, -} from 'src/backoffice/users/current-user/current-user-history.store'; +} from '../../../backoffice/users/current-user/current-user-history.store'; import { UmbCurrentUserStore, UMB_CURRENT_USER_STORE_CONTEXT_ALIAS, -} from 'src/backoffice/users/current-user/current-user.store'; +} from '../../../backoffice/users/current-user/current-user.store'; +import type { UserDetails } from '@umbraco-cms/models'; import { UmbLitElement } from '@umbraco-cms/element'; @customElement('umb-modal-layout-current-user') diff --git a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts index 480a8694b3..d974541fb3 100644 --- a/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts +++ b/src/Umbraco.Web.UI.Client/src/core/modal/modal.service.ts @@ -6,7 +6,6 @@ import './layouts/modal-layout-current-user.element'; import { UUIModalSidebarSize } from '@umbraco-ui/uui-modal-sidebar'; import { BehaviorSubject } from 'rxjs'; -import { UmbContextAlias } from '../context-api/context-alias'; import { UmbModalChangePasswordData } from './layouts/modal-layout-change-password.element'; import type { UmbModalIconPickerData } from './layouts/icon-picker/modal-layout-icon-picker.element'; @@ -15,7 +14,8 @@ import './layouts/icon-picker/modal-layout-icon-picker.element'; import type { UmbModalConfirmData } from './layouts/confirm/modal-layout-confirm.element'; import type { UmbModalContentPickerData } from './layouts/content-picker/modal-layout-content-picker.element'; import type { UmbModalPropertyEditorUIPickerData } from './layouts/property-editor-ui-picker/modal-layout-property-editor-ui-picker.element'; -import { UmbModalHandler } from '.'; +import { UmbModalHandler } from './modal-handler'; +import { UmbContextAlias } from '@umbraco-cms/context-api'; export type UmbModalType = 'dialog' | 'sidebar'; From 313a4b88d1948fe9d9e5e64d4e39f8015f5fbea8 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Wed, 18 Jan 2023 13:44:15 +0100 Subject: [PATCH 70/75] generate new api models --- .../src/core/backend-api/core/ApiError.ts | 28 ++-- .../src/core/backend-api/index.ts | 20 +++ .../src/core/backend-api/models/Assembly.ts | 14 +- .../core/backend-api/models/ConsentLevel.ts | 2 +- .../backend-api/models/ConstructorInfo.ts | 4 +- .../backend-api/models/ContentTreeItem.ts | 7 +- .../core/backend-api/models/CreatedResult.ts | 6 +- .../src/core/backend-api/models/Culture.ts | 4 +- .../backend-api/models/CustomAttributeData.ts | 4 +- .../models/CustomAttributeNamedArgument.ts | 2 +- .../src/core/backend-api/models/DataType.ts | 7 +- .../backend-api/models/DataTypeCreateModel.ts | 7 +- .../backend-api/models/DataTypeProperty.ts | 2 +- .../models/DataTypePropertyReference.ts | 9 ++ .../backend-api/models/DataTypeReference.ts | 12 ++ .../backend-api/models/DataTypeUpdateModel.ts | 7 +- .../backend-api/models/DatabaseSettings.ts | 8 +- .../src/core/backend-api/models/Dictionary.ts | 8 +- .../backend-api/models/DictionaryImport.ts | 2 +- .../backend-api/models/DictionaryOverview.ts | 2 +- .../models/DictionaryTranslation.ts | 2 +- .../models/DocumentBlueprintTreeItem.ts | 8 +- .../backend-api/models/DocumentTreeItem.ts | 7 +- .../models/DocumentTypeTreeItem.ts | 6 +- .../core/backend-api/models/EntityTreeItem.ts | 6 +- .../src/core/backend-api/models/EventInfo.ts | 4 +- .../src/core/backend-api/models/Field.ts | 4 +- .../src/core/backend-api/models/FieldInfo.ts | 4 +- .../backend-api/models/FileSystemTreeItem.ts | 8 +- .../src/core/backend-api/models/Folder.ts | 10 ++ .../backend-api/models/FolderCreateModel.ts | 9 ++ .../core/backend-api/models/FolderTreeItem.ts | 6 +- .../backend-api/models/FolderUpdateModel.ts | 8 + .../core/backend-api/models/HealthCheck.ts | 2 +- .../backend-api/models/HealthCheckGroup.ts | 2 +- .../models/HealthCheckGroupWithResult.ts | 2 +- .../backend-api/models/HealthCheckResult.ts | 2 +- .../models/HealthCheckWithResult.ts | 2 +- .../core/backend-api/models/HealthStatus.ts | 9 ++ .../src/core/backend-api/models/Index.ts | 7 +- .../backend-api/models/InstallSettings.ts | 2 +- .../src/core/backend-api/models/JsonPatch.ts | 4 +- .../src/core/backend-api/models/MemberInfo.ts | 4 +- .../src/core/backend-api/models/MethodBase.ts | 4 +- .../src/core/backend-api/models/MethodInfo.ts | 4 +- .../src/core/backend-api/models/Module.ts | 8 +- .../src/core/backend-api/models/Operator.ts | 14 ++ .../core/backend-api/models/ParameterInfo.ts | 2 +- .../core/backend-api/models/PropertyInfo.ts | 4 +- .../core/backend-api/models/RecycleBinItem.ts | 6 +- .../core/backend-api/models/RedirectUrl.ts | 4 +- .../core/backend-api/models/SearchResult.ts | 4 +- .../src/core/backend-api/models/Searcher.ts | 2 +- .../src/core/backend-api/models/Template.ts | 11 ++ .../backend-api/models/TemplateCreateModel.ts | 10 ++ .../models/TemplateQueryExecuteFilterModel.ts | 12 ++ .../models/TemplateQueryExecuteModel.ts | 15 ++ .../models/TemplateQueryExecuteSortModel.ts | 9 ++ .../models/TemplateQueryOperator.ts | 12 ++ .../models/TemplateQueryProperty.ts | 11 ++ .../models/TemplateQueryPropertyType.ts | 9 ++ .../backend-api/models/TemplateQueryResult.ts | 13 ++ .../models/TemplateQueryResultItem.ts | 9 ++ .../models/TemplateQuerySettings.ts | 13 ++ .../backend-api/models/TemplateScaffold.ts | 8 + .../backend-api/models/TemplateUpdateModel.ts | 10 ++ .../src/core/backend-api/models/Type.ts | 6 +- .../src/core/backend-api/models/TypeInfo.ts | 24 +-- .../backend-api/models/UpgradeSettings.ts | 10 +- .../core/backend-api/models/UserSettings.ts | 2 +- .../src/core/backend-api/models/Version.ts | 2 +- .../backend-api/services/DataTypeResource.ts | 138 ++++++++++++++++- .../backend-api/services/TemplateResource.ts | 143 ++++++++++++++++++ 73 files changed, 652 insertions(+), 140 deletions(-) create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypePropertyReference.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeReference.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/Folder.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderCreateModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderUpdateModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthStatus.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/Operator.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/Template.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateCreateModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteFilterModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteSortModel.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryOperator.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryProperty.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryPropertyType.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResult.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResultItem.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQuerySettings.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateScaffold.ts create mode 100644 src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateUpdateModel.ts diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/core/ApiError.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/core/ApiError.ts index 1dfee0af35..99d7929967 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/core/ApiError.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/core/ApiError.ts @@ -5,20 +5,20 @@ import type { ApiRequestOptions } from './ApiRequestOptions'; import type { ApiResult } from './ApiResult'; export class ApiError extends Error { - public readonly url: string; - public readonly status: number; - public readonly statusText: string; - public readonly body: any; - public readonly request: ApiRequestOptions; + public readonly url: string; + public readonly status: number; + public readonly statusText: string; + public readonly body: any; + public readonly request: ApiRequestOptions; - constructor(request: ApiRequestOptions, response: ApiResult, message: string) { - super(message); + constructor(request: ApiRequestOptions, response: ApiResult, message: string) { + super(message); - this.name = 'ApiError'; - this.url = response.url; - this.status = response.status; - this.statusText = response.statusText; - this.body = response.body; - this.request = request; - } + this.name = 'ApiError'; + this.url = response.url; + this.status = response.status; + this.statusText = response.statusText; + this.body = response.body; + this.request = request; + } } diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/index.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/index.ts index 6687aed063..7d1b97b143 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/index.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/index.ts @@ -26,6 +26,8 @@ export type { DatabaseSettings } from './models/DatabaseSettings'; export type { DataType } from './models/DataType'; export type { DataTypeCreateModel } from './models/DataTypeCreateModel'; export type { DataTypeProperty } from './models/DataTypeProperty'; +export type { DataTypePropertyReference } from './models/DataTypePropertyReference'; +export type { DataTypeReference } from './models/DataTypeReference'; export type { DataTypeUpdateModel } from './models/DataTypeUpdateModel'; export type { Dictionary } from './models/Dictionary'; export type { DictionaryImport } from './models/DictionaryImport'; @@ -44,7 +46,10 @@ export type { Field } from './models/Field'; export { FieldAttributes } from './models/FieldAttributes'; export type { FieldInfo } from './models/FieldInfo'; export type { FileSystemTreeItem } from './models/FileSystemTreeItem'; +export type { Folder } from './models/Folder'; +export type { FolderCreateModel } from './models/FolderCreateModel'; export type { FolderTreeItem } from './models/FolderTreeItem'; +export type { FolderUpdateModel } from './models/FolderUpdateModel'; export { GenericParameterAttributes } from './models/GenericParameterAttributes'; export type { HealthCheck } from './models/HealthCheck'; export type { HealthCheckAction } from './models/HealthCheckAction'; @@ -52,6 +57,7 @@ export type { HealthCheckGroup } from './models/HealthCheckGroup'; export type { HealthCheckGroupWithResult } from './models/HealthCheckGroupWithResult'; export type { HealthCheckResult } from './models/HealthCheckResult'; export type { HealthCheckWithResult } from './models/HealthCheckWithResult'; +export { HealthStatus } from './models/HealthStatus'; export type { HelpPage } from './models/HelpPage'; export type { ICustomAttributeProvider } from './models/ICustomAttributeProvider'; export type { Index } from './models/Index'; @@ -75,6 +81,7 @@ export type { ModuleHandle } from './models/ModuleHandle'; export type { NotFoundResult } from './models/NotFoundResult'; export { NotificationStyle } from './models/NotificationStyle'; export type { OkResult } from './models/OkResult'; +export { Operator } from './models/Operator'; export type { OutOfDateStatus } from './models/OutOfDateStatus'; export { OutOfDateType } from './models/OutOfDateType'; export type { PagedContentTreeItem } from './models/PagedContentTreeItem'; @@ -121,6 +128,19 @@ export { StatusResultType } from './models/StatusResultType'; export type { StructLayoutAttribute } from './models/StructLayoutAttribute'; export type { Telemetry } from './models/Telemetry'; export { TelemetryLevel } from './models/TelemetryLevel'; +export type { Template } from './models/Template'; +export type { TemplateCreateModel } from './models/TemplateCreateModel'; +export type { TemplateQueryExecuteFilterModel } from './models/TemplateQueryExecuteFilterModel'; +export type { TemplateQueryExecuteModel } from './models/TemplateQueryExecuteModel'; +export type { TemplateQueryExecuteSortModel } from './models/TemplateQueryExecuteSortModel'; +export type { TemplateQueryOperator } from './models/TemplateQueryOperator'; +export type { TemplateQueryProperty } from './models/TemplateQueryProperty'; +export { TemplateQueryPropertyType } from './models/TemplateQueryPropertyType'; +export type { TemplateQueryResult } from './models/TemplateQueryResult'; +export type { TemplateQueryResultItem } from './models/TemplateQueryResultItem'; +export type { TemplateQuerySettings } from './models/TemplateQuerySettings'; +export type { TemplateScaffold } from './models/TemplateScaffold'; +export type { TemplateUpdateModel } from './models/TemplateUpdateModel'; export type { Type } from './models/Type'; export { TypeAttributes } from './models/TypeAttributes'; export type { TypeInfo } from './models/TypeInfo'; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Assembly.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Assembly.ts index 13d126ea17..188ab7ecbe 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Assembly.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Assembly.ts @@ -10,27 +10,27 @@ import type { Type } from './Type'; import type { TypeInfo } from './TypeInfo'; export type Assembly = { - readonly definedTypes?: Array | null; - readonly exportedTypes?: Array | null; + readonly definedTypes?: Array; + readonly exportedTypes?: Array; /** * @deprecated */ readonly codeBase?: string | null; entryPoint?: MethodInfo; readonly fullName?: string | null; - readonly imageRuntimeVersion?: string | null; + readonly imageRuntimeVersion?: string; readonly isDynamic?: boolean; - readonly location?: string | null; + readonly location?: string; readonly reflectionOnly?: boolean; readonly isCollectible?: boolean; readonly isFullyTrusted?: boolean; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; /** * @deprecated */ - readonly escapedCodeBase?: string | null; + readonly escapedCodeBase?: string; manifestModule?: Module; - readonly modules?: Array | null; + readonly modules?: Array; /** * @deprecated */ diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConsentLevel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConsentLevel.ts index 155a1b210e..d581eed573 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConsentLevel.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConsentLevel.ts @@ -6,6 +6,6 @@ import type { TelemetryLevel } from './TelemetryLevel'; export type ConsentLevel = { level?: TelemetryLevel; - description?: string | null; + description?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConstructorInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConstructorInfo.ts index d8fcf5ff11..bc87002c57 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConstructorInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ConstructorInfo.ts @@ -12,11 +12,11 @@ import type { RuntimeMethodHandle } from './RuntimeMethodHandle'; import type { Type } from './Type'; export type ConstructorInfo = { - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; attributes?: MethodAttributes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ContentTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ContentTreeItem.ts index 8cafbf1308..6f7ad5f2bf 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ContentTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ContentTreeItem.ts @@ -3,13 +3,14 @@ /* eslint-disable */ export type ContentTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; parentKey?: string | null; noAccess?: boolean; + isTrashed?: boolean; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CreatedResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CreatedResult.ts index 8f0739f88f..0b19517af2 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CreatedResult.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CreatedResult.ts @@ -7,10 +7,10 @@ import type { Type } from './Type'; export type CreatedResult = { value?: any; - formatters?: Array | null; - contentTypes?: Array | null; + formatters?: Array; + contentTypes?: Array; declaredType?: Type; statusCode?: number | null; - location?: string | null; + location?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Culture.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Culture.ts index f8b6bb184b..15f63f8740 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Culture.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Culture.ts @@ -3,7 +3,7 @@ /* eslint-disable */ export type Culture = { - name?: string | null; - englishName?: string | null; + name?: string; + englishName?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeData.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeData.ts index c91d2b383d..c16e0f1c0a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeData.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeData.ts @@ -10,7 +10,7 @@ import type { Type } from './Type'; export type CustomAttributeData = { attributeType?: Type; constructor?: ConstructorInfo; - readonly constructorArguments?: Array | null; - readonly namedArguments?: Array | null; + readonly constructorArguments?: Array; + readonly namedArguments?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeNamedArgument.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeNamedArgument.ts index 0985714283..cf176a6832 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeNamedArgument.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/CustomAttributeNamedArgument.ts @@ -8,7 +8,7 @@ import type { MemberInfo } from './MemberInfo'; export type CustomAttributeNamedArgument = { memberInfo?: MemberInfo; typedValue?: CustomAttributeTypedArgument; - readonly memberName?: string | null; + readonly memberName?: string; readonly isField?: boolean; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataType.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataType.ts index 4476e50e7b..951f65e274 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataType.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataType.ts @@ -5,9 +5,10 @@ import type { DataTypeProperty } from './DataTypeProperty'; export type DataType = { - name?: string | null; - propertyEditorAlias?: string | null; - data?: Array | null; + name?: string; + propertyEditorAlias?: string; + propertyEditorUiAlias?: string | null; + data?: Array; key?: string; parentKey?: string | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeCreateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeCreateModel.ts index 18592412d1..bdceaf80cb 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeCreateModel.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeCreateModel.ts @@ -5,9 +5,10 @@ import type { DataTypeProperty } from './DataTypeProperty'; export type DataTypeCreateModel = { - name?: string | null; - propertyEditorAlias?: string | null; - data?: Array | null; + name?: string; + propertyEditorAlias?: string; + propertyEditorUiAlias?: string | null; + data?: Array; parentKey?: string | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeProperty.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeProperty.ts index d069cab255..75031fa9af 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeProperty.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeProperty.ts @@ -3,7 +3,7 @@ /* eslint-disable */ export type DataTypeProperty = { - alias?: string | null; + alias?: string; value?: any; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypePropertyReference.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypePropertyReference.ts new file mode 100644 index 0000000000..07bf4500db --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypePropertyReference.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type DataTypePropertyReference = { + name?: string; + alias?: string; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeReference.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeReference.ts new file mode 100644 index 0000000000..b1c0c02770 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeReference.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { DataTypePropertyReference } from './DataTypePropertyReference'; + +export type DataTypeReference = { + key?: string; + type?: string; + properties?: Array; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeUpdateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeUpdateModel.ts index 95f65138f5..f264cdf90b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeUpdateModel.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DataTypeUpdateModel.ts @@ -5,8 +5,9 @@ import type { DataTypeProperty } from './DataTypeProperty'; export type DataTypeUpdateModel = { - name?: string | null; - propertyEditorAlias?: string | null; - data?: Array | null; + name?: string; + propertyEditorAlias?: string; + propertyEditorUiAlias?: string | null; + data?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DatabaseSettings.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DatabaseSettings.ts index fa99b51d1f..ccaa1ff21c 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DatabaseSettings.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DatabaseSettings.ts @@ -5,12 +5,12 @@ export type DatabaseSettings = { id?: string; sortOrder?: number; - displayName?: string | null; - defaultDatabaseName?: string | null; - providerName?: string | null; + displayName?: string; + defaultDatabaseName?: string; + providerName?: string; isConfigured?: boolean; requiresServer?: boolean; - serverPlaceholder?: string | null; + serverPlaceholder?: string; requiresCredentials?: boolean; supportsIntegratedAuthentication?: boolean; requiresConnectionTest?: boolean; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Dictionary.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Dictionary.ts index 5464bde7b8..ae6139cb92 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Dictionary.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Dictionary.ts @@ -8,11 +8,11 @@ import type { DictionaryTranslation } from './DictionaryTranslation'; export type Dictionary = { parentId?: string | null; - translations?: Array | null; - contentApps?: Array | null; - readonly notifications?: Array | null; + translations?: Array; + contentApps?: Array; + readonly notifications?: Array; name: string; key?: string; - path?: string | null; + path?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryImport.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryImport.ts index 9d4d282be0..400116fd57 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryImport.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryImport.ts @@ -5,7 +5,7 @@ import type { DictionaryItemsImport } from './DictionaryItemsImport'; export type DictionaryImport = { - dictionaryItems?: Array | null; + dictionaryItems?: Array; tempFileName?: string | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryOverview.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryOverview.ts index 438c2bbc78..42d0015a0e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryOverview.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryOverview.ts @@ -8,6 +8,6 @@ export type DictionaryOverview = { name?: string | null; key?: string; level?: number; - readonly translations?: Array | null; + readonly translations?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryTranslation.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryTranslation.ts index 669e0a94cf..97f245a415 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryTranslation.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DictionaryTranslation.ts @@ -7,7 +7,7 @@ export type DictionaryTranslation = { key?: string; displayName?: string | null; isoCode?: string | null; - translation?: string | null; + translation?: string; languageId?: number; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentBlueprintTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentBlueprintTreeItem.ts index ef120659bd..95af2225f0 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentBlueprintTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentBlueprintTreeItem.ts @@ -3,15 +3,15 @@ /* eslint-disable */ export type DocumentBlueprintTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; parentKey?: string | null; documentTypeKey?: string; - documentTypeAlias?: string | null; + documentTypeAlias?: string; documentTypeName?: string | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTreeItem.ts index 489cc15166..c3fda312be 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTreeItem.ts @@ -3,14 +3,15 @@ /* eslint-disable */ export type DocumentTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; parentKey?: string | null; noAccess?: boolean; + isTrashed?: boolean; isProtected?: boolean; isPublished?: boolean; isEdited?: boolean; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTypeTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTypeTreeItem.ts index 72bd8082d6..ffe110b4fc 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTypeTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/DocumentTypeTreeItem.ts @@ -3,9 +3,9 @@ /* eslint-disable */ export type DocumentTypeTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EntityTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EntityTreeItem.ts index 77a5b9cda9..47c461934d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EntityTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EntityTreeItem.ts @@ -3,9 +3,9 @@ /* eslint-disable */ export type EntityTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EventInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EventInfo.ts index 4ec49e7f1b..1f85186081 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EventInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/EventInfo.ts @@ -10,11 +10,11 @@ import type { Module } from './Module'; import type { Type } from './Type'; export type EventInfo = { - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; memberType?: MemberTypes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Field.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Field.ts index f03083b81d..7bc3138a69 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Field.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Field.ts @@ -3,7 +3,7 @@ /* eslint-disable */ export type Field = { - name?: string | null; - values?: Array | null; + name?: string; + values?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FieldInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FieldInfo.ts index e54075e1a8..2a1bd213f0 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FieldInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FieldInfo.ts @@ -10,11 +10,11 @@ import type { RuntimeFieldHandle } from './RuntimeFieldHandle'; import type { Type } from './Type'; export type FieldInfo = { - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; memberType?: MemberTypes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FileSystemTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FileSystemTreeItem.ts index 058f032a68..11fb5b5b07 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FileSystemTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FileSystemTreeItem.ts @@ -3,11 +3,11 @@ /* eslint-disable */ export type FileSystemTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; - path?: string | null; + path?: string; isFolder?: boolean; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Folder.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Folder.ts new file mode 100644 index 0000000000..95565e60d8 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Folder.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Folder = { + name?: string; + key?: string; + parentKey?: string | null; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderCreateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderCreateModel.ts new file mode 100644 index 0000000000..fc34bb2ce8 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderCreateModel.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type FolderCreateModel = { + name?: string; + parentKey?: string | null; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderTreeItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderTreeItem.ts index 8407711e91..f3ca6a12e5 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderTreeItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderTreeItem.ts @@ -3,9 +3,9 @@ /* eslint-disable */ export type FolderTreeItem = { - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; key?: string; isContainer?: boolean; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderUpdateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderUpdateModel.ts new file mode 100644 index 0000000000..8cf803666d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/FolderUpdateModel.ts @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type FolderUpdateModel = { + name?: string; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheck.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheck.ts index bbd5d72496..c3a55c8fe2 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheck.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheck.ts @@ -4,7 +4,7 @@ export type HealthCheck = { key?: string; - name?: string | null; + name?: string; description?: string | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroup.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroup.ts index f96bad143e..f9cec322a2 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroup.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroup.ts @@ -6,6 +6,6 @@ import type { HealthCheck } from './HealthCheck'; export type HealthCheckGroup = { name?: string | null; - checks?: Array | null; + checks?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroupWithResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroupWithResult.ts index 797b13c46e..da13fe5aea 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroupWithResult.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckGroupWithResult.ts @@ -6,6 +6,6 @@ import type { HealthCheckWithResult } from './HealthCheckWithResult'; export type HealthCheckGroupWithResult = { name?: string | null; - checks?: Array | null; + checks?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckResult.ts index 332200c5c4..24542f559c 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckResult.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckResult.ts @@ -6,7 +6,7 @@ import type { HealthCheckAction } from './HealthCheckAction'; import type { StatusResultType } from './StatusResultType'; export type HealthCheckResult = { - message?: string | null; + message?: string; resultType?: StatusResultType; actions?: Array | null; readMoreLink?: string | null; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckWithResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckWithResult.ts index 8001e4b7a5..31cb5d56e1 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckWithResult.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthCheckWithResult.ts @@ -6,7 +6,7 @@ import type { HealthCheckResult } from './HealthCheckResult'; export type HealthCheckWithResult = { key?: string; - name?: string | null; + name?: string; description?: string | null; results?: Array | null; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthStatus.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthStatus.ts new file mode 100644 index 0000000000..4c4307a292 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/HealthStatus.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export enum HealthStatus { + HEALTHY = 'Healthy', + UNHEALTHY = 'Unhealthy', + REBUILDING = 'Rebuilding', +} diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Index.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Index.ts index c34fc480b8..07f935b31e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Index.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Index.ts @@ -2,12 +2,13 @@ /* tslint:disable */ /* eslint-disable */ +import type { HealthStatus } from './HealthStatus'; + export type Index = { name: string; - healthStatus?: string | null; - readonly isHealthy: boolean; + healthStatus?: HealthStatus; canRebuild: boolean; - searcherName?: string | null; + searcherName?: string; documentCount: number; fieldCount: number; providerProperties?: Record | null; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/InstallSettings.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/InstallSettings.ts index 746fa1728a..334bbcdefd 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/InstallSettings.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/InstallSettings.ts @@ -7,6 +7,6 @@ import type { UserSettings } from './UserSettings'; export type InstallSettings = { user?: UserSettings; - databases?: Array | null; + databases?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/JsonPatch.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/JsonPatch.ts index e18637fcee..fb9e0177ba 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/JsonPatch.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/JsonPatch.ts @@ -3,8 +3,8 @@ /* eslint-disable */ export type JsonPatch = { - op?: string | null; - path?: string | null; + op?: string; + path?: string; value?: any; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MemberInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MemberInfo.ts index 3e3f9819c7..4b559a865e 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MemberInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MemberInfo.ts @@ -9,11 +9,11 @@ import type { Type } from './Type'; export type MemberInfo = { memberType?: MemberTypes; - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodBase.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodBase.ts index 94cfa1b3cc..30167ffc4d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodBase.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodBase.ts @@ -13,11 +13,11 @@ import type { Type } from './Type'; export type MethodBase = { memberType?: MemberTypes; - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; attributes?: MethodAttributes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodInfo.ts index 382fb5adf5..c1a3d421cd 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/MethodInfo.ts @@ -14,11 +14,11 @@ import type { RuntimeMethodHandle } from './RuntimeMethodHandle'; import type { Type } from './Type'; export type MethodInfo = { - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; attributes?: MethodAttributes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Module.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Module.ts index 7843f8da04..87a07e860a 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Module.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Module.ts @@ -8,13 +8,13 @@ import type { ModuleHandle } from './ModuleHandle'; export type Module = { assembly?: Assembly; - readonly fullyQualifiedName?: string | null; - readonly name?: string | null; + readonly fullyQualifiedName?: string; + readonly name?: string; readonly mdStreamVersion?: number; readonly moduleVersionId?: string; - readonly scopeName?: string | null; + readonly scopeName?: string; moduleHandle?: ModuleHandle; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly metadataToken?: number; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Operator.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Operator.ts new file mode 100644 index 0000000000..7d4e681831 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Operator.ts @@ -0,0 +1,14 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export enum Operator { + EQUALS = 'Equals', + NOT_EQUALS = 'NotEquals', + CONTAINS = 'Contains', + NOT_CONTAINS = 'NotContains', + LESS_THAN = 'LessThan', + LESS_THAN_EQUAL_TO = 'LessThanEqualTo', + GREATER_THAN = 'GreaterThan', + GREATER_THAN_EQUAL_TO = 'GreaterThanEqualTo', +} diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ParameterInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ParameterInfo.ts index 15c13932a7..b83cfb909b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ParameterInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/ParameterInfo.ts @@ -21,7 +21,7 @@ export type ParameterInfo = { readonly defaultValue?: any; readonly rawDefaultValue?: any; readonly hasDefaultValue?: boolean; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly metadataToken?: number; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/PropertyInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/PropertyInfo.ts index df98f1e0c1..cc2b6cbfb3 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/PropertyInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/PropertyInfo.ts @@ -10,11 +10,11 @@ import type { PropertyAttributes } from './PropertyAttributes'; import type { Type } from './Type'; export type PropertyInfo = { - readonly name?: string | null; + readonly name?: string; declaringType?: Type; reflectedType?: Type; module?: Module; - readonly customAttributes?: Array | null; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; memberType?: MemberTypes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RecycleBinItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RecycleBinItem.ts index 6e077b49fd..726cf81eec 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RecycleBinItem.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RecycleBinItem.ts @@ -4,9 +4,9 @@ export type RecycleBinItem = { key?: string; - name?: string | null; - type?: string | null; - icon?: string | null; + name?: string; + type?: string; + icon?: string; hasChildren?: boolean; isContainer?: boolean; parentKey?: string | null; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RedirectUrl.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RedirectUrl.ts index 7f7eaf0ddb..5c1fec3934 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RedirectUrl.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/RedirectUrl.ts @@ -4,8 +4,8 @@ export type RedirectUrl = { key?: string; - originalUrl?: string | null; - destinationUrl?: string | null; + originalUrl?: string; + destinationUrl?: string; created?: string; contentKey?: string; culture?: string | null; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/SearchResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/SearchResult.ts index e468166035..d6dc140d8d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/SearchResult.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/SearchResult.ts @@ -5,9 +5,9 @@ import type { Field } from './Field'; export type SearchResult = { - id?: string | null; + id?: string; score?: number; readonly fieldCount?: number; - fields?: Array | null; + fields?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Searcher.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Searcher.ts index bc89694c3a..1e55566aa3 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Searcher.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Searcher.ts @@ -3,6 +3,6 @@ /* eslint-disable */ export type Searcher = { - name?: string | null; + name?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Template.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Template.ts new file mode 100644 index 0000000000..3055919ab5 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Template.ts @@ -0,0 +1,11 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type Template = { + name?: string; + alias?: string; + content?: string | null; + key?: string; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateCreateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateCreateModel.ts new file mode 100644 index 0000000000..6a393e41ba --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateCreateModel.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TemplateCreateModel = { + name?: string; + alias?: string; + content?: string | null; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteFilterModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteFilterModel.ts new file mode 100644 index 0000000000..d04281f02d --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteFilterModel.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Operator } from './Operator'; + +export type TemplateQueryExecuteFilterModel = { + propertyAlias?: string; + constraintValue?: string; + operator?: Operator; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteModel.ts new file mode 100644 index 0000000000..53481eabcf --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteModel.ts @@ -0,0 +1,15 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TemplateQueryExecuteFilterModel } from './TemplateQueryExecuteFilterModel'; +import type { TemplateQueryExecuteSortModel } from './TemplateQueryExecuteSortModel'; + +export type TemplateQueryExecuteModel = { + rootContentKey?: string | null; + contentTypeAlias?: string | null; + filters?: Array | null; + sort?: TemplateQueryExecuteSortModel; + take?: number; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteSortModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteSortModel.ts new file mode 100644 index 0000000000..d3a1b6cf56 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryExecuteSortModel.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TemplateQueryExecuteSortModel = { + propertyAlias?: string; + direction?: string | null; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryOperator.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryOperator.ts new file mode 100644 index 0000000000..f1e3cd66cb --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryOperator.ts @@ -0,0 +1,12 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { Operator } from './Operator'; +import type { TemplateQueryPropertyType } from './TemplateQueryPropertyType'; + +export type TemplateQueryOperator = { + operator?: Operator; + applicableTypes?: Array; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryProperty.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryProperty.ts new file mode 100644 index 0000000000..2b8472d303 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryProperty.ts @@ -0,0 +1,11 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TemplateQueryPropertyType } from './TemplateQueryPropertyType'; + +export type TemplateQueryProperty = { + alias?: string; + type?: TemplateQueryPropertyType; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryPropertyType.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryPropertyType.ts new file mode 100644 index 0000000000..2ec073e349 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryPropertyType.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export enum TemplateQueryPropertyType { + STRING = 'String', + DATE_TIME = 'DateTime', + INTEGER = 'Integer', +} diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResult.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResult.ts new file mode 100644 index 0000000000..92773aedb5 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResult.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TemplateQueryResultItem } from './TemplateQueryResultItem'; + +export type TemplateQueryResult = { + queryExpression?: string; + sampleResults?: Array; + resultCount?: number; + executionTime?: number; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResultItem.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResultItem.ts new file mode 100644 index 0000000000..f04b8cbe5b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQueryResultItem.ts @@ -0,0 +1,9 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TemplateQueryResultItem = { + icon?: string; + name?: string; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQuerySettings.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQuerySettings.ts new file mode 100644 index 0000000000..cc21151d6c --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateQuerySettings.ts @@ -0,0 +1,13 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { TemplateQueryOperator } from './TemplateQueryOperator'; +import type { TemplateQueryProperty } from './TemplateQueryProperty'; + +export type TemplateQuerySettings = { + contentTypeAliases?: Array; + properties?: Array; + operators?: Array; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateScaffold.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateScaffold.ts new file mode 100644 index 0000000000..a6de02512b --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateScaffold.ts @@ -0,0 +1,8 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TemplateScaffold = { + content?: string; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateUpdateModel.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateUpdateModel.ts new file mode 100644 index 0000000000..f33c895029 --- /dev/null +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TemplateUpdateModel.ts @@ -0,0 +1,10 @@ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type TemplateUpdateModel = { + name?: string; + alias?: string; + content?: string | null; +}; + diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Type.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Type.ts index 5aa4d99801..3b3f03fe0d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Type.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Type.ts @@ -14,8 +14,8 @@ import type { StructLayoutAttribute } from './StructLayoutAttribute'; import type { TypeAttributes } from './TypeAttributes'; export type Type = { - readonly name?: string | null; - readonly customAttributes?: Array | null; + readonly name?: string; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; readonly isInterface?: boolean; @@ -44,7 +44,7 @@ export type Type = { readonly isVariableBoundArray?: boolean; readonly isByRefLike?: boolean; readonly hasElementType?: boolean; - readonly genericTypeArguments?: Array | null; + readonly genericTypeArguments?: Array; readonly genericParameterPosition?: number; genericParameterAttributes?: GenericParameterAttributes; attributes?: TypeAttributes; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TypeInfo.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TypeInfo.ts index 1d5cfc6397..4010b30ea1 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TypeInfo.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/TypeInfo.ts @@ -20,8 +20,8 @@ import type { Type } from './Type'; import type { TypeAttributes } from './TypeAttributes'; export type TypeInfo = { - readonly name?: string | null; - readonly customAttributes?: Array | null; + readonly name?: string; + readonly customAttributes?: Array; readonly isCollectible?: boolean; readonly metadataToken?: number; readonly isInterface?: boolean; @@ -50,7 +50,7 @@ export type TypeInfo = { readonly isVariableBoundArray?: boolean; readonly isByRefLike?: boolean; readonly hasElementType?: boolean; - readonly genericTypeArguments?: Array | null; + readonly genericTypeArguments?: Array; readonly genericParameterPosition?: number; genericParameterAttributes?: GenericParameterAttributes; attributes?: TypeAttributes; @@ -91,14 +91,14 @@ export type TypeInfo = { readonly isSerializable?: boolean; readonly containsGenericParameters?: boolean; readonly isVisible?: boolean; - readonly genericTypeParameters?: Array | null; - readonly declaredConstructors?: Array | null; - readonly declaredEvents?: Array | null; - readonly declaredFields?: Array | null; - readonly declaredMembers?: Array | null; - readonly declaredMethods?: Array | null; - readonly declaredNestedTypes?: Array | null; - readonly declaredProperties?: Array | null; - readonly implementedInterfaces?: Array | null; + readonly genericTypeParameters?: Array; + readonly declaredConstructors?: Array; + readonly declaredEvents?: Array; + readonly declaredFields?: Array; + readonly declaredMembers?: Array; + readonly declaredMethods?: Array; + readonly declaredNestedTypes?: Array; + readonly declaredProperties?: Array; + readonly implementedInterfaces?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UpgradeSettings.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UpgradeSettings.ts index 88faaeecc7..f3b582ab1d 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UpgradeSettings.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UpgradeSettings.ts @@ -3,10 +3,10 @@ /* eslint-disable */ export type UpgradeSettings = { - currentState?: string | null; - newState?: string | null; - newVersion?: string | null; - oldVersion?: string | null; - readonly reportUrl?: string | null; + currentState?: string; + newState?: string; + newVersion?: string; + oldVersion?: string; + readonly reportUrl?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UserSettings.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UserSettings.ts index 1b875f4d36..ddc42d069b 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UserSettings.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/UserSettings.ts @@ -7,6 +7,6 @@ import type { ConsentLevel } from './ConsentLevel'; export type UserSettings = { minCharLength?: number; minNonAlphaNumericLength?: number; - consentLevels?: Array | null; + consentLevels?: Array; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Version.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Version.ts index 3ee6e570a7..35249a3fba 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Version.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/models/Version.ts @@ -3,6 +3,6 @@ /* eslint-disable */ export type Version = { - version?: string | null; + version?: string; }; diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/services/DataTypeResource.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/services/DataTypeResource.ts index 51a0f68819..fffdb6fb45 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/services/DataTypeResource.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/services/DataTypeResource.ts @@ -3,8 +3,12 @@ /* eslint-disable */ import type { DataType } from '../models/DataType'; import type { DataTypeCreateModel } from '../models/DataTypeCreateModel'; +import type { DataTypeReference } from '../models/DataTypeReference'; import type { DataTypeUpdateModel } from '../models/DataTypeUpdateModel'; +import type { Folder } from '../models/Folder'; +import type { FolderCreateModel } from '../models/FolderCreateModel'; import type { FolderTreeItem } from '../models/FolderTreeItem'; +import type { FolderUpdateModel } from '../models/FolderUpdateModel'; import type { PagedFolderTreeItem } from '../models/PagedFolderTreeItem'; import type { CancelablePromise } from '../core/CancelablePromise'; @@ -14,14 +18,14 @@ import { request as __request } from '../core/request'; export class DataTypeResource { /** - * @returns DataType Success + * @returns any Created * @throws ApiError */ public static postDataType({ requestBody, }: { requestBody?: DataTypeCreateModel, - }): CancelablePromise { + }): CancelablePromise { return __request(OpenAPI, { method: 'POST', url: '/umbraco/management/api/v1/data-type', @@ -55,7 +59,28 @@ export class DataTypeResource { } /** - * @returns DataType Success + * @returns any Success + * @throws ApiError + */ + public static deleteDataTypeByKey({ + key, + }: { + key: string, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/umbraco/management/api/v1/data-type/{key}', + path: { + 'key': key, + }, + errors: { + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success * @throws ApiError */ public static putDataTypeByKey({ @@ -64,7 +89,7 @@ export class DataTypeResource { }: { key: string, requestBody?: DataTypeUpdateModel, - }): CancelablePromise { + }): CancelablePromise { return __request(OpenAPI, { method: 'PUT', url: '/umbraco/management/api/v1/data-type/{key}', @@ -79,6 +104,111 @@ export class DataTypeResource { }); } + /** + * @returns DataTypeReference Success + * @throws ApiError + */ + public static getDataTypeByKeyReferences({ + key, + }: { + key: string, + }): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/data-type/{key}/references', + path: { + 'key': key, + }, + errors: { + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Created + * @throws ApiError + */ + public static postDataTypeFolder({ + requestBody, + }: { + requestBody?: FolderCreateModel, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/data-type/folder', + body: requestBody, + mediaType: 'application/json', + }); + } + + /** + * @returns Folder Success + * @throws ApiError + */ + public static getDataTypeFolderByKey({ + key, + }: { + key: string, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/data-type/folder/{key}', + path: { + 'key': key, + }, + errors: { + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static deleteDataTypeFolderByKey({ + key, + }: { + key: string, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/umbraco/management/api/v1/data-type/folder/{key}', + path: { + 'key': key, + }, + errors: { + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static putDataTypeFolderByKey({ + key, + requestBody, + }: { + key: string, + requestBody?: FolderUpdateModel, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/data-type/folder/{key}', + path: { + 'key': key, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 404: `Not Found`, + }, + }); + } + /** * @returns PagedFolderTreeItem Success * @throws ApiError diff --git a/src/Umbraco.Web.UI.Client/src/core/backend-api/services/TemplateResource.ts b/src/Umbraco.Web.UI.Client/src/core/backend-api/services/TemplateResource.ts index 5050c7314f..771d6ef5ef 100644 --- a/src/Umbraco.Web.UI.Client/src/core/backend-api/services/TemplateResource.ts +++ b/src/Umbraco.Web.UI.Client/src/core/backend-api/services/TemplateResource.ts @@ -3,6 +3,13 @@ /* eslint-disable */ import type { EntityTreeItem } from '../models/EntityTreeItem'; import type { PagedEntityTreeItem } from '../models/PagedEntityTreeItem'; +import type { Template } from '../models/Template'; +import type { TemplateCreateModel } from '../models/TemplateCreateModel'; +import type { TemplateQueryExecuteModel } from '../models/TemplateQueryExecuteModel'; +import type { TemplateQueryResult } from '../models/TemplateQueryResult'; +import type { TemplateQuerySettings } from '../models/TemplateQuerySettings'; +import type { TemplateScaffold } from '../models/TemplateScaffold'; +import type { TemplateUpdateModel } from '../models/TemplateUpdateModel'; import type { CancelablePromise } from '../core/CancelablePromise'; import { OpenAPI } from '../core/OpenAPI'; @@ -10,6 +17,142 @@ import { request as __request } from '../core/request'; export class TemplateResource { + /** + * @returns any Created + * @throws ApiError + */ + public static postTemplate({ + requestBody, + }: { + requestBody?: TemplateCreateModel, + }): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/template', + body: requestBody, + mediaType: 'application/json', + errors: { + 404: `Not Found`, + }, + }); + } + + /** + * @returns Template Success + * @throws ApiError + */ + public static getTemplateByKey({ + key, + }: { + key: string, + }): CancelablePromise