From cbab06e652534094afb5a5e01d8b5ac24d312d19 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 3 Nov 2023 21:02:29 +0100 Subject: [PATCH 01/44] Add webhooks workspace --- src/packages/settings/manifests.ts | 2 + src/packages/settings/webhooks/index.ts | 1 + src/packages/settings/webhooks/manifests.ts | 4 ++ .../settings/webhooks/menu-item/manifests.ts | 16 +++++ .../settings/webhooks/repository/index.ts | 2 + .../settings/webhooks/workspace/manifests.ts | 3 + .../views/overview/components/index.ts | 1 + .../workspace/views/overview/index.ts | 4 ++ .../views/overview/webhooks-view.element.ts | 57 ++++++++++++++++++ .../webhooks/workspace/webhooks/manifests.ts | 60 +++++++++++++++++++ .../webhooks/webhooks-workspace.element.ts | 56 +++++++++++++++++ web-test-runner.config.mjs | 1 + 12 files changed, 207 insertions(+) create mode 100644 src/packages/settings/webhooks/index.ts create mode 100644 src/packages/settings/webhooks/manifests.ts create mode 100644 src/packages/settings/webhooks/menu-item/manifests.ts create mode 100644 src/packages/settings/webhooks/repository/index.ts create mode 100644 src/packages/settings/webhooks/workspace/manifests.ts create mode 100644 src/packages/settings/webhooks/workspace/views/overview/components/index.ts create mode 100644 src/packages/settings/webhooks/workspace/views/overview/index.ts create mode 100644 src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts create mode 100644 src/packages/settings/webhooks/workspace/webhooks/manifests.ts create mode 100644 src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts diff --git a/src/packages/settings/manifests.ts b/src/packages/settings/manifests.ts index 31b0d628c7..207f1f83c5 100644 --- a/src/packages/settings/manifests.ts +++ b/src/packages/settings/manifests.ts @@ -2,6 +2,7 @@ import { manifests as dashboardManifests } from './dashboards/manifests.js'; import { manifests as dataTypeManifests } from './data-types/manifests.js'; import { manifests as extensionManifests } from './extensions/manifests.js'; import { manifests as languageManifests } from './languages/manifests.js'; +import { manifests as webhooksManifests } from './webhooks/manifests.js'; import { manifests as relationTypeManifests } from './relation-types/manifests.js'; import { manifests as settingsMenuManifests } from './menu.manifests.js'; import { manifests as settingsSectionManifests } from './section.manifests.js'; @@ -11,6 +12,7 @@ export const manifests = [ ...dataTypeManifests, ...extensionManifests, ...languageManifests, + ...webhooksManifests, ...relationTypeManifests, ...settingsMenuManifests, ...settingsSectionManifests, diff --git a/src/packages/settings/webhooks/index.ts b/src/packages/settings/webhooks/index.ts new file mode 100644 index 0000000000..20c30af634 --- /dev/null +++ b/src/packages/settings/webhooks/index.ts @@ -0,0 +1 @@ +//export * from './repository/index.js'; diff --git a/src/packages/settings/webhooks/manifests.ts b/src/packages/settings/webhooks/manifests.ts new file mode 100644 index 0000000000..05be6d3978 --- /dev/null +++ b/src/packages/settings/webhooks/manifests.ts @@ -0,0 +1,4 @@ +import { manifests as treeManifests } from './menu-item/manifests.js'; +import { manifests as workspaceManifests } from './workspace/manifests.js'; + +export const manifests = [...treeManifests, ...workspaceManifests]; diff --git a/src/packages/settings/webhooks/menu-item/manifests.ts b/src/packages/settings/webhooks/menu-item/manifests.ts new file mode 100644 index 0000000000..d464a03cf3 --- /dev/null +++ b/src/packages/settings/webhooks/menu-item/manifests.ts @@ -0,0 +1,16 @@ +import type { ManifestMenuItem } from '@umbraco-cms/backoffice/extension-registry'; + +const menuItem: ManifestMenuItem = { + type: 'menuItem', + alias: 'Umb.MenuItem.Webhooks', + name: 'Webhooks Menu Item', + weight: 100, + meta: { + label: 'Webhooks', + icon: 'umb:anchor', + entityType: 'webhooks', + menus: ['Umb.Menu.Settings'], + }, +}; + +export const manifests = [menuItem]; diff --git a/src/packages/settings/webhooks/repository/index.ts b/src/packages/settings/webhooks/repository/index.ts new file mode 100644 index 0000000000..aaba40b8b0 --- /dev/null +++ b/src/packages/settings/webhooks/repository/index.ts @@ -0,0 +1,2 @@ +//export * from './webhooks.repository.js'; +//export * from './sources/index.js'; diff --git a/src/packages/settings/webhooks/workspace/manifests.ts b/src/packages/settings/webhooks/workspace/manifests.ts new file mode 100644 index 0000000000..b627b8cbd1 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/manifests.ts @@ -0,0 +1,3 @@ +import { manifests as webhooksRootManifests } from './webhooks/manifests.js'; + +export const manifests = [...webhooksRootManifests]; diff --git a/src/packages/settings/webhooks/workspace/views/overview/components/index.ts b/src/packages/settings/webhooks/workspace/views/overview/components/index.ts new file mode 100644 index 0000000000..8b13789179 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/views/overview/components/index.ts @@ -0,0 +1 @@ + diff --git a/src/packages/settings/webhooks/workspace/views/overview/index.ts b/src/packages/settings/webhooks/workspace/views/overview/index.ts new file mode 100644 index 0000000000..fea52791a8 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/views/overview/index.ts @@ -0,0 +1,4 @@ +import './components/index.js'; +import { UmbWebhooksOverviewViewElement } from './webhooks-view.element.js'; + +export default UmbWebhooksOverviewViewElement; diff --git a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts new file mode 100644 index 0000000000..21b4427742 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts @@ -0,0 +1,57 @@ +import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; + +@customElement('umb-webhooks-overview-view') +export class UmbWebhooksOverviewViewElement extends UmbLitElement { + + constructor() { + super(); + } + + render() { + return html` +
+ + + + + + + + + + + + +
EnabledEventsUrlTypes
+
+ `; + } + + static styles = [ + css` + :host { + display: block; + margin: var(--uui-size-layout-1); + } + + #webhooks-layout { + padding-bottom: var(--uui-size-layout-1); + display: grid; + grid-template-columns: 7fr 2fr; + grid-template-rows: auto auto; + gap: 20px 20px; + grid-auto-flow: row; + grid-template-areas: + 'saved-searches info' + 'common-messages info'; + } + `, + ]; +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhooks-overview-view': UmbWebhooksOverviewViewElement; + } +} diff --git a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts new file mode 100644 index 0000000000..77d7a78059 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts @@ -0,0 +1,60 @@ +import type { + ManifestWorkspace, + ManifestWorkspaceAction, + ManifestWorkspaceEditorView, +} from '@umbraco-cms/backoffice/extension-registry'; + +const workspaceAlias = 'Umb.Workspace.Webhooks'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: workspaceAlias, + name: 'Webhooks Root Workspace', + loader: () => import('./webhooks-workspace.element.js'), + meta: { + entityType: 'webhooks-root', + }, +}; + +const workspaceViews: Array = [ + { + type: 'workspaceEditorView', + alias: 'Umb.WorkspaceView.Webhooks.Overview', + name: 'Webhooks Root Workspace Overview View', + loader: () => import('../views/overview/index.js'), + weight: 300, + meta: { + label: 'Webhooks', + pathname: 'webhooks', + icon: 'umb:anchor', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, + { + type: 'workspaceEditorView', + alias: 'Umb.WorkspaceView.Webhooks.Logs', + name: 'Webhooks Root Workspace Logs View', + loader: () => import('../views/logs/index.js'), + weight: 200, + meta: { + label: 'Logs', + pathname: 'logs', + icon: 'umb:search', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, +]; + +const workspaceActions: Array = []; + +export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; diff --git a/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts b/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts new file mode 100644 index 0000000000..3deaa89b85 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts @@ -0,0 +1,56 @@ +import { PropertyValueMap, css, html, customElement } from '@umbraco-cms/backoffice/external/lit'; +import { UmbTextStyles } from "@umbraco-cms/backoffice/style"; +import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; + +@customElement('umb-webhooks-workspace') +export class UmbWebhooksWorkspaceElement extends UmbLitElement { + + firstUpdated(props: PropertyValueMap) { + super.firstUpdated(props); + + } + + disconnectedCallback(): void { + super.disconnectedCallback(); + } + + load(): void { + // Not relevant for this workspace -added to prevent the error from popping up + } + + create(): void { + // Not relevant for this workspace + } + + render() { + return html` + + + `; + } + + static styles = [ + UmbTextStyles, + css` + :host { + display: block; + width: 100%; + height: 100%; + } + + uui-tab-group { + --uui-tab-divider: var(--uui-color-border); + border-left: 1px solid var(--uui-color-border); + border-right: 1px solid var(--uui-color-border); + } + `, + ]; +} + +export default UmbWebhooksWorkspaceElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhooks-workspace': UmbWebhooksWorkspaceElement; + } +} diff --git a/web-test-runner.config.mjs b/web-test-runner.config.mjs index ff690f70f4..6047ffcf2c 100644 --- a/web-test-runner.config.mjs +++ b/web-test-runner.config.mjs @@ -96,6 +96,7 @@ export default { '@umbraco-cms/backoffice/data-type': './src/packages/settings/data-types/index.ts', '@umbraco-cms/backoffice/language': './src/packages/settings/languages/index.ts', '@umbraco-cms/backoffice/logviewer': './src/packages/settings/logviewer/index.ts', + '@umbraco-cms/backoffice/webhooks': './src/packages/settings/webhooks/index.ts', '@umbraco-cms/backoffice/relation-type': './src/packages/settings/relation-types/index.ts', '@umbraco-cms/backoffice/tags': './src/packages/tags/index.ts', '@umbraco-cms/backoffice/partial-view': './src/packages/templating/partial-views/index.ts', From 06ac012f054e58c19ecec83b11426c7f8cac4caa Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 3 Nov 2023 21:03:00 +0100 Subject: [PATCH 02/44] Update workspace alias for log viewer --- .../workspace/logviewer/logviewer-workspace.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts index d1e1f9b076..1fb940c3c5 100644 --- a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts +++ b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts @@ -33,7 +33,7 @@ export class UmbLogViewerWorkspaceElement extends UmbLitElement { render() { return html` - + `; } From b7b1e6c295ab5cb80abfdfa5aac9e9f7ac06ea94 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 3 Nov 2023 21:13:31 +0100 Subject: [PATCH 03/44] Rename entity type --- src/packages/settings/webhooks/workspace/webhooks/manifests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts index 77d7a78059..862b220ed1 100644 --- a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts @@ -12,7 +12,7 @@ const workspace: ManifestWorkspace = { name: 'Webhooks Root Workspace', loader: () => import('./webhooks-workspace.element.js'), meta: { - entityType: 'webhooks-root', + entityType: 'webhooks', }, }; From da2610e13687119362d30e3223f5b24c9bd3a9a9 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 3 Nov 2023 21:13:58 +0100 Subject: [PATCH 04/44] Comment import of components --- .../webhooks/workspace/views/overview/components/index.ts | 1 - .../settings/webhooks/workspace/views/overview/index.ts | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) delete mode 100644 src/packages/settings/webhooks/workspace/views/overview/components/index.ts diff --git a/src/packages/settings/webhooks/workspace/views/overview/components/index.ts b/src/packages/settings/webhooks/workspace/views/overview/components/index.ts deleted file mode 100644 index 8b13789179..0000000000 --- a/src/packages/settings/webhooks/workspace/views/overview/components/index.ts +++ /dev/null @@ -1 +0,0 @@ - diff --git a/src/packages/settings/webhooks/workspace/views/overview/index.ts b/src/packages/settings/webhooks/workspace/views/overview/index.ts index fea52791a8..d57d3d5b14 100644 --- a/src/packages/settings/webhooks/workspace/views/overview/index.ts +++ b/src/packages/settings/webhooks/workspace/views/overview/index.ts @@ -1,4 +1,4 @@ -import './components/index.js'; +//import './components/index.js'; import { UmbWebhooksOverviewViewElement } from './webhooks-view.element.js'; export default UmbWebhooksOverviewViewElement; From 7c0b55541ba8e967756156febff116bf54218fc9 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Fri, 3 Nov 2023 21:32:43 +0100 Subject: [PATCH 05/44] Add repository and context --- .../settings/webhooks/repository/index.ts | 2 +- .../repository/webhooks.repository.ts | 22 ++++++++++ .../webhooks/workspace/webhooks.context.ts | 40 +++++++++++++++++++ 3 files changed, 63 insertions(+), 1 deletion(-) create mode 100644 src/packages/settings/webhooks/repository/webhooks.repository.ts create mode 100644 src/packages/settings/webhooks/workspace/webhooks.context.ts diff --git a/src/packages/settings/webhooks/repository/index.ts b/src/packages/settings/webhooks/repository/index.ts index aaba40b8b0..8dbf9566cc 100644 --- a/src/packages/settings/webhooks/repository/index.ts +++ b/src/packages/settings/webhooks/repository/index.ts @@ -1,2 +1,2 @@ -//export * from './webhooks.repository.js'; +export * from './webhooks.repository.js'; //export * from './sources/index.js'; diff --git a/src/packages/settings/webhooks/repository/webhooks.repository.ts b/src/packages/settings/webhooks/repository/webhooks.repository.ts new file mode 100644 index 0000000000..d190dd8353 --- /dev/null +++ b/src/packages/settings/webhooks/repository/webhooks.repository.ts @@ -0,0 +1,22 @@ +import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; +import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification'; +import { DirectionModel, LogLevelModel, SavedLogSearchPresenationBaseModel } from '@umbraco-cms/backoffice/backend-api'; + +// Move to documentation / JSdoc +/* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */ +// element -> context -> repository -> (store) -> data source +// All methods should be async and return a promise. Some methods might return an observable as part of the promise response. +export class UmbWebhooksRepository { + #host: UmbControllerHostElement; + #notificationService?: UmbNotificationContext; + #init; + + constructor(host: UmbControllerHostElement) { + this.#host = host; + + this.#init = new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#notificationService = instance; + }).asPromise(); + } +} diff --git a/src/packages/settings/webhooks/workspace/webhooks.context.ts b/src/packages/settings/webhooks/workspace/webhooks.context.ts new file mode 100644 index 0000000000..11320b0560 --- /dev/null +++ b/src/packages/settings/webhooks/workspace/webhooks.context.ts @@ -0,0 +1,40 @@ +import { UmbWebhooksRepository } from '../repository/webhooks.repository.js'; +import { UmbBaseController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; +import { UMB_WORKSPACE_CONTEXT, UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; + +// TODO: Revisit usage of workspace for this case... +export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { + public readonly workspaceAlias: string = 'Umb.Workspace.Webhooks'; + #repository: UmbWebhooksRepository; + + getEntityType() { + return 'webhooks'; + } + + getEntityName() { + return 'Webhooks'; + } + + getEntityId() { + return undefined; + } + + currentPage = 1; + + constructor(host: UmbControllerHostElement) { + super(host); + this.provideContext(UMB_WORKSPACE_CONTEXT, this); + // TODO: Revisit usage of workspace for this case... currently no other workspace context provides them self with their own token. + this.provideContext(UMB_APP_WEBHOOKS_CONTEXT_TOKEN, this); + this.#repository = new UmbWebhooksRepository(host); + } + + onChangeState = () => { + + }; +} + +export const UMB_APP_WEBHOOKS_CONTEXT_TOKEN = new UmbContextToken( + UmbWebhooksWorkspaceContext.name, +); From 30dad4c1fd30f59baac50187f4fd0f15653aba64 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 15:52:42 +0100 Subject: [PATCH 06/44] Export repository --- src/packages/settings/webhooks/index.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/settings/webhooks/index.ts b/src/packages/settings/webhooks/index.ts index 20c30af634..3d76f338dd 100644 --- a/src/packages/settings/webhooks/index.ts +++ b/src/packages/settings/webhooks/index.ts @@ -1 +1 @@ -//export * from './repository/index.js'; +export * from './repository/index.js'; From 533ac9191d4d6f614cb3944d66064b66d772ae92 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 16:21:18 +0100 Subject: [PATCH 07/44] Set workspace context --- .../workspace/views/overview/webhooks-view.element.ts | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts index 21b4427742..24cd8eb869 100644 --- a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts +++ b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts @@ -1,11 +1,17 @@ +import { UmbWebhooksWorkspaceContext, UMB_APP_WEBHOOKS_CONTEXT_TOKEN } from '../../webhooks.context.js'; import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; @customElement('umb-webhooks-overview-view') export class UmbWebhooksOverviewViewElement extends UmbLitElement { + #webhooksContext?: UmbWebhooksWorkspaceContext; constructor() { super(); + + this.consumeContext(UMB_APP_WEBHOOKS_CONTEXT_TOKEN, (instance) => { + this.#webhooksContext = instance; + }); } render() { From 6bbddc4037859daee3be66a60110f58a2fbf298c Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 16:32:18 +0100 Subject: [PATCH 08/44] Include webhooks --- package.json | 1 + src/assets/lang/da-dk.ts | 1 + src/assets/lang/en-us.ts | 1 + 3 files changed, 3 insertions(+) diff --git a/package.json b/package.json index 85297011f5..04d49f7112 100644 --- a/package.json +++ b/package.json @@ -60,6 +60,7 @@ "./data-type": "./dist-cms/packages/settings/data-types/index.js", "./language": "./dist-cms/packages/settings/languages/index.js", "./logviewer": "./dist-cms/packages/settings/logviewer/index.js", + "./webhooks": "./dist-cms/packages/settings/webhooks/index.js", "./relation-type": "./dist-cms/packages/settings/relation-types/index.js", "./tags": "./dist-cms/packages/tags/index.js", "./partial-view": "./dist-cms/packages/templating/partial-views/index.js", diff --git a/src/assets/lang/da-dk.ts b/src/assets/lang/da-dk.ts index df0a6a2e45..dc9976e43d 100644 --- a/src/assets/lang/da-dk.ts +++ b/src/assets/lang/da-dk.ts @@ -1751,6 +1751,7 @@ export default { settingsGroup: 'Indstillinger', templatingGroup: 'Design og layout', thirdPartyGroup: 'Tredjepart', + webhooks: 'Webhooks', }, update: { updateAvailable: 'Ny opdatering er klar', diff --git a/src/assets/lang/en-us.ts b/src/assets/lang/en-us.ts index 33f798dfed..3b7d7ad608 100644 --- a/src/assets/lang/en-us.ts +++ b/src/assets/lang/en-us.ts @@ -1741,6 +1741,7 @@ export default { settingsGroup: 'Settings', templatingGroup: 'Templating', thirdPartyGroup: 'Third Party', + webhooks: 'Webhooks', }, update: { updateAvailable: 'New update ready', From 5aeb0243a6dfbcf4a78c92b2161baac5cdf1af88 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 16:37:10 +0100 Subject: [PATCH 09/44] Add webhooks package --- tsconfig.json | 1 + 1 file changed, 1 insertion(+) diff --git a/tsconfig.json b/tsconfig.json index 2dc002fed3..180ca32c14 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -85,6 +85,7 @@ "@umbraco-cms/backoffice/data-type": ["./src/packages/settings/data-types/index.ts"], "@umbraco-cms/backoffice/language": ["./src/packages/settings/languages/index.ts"], "@umbraco-cms/backoffice/logviewer": ["src/packages/log-viewer/index.ts"], + "@umbraco-cms/backoffice/webhooks": ["src/packages/webhooks/index.ts"], "@umbraco-cms/backoffice/relation-type": ["./src/packages/settings/relation-types/index.ts"], "@umbraco-cms/backoffice/tags": ["./src/packages/tags/index.ts"], From 1aafc82dd8a25dacaba0e769a010037269096492 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 18:21:03 +0100 Subject: [PATCH 10/44] Add webhook handlers --- src/mocks/browser-handlers.ts | 2 ++ src/mocks/data/webhooks.data.ts | 15 +++++++++++++++ src/mocks/handlers/webhook.handlers.ts | 6 ++++++ 3 files changed, 23 insertions(+) create mode 100644 src/mocks/data/webhooks.data.ts create mode 100644 src/mocks/handlers/webhook.handlers.ts diff --git a/src/mocks/browser-handlers.ts b/src/mocks/browser-handlers.ts index 32e57dfdb8..106c6009e5 100644 --- a/src/mocks/browser-handlers.ts +++ b/src/mocks/browser-handlers.ts @@ -25,6 +25,7 @@ import { handlers as languageHandlers } from './handlers/language.handlers.js'; import { handlers as cultureHandlers } from './handlers/culture.handlers.js'; import { handlers as redirectManagementHandlers } from './handlers/redirect-management.handlers.js'; import { handlers as logViewerHandlers } from './handlers/log-viewer.handlers.js'; +import { handlers as webhookHandlers } from './handlers/webhook.handlers.js'; import { handlers as packageHandlers } from './handlers/package.handlers.js'; import { handlers as rteEmbedHandlers } from './handlers/rte-embed.handlers.js'; import { handlers as stylesheetHandlers } from './handlers/stylesheet.handlers.js'; @@ -60,6 +61,7 @@ const handlers = [ ...cultureHandlers, ...redirectManagementHandlers, ...logViewerHandlers, + ...webhookHandlers, ...packageHandlers, ...rteEmbedHandlers, ...stylesheetHandlers, diff --git a/src/mocks/data/webhooks.data.ts b/src/mocks/data/webhooks.data.ts new file mode 100644 index 0000000000..a46cc4cb9b --- /dev/null +++ b/src/mocks/data/webhooks.data.ts @@ -0,0 +1,15 @@ +import { UmbData } from './data.js'; +//import { +// WebhooksResponseModel, +//} from '@umbraco-cms/backoffice/backend-api'; + +class UmbWebhooksData extends UmbData { + constructor(data: any[]) { + super(data); + } + +} + +export const umbWebhooksData = { + //webhooks: new UmbWebhooksData(webhooks), +}; diff --git a/src/mocks/handlers/webhook.handlers.ts b/src/mocks/handlers/webhook.handlers.ts new file mode 100644 index 0000000000..cfc6005826 --- /dev/null +++ b/src/mocks/handlers/webhook.handlers.ts @@ -0,0 +1,6 @@ +const { rest } = window.MockServiceWorker; +//import { umbracoPath } from '@umbraco-cms/backoffice/utils'; + +export const handlers = [ + +]; From 312e0d8943a7e1834a7c62c2c95b7b9a40a6c876 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 18:26:21 +0100 Subject: [PATCH 11/44] Fix typo --- src/mocks/handlers/log-viewer.handlers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/mocks/handlers/log-viewer.handlers.ts b/src/mocks/handlers/log-viewer.handlers.ts index 836a4ae1ef..ff39c86513 100644 --- a/src/mocks/handlers/log-viewer.handlers.ts +++ b/src/mocks/handlers/log-viewer.handlers.ts @@ -40,7 +40,7 @@ export const handlers = [ }), //#endregion - //#region Temaplates + //#region Templates rest.get(umbracoPath('/log-viewer/message-template'), (req, res, ctx) => { const skip = req.url.searchParams.get('skip'); const skipNumber = skip ? Number.parseInt(skip) : undefined; @@ -57,6 +57,7 @@ export const handlers = [ return res(ctx.delay(), ctx.status(200), ctx.json(response)); }), //#endregion + //#region Logs rest.get(umbracoPath('/log-viewer/level'), (req, res, ctx) => { return res(ctx.delay(), ctx.status(200), ctx.json(umbLogViewerData.logLevels)); From 4a39b06fa17fd186bcf0070ea8be72c0e9fe22ec Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 20:52:43 +0100 Subject: [PATCH 12/44] Set webhooks context --- .../workspace/webhooks/webhooks-workspace.element.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts b/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts index 3deaa89b85..7b89a65493 100644 --- a/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts +++ b/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts @@ -1,17 +1,24 @@ +//import '../../components/index.js'; +import { UmbWebhooksWorkspaceContext } from '../webhooks.context.js'; import { PropertyValueMap, css, html, customElement } from '@umbraco-cms/backoffice/external/lit'; import { UmbTextStyles } from "@umbraco-cms/backoffice/style"; import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; @customElement('umb-webhooks-workspace') export class UmbWebhooksWorkspaceElement extends UmbLitElement { + #webhooksContext = new UmbWebhooksWorkspaceContext(this); firstUpdated(props: PropertyValueMap) { super.firstUpdated(props); + // TODO: This should be moved to the log viewer context: + window.addEventListener('changestate', this.#webhooksContext.onChangeState); + this.#webhooksContext.onChangeState(); } disconnectedCallback(): void { super.disconnectedCallback(); + window.removeEventListener('changestate', this.#webhooksContext.onChangeState); } load(): void { From e4cb9e616f3e87e47f095152749326f6062aa4ba Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Sun, 5 Nov 2023 20:55:39 +0100 Subject: [PATCH 13/44] Update logs icon --- src/packages/settings/webhooks/workspace/webhooks/manifests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts index 862b220ed1..c17f8483da 100644 --- a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/settings/webhooks/workspace/webhooks/manifests.ts @@ -44,7 +44,7 @@ const workspaceViews: Array = [ meta: { label: 'Logs', pathname: 'logs', - icon: 'umb:search', + icon: 'umb:box-alt', }, conditions: [ { From 740aac2b615ad2a5b1a3b12e0f764208ae0504ba Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 6 Nov 2023 00:12:12 +0100 Subject: [PATCH 14/44] Prepare table data --- .../language-root-workspace.element.ts | 3 +- .../repository/webhooks.repository.ts | 7 +- .../views/overview/webhooks-view.element.ts | 123 ++++++++++++++---- 3 files changed, 104 insertions(+), 29 deletions(-) diff --git a/src/packages/settings/languages/workspace/language-root/language-root-workspace.element.ts b/src/packages/settings/languages/workspace/language-root/language-root-workspace.element.ts index 08fb44a875..df8434d8be 100644 --- a/src/packages/settings/languages/workspace/language-root/language-root-workspace.element.ts +++ b/src/packages/settings/languages/workspace/language-root/language-root-workspace.element.ts @@ -112,7 +112,8 @@ export class UmbLanguageRootWorkspaceElement extends UmbLitElement { label="Add language" look="outline" color="default" - href="section/settings/workspace/language/create"> + href="section/settings/workspace/language/create"> + diff --git a/src/packages/settings/webhooks/repository/webhooks.repository.ts b/src/packages/settings/webhooks/repository/webhooks.repository.ts index d190dd8353..6662a36359 100644 --- a/src/packages/settings/webhooks/repository/webhooks.repository.ts +++ b/src/packages/settings/webhooks/repository/webhooks.repository.ts @@ -7,7 +7,7 @@ import { DirectionModel, LogLevelModel, SavedLogSearchPresenationBaseModel } fro /* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */ // element -> context -> repository -> (store) -> data source // All methods should be async and return a promise. Some methods might return an observable as part of the promise response. -export class UmbWebhooksRepository { +export class UmbWebhookRepository { #host: UmbControllerHostElement; #notificationService?: UmbNotificationContext; #init; @@ -19,4 +19,9 @@ export class UmbWebhooksRepository { this.#notificationService = instance; }).asPromise(); } + + async requestWebhooks({ skip, take } = { skip: 0, take: 1000 }) { + await this.#init; + + } } diff --git a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts index 24cd8eb869..222ff3f91a 100644 --- a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts +++ b/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts @@ -1,10 +1,48 @@ +import { UmbWebhookRepository } from '../../../repository/webhooks.repository.js'; import { UmbWebhooksWorkspaceContext, UMB_APP_WEBHOOKS_CONTEXT_TOKEN } from '../../webhooks.context.js'; import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; +import { LanguageResponseModel } from '@umbraco-cms/backoffice/backend-api'; @customElement('umb-webhooks-overview-view') export class UmbWebhooksOverviewViewElement extends UmbLitElement { + @state() + private _tableConfig: UmbTableConfig = { + allowSelection: false, + }; + @state() + private _tableColumns: Array = [ + { + name: 'Enabled', + alias: 'enabled', + elementName: 'umb-language-root-table-name-column-layout', + }, + { + name: 'Events', + alias: 'events', + }, + { + name: 'Url', + alias: 'url', + }, + { + name: 'Types', + alias: 'types', + }, + { + name: '', + alias: 'delete', + elementName: 'umb-language-root-table-delete-column-layout', + }, + ]; + + @state()s + private _tableItems: Array = []; + + #webhookRepository = new UmbWebhookRepository(this); + #webhooksContext?: UmbWebhooksWorkspaceContext; constructor() { super(); @@ -14,23 +52,66 @@ export class UmbWebhooksOverviewViewElement extends UmbLitElement { }); } + connectedCallback() { + super.connectedCallback(); + this.#observeWebhook(); + } + + async #observeWebhook() { + const { asObservable } = await this.#webhookRepository.requestWebhooks(); + + if (asObservable) { + this.observe(asObservable(), (webhook) => this.#createTableItems(webhooks)); + } + } + + #createTableItems(webhooks: Array) { + this._tableItems = webhooks.map((webhook) => { + return { + id: webhook.id ?? '', + icon: 'umb:anchor', + data: [ + { + columnAlias: 'enabled', + value: webhook.enabled, + }, + { + columnAlias: 'events', + value: webhook.events, + }, + { + columnAlias: 'url', + value: webhook.url, + }, + { + columnAlias: 'types', + value: webhook.types, + }, + { + columnAlias: 'delete', + value: webhook, + }, + ], + }; + }); + } + render() { return html` -
- - - - - - - - - - - - -
EnabledEventsUrlTypes
-
+ + + + + + + + + `; } @@ -40,18 +121,6 @@ export class UmbWebhooksOverviewViewElement extends UmbLitElement { display: block; margin: var(--uui-size-layout-1); } - - #webhooks-layout { - padding-bottom: var(--uui-size-layout-1); - display: grid; - grid-template-columns: 7fr 2fr; - grid-template-rows: auto auto; - gap: 20px 20px; - grid-auto-flow: row; - grid-template-areas: - 'saved-searches info' - 'common-messages info'; - } `, ]; } From bc0d3a0d7ec10c7c8de8bde7c617a44813e62f69 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 6 Nov 2023 00:18:40 +0100 Subject: [PATCH 15/44] Fix renamed repository --- .../settings/webhooks/workspace/webhooks.context.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/settings/webhooks/workspace/webhooks.context.ts b/src/packages/settings/webhooks/workspace/webhooks.context.ts index 11320b0560..eb85847067 100644 --- a/src/packages/settings/webhooks/workspace/webhooks.context.ts +++ b/src/packages/settings/webhooks/workspace/webhooks.context.ts @@ -1,4 +1,4 @@ -import { UmbWebhooksRepository } from '../repository/webhooks.repository.js'; +import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; import { UmbBaseController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import { UMB_WORKSPACE_CONTEXT, UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; @@ -6,7 +6,7 @@ import { UMB_WORKSPACE_CONTEXT, UmbWorkspaceContextInterface } from '@umbraco-cm // TODO: Revisit usage of workspace for this case... export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { public readonly workspaceAlias: string = 'Umb.Workspace.Webhooks'; - #repository: UmbWebhooksRepository; + #repository: UmbWebhookRepository; getEntityType() { return 'webhooks'; @@ -27,7 +27,7 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um this.provideContext(UMB_WORKSPACE_CONTEXT, this); // TODO: Revisit usage of workspace for this case... currently no other workspace context provides them self with their own token. this.provideContext(UMB_APP_WEBHOOKS_CONTEXT_TOKEN, this); - this.#repository = new UmbWebhooksRepository(host); + this.#repository = new UmbWebhookRepository(host); } onChangeState = () => { From 5208f42cf37e7a8f6c3481c276786881b7f5604a Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 6 Nov 2023 21:26:58 +0100 Subject: [PATCH 16/44] Revert "Update workspace alias for log viewer" This reverts commit 06ac012f054e58c19ecec83b11426c7f8cac4caa. --- .../workspace/logviewer/logviewer-workspace.element.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts index 1fb940c3c5..d1e1f9b076 100644 --- a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts +++ b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts @@ -33,7 +33,7 @@ export class UmbLogViewerWorkspaceElement extends UmbLitElement { render() { return html` - + `; } From 590405bf7c25d6e616518a06121d56388f58118e Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 18:29:51 +0100 Subject: [PATCH 17/44] Add webhook models --- src/external/backend-api/src/index.ts | 7 + .../src/models/CreateWebhookRequestModel.ts | 11 ++ .../src/models/UpdateWebhookRequestModel.ts | 10 ++ .../src/models/WebhookEventResponseModel.ts | 10 ++ .../src/models/WebhookItemResponseModel.ts | 12 ++ .../src/models/WebhookModelBaseModel.ts | 11 ++ .../src/models/WebhookResponseModel.ts | 12 ++ .../src/services/WebhookResource.ts | 132 ++++++++++++++++++ 8 files changed, 205 insertions(+) create mode 100644 src/external/backend-api/src/models/CreateWebhookRequestModel.ts create mode 100644 src/external/backend-api/src/models/UpdateWebhookRequestModel.ts create mode 100644 src/external/backend-api/src/models/WebhookEventResponseModel.ts create mode 100644 src/external/backend-api/src/models/WebhookItemResponseModel.ts create mode 100644 src/external/backend-api/src/models/WebhookModelBaseModel.ts create mode 100644 src/external/backend-api/src/models/WebhookResponseModel.ts create mode 100644 src/external/backend-api/src/services/WebhookResource.ts diff --git a/src/external/backend-api/src/index.ts b/src/external/backend-api/src/index.ts index 5571e4b3eb..62ee999657 100644 --- a/src/external/backend-api/src/index.ts +++ b/src/external/backend-api/src/index.ts @@ -76,6 +76,7 @@ export type { CreateTemplateRequestModel } from './models/CreateTemplateRequestM export type { CreateUserGroupRequestModel } from './models/CreateUserGroupRequestModel'; export type { CreateUserRequestModel } from './models/CreateUserRequestModel'; export type { CreateUserResponseModel } from './models/CreateUserResponseModel'; +export type { CreateWebhookRequestModel } from './models/CreateWebhookRequestModel'; export type { CultureAndScheduleRequestModel } from './models/CultureAndScheduleRequestModel'; export type { CultureReponseModel } from './models/CultureReponseModel'; export type { CurrentUserResponseModel } from './models/CurrentUserResponseModel'; @@ -400,6 +401,7 @@ export type { UpdateTemplateRequestModel } from './models/UpdateTemplateRequestM export type { UpdateUserGroupRequestModel } from './models/UpdateUserGroupRequestModel'; export type { UpdateUserGroupsOnUserRequestModel } from './models/UpdateUserGroupsOnUserRequestModel'; export type { UpdateUserRequestModel } from './models/UpdateUserRequestModel'; +export type { UpdateWebhookRequestModel } from './models/UpdateWebhookRequestModel'; export type { UpgradeSettingsResponseModel } from './models/UpgradeSettingsResponseModel'; export type { UserConfigurationResponseModel } from './models/UserConfigurationResponseModel'; export type { UserGroupBaseModel } from './models/UserGroupBaseModel'; @@ -423,6 +425,10 @@ export type { VariantModelBaseModel } from './models/VariantModelBaseModel'; export type { VariantResponseModelBaseModel } from './models/VariantResponseModelBaseModel'; export type { VerifyInviteUserRequestModel } from './models/VerifyInviteUserRequestModel'; export type { VerifyResetPasswordTokenRequestModel } from './models/VerifyResetPasswordTokenRequestModel'; +export type { WebhookEventResponseModel } from './models/WebhookEventResponseModel'; +export type { WebhookItemResponseModel } from './models/WebhookItemResponseModel'; +export type { WebhookModelBaseModel } from './models/WebhookModelBaseModel'; +export type { WebhookResponseModel } from './models/WebhookResponseModel'; export { AuditLogResource } from './services/AuditLogResource'; export { CultureResource } from './services/CultureResource'; @@ -469,3 +475,4 @@ export { TrackedReferenceResource } from './services/TrackedReferenceResource'; export { UpgradeResource } from './services/UpgradeResource'; export { UserResource } from './services/UserResource'; export { UserGroupResource } from './services/UserGroupResource'; +export { WebhookResource } from './services/WebhookResource'; diff --git a/src/external/backend-api/src/models/CreateWebhookRequestModel.ts b/src/external/backend-api/src/models/CreateWebhookRequestModel.ts new file mode 100644 index 0000000000..0f2185bd19 --- /dev/null +++ b/src/external/backend-api/src/models/CreateWebhookRequestModel.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WebhookModelBaseModel } from './WebhookModelBaseModel'; + +export type CreateWebhookRequestModel = (WebhookModelBaseModel & { +id?: string | null; +events: Array; +}); diff --git a/src/external/backend-api/src/models/UpdateWebhookRequestModel.ts b/src/external/backend-api/src/models/UpdateWebhookRequestModel.ts new file mode 100644 index 0000000000..e4e72a1cfa --- /dev/null +++ b/src/external/backend-api/src/models/UpdateWebhookRequestModel.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WebhookModelBaseModel } from './WebhookModelBaseModel'; + +export type UpdateWebhookRequestModel = (WebhookModelBaseModel & { +events: Array; +}); diff --git a/src/external/backend-api/src/models/WebhookEventResponseModel.ts b/src/external/backend-api/src/models/WebhookEventResponseModel.ts new file mode 100644 index 0000000000..2ce0acac6f --- /dev/null +++ b/src/external/backend-api/src/models/WebhookEventResponseModel.ts @@ -0,0 +1,10 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type WebhookEventResponseModel = { + eventName: string; + eventType: string; + alias: string; +}; diff --git a/src/external/backend-api/src/models/WebhookItemResponseModel.ts b/src/external/backend-api/src/models/WebhookItemResponseModel.ts new file mode 100644 index 0000000000..5808f57e53 --- /dev/null +++ b/src/external/backend-api/src/models/WebhookItemResponseModel.ts @@ -0,0 +1,12 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type WebhookItemResponseModel = { + enabled: boolean; + name: string; + events: string; + url: string; + types: string; +}; diff --git a/src/external/backend-api/src/models/WebhookModelBaseModel.ts b/src/external/backend-api/src/models/WebhookModelBaseModel.ts new file mode 100644 index 0000000000..a6ded4467d --- /dev/null +++ b/src/external/backend-api/src/models/WebhookModelBaseModel.ts @@ -0,0 +1,11 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +export type WebhookModelBaseModel = { + enabled: boolean; + url: string; + contentTypeKeys: Array; + headers: Record; +}; diff --git a/src/external/backend-api/src/models/WebhookResponseModel.ts b/src/external/backend-api/src/models/WebhookResponseModel.ts new file mode 100644 index 0000000000..d2f0936e07 --- /dev/null +++ b/src/external/backend-api/src/models/WebhookResponseModel.ts @@ -0,0 +1,12 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ + +import type { WebhookEventResponseModel } from './WebhookEventResponseModel'; +import type { WebhookModelBaseModel } from './WebhookModelBaseModel'; + +export type WebhookResponseModel = (WebhookModelBaseModel & { +id: string; +events: Array; +}); diff --git a/src/external/backend-api/src/services/WebhookResource.ts b/src/external/backend-api/src/services/WebhookResource.ts new file mode 100644 index 0000000000..04dd3f52b7 --- /dev/null +++ b/src/external/backend-api/src/services/WebhookResource.ts @@ -0,0 +1,132 @@ +/* generated using openapi-typescript-codegen -- do no edit */ +/* istanbul ignore file */ +/* tslint:disable */ +/* eslint-disable */ +import type { CreateWebhookRequestModel } from '../models/CreateWebhookRequestModel'; +import type { UpdateWebhookRequestModel } from '../models/UpdateWebhookRequestModel'; +import type { WebhookItemResponseModel } from '../models/WebhookItemResponseModel'; +import type { WebhookResponseModel } from '../models/WebhookResponseModel'; + +import type { CancelablePromise } from '../core/CancelablePromise'; +import { OpenAPI } from '../core/OpenAPI'; +import { request as __request } from '../core/request'; + +export class WebhookResource { + + /** + * @returns string Created + * @throws ApiError + */ + public static postWebhook({ +requestBody, +}: { +requestBody?: CreateWebhookRequestModel, +}): CancelablePromise { + return __request(OpenAPI, { + method: 'POST', + url: '/umbraco/management/api/v1/webhook', + body: requestBody, + mediaType: 'application/json', + responseHeader: 'Umb-Generated-Resource', + errors: { + 400: `Bad Request`, + 401: `The resource is protected and requires an authentication token`, + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static getWebhookById({ +id, +}: { +id: string, +}): CancelablePromise { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/webhook/{id}', + path: { + 'id': id, + }, + errors: { + 401: `The resource is protected and requires an authentication token`, + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static putWebhookById({ +id, +requestBody, +}: { +id: string, +requestBody?: UpdateWebhookRequestModel, +}): CancelablePromise { + return __request(OpenAPI, { + method: 'PUT', + url: '/umbraco/management/api/v1/webhook/{id}', + path: { + 'id': id, + }, + body: requestBody, + mediaType: 'application/json', + errors: { + 400: `Bad Request`, + 401: `The resource is protected and requires an authentication token`, + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static deleteWebhookById({ +id, +}: { +id: string, +}): CancelablePromise { + return __request(OpenAPI, { + method: 'DELETE', + url: '/umbraco/management/api/v1/webhook/{id}', + path: { + 'id': id, + }, + errors: { + 400: `Bad Request`, + 401: `The resource is protected and requires an authentication token`, + 404: `Not Found`, + }, + }); + } + + /** + * @returns any Success + * @throws ApiError + */ + public static getWebhookItem({ +ids, +}: { +ids?: Array, +}): CancelablePromise> { + return __request(OpenAPI, { + method: 'GET', + url: '/umbraco/management/api/v1/webhook/item', + query: { + 'ids': ids, + }, + errors: { + 401: `The resource is protected and requires an authentication token`, + }, + }); + } + +} From 6426c1018242a10e04a3a2f1495ff506b8f2f245 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 18:34:44 +0100 Subject: [PATCH 18/44] Move workspace --- src/packages/{settings => }/webhooks/index.ts | 0 src/packages/{settings => }/webhooks/manifests.ts | 0 src/packages/{settings => }/webhooks/menu-item/manifests.ts | 0 src/packages/{settings => }/webhooks/repository/index.ts | 0 .../{settings => }/webhooks/repository/webhooks.repository.ts | 0 src/packages/{settings => }/webhooks/workspace/manifests.ts | 0 .../{settings => }/webhooks/workspace/views/overview/index.ts | 0 .../webhooks/workspace/views/overview/webhooks-view.element.ts | 0 .../{settings => }/webhooks/workspace/webhooks.context.ts | 0 .../{settings => }/webhooks/workspace/webhooks/manifests.ts | 0 .../webhooks/workspace/webhooks/webhooks-workspace.element.ts | 0 11 files changed, 0 insertions(+), 0 deletions(-) rename src/packages/{settings => }/webhooks/index.ts (100%) rename src/packages/{settings => }/webhooks/manifests.ts (100%) rename src/packages/{settings => }/webhooks/menu-item/manifests.ts (100%) rename src/packages/{settings => }/webhooks/repository/index.ts (100%) rename src/packages/{settings => }/webhooks/repository/webhooks.repository.ts (100%) rename src/packages/{settings => }/webhooks/workspace/manifests.ts (100%) rename src/packages/{settings => }/webhooks/workspace/views/overview/index.ts (100%) rename src/packages/{settings => }/webhooks/workspace/views/overview/webhooks-view.element.ts (100%) rename src/packages/{settings => }/webhooks/workspace/webhooks.context.ts (100%) rename src/packages/{settings => }/webhooks/workspace/webhooks/manifests.ts (100%) rename src/packages/{settings => }/webhooks/workspace/webhooks/webhooks-workspace.element.ts (100%) diff --git a/src/packages/settings/webhooks/index.ts b/src/packages/webhooks/index.ts similarity index 100% rename from src/packages/settings/webhooks/index.ts rename to src/packages/webhooks/index.ts diff --git a/src/packages/settings/webhooks/manifests.ts b/src/packages/webhooks/manifests.ts similarity index 100% rename from src/packages/settings/webhooks/manifests.ts rename to src/packages/webhooks/manifests.ts diff --git a/src/packages/settings/webhooks/menu-item/manifests.ts b/src/packages/webhooks/menu-item/manifests.ts similarity index 100% rename from src/packages/settings/webhooks/menu-item/manifests.ts rename to src/packages/webhooks/menu-item/manifests.ts diff --git a/src/packages/settings/webhooks/repository/index.ts b/src/packages/webhooks/repository/index.ts similarity index 100% rename from src/packages/settings/webhooks/repository/index.ts rename to src/packages/webhooks/repository/index.ts diff --git a/src/packages/settings/webhooks/repository/webhooks.repository.ts b/src/packages/webhooks/repository/webhooks.repository.ts similarity index 100% rename from src/packages/settings/webhooks/repository/webhooks.repository.ts rename to src/packages/webhooks/repository/webhooks.repository.ts diff --git a/src/packages/settings/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/manifests.ts rename to src/packages/webhooks/workspace/manifests.ts diff --git a/src/packages/settings/webhooks/workspace/views/overview/index.ts b/src/packages/webhooks/workspace/views/overview/index.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/views/overview/index.ts rename to src/packages/webhooks/workspace/views/overview/index.ts diff --git a/src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts b/src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts rename to src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts diff --git a/src/packages/settings/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/webhooks.context.ts rename to src/packages/webhooks/workspace/webhooks.context.ts diff --git a/src/packages/settings/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/webhooks/manifests.ts rename to src/packages/webhooks/workspace/webhooks/manifests.ts diff --git a/src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts b/src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts similarity index 100% rename from src/packages/settings/webhooks/workspace/webhooks/webhooks-workspace.element.ts rename to src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts From 79ed1ef7af8eac9244b00dc63ead0d5a95f15ce0 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 20:47:47 +0100 Subject: [PATCH 19/44] Update using new collection view --- .../language/collection/action/manifests.ts | 8 +- .../webhooks/collection/action/manifests.ts | 22 ++ src/packages/webhooks/collection/index.ts | 2 + src/packages/webhooks/collection/manifests.ts | 24 ++ .../webhooks/collection/repository/index.ts | 2 + .../collection/repository/manifests.ts | 12 + .../webhooks/collection/repository/types.ts | 8 + .../webhook-collection.repository.ts | 21 ++ .../webhook-collection.server.data-source.ts | 55 +++++ src/packages/webhooks/collection/types.ts | 4 + .../webhooks/collection/views/index.ts | 1 + .../webhooks/collection/views/manifests.ts | 24 ++ ...age-table-boolean-column-layout.element.ts | 18 ++ ...le-entity-actions-column-layout.element.ts | 38 +++ ...nguage-table-name-column-layout.element.ts | 21 ++ .../language-table-collection-view.element.ts | 133 +++++++++++ src/packages/webhooks/entity.ts | 5 + .../global-contexts/app-webhook.context.ts | 40 ++++ .../webhooks/global-contexts/index.ts | 1 + .../webhooks/global-contexts/manifests.ts | 10 + src/packages/webhooks/index.ts | 6 + .../repository/webhooks.repository.ts | 6 +- src/packages/webhooks/types.ts | 10 + .../language-workspace-editor.element.ts | 103 ++++++++ .../language/language-workspace.context.ts | 119 ++++++++++ .../language/language-workspace.element.ts | 49 ++++ .../webhooks/workspace/language/manifests.ts | 59 +++++ ...language-details-workspace-view.element.ts | 222 ++++++++++++++++++ .../webhooks/workspace/overview/manifests.ts | 13 + .../webhook-root-workspace.element.ts | 20 ++ .../workspace/views/overview/index.ts | 4 - .../views/overview/webhooks-view.element.ts | 132 ----------- .../webhooks/workspace/webhooks.context.ts | 10 +- .../webhooks/workspace/webhooks/manifests.ts | 22 +- 34 files changed, 1066 insertions(+), 158 deletions(-) create mode 100644 src/packages/webhooks/collection/action/manifests.ts create mode 100644 src/packages/webhooks/collection/index.ts create mode 100644 src/packages/webhooks/collection/manifests.ts create mode 100644 src/packages/webhooks/collection/repository/index.ts create mode 100644 src/packages/webhooks/collection/repository/manifests.ts create mode 100644 src/packages/webhooks/collection/repository/types.ts create mode 100644 src/packages/webhooks/collection/repository/webhook-collection.repository.ts create mode 100644 src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts create mode 100644 src/packages/webhooks/collection/types.ts create mode 100644 src/packages/webhooks/collection/views/index.ts create mode 100644 src/packages/webhooks/collection/views/manifests.ts create mode 100644 src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts create mode 100644 src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts create mode 100644 src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts create mode 100644 src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts create mode 100644 src/packages/webhooks/entity.ts create mode 100644 src/packages/webhooks/global-contexts/app-webhook.context.ts create mode 100644 src/packages/webhooks/global-contexts/index.ts create mode 100644 src/packages/webhooks/global-contexts/manifests.ts create mode 100644 src/packages/webhooks/types.ts create mode 100644 src/packages/webhooks/workspace/language/language-workspace-editor.element.ts create mode 100644 src/packages/webhooks/workspace/language/language-workspace.context.ts create mode 100644 src/packages/webhooks/workspace/language/language-workspace.element.ts create mode 100644 src/packages/webhooks/workspace/language/manifests.ts create mode 100644 src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts create mode 100644 src/packages/webhooks/workspace/overview/manifests.ts create mode 100644 src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts delete mode 100644 src/packages/webhooks/workspace/views/overview/index.ts delete mode 100644 src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts diff --git a/src/packages/language/collection/action/manifests.ts b/src/packages/language/collection/action/manifests.ts index c4c98eca4d..bfaabbb79a 100644 --- a/src/packages/language/collection/action/manifests.ts +++ b/src/packages/language/collection/action/manifests.ts @@ -4,17 +4,17 @@ import type { ManifestCollectionAction } from '@umbraco-cms/backoffice/extension export const createManifest: ManifestCollectionAction = { type: 'collectionAction', kind: 'button', - name: 'Create Language Collection Action', - alias: 'Umb.CollectionAction.Language.Create', + name: 'Create Webhook Collection Action', + alias: 'Umb.CollectionAction.Webhook.Create', weight: 200, meta: { label: 'Create', - href: 'section/settings/workspace/language/create', + href: 'section/settings/workspace/webhook/create', }, conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Language', + match: 'Umb.Collection.Webhook', }, ], }; diff --git a/src/packages/webhooks/collection/action/manifests.ts b/src/packages/webhooks/collection/action/manifests.ts new file mode 100644 index 0000000000..bfaabbb79a --- /dev/null +++ b/src/packages/webhooks/collection/action/manifests.ts @@ -0,0 +1,22 @@ +import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection'; +import type { ManifestCollectionAction } from '@umbraco-cms/backoffice/extension-registry'; + +export const createManifest: ManifestCollectionAction = { + type: 'collectionAction', + kind: 'button', + name: 'Create Webhook Collection Action', + alias: 'Umb.CollectionAction.Webhook.Create', + weight: 200, + meta: { + label: 'Create', + href: 'section/settings/workspace/webhook/create', + }, + conditions: [ + { + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: 'Umb.Collection.Webhook', + }, + ], +}; + +export const manifests = [createManifest]; diff --git a/src/packages/webhooks/collection/index.ts b/src/packages/webhooks/collection/index.ts new file mode 100644 index 0000000000..6ac354feaf --- /dev/null +++ b/src/packages/webhooks/collection/index.ts @@ -0,0 +1,2 @@ +export { UmbWebhookCollectionRepository } from './repository/index.js'; +export { UMB_WEBHOOK_COLLECTION_ALIAS } from './manifests.js'; diff --git a/src/packages/webhooks/collection/manifests.ts b/src/packages/webhooks/collection/manifests.ts new file mode 100644 index 0000000000..f76cadfc0e --- /dev/null +++ b/src/packages/webhooks/collection/manifests.ts @@ -0,0 +1,24 @@ +import { UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS } from './repository/index.js'; +import { manifests as collectionRepositoryManifests } from './repository/manifests.js'; +import { manifests as collectionViewManifests } from './views/manifests.js'; +import { manifests as collectionActionManifests } from './action/manifests.js'; +import type { ManifestCollection } from '@umbraco-cms/backoffice/extension-registry'; + +export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhook'; + +const collectionManifest: ManifestCollection = { + type: 'collection', + kind: 'default', + alias: UMB_WEBHOOK_COLLECTION_ALIAS, + name: 'Webhook Collection', + meta: { + repositoryAlias: UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS, + }, +}; + +export const manifests = [ + collectionManifest, + ...collectionRepositoryManifests, + ...collectionViewManifests, + ...collectionActionManifests, +]; diff --git a/src/packages/webhooks/collection/repository/index.ts b/src/packages/webhooks/collection/repository/index.ts new file mode 100644 index 0000000000..aa27b1259b --- /dev/null +++ b/src/packages/webhooks/collection/repository/index.ts @@ -0,0 +1,2 @@ +export { UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS } from './manifests.js'; +export { UmbWebhookCollectionRepository } from './webhook-collection.repository.js'; diff --git a/src/packages/webhooks/collection/repository/manifests.ts b/src/packages/webhooks/collection/repository/manifests.ts new file mode 100644 index 0000000000..6295051cb7 --- /dev/null +++ b/src/packages/webhooks/collection/repository/manifests.ts @@ -0,0 +1,12 @@ +import type { ManifestRepository } from '@umbraco-cms/backoffice/extension-registry'; + +export const UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS = 'Umb.Repository.WebhookCollection'; + +const repository: ManifestRepository = { + type: 'repository', + alias: UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS, + name: 'Webhook Collection Repository', + api: () => import('./webhook-collection.repository.js'), +}; + +export const manifests = [repository]; diff --git a/src/packages/webhooks/collection/repository/types.ts b/src/packages/webhooks/collection/repository/types.ts new file mode 100644 index 0000000000..28989e140e --- /dev/null +++ b/src/packages/webhooks/collection/repository/types.ts @@ -0,0 +1,8 @@ +import type { UmbWebhookDetailModel } from '../../types.js'; +import type { UmbWebhookCollectionFilterModel } from '../types.js'; +import type { UmbCollectionDataSource } from '@umbraco-cms/backoffice/collection'; + +export type UmbWebhookCollectionDataSource = UmbCollectionDataSource< + UmbWebhookDetailModel, + UmbWebhookCollectionFilterModel +>; diff --git a/src/packages/webhooks/collection/repository/webhook-collection.repository.ts b/src/packages/webhooks/collection/repository/webhook-collection.repository.ts new file mode 100644 index 0000000000..96a19f53ca --- /dev/null +++ b/src/packages/webhooks/collection/repository/webhook-collection.repository.ts @@ -0,0 +1,21 @@ +import type { UmbWebhookCollectionFilterModel } from '../types.js'; +import { UmbWebhookCollectionServerDataSource } from './webhook-collection.server.data-source.js'; +import type { UmbWebhookCollectionDataSource } from './types.js'; +import type { UmbCollectionRepository } from '@umbraco-cms/backoffice/collection'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; + +export class UmbWebhookCollectionRepository implements UmbCollectionRepository { + #collectionSource: UmbWebhookCollectionDataSource; + + constructor(host: UmbControllerHost) { + this.#collectionSource = new UmbWebhookCollectionServerDataSource(host); + } + + async requestCollection(filter: UmbWebhookCollectionFilterModel) { + return this.#collectionSource.getCollection(filter); + } + + destroy(): void {} +} + +export default UmbWebhookCollectionRepository; diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts new file mode 100644 index 0000000000..bfe7632038 --- /dev/null +++ b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts @@ -0,0 +1,55 @@ +import type { UmbWebhookCollectionFilterModel } from '../types.js'; +import type { UmbWebhookDetailModel } from '../../types.js'; +import { UMB_WEBHOOK_ENTITY_TYPE } from '../../entity.js'; +import type { UmbCollectionDataSource } from '@umbraco-cms/backoffice/collection'; +import { WebhookResource } from '@umbraco-cms/backoffice/external/backend-api'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; +import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; + +/** + * A data source that fetches the webhook collection data from the server. + * @export + * @class UmbWebhookCollectionServerDataSource + * @implements {UmbCollectionDataSource} + */ +export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSource { + #host: UmbControllerHost; + + /** + * Creates an instance of UmbWebhookCollectionServerDataSource. + * @param {UmbControllerHost} host + * @memberof UmbWebhookCollectionServerDataSource + */ + constructor(host: UmbControllerHost) { + this.#host = host; + } + + /** + * Gets the Wwbhook collection filtered by the given filter. + * @param {UmbWebhookeCollectionFilterModel} filter + * @return {*} + * @memberof UmbWebhookeCollectionServerDataSource + */ + async getCollection(filter: UmbWebhookCollectionFilterModel) { + const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhook(filter)); + + if (data) { + const items = data.items.map((item) => { + const model: UmbWebhookDetailModel = { + unique: item.isoCode.toLowerCase(), + name: item.name, + entityType: UMB_WEBHOOK_ENTITY_TYPE, + isDefault: item.isDefault, + isMandatory: item.isMandatory, + fallbackIsoCode: item.fallbackIsoCode?.toLowerCase() || null, + }; + + return model; + }); + + return { data: { items, total: data.total } }; + } + + return { error }; + } +} diff --git a/src/packages/webhooks/collection/types.ts b/src/packages/webhooks/collection/types.ts new file mode 100644 index 0000000000..7558eec496 --- /dev/null +++ b/src/packages/webhooks/collection/types.ts @@ -0,0 +1,4 @@ +export interface UmbLanguageCollectionFilterModel { + skip?: number; + take?: number; +} diff --git a/src/packages/webhooks/collection/views/index.ts b/src/packages/webhooks/collection/views/index.ts new file mode 100644 index 0000000000..e9d6c50fc5 --- /dev/null +++ b/src/packages/webhooks/collection/views/index.ts @@ -0,0 +1 @@ +export { UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js'; diff --git a/src/packages/webhooks/collection/views/manifests.ts b/src/packages/webhooks/collection/views/manifests.ts new file mode 100644 index 0000000000..dd0183bcdb --- /dev/null +++ b/src/packages/webhooks/collection/views/manifests.ts @@ -0,0 +1,24 @@ +import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection'; +import type { ManifestCollectionView } from '@umbraco-cms/backoffice/extension-registry'; + +export const UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS = 'Umb.CollectionView.Language.Table'; + +const tableCollectionView: ManifestCollectionView = { + type: 'collectionView', + alias: UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS, + name: 'Language Table Collection View', + js: () => import('./table/language-table-collection-view.element.js'), + meta: { + label: 'Table', + icon: 'icon-list', + pathName: 'table', + }, + conditions: [ + { + alias: UMB_COLLECTION_ALIAS_CONDITION, + match: 'Umb.Collection.Language', + }, + ], +}; + +export const manifests = [tableCollectionView]; diff --git a/src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts new file mode 100644 index 0000000000..3dc43bbbb6 --- /dev/null +++ b/src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts @@ -0,0 +1,18 @@ +import { html, nothing, customElement, property } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-language-table-boolean-column-layout') +export class UmbLanguageTableBooleanColumnLayoutElement extends UmbLitElement { + @property({ attribute: false }) + value = false; + + render() { + return this.value ? html`` : nothing; + } +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-table-boolean-column-layout': UmbLanguageTableBooleanColumnLayoutElement; + } +} diff --git a/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts new file mode 100644 index 0000000000..e9250a09ad --- /dev/null +++ b/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts @@ -0,0 +1,38 @@ +import type { UmbLanguageDetailModel } from '../../../../../types.js'; +import { html, nothing, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-language-table-entity-actions-column-layout') +export class UmbLanguageTableEntityActionsColumnLayoutElement extends UmbLitElement { + @property({ attribute: false }) + value!: UmbLanguageDetailModel; + + @state() + _isOpen = false; + + #onActionExecuted() { + this._isOpen = false; + } + + render() { + // TODO: we need to use conditionals on each action here. But until we have that in place + // we'll just remove all actions on the default language. + if (this.value.isDefault) return nothing; + + return html` + + + + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-table-entity-actions-column-layout': UmbLanguageTableEntityActionsColumnLayoutElement; + } +} diff --git a/src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts new file mode 100644 index 0000000000..4c3ce5ec56 --- /dev/null +++ b/src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts @@ -0,0 +1,21 @@ +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +import { html, LitElement, nothing, customElement, property } from '@umbraco-cms/backoffice/external/lit'; + +@customElement('umb-language-table-name-column-layout') +export class UmbLanguageTableNameColumnLayoutElement extends LitElement { + @property({ attribute: false }) + value!: { unique: string; name: string }; + + render() { + if (!this.value) return nothing; + return html`${this.value.name}`; + } + + static styles = [UmbTextStyles]; +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-table-name-column-layout': UmbLanguageTableNameColumnLayoutElement; + } +} diff --git a/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts b/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts new file mode 100644 index 0000000000..3e3359dc27 --- /dev/null +++ b/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts @@ -0,0 +1,133 @@ +import type { UmbLanguageDetailModel } from '../../../types.js'; +import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'; +import { UMB_DEFAULT_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection'; +import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; +import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +import './column-layouts/boolean/language-table-boolean-column-layout.element.js'; +import './column-layouts/name/language-table-name-column-layout.element.js'; +import './column-layouts/entity-actions/language-table-entity-actions-column-layout.element.js'; + +@customElement('umb-language-table-collection-view') +export class UmbLanguageTableCollectionViewElement extends UmbLitElement { + @state() + private _tableConfig: UmbTableConfig = { + allowSelection: false, + }; + + @state() + private _tableColumns: Array = [ + { + name: 'Name', + alias: 'languageName', + elementName: 'umb-language-table-name-column-layout', + }, + { + name: 'ISO Code', + alias: 'isoCode', + }, + { + name: 'Default', + alias: 'defaultLanguage', + elementName: 'umb-language-table-boolean-column-layout', + }, + { + name: 'Mandatory', + alias: 'mandatoryLanguage', + elementName: 'umb-language-table-boolean-column-layout', + }, + { + name: 'Fallback', + alias: 'fallbackLanguage', + }, + { + name: '', + alias: 'entityActions', + elementName: 'umb-language-table-entity-actions-column-layout', + }, + ]; + + @state() + private _tableItems: Array = []; + private _cultureNames = new Intl.DisplayNames('en', { type: 'language' }); + + #collectionContext?: UmbDefaultCollectionContext; + + constructor() { + super(); + + this.consumeContext(UMB_DEFAULT_COLLECTION_CONTEXT, (instance) => { + this.#collectionContext = instance; + this.#observeCollectionItems(); + }); + } + + #observeCollectionItems() { + if (!this.#collectionContext) return; + this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver'); + } + + #createTableItems(languages: Array) { + this._tableItems = languages.map((language) => { + return { + id: language.unique, + icon: 'icon-globe', + data: [ + { + columnAlias: 'languageName', + value: { + name: language.name ? language.name : this._cultureNames.of(language.unique), + unique: language.unique, + }, + }, + { + columnAlias: 'isoCode', + value: language.unique, + }, + { + columnAlias: 'defaultLanguage', + value: language.isDefault, + }, + { + columnAlias: 'mandatoryLanguage', + value: language.isMandatory, + }, + { + columnAlias: 'fallbackLanguage', + value: languages.find((x) => x.unique === language.fallbackIsoCode)?.name, + }, + { + columnAlias: 'entityActions', + value: language, + }, + ], + }; + }); + } + + render() { + return html` + + `; + } + + static styles = [ + UmbTextStyles, + css` + :host { + display: flex; + flex-direction: column; + } + `, + ]; +} + +export default UmbLanguageTableCollectionViewElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-table-collection-view': UmbLanguageTableCollectionViewElement; + } +} diff --git a/src/packages/webhooks/entity.ts b/src/packages/webhooks/entity.ts new file mode 100644 index 0000000000..90e4c7b9ed --- /dev/null +++ b/src/packages/webhooks/entity.ts @@ -0,0 +1,5 @@ +export const UMB_WEBHOOK_ENTITY_TYPE = 'webhook'; +export const UMB_WEBHOOK_ROOT_ENTITY_TYPE = 'webhook-root'; + +export type UmbWebhookEntityType = typeof UMB_WEBHOOK_ENTITY_TYPE; +export type UmbWebhookRootEntityType = typeof UMB_WEBHOOK_ROOT_ENTITY_TYPE; diff --git a/src/packages/webhooks/global-contexts/app-webhook.context.ts b/src/packages/webhooks/global-contexts/app-webhook.context.ts new file mode 100644 index 0000000000..971d1edc8f --- /dev/null +++ b/src/packages/webhooks/global-contexts/app-webhook.context.ts @@ -0,0 +1,40 @@ +import { UmbWebhookCollectionRepository } from '../collection/index.js'; +import type { UmbWebhookDetailModel } from '../types.js'; +import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; +import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; +import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; +import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; +import type { UmbApi } from '@umbraco-cms/backoffice/extension-api'; + +export class UmbAppWebhookContext extends UmbBaseController implements UmbApi { + #webhookCollectionRepository: UmbWebhookCollectionRepository; + #webhooks: Array = []; + #appWebhook = new UmbObjectState(undefined); + appWebhook = this.#appWebhook.asObservable(); + + constructor(host: UmbControllerHost) { + super(host); + this.provideContext(UMB_APP_WEBHOOK_CONTEXT, this); + this.#webhookCollectionRepository = new UmbWebhookCollectionRepository(this); + this.#observeWebhooks(); + } + + setLanguage(unique: string) { + const webhook = this.#webhooks.find((x) => x.unique === unique); + this.#appWebhook.update(webhook); + } + + async #observeWebhooks() { + const { data } = await this.#webhookCollectionRepository.requestCollection({ skip: 0, take: 100 }); + + // TODO: make this observable / update when webhooks are added/removed/updated + if (data) { + this.#webhooks = data.items; + } + } +} + +// Default export to enable this as a globalContext extension js: +export default UmbAppWebhookContext; + +export const UMB_APP_WEBHOOK_CONTEXT = new UmbContextToken('UmbAppWebhookContext'); diff --git a/src/packages/webhooks/global-contexts/index.ts b/src/packages/webhooks/global-contexts/index.ts new file mode 100644 index 0000000000..868bf754a7 --- /dev/null +++ b/src/packages/webhooks/global-contexts/index.ts @@ -0,0 +1 @@ +export * from './app-webhook.context.js'; diff --git a/src/packages/webhooks/global-contexts/manifests.ts b/src/packages/webhooks/global-contexts/manifests.ts new file mode 100644 index 0000000000..a38ca4af40 --- /dev/null +++ b/src/packages/webhooks/global-contexts/manifests.ts @@ -0,0 +1,10 @@ +import type { ManifestGlobalContext } from '@umbraco-cms/backoffice/extension-registry'; + +export const manifests: Array = [ + { + type: 'globalContext', + alias: 'Umb.GlobalContext.AppWebhook', + name: 'App Webhook Context', + js: () => import('./app-webhook.context.js'), + }, +]; diff --git a/src/packages/webhooks/index.ts b/src/packages/webhooks/index.ts index 3d76f338dd..734e11ca45 100644 --- a/src/packages/webhooks/index.ts +++ b/src/packages/webhooks/index.ts @@ -1 +1,7 @@ +import './components/index.js'; + export * from './repository/index.js'; +export * from './collection/index.js'; +export * from './global-contexts/index.js'; + +export type { UmbWebhookDetailModel } from './types.js'; \ No newline at end of file diff --git a/src/packages/webhooks/repository/webhooks.repository.ts b/src/packages/webhooks/repository/webhooks.repository.ts index 6662a36359..4593765abf 100644 --- a/src/packages/webhooks/repository/webhooks.repository.ts +++ b/src/packages/webhooks/repository/webhooks.repository.ts @@ -1,7 +1,7 @@ import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { UmbNotificationContext, UMB_NOTIFICATION_CONTEXT_TOKEN } from '@umbraco-cms/backoffice/notification'; -import { DirectionModel, LogLevelModel, SavedLogSearchPresenationBaseModel } from '@umbraco-cms/backoffice/backend-api'; +import { UmbNotificationContext } from '@umbraco-cms/backoffice/notification'; +import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'; // Move to documentation / JSdoc /* We need to create a new instance of the repository from within the element context. We want the notifications to be displayed in the right context. */ @@ -15,7 +15,7 @@ export class UmbWebhookRepository { constructor(host: UmbControllerHostElement) { this.#host = host; - this.#init = new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT_TOKEN, (instance) => { + this.#init = new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT, (instance) => { this.#notificationService = instance; }).asPromise(); } diff --git a/src/packages/webhooks/types.ts b/src/packages/webhooks/types.ts new file mode 100644 index 0000000000..e3f11eadf6 --- /dev/null +++ b/src/packages/webhooks/types.ts @@ -0,0 +1,10 @@ +import type { UmbWebhookEntityType } from './entity.js'; + +export interface UmbWebhookDetailModel { + entityType: UmbWebhookEntityType; + unique: string; + enabled: boolean; + url: string; + events: string[] | null; + types: string[] | null; +} \ No newline at end of file diff --git a/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts b/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts new file mode 100644 index 0000000000..122fca7de5 --- /dev/null +++ b/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts @@ -0,0 +1,103 @@ +import type { UmbLanguageDetailModel } from '../../types.js'; +import { UMB_LANGUAGE_WORKSPACE_CONTEXT } from './language-workspace.context.js'; +import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui'; +import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui'; +import { css, html, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +@customElement('umb-language-workspace-editor') +export class UmbLanguageWorkspaceEditorElement extends UmbLitElement { + #workspaceContext?: typeof UMB_LANGUAGE_WORKSPACE_CONTEXT.TYPE; + + @state() + _language?: UmbLanguageDetailModel; + + @state() + _isNew?: boolean; + + constructor() { + super(); + + this.consumeContext(UMB_LANGUAGE_WORKSPACE_CONTEXT, (context) => { + this.#workspaceContext = context; + this.#observeData(); + }); + } + + #observeData() { + if (!this.#workspaceContext) return; + this.observe(this.#workspaceContext.data, (data) => { + this._language = data; + }); + this.observe(this.#workspaceContext.isNew, (isNew) => { + this._isNew = isNew; + }); + } + + #handleInput(event: UUIInputEvent) { + if (event instanceof UUIInputEvent) { + const target = event.composedPath()[0] as UUIInputElement; + + if (typeof target?.value === 'string') { + this.#workspaceContext?.setName(target.value); + } + } + } + + render() { + return html` + + + `; + } + + static styles = [ + UmbTextStyles, + css` + #header { + display: flex; + padding: 0 var(--uui-size-space-6); + gap: var(--uui-size-space-4); + width: 100%; + } + + uui-input { + width: 100%; + } + + strong { + display: flex; + align-items: center; + } + + #footer-into { + padding: 0 var(--uui-size-layout-1); + } + + uui-input:not(:focus) { + border: 1px solid transparent; + } + `, + ]; +} + +export default UmbLanguageWorkspaceEditorElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-workspace-editor': UmbLanguageWorkspaceEditorElement; + } +} diff --git a/src/packages/webhooks/workspace/language/language-workspace.context.ts b/src/packages/webhooks/workspace/language/language-workspace.context.ts new file mode 100644 index 0000000000..47793e2860 --- /dev/null +++ b/src/packages/webhooks/workspace/language/language-workspace.context.ts @@ -0,0 +1,119 @@ +import { UmbLanguageDetailRepository } from '../../repository/index.js'; +import type { UmbLanguageDetailModel } from '../../types.js'; +import { + type UmbSaveableWorkspaceContextInterface, + UmbEditableWorkspaceContextBase, +} from '@umbraco-cms/backoffice/workspace'; +import { ApiError } from '@umbraco-cms/backoffice/external/backend-api'; +import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; + +export class UmbLanguageWorkspaceContext + extends UmbEditableWorkspaceContextBase + implements UmbSaveableWorkspaceContextInterface +{ + public readonly repository: UmbLanguageDetailRepository = new UmbLanguageDetailRepository(this); + + #data = new UmbObjectState(undefined); + readonly data = this.#data.asObservable(); + + // TODO: this is a temp solution to bubble validation errors to the UI + #validationErrors = new UmbObjectState(undefined); + readonly validationErrors = this.#validationErrors.asObservable(); + + constructor(host: UmbControllerHostElement) { + super(host, 'Umb.Workspace.Language'); + } + + async load(unique: string) { + const { data } = await this.repository.requestByUnique(unique); + if (data) { + this.setIsNew(false); + this.#data.update(data); + } + } + + async create() { + const { data } = await this.repository.createScaffold(null); + if (!data) return; + this.setIsNew(true); + this.#data.update(data); + return { data }; + } + + getData() { + return this.#data.getValue(); + } + + getEntityType() { + return 'language'; + } + + // TODO: Convert to uniques: + getEntityId() { + return this.#data.getValue()?.unique; + } + + setName(name: string) { + this.#data.update({ name }); + } + + setCulture(unique: string) { + this.#data.update({ unique }); + } + + setMandatory(isMandatory: boolean) { + this.#data.update({ isMandatory }); + } + + setDefault(isDefault: boolean) { + this.#data.update({ isDefault }); + } + + setFallbackCulture(unique: string) { + this.#data.update({ fallbackIsoCode: unique }); + } + + // TODO: this is a temp solution to bubble validation errors to the UI + setValidationErrors(errorMap: any) { + // TODO: I can't use the update method to set the value to undefined + this.#validationErrors.setValue(errorMap); + } + + async save() { + const data = this.getData(); + if (!data) return; + + if (this.getIsNew()) { + const { error } = await this.repository.create(data); + // TODO: this is temp solution to bubble validation errors to the UI + if (error) { + if (error instanceof ApiError && error.body.type === 'validation') { + this.setValidationErrors?.(error.body.errors); + } + } else { + this.setValidationErrors?.(undefined); + // TODO: do not make it the buttons responsibility to set the workspace to not new. + this.setIsNew(false); + } + } else { + await this.repository.save(data); + // TODO: Show validation errors as warnings? + } + } + + destroy(): void { + this.#data.destroy(); + super.destroy(); + } +} + +export const UMB_LANGUAGE_WORKSPACE_CONTEXT = new UmbContextToken< + UmbSaveableWorkspaceContextInterface, + UmbLanguageWorkspaceContext +>( + 'UmbWorkspaceContext', + undefined, + (context): context is UmbLanguageWorkspaceContext => context.getEntityType?.() === 'language', +); diff --git a/src/packages/webhooks/workspace/language/language-workspace.element.ts b/src/packages/webhooks/workspace/language/language-workspace.element.ts new file mode 100644 index 0000000000..604b0cec11 --- /dev/null +++ b/src/packages/webhooks/workspace/language/language-workspace.element.ts @@ -0,0 +1,49 @@ +import { UmbLanguageWorkspaceContext } from './language-workspace.context.js'; +import { UmbLanguageWorkspaceEditorElement } from './language-workspace-editor.element.js'; +import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import type { UmbRoute } from '@umbraco-cms/backoffice/router'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; +import { UmbWorkspaceIsNewRedirectController } from '@umbraco-cms/backoffice/workspace'; + +@customElement('umb-language-workspace') +export class UmbLanguageWorkspaceElement extends UmbLitElement { + #languageWorkspaceContext = new UmbLanguageWorkspaceContext(this); + #createElement = () => new UmbLanguageWorkspaceEditorElement(); + + @state() + _routes: UmbRoute[] = [ + { + path: 'edit/:unique', + component: this.#createElement, + setup: (_component, info) => { + this.removeControllerByAlias('_observeIsNew'); + this.#languageWorkspaceContext.load(info.match.params.unique); + }, + }, + { + path: 'create', + component: this.#createElement, + setup: async () => { + this.#languageWorkspaceContext.create(); + + new UmbWorkspaceIsNewRedirectController( + this, + this.#languageWorkspaceContext, + this.shadowRoot!.querySelector('umb-router-slot')!, + ); + }, + }, + ]; + + render() { + return html``; + } +} + +export default UmbLanguageWorkspaceElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-workspace': UmbLanguageWorkspaceElement; + } +} diff --git a/src/packages/webhooks/workspace/language/manifests.ts b/src/packages/webhooks/workspace/language/manifests.ts new file mode 100644 index 0000000000..7f19a16a3c --- /dev/null +++ b/src/packages/webhooks/workspace/language/manifests.ts @@ -0,0 +1,59 @@ +import { UmbSaveWorkspaceAction } from '@umbraco-cms/backoffice/workspace'; +import type { + ManifestWorkspace, + ManifestWorkspaceAction, + ManifestWorkspaceView, +} from '@umbraco-cms/backoffice/extension-registry'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: 'Umb.Workspace.Language', + name: 'Language Workspace', + js: () => import('./language-workspace.element.js'), + meta: { + entityType: 'language', + }, +}; + +const workspaceViews: Array = [ + { + type: 'workspaceView', + alias: 'Umb.WorkspaceView.Language.Details', + name: 'Language Workspace Details View', + js: () => import('./views/language-details-workspace-view.element.js'), + weight: 90, + meta: { + label: 'Details', + pathname: 'details', + icon: 'edit', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, +]; + +const workspaceActions: Array = [ + { + type: 'workspaceAction', + alias: 'Umb.WorkspaceAction.Language.Save', + name: 'Save Language Workspace Action', + api: UmbSaveWorkspaceAction, + meta: { + look: 'primary', + color: 'positive', + label: 'Save', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, +]; + +export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; diff --git a/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts b/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts new file mode 100644 index 0000000000..783d708d03 --- /dev/null +++ b/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts @@ -0,0 +1,222 @@ +import { UMB_LANGUAGE_WORKSPACE_CONTEXT } from '../language-workspace.context.js'; +import type { UmbInputLanguageElement } from '../../../components/input-language/input-language.element.js'; +import type { UmbLanguageDetailModel } from '../../../types.js'; +import type { UmbLanguageItemModel } from '../../../repository/index.js'; +import type { UmbInputCultureSelectElement } from '@umbraco-cms/backoffice/culture'; +import type { UUIToggleElement } from '@umbraco-cms/backoffice/external/uui'; +import { UUIBooleanInputEvent } from '@umbraco-cms/backoffice/external/uui'; +import { css, html, nothing, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; +import { UmbChangeEvent } from '@umbraco-cms/backoffice/event'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; +import type { UmbWorkspaceViewElement } from '@umbraco-cms/backoffice/extension-registry'; +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; + +@customElement('umb-language-details-workspace-view') +export class UmbLanguageDetailsWorkspaceViewElement extends UmbLitElement implements UmbWorkspaceViewElement { + @state() + _language?: UmbLanguageDetailModel; + + @state() + _isDefaultLanguage = false; + + @state() + _isNew?: boolean; + + @state() + _validationErrors?: { [key: string]: Array }; + + #languageWorkspaceContext?: typeof UMB_LANGUAGE_WORKSPACE_CONTEXT.TYPE; + + constructor() { + super(); + + /* TODO: we will need some system to notify about an action has been executed. + In the language workspace we want to clear a default language change warning and reset the initial state after a save action has been executed. */ + let initialStateSet = false; + + this.consumeContext(UMB_LANGUAGE_WORKSPACE_CONTEXT, (instance) => { + this.#languageWorkspaceContext = instance; + + this.observe(this.#languageWorkspaceContext.data, (language) => { + this._language = language; + + /* Store the initial value of the default language. + When we change the default language we get notified of the change, + and we need the initial value to compare against */ + if (initialStateSet === false) { + this._isDefaultLanguage = language?.isDefault ?? false; + initialStateSet = true; + } + }); + + this.observe(this.#languageWorkspaceContext.isNew, (isNew) => { + this._isNew = isNew; + }); + + this.observe(this.#languageWorkspaceContext.validationErrors, (value) => { + this._validationErrors = value; + this.requestUpdate('_validationErrors'); + }); + }); + } + + #handleCultureChange(event: Event) { + if (event instanceof UmbChangeEvent) { + const target = event.target as UmbInputCultureSelectElement; + const unique = target.value.toString(); + const cultureName = target.selectedCultureName; + + // If there is no cultureName, it was probably an unknown event that triggered the change event, so ignore it. + if (!cultureName) { + return; + } + + if (!unique) { + // If the unique is empty, we reset the value to the original value. + // Provides a way better UX + //TODO: Maybe the combobox should implement something similar? + const resetFunction = () => (target.value = this._language?.unique as string); + + target.addEventListener('close', resetFunction, { once: true }); + target.addEventListener('blur', resetFunction, { once: true }); + return; + } + + this.#languageWorkspaceContext?.setCulture(unique); + + // to improve UX, we set the name to the culture name if it's a new language + if (this._isNew && cultureName) { + this.#languageWorkspaceContext?.setName(cultureName); + } + } + } + + #handleDefaultChange(event: UUIBooleanInputEvent) { + if (event instanceof UUIBooleanInputEvent) { + const target = event.composedPath()[0] as UUIToggleElement; + this.#languageWorkspaceContext?.setDefault(target.checked); + } + } + + #handleMandatoryChange(event: UUIBooleanInputEvent) { + if (event instanceof UUIBooleanInputEvent) { + const target = event.composedPath()[0] as UUIToggleElement; + this.#languageWorkspaceContext?.setMandatory(target.checked); + } + } + + #handleFallbackChange(event: UmbChangeEvent) { + if (event instanceof UmbChangeEvent) { + const target = event.target as UmbInputLanguageElement; + const selectedLanguageUnique = target.selectedUniques?.[0]; + this.#languageWorkspaceContext?.setFallbackCulture(selectedLanguageUnique); + } + } + + render() { + return html` + + +
+ + + + + ${this._validationErrors?.isoCode.map((error) => html`
${error}
`)} +
+
+ + +
${this._language?.unique}
+
+ + +
+ +
+ Default language +
An Umbraco site can only have one default language set.
+
+
+ + ${this._language?.isDefault && this._language?.isDefault !== this._isDefaultLanguage + ? html`
+ Switching default language may result in default content missing. +
` + : nothing} + +
+ +
+ Mandatory language +
Properties on this language have to be filled out before the node can be published.
+
+
+
+
+ + + + language.unique !== this._language?.unique}> + +
+ `; + } + + static styles = [ + UmbTextStyles, + css` + :host { + display: block; + padding: var(--uui-size-space-6); + } + + uui-combobox { + width: 100%; + } + + hr { + border: none; + border-bottom: 1px solid var(--uui-color-divider); + } + + #default-language-warning { + background-color: var(--uui-color-warning); + color: var(--uui-color-warning-contrast); + padding: var(--uui-size-space-4) var(--uui-size-space-5); + border: 1px solid var(--uui-color-warning-standalone); + margin-top: var(--uui-size-space-4); + border-radius: var(--uui-border-radius); + } + + .validation-message { + color: var(--uui-color-danger); + } + `, + ]; +} + +export default UmbLanguageDetailsWorkspaceViewElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-language-details-workspace-view': UmbLanguageDetailsWorkspaceViewElement; + } +} diff --git a/src/packages/webhooks/workspace/overview/manifests.ts b/src/packages/webhooks/workspace/overview/manifests.ts new file mode 100644 index 0000000000..918e31433c --- /dev/null +++ b/src/packages/webhooks/workspace/overview/manifests.ts @@ -0,0 +1,13 @@ +import type { ManifestWorkspace } from '@umbraco-cms/backoffice/extension-registry'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: 'Umb.Workspace.WebhookRoot', + name: 'Webhook Root Workspace', + js: () => import('./webhook-root-workspace.element.js'), + meta: { + entityType: 'webhook-root', + }, +}; + +export const manifests = [workspace]; diff --git a/src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts new file mode 100644 index 0000000000..0ca586fa94 --- /dev/null +++ b/src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts @@ -0,0 +1,20 @@ +import { UMB_WEBHOOK_COLLECTION_ALIAS } from '../../collection/index.js'; +import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-webook-root-workspace') +export class UmbWebhookRootWorkspaceElement extends UmbLitElement { + render() { + return html` + ; + `; + } +} + +export default UmbWebhookRootWorkspaceElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhook-root-workspace': UmbWebhookRootWorkspaceElement; + } +} diff --git a/src/packages/webhooks/workspace/views/overview/index.ts b/src/packages/webhooks/workspace/views/overview/index.ts deleted file mode 100644 index d57d3d5b14..0000000000 --- a/src/packages/webhooks/workspace/views/overview/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -//import './components/index.js'; -import { UmbWebhooksOverviewViewElement } from './webhooks-view.element.js'; - -export default UmbWebhooksOverviewViewElement; diff --git a/src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts b/src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts deleted file mode 100644 index 222ff3f91a..0000000000 --- a/src/packages/webhooks/workspace/views/overview/webhooks-view.element.ts +++ /dev/null @@ -1,132 +0,0 @@ -import { UmbWebhookRepository } from '../../../repository/webhooks.repository.js'; -import { UmbWebhooksWorkspaceContext, UMB_APP_WEBHOOKS_CONTEXT_TOKEN } from '../../webhooks.context.js'; -import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; -import { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; -import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; -import { LanguageResponseModel } from '@umbraco-cms/backoffice/backend-api'; - -@customElement('umb-webhooks-overview-view') -export class UmbWebhooksOverviewViewElement extends UmbLitElement { - @state() - private _tableConfig: UmbTableConfig = { - allowSelection: false, - }; - - @state() - private _tableColumns: Array = [ - { - name: 'Enabled', - alias: 'enabled', - elementName: 'umb-language-root-table-name-column-layout', - }, - { - name: 'Events', - alias: 'events', - }, - { - name: 'Url', - alias: 'url', - }, - { - name: 'Types', - alias: 'types', - }, - { - name: '', - alias: 'delete', - elementName: 'umb-language-root-table-delete-column-layout', - }, - ]; - - @state()s - private _tableItems: Array = []; - - #webhookRepository = new UmbWebhookRepository(this); - - #webhooksContext?: UmbWebhooksWorkspaceContext; - constructor() { - super(); - - this.consumeContext(UMB_APP_WEBHOOKS_CONTEXT_TOKEN, (instance) => { - this.#webhooksContext = instance; - }); - } - - connectedCallback() { - super.connectedCallback(); - this.#observeWebhook(); - } - - async #observeWebhook() { - const { asObservable } = await this.#webhookRepository.requestWebhooks(); - - if (asObservable) { - this.observe(asObservable(), (webhook) => this.#createTableItems(webhooks)); - } - } - - #createTableItems(webhooks: Array) { - this._tableItems = webhooks.map((webhook) => { - return { - id: webhook.id ?? '', - icon: 'umb:anchor', - data: [ - { - columnAlias: 'enabled', - value: webhook.enabled, - }, - { - columnAlias: 'events', - value: webhook.events, - }, - { - columnAlias: 'url', - value: webhook.url, - }, - { - columnAlias: 'types', - value: webhook.types, - }, - { - columnAlias: 'delete', - value: webhook, - }, - ], - }; - }); - } - - render() { - return html` - - - - - - - - - - `; - } - - static styles = [ - css` - :host { - display: block; - margin: var(--uui-size-layout-1); - } - `, - ]; -} - -declare global { - interface HTMLElementTagNameMap { - 'umb-webhooks-overview-view': UmbWebhooksOverviewViewElement; - } -} diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts index eb85847067..77615bb230 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -1,7 +1,9 @@ import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; -import { UmbBaseController, UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import { UMB_WORKSPACE_CONTEXT, UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; +import type { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; +import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'; // TODO: Revisit usage of workspace for this case... export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { @@ -26,7 +28,7 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um super(host); this.provideContext(UMB_WORKSPACE_CONTEXT, this); // TODO: Revisit usage of workspace for this case... currently no other workspace context provides them self with their own token. - this.provideContext(UMB_APP_WEBHOOKS_CONTEXT_TOKEN, this); + this.provideContext(UMB_APP_WEBHOOKS_CONTEXT, this); this.#repository = new UmbWebhookRepository(host); } @@ -35,6 +37,6 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um }; } -export const UMB_APP_WEBHOOKS_CONTEXT_TOKEN = new UmbContextToken( +export const UMB_APP_WEBHOOKS_CONTEXT = new UmbContextToken( UmbWebhooksWorkspaceContext.name, ); diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts index c17f8483da..bd7b2c038d 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -1,7 +1,7 @@ import type { ManifestWorkspace, ManifestWorkspaceAction, - ManifestWorkspaceEditorView, + ManifestWorkspaceView, } from '@umbraco-cms/backoffice/extension-registry'; const workspaceAlias = 'Umb.Workspace.Webhooks'; @@ -10,23 +10,23 @@ const workspace: ManifestWorkspace = { type: 'workspace', alias: workspaceAlias, name: 'Webhooks Root Workspace', - loader: () => import('./webhooks-workspace.element.js'), + js: () => import('./webhooks-workspace.element.js'), meta: { entityType: 'webhooks', }, }; -const workspaceViews: Array = [ +const workspaceViews: Array = [ { - type: 'workspaceEditorView', - alias: 'Umb.WorkspaceView.Webhooks.Overview', + type: 'workspaceView', + alias: 'Umb.WorkspaceView.Webhook.Overview', name: 'Webhooks Root Workspace Overview View', - loader: () => import('../views/overview/index.js'), + js: () => import('../views/webhook-details-workspace-view.js'), weight: 300, meta: { label: 'Webhooks', pathname: 'webhooks', - icon: 'umb:anchor', + icon: 'anchor', }, conditions: [ { @@ -36,15 +36,15 @@ const workspaceViews: Array = [ ], }, { - type: 'workspaceEditorView', - alias: 'Umb.WorkspaceView.Webhooks.Logs', + type: 'workspaceView', + alias: 'Umb.WorkspaceView.Webhook.Logs', name: 'Webhooks Root Workspace Logs View', - loader: () => import('../views/logs/index.js'), + js: () => import('../views/logs/index.js'), weight: 200, meta: { label: 'Logs', pathname: 'logs', - icon: 'umb:box-alt', + icon: 'box-alt', }, conditions: [ { From 43f0219577a8a5972b03bdafe0e8114a2a059efb Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 23:09:26 +0100 Subject: [PATCH 20/44] Update manifests --- src/packages/webhooks/collection/manifests.ts | 2 +- .../webhook-collection.server.data-source.ts | 11 +- src/packages/webhooks/collection/types.ts | 2 +- src/packages/webhooks/manifests.ts | 13 +- src/packages/webhooks/menu-item/manifests.ts | 4 +- src/packages/webhooks/repository/manifests.ts | 4 + .../language-workspace-editor.element.ts | 103 -------- .../language/language-workspace.context.ts | 119 ---------- .../language/language-workspace.element.ts | 49 ---- .../webhooks/workspace/language/manifests.ts | 59 ----- ...language-details-workspace-view.element.ts | 222 ------------------ src/packages/webhooks/workspace/manifests.ts | 4 +- .../webhooks/workspace/webhooks.context.ts | 4 - .../webhooks/workspace/webhooks/manifests.ts | 60 ----- .../webhooks/webhooks-workspace.element.ts | 63 ----- 15 files changed, 28 insertions(+), 691 deletions(-) create mode 100644 src/packages/webhooks/repository/manifests.ts delete mode 100644 src/packages/webhooks/workspace/language/language-workspace-editor.element.ts delete mode 100644 src/packages/webhooks/workspace/language/language-workspace.context.ts delete mode 100644 src/packages/webhooks/workspace/language/language-workspace.element.ts delete mode 100644 src/packages/webhooks/workspace/language/manifests.ts delete mode 100644 src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts delete mode 100644 src/packages/webhooks/workspace/webhooks/manifests.ts delete mode 100644 src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts diff --git a/src/packages/webhooks/collection/manifests.ts b/src/packages/webhooks/collection/manifests.ts index f76cadfc0e..5d01250700 100644 --- a/src/packages/webhooks/collection/manifests.ts +++ b/src/packages/webhooks/collection/manifests.ts @@ -18,7 +18,7 @@ const collectionManifest: ManifestCollection = { export const manifests = [ collectionManifest, - ...collectionRepositoryManifests, + //...collectionRepositoryManifests, ...collectionViewManifests, ...collectionActionManifests, ]; diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts index bfe7632038..4576a8bb0b 100644 --- a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts +++ b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts @@ -36,12 +36,13 @@ export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSo if (data) { const items = data.items.map((item) => { const model: UmbWebhookDetailModel = { - unique: item.isoCode.toLowerCase(), - name: item.name, + unique: '', //item.id.toLowerCase(), + //name: item.name, entityType: UMB_WEBHOOK_ENTITY_TYPE, - isDefault: item.isDefault, - isMandatory: item.isMandatory, - fallbackIsoCode: item.fallbackIsoCode?.toLowerCase() || null, + url: item.url, + enabled: item.enabled, + events: item.events.split(','), + types: item.types.split(','), }; return model; diff --git a/src/packages/webhooks/collection/types.ts b/src/packages/webhooks/collection/types.ts index 7558eec496..fc7ef64ca7 100644 --- a/src/packages/webhooks/collection/types.ts +++ b/src/packages/webhooks/collection/types.ts @@ -1,4 +1,4 @@ -export interface UmbLanguageCollectionFilterModel { +export interface UmbWebhookCollectionFilterModel { skip?: number; take?: number; } diff --git a/src/packages/webhooks/manifests.ts b/src/packages/webhooks/manifests.ts index 05be6d3978..ccfa411c5d 100644 --- a/src/packages/webhooks/manifests.ts +++ b/src/packages/webhooks/manifests.ts @@ -1,4 +1,15 @@ +import { manifests as repositoryManifests } from './repository/manifests.js'; import { manifests as treeManifests } from './menu-item/manifests.js'; +//import { manifests as entityActions } from './entity-actions/manifests.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; +import { manifests as collectionManifests } from './collection/manifests.js'; +import { manifests as globalContextManifests } from './global-contexts/manifests.js'; -export const manifests = [...treeManifests, ...workspaceManifests]; +export const manifests = [ + ...repositoryManifests, + //...entityActions, + ...treeManifests, + ...workspaceManifests, + ...collectionManifests, + ...globalContextManifests, +]; diff --git a/src/packages/webhooks/menu-item/manifests.ts b/src/packages/webhooks/menu-item/manifests.ts index d464a03cf3..afdfe8dd8d 100644 --- a/src/packages/webhooks/menu-item/manifests.ts +++ b/src/packages/webhooks/menu-item/manifests.ts @@ -7,8 +7,8 @@ const menuItem: ManifestMenuItem = { weight: 100, meta: { label: 'Webhooks', - icon: 'umb:anchor', - entityType: 'webhooks', + icon: 'webhook', + entityType: 'webhook-root', menus: ['Umb.Menu.Settings'], }, }; diff --git a/src/packages/webhooks/repository/manifests.ts b/src/packages/webhooks/repository/manifests.ts new file mode 100644 index 0000000000..ea49feb4a4 --- /dev/null +++ b/src/packages/webhooks/repository/manifests.ts @@ -0,0 +1,4 @@ +//import { manifests as detailManifests } from './detail/manifests.js'; +//import { manifests as itemManifests } from './item/manifests.js'; + +export const manifests = []; //[...detailManifests, ...itemManifests]; diff --git a/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts b/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts deleted file mode 100644 index 122fca7de5..0000000000 --- a/src/packages/webhooks/workspace/language/language-workspace-editor.element.ts +++ /dev/null @@ -1,103 +0,0 @@ -import type { UmbLanguageDetailModel } from '../../types.js'; -import { UMB_LANGUAGE_WORKSPACE_CONTEXT } from './language-workspace.context.js'; -import type { UUIInputElement } from '@umbraco-cms/backoffice/external/uui'; -import { UUIInputEvent } from '@umbraco-cms/backoffice/external/uui'; -import { css, html, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; -@customElement('umb-language-workspace-editor') -export class UmbLanguageWorkspaceEditorElement extends UmbLitElement { - #workspaceContext?: typeof UMB_LANGUAGE_WORKSPACE_CONTEXT.TYPE; - - @state() - _language?: UmbLanguageDetailModel; - - @state() - _isNew?: boolean; - - constructor() { - super(); - - this.consumeContext(UMB_LANGUAGE_WORKSPACE_CONTEXT, (context) => { - this.#workspaceContext = context; - this.#observeData(); - }); - } - - #observeData() { - if (!this.#workspaceContext) return; - this.observe(this.#workspaceContext.data, (data) => { - this._language = data; - }); - this.observe(this.#workspaceContext.isNew, (isNew) => { - this._isNew = isNew; - }); - } - - #handleInput(event: UUIInputEvent) { - if (event instanceof UUIInputEvent) { - const target = event.composedPath()[0] as UUIInputElement; - - if (typeof target?.value === 'string') { - this.#workspaceContext?.setName(target.value); - } - } - } - - render() { - return html` - - - `; - } - - static styles = [ - UmbTextStyles, - css` - #header { - display: flex; - padding: 0 var(--uui-size-space-6); - gap: var(--uui-size-space-4); - width: 100%; - } - - uui-input { - width: 100%; - } - - strong { - display: flex; - align-items: center; - } - - #footer-into { - padding: 0 var(--uui-size-layout-1); - } - - uui-input:not(:focus) { - border: 1px solid transparent; - } - `, - ]; -} - -export default UmbLanguageWorkspaceEditorElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-language-workspace-editor': UmbLanguageWorkspaceEditorElement; - } -} diff --git a/src/packages/webhooks/workspace/language/language-workspace.context.ts b/src/packages/webhooks/workspace/language/language-workspace.context.ts deleted file mode 100644 index 47793e2860..0000000000 --- a/src/packages/webhooks/workspace/language/language-workspace.context.ts +++ /dev/null @@ -1,119 +0,0 @@ -import { UmbLanguageDetailRepository } from '../../repository/index.js'; -import type { UmbLanguageDetailModel } from '../../types.js'; -import { - type UmbSaveableWorkspaceContextInterface, - UmbEditableWorkspaceContextBase, -} from '@umbraco-cms/backoffice/workspace'; -import { ApiError } from '@umbraco-cms/backoffice/external/backend-api'; -import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; -import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; - -export class UmbLanguageWorkspaceContext - extends UmbEditableWorkspaceContextBase - implements UmbSaveableWorkspaceContextInterface -{ - public readonly repository: UmbLanguageDetailRepository = new UmbLanguageDetailRepository(this); - - #data = new UmbObjectState(undefined); - readonly data = this.#data.asObservable(); - - // TODO: this is a temp solution to bubble validation errors to the UI - #validationErrors = new UmbObjectState(undefined); - readonly validationErrors = this.#validationErrors.asObservable(); - - constructor(host: UmbControllerHostElement) { - super(host, 'Umb.Workspace.Language'); - } - - async load(unique: string) { - const { data } = await this.repository.requestByUnique(unique); - if (data) { - this.setIsNew(false); - this.#data.update(data); - } - } - - async create() { - const { data } = await this.repository.createScaffold(null); - if (!data) return; - this.setIsNew(true); - this.#data.update(data); - return { data }; - } - - getData() { - return this.#data.getValue(); - } - - getEntityType() { - return 'language'; - } - - // TODO: Convert to uniques: - getEntityId() { - return this.#data.getValue()?.unique; - } - - setName(name: string) { - this.#data.update({ name }); - } - - setCulture(unique: string) { - this.#data.update({ unique }); - } - - setMandatory(isMandatory: boolean) { - this.#data.update({ isMandatory }); - } - - setDefault(isDefault: boolean) { - this.#data.update({ isDefault }); - } - - setFallbackCulture(unique: string) { - this.#data.update({ fallbackIsoCode: unique }); - } - - // TODO: this is a temp solution to bubble validation errors to the UI - setValidationErrors(errorMap: any) { - // TODO: I can't use the update method to set the value to undefined - this.#validationErrors.setValue(errorMap); - } - - async save() { - const data = this.getData(); - if (!data) return; - - if (this.getIsNew()) { - const { error } = await this.repository.create(data); - // TODO: this is temp solution to bubble validation errors to the UI - if (error) { - if (error instanceof ApiError && error.body.type === 'validation') { - this.setValidationErrors?.(error.body.errors); - } - } else { - this.setValidationErrors?.(undefined); - // TODO: do not make it the buttons responsibility to set the workspace to not new. - this.setIsNew(false); - } - } else { - await this.repository.save(data); - // TODO: Show validation errors as warnings? - } - } - - destroy(): void { - this.#data.destroy(); - super.destroy(); - } -} - -export const UMB_LANGUAGE_WORKSPACE_CONTEXT = new UmbContextToken< - UmbSaveableWorkspaceContextInterface, - UmbLanguageWorkspaceContext ->( - 'UmbWorkspaceContext', - undefined, - (context): context is UmbLanguageWorkspaceContext => context.getEntityType?.() === 'language', -); diff --git a/src/packages/webhooks/workspace/language/language-workspace.element.ts b/src/packages/webhooks/workspace/language/language-workspace.element.ts deleted file mode 100644 index 604b0cec11..0000000000 --- a/src/packages/webhooks/workspace/language/language-workspace.element.ts +++ /dev/null @@ -1,49 +0,0 @@ -import { UmbLanguageWorkspaceContext } from './language-workspace.context.js'; -import { UmbLanguageWorkspaceEditorElement } from './language-workspace-editor.element.js'; -import { html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; -import type { UmbRoute } from '@umbraco-cms/backoffice/router'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -import { UmbWorkspaceIsNewRedirectController } from '@umbraco-cms/backoffice/workspace'; - -@customElement('umb-language-workspace') -export class UmbLanguageWorkspaceElement extends UmbLitElement { - #languageWorkspaceContext = new UmbLanguageWorkspaceContext(this); - #createElement = () => new UmbLanguageWorkspaceEditorElement(); - - @state() - _routes: UmbRoute[] = [ - { - path: 'edit/:unique', - component: this.#createElement, - setup: (_component, info) => { - this.removeControllerByAlias('_observeIsNew'); - this.#languageWorkspaceContext.load(info.match.params.unique); - }, - }, - { - path: 'create', - component: this.#createElement, - setup: async () => { - this.#languageWorkspaceContext.create(); - - new UmbWorkspaceIsNewRedirectController( - this, - this.#languageWorkspaceContext, - this.shadowRoot!.querySelector('umb-router-slot')!, - ); - }, - }, - ]; - - render() { - return html``; - } -} - -export default UmbLanguageWorkspaceElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-language-workspace': UmbLanguageWorkspaceElement; - } -} diff --git a/src/packages/webhooks/workspace/language/manifests.ts b/src/packages/webhooks/workspace/language/manifests.ts deleted file mode 100644 index 7f19a16a3c..0000000000 --- a/src/packages/webhooks/workspace/language/manifests.ts +++ /dev/null @@ -1,59 +0,0 @@ -import { UmbSaveWorkspaceAction } from '@umbraco-cms/backoffice/workspace'; -import type { - ManifestWorkspace, - ManifestWorkspaceAction, - ManifestWorkspaceView, -} from '@umbraco-cms/backoffice/extension-registry'; - -const workspace: ManifestWorkspace = { - type: 'workspace', - alias: 'Umb.Workspace.Language', - name: 'Language Workspace', - js: () => import('./language-workspace.element.js'), - meta: { - entityType: 'language', - }, -}; - -const workspaceViews: Array = [ - { - type: 'workspaceView', - alias: 'Umb.WorkspaceView.Language.Details', - name: 'Language Workspace Details View', - js: () => import('./views/language-details-workspace-view.element.js'), - weight: 90, - meta: { - label: 'Details', - pathname: 'details', - icon: 'edit', - }, - conditions: [ - { - alias: 'Umb.Condition.WorkspaceAlias', - match: workspace.alias, - }, - ], - }, -]; - -const workspaceActions: Array = [ - { - type: 'workspaceAction', - alias: 'Umb.WorkspaceAction.Language.Save', - name: 'Save Language Workspace Action', - api: UmbSaveWorkspaceAction, - meta: { - look: 'primary', - color: 'positive', - label: 'Save', - }, - conditions: [ - { - alias: 'Umb.Condition.WorkspaceAlias', - match: workspace.alias, - }, - ], - }, -]; - -export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; diff --git a/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts b/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts deleted file mode 100644 index 783d708d03..0000000000 --- a/src/packages/webhooks/workspace/language/views/language-details-workspace-view.element.ts +++ /dev/null @@ -1,222 +0,0 @@ -import { UMB_LANGUAGE_WORKSPACE_CONTEXT } from '../language-workspace.context.js'; -import type { UmbInputLanguageElement } from '../../../components/input-language/input-language.element.js'; -import type { UmbLanguageDetailModel } from '../../../types.js'; -import type { UmbLanguageItemModel } from '../../../repository/index.js'; -import type { UmbInputCultureSelectElement } from '@umbraco-cms/backoffice/culture'; -import type { UUIToggleElement } from '@umbraco-cms/backoffice/external/uui'; -import { UUIBooleanInputEvent } from '@umbraco-cms/backoffice/external/uui'; -import { css, html, nothing, customElement, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; -import { UmbChangeEvent } from '@umbraco-cms/backoffice/event'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -import type { UmbWorkspaceViewElement } from '@umbraco-cms/backoffice/extension-registry'; -import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; - -@customElement('umb-language-details-workspace-view') -export class UmbLanguageDetailsWorkspaceViewElement extends UmbLitElement implements UmbWorkspaceViewElement { - @state() - _language?: UmbLanguageDetailModel; - - @state() - _isDefaultLanguage = false; - - @state() - _isNew?: boolean; - - @state() - _validationErrors?: { [key: string]: Array }; - - #languageWorkspaceContext?: typeof UMB_LANGUAGE_WORKSPACE_CONTEXT.TYPE; - - constructor() { - super(); - - /* TODO: we will need some system to notify about an action has been executed. - In the language workspace we want to clear a default language change warning and reset the initial state after a save action has been executed. */ - let initialStateSet = false; - - this.consumeContext(UMB_LANGUAGE_WORKSPACE_CONTEXT, (instance) => { - this.#languageWorkspaceContext = instance; - - this.observe(this.#languageWorkspaceContext.data, (language) => { - this._language = language; - - /* Store the initial value of the default language. - When we change the default language we get notified of the change, - and we need the initial value to compare against */ - if (initialStateSet === false) { - this._isDefaultLanguage = language?.isDefault ?? false; - initialStateSet = true; - } - }); - - this.observe(this.#languageWorkspaceContext.isNew, (isNew) => { - this._isNew = isNew; - }); - - this.observe(this.#languageWorkspaceContext.validationErrors, (value) => { - this._validationErrors = value; - this.requestUpdate('_validationErrors'); - }); - }); - } - - #handleCultureChange(event: Event) { - if (event instanceof UmbChangeEvent) { - const target = event.target as UmbInputCultureSelectElement; - const unique = target.value.toString(); - const cultureName = target.selectedCultureName; - - // If there is no cultureName, it was probably an unknown event that triggered the change event, so ignore it. - if (!cultureName) { - return; - } - - if (!unique) { - // If the unique is empty, we reset the value to the original value. - // Provides a way better UX - //TODO: Maybe the combobox should implement something similar? - const resetFunction = () => (target.value = this._language?.unique as string); - - target.addEventListener('close', resetFunction, { once: true }); - target.addEventListener('blur', resetFunction, { once: true }); - return; - } - - this.#languageWorkspaceContext?.setCulture(unique); - - // to improve UX, we set the name to the culture name if it's a new language - if (this._isNew && cultureName) { - this.#languageWorkspaceContext?.setName(cultureName); - } - } - } - - #handleDefaultChange(event: UUIBooleanInputEvent) { - if (event instanceof UUIBooleanInputEvent) { - const target = event.composedPath()[0] as UUIToggleElement; - this.#languageWorkspaceContext?.setDefault(target.checked); - } - } - - #handleMandatoryChange(event: UUIBooleanInputEvent) { - if (event instanceof UUIBooleanInputEvent) { - const target = event.composedPath()[0] as UUIToggleElement; - this.#languageWorkspaceContext?.setMandatory(target.checked); - } - } - - #handleFallbackChange(event: UmbChangeEvent) { - if (event instanceof UmbChangeEvent) { - const target = event.target as UmbInputLanguageElement; - const selectedLanguageUnique = target.selectedUniques?.[0]; - this.#languageWorkspaceContext?.setFallbackCulture(selectedLanguageUnique); - } - } - - render() { - return html` - - -
- - - - - ${this._validationErrors?.isoCode.map((error) => html`
${error}
`)} -
-
- - -
${this._language?.unique}
-
- - -
- -
- Default language -
An Umbraco site can only have one default language set.
-
-
- - ${this._language?.isDefault && this._language?.isDefault !== this._isDefaultLanguage - ? html`
- Switching default language may result in default content missing. -
` - : nothing} - -
- -
- Mandatory language -
Properties on this language have to be filled out before the node can be published.
-
-
-
-
- - - - language.unique !== this._language?.unique}> - -
- `; - } - - static styles = [ - UmbTextStyles, - css` - :host { - display: block; - padding: var(--uui-size-space-6); - } - - uui-combobox { - width: 100%; - } - - hr { - border: none; - border-bottom: 1px solid var(--uui-color-divider); - } - - #default-language-warning { - background-color: var(--uui-color-warning); - color: var(--uui-color-warning-contrast); - padding: var(--uui-size-space-4) var(--uui-size-space-5); - border: 1px solid var(--uui-color-warning-standalone); - margin-top: var(--uui-size-space-4); - border-radius: var(--uui-border-radius); - } - - .validation-message { - color: var(--uui-color-danger); - } - `, - ]; -} - -export default UmbLanguageDetailsWorkspaceViewElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-language-details-workspace-view': UmbLanguageDetailsWorkspaceViewElement; - } -} diff --git a/src/packages/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts index b627b8cbd1..0c31d66295 100644 --- a/src/packages/webhooks/workspace/manifests.ts +++ b/src/packages/webhooks/workspace/manifests.ts @@ -1,3 +1,3 @@ -import { manifests as webhooksRootManifests } from './webhooks/manifests.js'; +import { manifests as webhookRootManifests } from './overview/manifests.js'; -export const manifests = [...webhooksRootManifests]; +export const manifests = [...webhookRootManifests]; diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts index 77615bb230..98b77c4c6d 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -31,10 +31,6 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um this.provideContext(UMB_APP_WEBHOOKS_CONTEXT, this); this.#repository = new UmbWebhookRepository(host); } - - onChangeState = () => { - - }; } export const UMB_APP_WEBHOOKS_CONTEXT = new UmbContextToken( diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts deleted file mode 100644 index bd7b2c038d..0000000000 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ /dev/null @@ -1,60 +0,0 @@ -import type { - ManifestWorkspace, - ManifestWorkspaceAction, - ManifestWorkspaceView, -} from '@umbraco-cms/backoffice/extension-registry'; - -const workspaceAlias = 'Umb.Workspace.Webhooks'; - -const workspace: ManifestWorkspace = { - type: 'workspace', - alias: workspaceAlias, - name: 'Webhooks Root Workspace', - js: () => import('./webhooks-workspace.element.js'), - meta: { - entityType: 'webhooks', - }, -}; - -const workspaceViews: Array = [ - { - type: 'workspaceView', - alias: 'Umb.WorkspaceView.Webhook.Overview', - name: 'Webhooks Root Workspace Overview View', - js: () => import('../views/webhook-details-workspace-view.js'), - weight: 300, - meta: { - label: 'Webhooks', - pathname: 'webhooks', - icon: 'anchor', - }, - conditions: [ - { - alias: 'Umb.Condition.WorkspaceAlias', - match: workspace.alias, - }, - ], - }, - { - type: 'workspaceView', - alias: 'Umb.WorkspaceView.Webhook.Logs', - name: 'Webhooks Root Workspace Logs View', - js: () => import('../views/logs/index.js'), - weight: 200, - meta: { - label: 'Logs', - pathname: 'logs', - icon: 'box-alt', - }, - conditions: [ - { - alias: 'Umb.Condition.WorkspaceAlias', - match: workspace.alias, - }, - ], - }, -]; - -const workspaceActions: Array = []; - -export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; diff --git a/src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts b/src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts deleted file mode 100644 index 7b89a65493..0000000000 --- a/src/packages/webhooks/workspace/webhooks/webhooks-workspace.element.ts +++ /dev/null @@ -1,63 +0,0 @@ -//import '../../components/index.js'; -import { UmbWebhooksWorkspaceContext } from '../webhooks.context.js'; -import { PropertyValueMap, css, html, customElement } from '@umbraco-cms/backoffice/external/lit'; -import { UmbTextStyles } from "@umbraco-cms/backoffice/style"; -import { UmbLitElement } from '@umbraco-cms/internal/lit-element'; - -@customElement('umb-webhooks-workspace') -export class UmbWebhooksWorkspaceElement extends UmbLitElement { - #webhooksContext = new UmbWebhooksWorkspaceContext(this); - - firstUpdated(props: PropertyValueMap) { - super.firstUpdated(props); - - // TODO: This should be moved to the log viewer context: - window.addEventListener('changestate', this.#webhooksContext.onChangeState); - this.#webhooksContext.onChangeState(); - } - - disconnectedCallback(): void { - super.disconnectedCallback(); - window.removeEventListener('changestate', this.#webhooksContext.onChangeState); - } - - load(): void { - // Not relevant for this workspace -added to prevent the error from popping up - } - - create(): void { - // Not relevant for this workspace - } - - render() { - return html` - - - `; - } - - static styles = [ - UmbTextStyles, - css` - :host { - display: block; - width: 100%; - height: 100%; - } - - uui-tab-group { - --uui-tab-divider: var(--uui-color-border); - border-left: 1px solid var(--uui-color-border); - border-right: 1px solid var(--uui-color-border); - } - `, - ]; -} - -export default UmbWebhooksWorkspaceElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-webhooks-workspace': UmbWebhooksWorkspaceElement; - } -} From 267967be5955b1f4227abf4fd503eaca2d8f5908 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 23:15:39 +0100 Subject: [PATCH 21/44] Add package bundle --- src/packages/webhooks/umbraco-package.ts | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 src/packages/webhooks/umbraco-package.ts diff --git a/src/packages/webhooks/umbraco-package.ts b/src/packages/webhooks/umbraco-package.ts new file mode 100644 index 0000000000..a5c24dd8b6 --- /dev/null +++ b/src/packages/webhooks/umbraco-package.ts @@ -0,0 +1,9 @@ +export const name = 'Umbraco.Core.Webhook'; +export const extensions = [ + { + name: 'Webhook Bundle', + alias: 'Umb.Bundle.Webhook', + type: 'bundle', + js: () => import('./manifests.js'), + }, +]; From 9259cddf0c1ea34134c29418cf4785475e215f48 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 23:20:32 +0100 Subject: [PATCH 22/44] Update icon --- src/packages/webhooks/menu-item/manifests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/webhooks/menu-item/manifests.ts b/src/packages/webhooks/menu-item/manifests.ts index afdfe8dd8d..eaf52d8312 100644 --- a/src/packages/webhooks/menu-item/manifests.ts +++ b/src/packages/webhooks/menu-item/manifests.ts @@ -7,7 +7,7 @@ const menuItem: ManifestMenuItem = { weight: 100, meta: { label: 'Webhooks', - icon: 'webhook', + icon: 'icon-webhook', entityType: 'webhook-root', menus: ['Umb.Menu.Settings'], }, From e40ce60eda612340abeb60769f7ae6211d5f7575 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Mon, 26 Feb 2024 23:26:04 +0100 Subject: [PATCH 23/44] Include handlers --- src/mocks/browser-handlers.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/mocks/browser-handlers.ts b/src/mocks/browser-handlers.ts index 67b6ae8118..161d6e9823 100644 --- a/src/mocks/browser-handlers.ts +++ b/src/mocks/browser-handlers.ts @@ -11,6 +11,7 @@ import { handlers as healthCheckHandlers } from './handlers/health-check.handler import { handlers as installHandlers } from './handlers/install.handlers.js'; import { handlers as languageHandlers } from './handlers/language/index.js'; import { handlers as logViewerHandlers } from './handlers/log-viewer.handlers.js'; +import { handlers as webhookHandlers } from './handlers/webhook.handlers.js'; import { handlers as mediaHandlers } from './handlers/media/index.js'; import { handlers as mediaTypeHandlers } from './handlers/media-type/index.js'; import { handlers as memberGroupHandlers } from './handlers/member-group/index.js'; @@ -52,6 +53,7 @@ const handlers = [ ...installHandlers, ...languageHandlers, ...logViewerHandlers, + ...webhookHandlers, ...mediaHandlers, ...mediaTypeHandlers, ...memberGroupHandlers, From 228e0ae1cd2746a2cd90104ab833924a77836d5c Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 27 Feb 2024 00:11:04 +0100 Subject: [PATCH 24/44] Adjust table collection for webhook --- .../webhook-collection.server.data-source.ts | 6 +- .../webhooks/collection/views/index.ts | 2 +- .../webhooks/collection/views/manifests.ts | 10 +- ...ok-table-boolean-column-layout.element.ts} | 6 +- ...le-entity-actions-column-layout.element.ts | 38 ----- ...le-entity-actions-column-layout.element.ts | 34 +++++ .../language-table-collection-view.element.ts | 133 ------------------ .../webhook-table-collection-view.element.ts | 119 ++++++++++++++++ 8 files changed, 165 insertions(+), 183 deletions(-) rename src/packages/webhooks/collection/views/table/column-layouts/boolean/{language-table-boolean-column-layout.element.ts => webhook-table-boolean-column-layout.element.ts} (61%) delete mode 100644 src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts create mode 100644 src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts delete mode 100644 src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts create mode 100644 src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts index 4576a8bb0b..0cbe98d9bf 100644 --- a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts +++ b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts @@ -31,9 +31,9 @@ export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSo * @memberof UmbWebhookeCollectionServerDataSource */ async getCollection(filter: UmbWebhookCollectionFilterModel) { - const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhook(filter)); + const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhookItem({ ids: [""] })); //WebhookResource.getWebhook(filter)); - if (data) { + /*if (data) { const items = data.items.map((item) => { const model: UmbWebhookDetailModel = { unique: '', //item.id.toLowerCase(), @@ -49,7 +49,7 @@ export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSo }); return { data: { items, total: data.total } }; - } + }*/ return { error }; } diff --git a/src/packages/webhooks/collection/views/index.ts b/src/packages/webhooks/collection/views/index.ts index e9d6c50fc5..31e3d80739 100644 --- a/src/packages/webhooks/collection/views/index.ts +++ b/src/packages/webhooks/collection/views/index.ts @@ -1 +1 @@ -export { UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js'; +export { UMB_WEBHOOK_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js'; diff --git a/src/packages/webhooks/collection/views/manifests.ts b/src/packages/webhooks/collection/views/manifests.ts index dd0183bcdb..2eed3f5374 100644 --- a/src/packages/webhooks/collection/views/manifests.ts +++ b/src/packages/webhooks/collection/views/manifests.ts @@ -1,13 +1,13 @@ import { UMB_COLLECTION_ALIAS_CONDITION } from '@umbraco-cms/backoffice/collection'; import type { ManifestCollectionView } from '@umbraco-cms/backoffice/extension-registry'; -export const UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS = 'Umb.CollectionView.Language.Table'; +export const UMB_WEBHOOK_TABLE_COLLECTION_VIEW_ALIAS = 'Umb.CollectionView.Webhook.Table'; const tableCollectionView: ManifestCollectionView = { type: 'collectionView', - alias: UMB_LANGUAGE_TABLE_COLLECTION_VIEW_ALIAS, - name: 'Language Table Collection View', - js: () => import('./table/language-table-collection-view.element.js'), + alias: UMB_WEBHOOK_TABLE_COLLECTION_VIEW_ALIAS, + name: 'Webhook Table Collection View', + js: () => import('./table/webhook-table-collection-view.element.js'), meta: { label: 'Table', icon: 'icon-list', @@ -16,7 +16,7 @@ const tableCollectionView: ManifestCollectionView = { conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Language', + match: 'Umb.Collection.Webhook', }, ], }; diff --git a/src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts similarity index 61% rename from src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts rename to src/packages/webhooks/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts index 3dc43bbbb6..c992d32667 100644 --- a/src/packages/webhooks/collection/views/table/column-layouts/boolean/language-table-boolean-column-layout.element.ts +++ b/src/packages/webhooks/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts @@ -1,8 +1,8 @@ import { html, nothing, customElement, property } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -@customElement('umb-language-table-boolean-column-layout') -export class UmbLanguageTableBooleanColumnLayoutElement extends UmbLitElement { +@customElement('umb-webhook-table-boolean-column-layout') +export class UmbWebhookTableBooleanColumnLayoutElement extends UmbLitElement { @property({ attribute: false }) value = false; @@ -13,6 +13,6 @@ export class UmbLanguageTableBooleanColumnLayoutElement extends UmbLitElement { declare global { interface HTMLElementTagNameMap { - 'umb-language-table-boolean-column-layout': UmbLanguageTableBooleanColumnLayoutElement; + 'umb-webhook-table-boolean-column-layout': UmbWebhookTableBooleanColumnLayoutElement; } } diff --git a/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts deleted file mode 100644 index e9250a09ad..0000000000 --- a/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/language-table-entity-actions-column-layout.element.ts +++ /dev/null @@ -1,38 +0,0 @@ -import type { UmbLanguageDetailModel } from '../../../../../types.js'; -import { html, nothing, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; - -@customElement('umb-language-table-entity-actions-column-layout') -export class UmbLanguageTableEntityActionsColumnLayoutElement extends UmbLitElement { - @property({ attribute: false }) - value!: UmbLanguageDetailModel; - - @state() - _isOpen = false; - - #onActionExecuted() { - this._isOpen = false; - } - - render() { - // TODO: we need to use conditionals on each action here. But until we have that in place - // we'll just remove all actions on the default language. - if (this.value.isDefault) return nothing; - - return html` - - - - - `; - } -} - -declare global { - interface HTMLElementTagNameMap { - 'umb-language-table-entity-actions-column-layout': UmbLanguageTableEntityActionsColumnLayoutElement; - } -} diff --git a/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts new file mode 100644 index 0000000000..7fc4561d65 --- /dev/null +++ b/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts @@ -0,0 +1,34 @@ +import type { UmbWebhookDetailModel } from '../../../../../types.js'; +import { html, customElement, property, state, ifDefined } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-webhook-table-entity-actions-column-layout') +export class UmbWebhookTableEntityActionsColumnLayoutElement extends UmbLitElement { + @property({ attribute: false }) + value!: UmbWebhookDetailModel; + + @state() + _isOpen = false; + + #onActionExecuted() { + this._isOpen = false; + } + + render() { + return html` + + + + + `; + } +} + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhook-table-entity-actions-column-layout': UmbWebhookTableEntityActionsColumnLayoutElement; + } +} diff --git a/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts b/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts deleted file mode 100644 index 3e3359dc27..0000000000 --- a/src/packages/webhooks/collection/views/table/language-table-collection-view.element.ts +++ /dev/null @@ -1,133 +0,0 @@ -import type { UmbLanguageDetailModel } from '../../../types.js'; -import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'; -import { UMB_DEFAULT_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection'; -import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; -import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; -import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; - -import './column-layouts/boolean/language-table-boolean-column-layout.element.js'; -import './column-layouts/name/language-table-name-column-layout.element.js'; -import './column-layouts/entity-actions/language-table-entity-actions-column-layout.element.js'; - -@customElement('umb-language-table-collection-view') -export class UmbLanguageTableCollectionViewElement extends UmbLitElement { - @state() - private _tableConfig: UmbTableConfig = { - allowSelection: false, - }; - - @state() - private _tableColumns: Array = [ - { - name: 'Name', - alias: 'languageName', - elementName: 'umb-language-table-name-column-layout', - }, - { - name: 'ISO Code', - alias: 'isoCode', - }, - { - name: 'Default', - alias: 'defaultLanguage', - elementName: 'umb-language-table-boolean-column-layout', - }, - { - name: 'Mandatory', - alias: 'mandatoryLanguage', - elementName: 'umb-language-table-boolean-column-layout', - }, - { - name: 'Fallback', - alias: 'fallbackLanguage', - }, - { - name: '', - alias: 'entityActions', - elementName: 'umb-language-table-entity-actions-column-layout', - }, - ]; - - @state() - private _tableItems: Array = []; - private _cultureNames = new Intl.DisplayNames('en', { type: 'language' }); - - #collectionContext?: UmbDefaultCollectionContext; - - constructor() { - super(); - - this.consumeContext(UMB_DEFAULT_COLLECTION_CONTEXT, (instance) => { - this.#collectionContext = instance; - this.#observeCollectionItems(); - }); - } - - #observeCollectionItems() { - if (!this.#collectionContext) return; - this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver'); - } - - #createTableItems(languages: Array) { - this._tableItems = languages.map((language) => { - return { - id: language.unique, - icon: 'icon-globe', - data: [ - { - columnAlias: 'languageName', - value: { - name: language.name ? language.name : this._cultureNames.of(language.unique), - unique: language.unique, - }, - }, - { - columnAlias: 'isoCode', - value: language.unique, - }, - { - columnAlias: 'defaultLanguage', - value: language.isDefault, - }, - { - columnAlias: 'mandatoryLanguage', - value: language.isMandatory, - }, - { - columnAlias: 'fallbackLanguage', - value: languages.find((x) => x.unique === language.fallbackIsoCode)?.name, - }, - { - columnAlias: 'entityActions', - value: language, - }, - ], - }; - }); - } - - render() { - return html` - - `; - } - - static styles = [ - UmbTextStyles, - css` - :host { - display: flex; - flex-direction: column; - } - `, - ]; -} - -export default UmbLanguageTableCollectionViewElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-language-table-collection-view': UmbLanguageTableCollectionViewElement; - } -} diff --git a/src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts b/src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts new file mode 100644 index 0000000000..c70a6e2e80 --- /dev/null +++ b/src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts @@ -0,0 +1,119 @@ +import type { UmbWebhookDetailModel } from '../../../types.js'; +import type { UmbDefaultCollectionContext } from '@umbraco-cms/backoffice/collection'; +import { UMB_DEFAULT_COLLECTION_CONTEXT } from '@umbraco-cms/backoffice/collection'; +import type { UmbTableColumn, UmbTableConfig, UmbTableItem } from '@umbraco-cms/backoffice/components'; +import { css, html, customElement, state } from '@umbraco-cms/backoffice/external/lit'; +import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +import './column-layouts/boolean/webhook-table-boolean-column-layout.element.js'; +import './column-layouts/name/webhook-table-name-column-layout.element.js'; +import './column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.js'; + +@customElement('umb-webhook-table-collection-view') +export class UmbWebhookTableCollectionViewElement extends UmbLitElement { + @state() + private _tableConfig: UmbTableConfig = { + allowSelection: false, + }; + + @state() + private _tableColumns: Array = [ + { + name: 'Enabled', + alias: 'enabled', + elementName: 'umb-webhook-table-boolean-column-layout', + }, + { + name: 'URL', + alias: 'url', + }, + { + name: 'Events', + alias: 'events', + }, + { + name: 'Types', + alias: 'types', + }, + { + name: '', + alias: 'entityActions', + elementName: 'umb-webhook-table-entity-actions-column-layout', + }, + ]; + + @state() + private _tableItems: Array = []; + + #collectionContext?: UmbDefaultCollectionContext; + + constructor() { + super(); + + this.consumeContext(UMB_DEFAULT_COLLECTION_CONTEXT, (instance) => { + this.#collectionContext = instance; + this.#observeCollectionItems(); + }); + } + + #observeCollectionItems() { + if (!this.#collectionContext) return; + this.observe(this.#collectionContext.items, (items) => this.#createTableItems(items), 'umbCollectionItemsObserver'); + } + + #createTableItems(webhooks: Array) { + this._tableItems = webhooks.map((webhook) => { + return { + id: webhook.unique, + icon: 'icon-webhook', + data: [ + { + columnAlias: 'enabled', + value: webhook.enabled, + }, + { + columnAlias: 'url', + value: webhook.url, + }, + { + columnAlias: 'events', + value: webhook.events, + }, + { + columnAlias: 'types', + value: webhook.types, + }, + { + columnAlias: 'entityActions', + value: webhook, + }, + ], + }; + }); + } + + render() { + return html` + + `; + } + + static styles = [ + UmbTextStyles, + css` + :host { + display: flex; + flex-direction: column; + } + `, + ]; +} + +export default UmbWebhookTableCollectionViewElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhook-table-collection-view': UmbWebhookTableCollectionViewElement; + } +} From e65fb99269aa67d83d73d13b31963f0efead1b06 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 27 Feb 2024 00:42:28 +0100 Subject: [PATCH 25/44] Adjust manifest files --- src/packages/webhooks/workspace/manifests.ts | 2 +- .../workspace/views/overview/index.ts | 4 ++ .../{ => views}/overview/manifests.ts | 0 .../webhook-root-workspace.element.ts | 20 +++++++ .../webhooks/workspace/webhooks/manifests.ts | 60 +++++++++++++++++++ .../webhook-root-workspace.element.ts | 0 6 files changed, 85 insertions(+), 1 deletion(-) create mode 100644 src/packages/webhooks/workspace/views/overview/index.ts rename src/packages/webhooks/workspace/{ => views}/overview/manifests.ts (100%) create mode 100644 src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts create mode 100644 src/packages/webhooks/workspace/webhooks/manifests.ts rename src/packages/webhooks/workspace/{overview => webhooks}/webhook-root-workspace.element.ts (100%) diff --git a/src/packages/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts index 0c31d66295..e9db618b71 100644 --- a/src/packages/webhooks/workspace/manifests.ts +++ b/src/packages/webhooks/workspace/manifests.ts @@ -1,3 +1,3 @@ -import { manifests as webhookRootManifests } from './overview/manifests.js'; +import { manifests as webhookRootManifests } from './webhooks/manifests.js'; export const manifests = [...webhookRootManifests]; diff --git a/src/packages/webhooks/workspace/views/overview/index.ts b/src/packages/webhooks/workspace/views/overview/index.ts new file mode 100644 index 0000000000..a6632c319d --- /dev/null +++ b/src/packages/webhooks/workspace/views/overview/index.ts @@ -0,0 +1,4 @@ +import './components/index.js'; +import { UmbWebhookRootWorkspaceElement } from './webhook-root-workspace.element.js'; + +export default UmbWebhookRootWorkspaceElement; diff --git a/src/packages/webhooks/workspace/overview/manifests.ts b/src/packages/webhooks/workspace/views/overview/manifests.ts similarity index 100% rename from src/packages/webhooks/workspace/overview/manifests.ts rename to src/packages/webhooks/workspace/views/overview/manifests.ts diff --git a/src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts new file mode 100644 index 0000000000..0a48d3711d --- /dev/null +++ b/src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts @@ -0,0 +1,20 @@ +import { UMB_WEBHOOK_COLLECTION_ALIAS } from '../../../collection/index.js'; +import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-webook-root-workspace') +export class UmbWebhookRootWorkspaceElement extends UmbLitElement { + render() { + return html` + ; + `; + } +} + +export default UmbWebhookRootWorkspaceElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhook-root-workspace': UmbWebhookRootWorkspaceElement; + } +} diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts new file mode 100644 index 0000000000..1ffde2526b --- /dev/null +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -0,0 +1,60 @@ +import type { + ManifestWorkspace, + ManifestWorkspaceAction, + ManifestWorkspaceView, +} from '@umbraco-cms/backoffice/extension-registry'; + +const workspaceAlias = 'Umb.Workspace.Webhooks'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: workspaceAlias, + name: 'Webhook Root Workspace', + js: () => import('./webhook-root-workspace.element.js'), + meta: { + entityType: 'webhooks', + }, +}; + +const workspaceViews: Array = [ + { + type: 'workspaceView', + alias: 'Umb.WorkspaceView.Webhooks.Overview', + name: 'Webhooks Root Workspace Overview View', + js: () => import('../views/overview/index.js'), + weight: 300, + meta: { + label: 'Overview', + pathname: 'overview', + icon: 'icon-webhook', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, + { + type: 'workspaceView', + alias: 'Umb.WorkspaceView.LogViewer.Search', + name: 'LogViewer Root Workspace Search View', + js: () => import('../views/logs/index.js'), + weight: 200, + meta: { + label: 'Logs', + pathname: 'logs', + icon: 'icon-box-alt', + }, + conditions: [ + { + alias: 'Umb.Condition.WorkspaceAlias', + match: workspace.alias, + }, + ], + }, +]; + +const workspaceActions: Array = []; + +export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; diff --git a/src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts similarity index 100% rename from src/packages/webhooks/workspace/overview/webhook-root-workspace.element.ts rename to src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts From d2ecd49e760a3d66d32ca361cf235420d5f85f0d Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 27 Feb 2024 00:46:46 +0100 Subject: [PATCH 26/44] Correction --- src/packages/webhooks/workspace/webhooks/manifests.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts index 1ffde2526b..ea6fb00a28 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -37,8 +37,8 @@ const workspaceViews: Array = [ }, { type: 'workspaceView', - alias: 'Umb.WorkspaceView.LogViewer.Search', - name: 'LogViewer Root Workspace Search View', + alias: 'Umb.WorkspaceView.Webhooks.Search', + name: 'Webhooks Root Workspace Logs View', js: () => import('../views/logs/index.js'), weight: 200, meta: { From 03ce1388674c363a055632bb4e4a49400de8fa0c Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 27 Feb 2024 08:23:25 +0100 Subject: [PATCH 27/44] Rename --- ...t.element.ts => webhook-table-name-column-layout.element.ts} | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename src/packages/webhooks/collection/views/table/column-layouts/name/{language-table-name-column-layout.element.ts => webhook-table-name-column-layout.element.ts} (92%) diff --git a/src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts b/src/packages/webhooks/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts similarity index 92% rename from src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts rename to src/packages/webhooks/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts index 4c3ce5ec56..f90515ddac 100644 --- a/src/packages/webhooks/collection/views/table/column-layouts/name/language-table-name-column-layout.element.ts +++ b/src/packages/webhooks/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts @@ -1,7 +1,7 @@ import { UmbTextStyles } from '@umbraco-cms/backoffice/style'; import { html, LitElement, nothing, customElement, property } from '@umbraco-cms/backoffice/external/lit'; -@customElement('umb-language-table-name-column-layout') +@customElement('umb-w-table-name-column-layout') export class UmbLanguageTableNameColumnLayoutElement extends LitElement { @property({ attribute: false }) value!: { unique: string; name: string }; From b9055f3762b8d0aa4215c483b2780063575f6db6 Mon Sep 17 00:00:00 2001 From: Bjarne Fyrstenborg Date: Tue, 27 Feb 2024 10:28:59 +0100 Subject: [PATCH 28/44] Overview workspace --- src/packages/webhooks/workspace/views/overview/index.ts | 2 +- src/packages/webhooks/workspace/views/overview/manifests.ts | 2 +- ...ot-workspace.element.ts => webhook-overview-view.element.ts} | 0 .../workspace/webhooks/webhook-root-workspace.element.ts | 2 +- 4 files changed, 3 insertions(+), 3 deletions(-) rename src/packages/webhooks/workspace/views/overview/{webhook-root-workspace.element.ts => webhook-overview-view.element.ts} (100%) diff --git a/src/packages/webhooks/workspace/views/overview/index.ts b/src/packages/webhooks/workspace/views/overview/index.ts index a6632c319d..391c5b22ac 100644 --- a/src/packages/webhooks/workspace/views/overview/index.ts +++ b/src/packages/webhooks/workspace/views/overview/index.ts @@ -1,4 +1,4 @@ import './components/index.js'; -import { UmbWebhookRootWorkspaceElement } from './webhook-root-workspace.element.js'; +import { UmbWebhookRootWorkspaceElement } from './webhook-overview-view.element.js'; export default UmbWebhookRootWorkspaceElement; diff --git a/src/packages/webhooks/workspace/views/overview/manifests.ts b/src/packages/webhooks/workspace/views/overview/manifests.ts index 918e31433c..ea8427e117 100644 --- a/src/packages/webhooks/workspace/views/overview/manifests.ts +++ b/src/packages/webhooks/workspace/views/overview/manifests.ts @@ -4,7 +4,7 @@ const workspace: ManifestWorkspace = { type: 'workspace', alias: 'Umb.Workspace.WebhookRoot', name: 'Webhook Root Workspace', - js: () => import('./webhook-root-workspace.element.js'), + js: () => import('./webhook-overview-view.element.js'), meta: { entityType: 'webhook-root', }, diff --git a/src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts similarity index 100% rename from src/packages/webhooks/workspace/views/overview/webhook-root-workspace.element.ts rename to src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts diff --git a/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts index 0ca586fa94..46c5376431 100644 --- a/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts +++ b/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts @@ -2,7 +2,7 @@ import { UMB_WEBHOOK_COLLECTION_ALIAS } from '../../collection/index.js'; import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; -@customElement('umb-webook-root-workspace') +@customElement('umb-webhook-root-workspace') export class UmbWebhookRootWorkspaceElement extends UmbLitElement { render() { return html` From 2f70fc54ebb2ab46d301dbf74e9324aa24545f3d Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:38:28 +0100 Subject: [PATCH 29/44] reset language manifests file --- src/packages/language/collection/action/manifests.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/packages/language/collection/action/manifests.ts b/src/packages/language/collection/action/manifests.ts index bfaabbb79a..c4c98eca4d 100644 --- a/src/packages/language/collection/action/manifests.ts +++ b/src/packages/language/collection/action/manifests.ts @@ -4,17 +4,17 @@ import type { ManifestCollectionAction } from '@umbraco-cms/backoffice/extension export const createManifest: ManifestCollectionAction = { type: 'collectionAction', kind: 'button', - name: 'Create Webhook Collection Action', - alias: 'Umb.CollectionAction.Webhook.Create', + name: 'Create Language Collection Action', + alias: 'Umb.CollectionAction.Language.Create', weight: 200, meta: { label: 'Create', - href: 'section/settings/workspace/webhook/create', + href: 'section/settings/workspace/language/create', }, conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Webhook', + match: 'Umb.Collection.Language', }, ], }; From a1333db51225edac879b2019bfe4b02b90dd7337 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:46:37 +0100 Subject: [PATCH 30/44] fix models --- .../webhook-collection.server.data-source.ts | 23 +++++++++---------- src/packages/webhooks/types.ts | 3 ++- 2 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts index 0cbe98d9bf..974168e63b 100644 --- a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts +++ b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts @@ -1,7 +1,6 @@ import type { UmbWebhookCollectionFilterModel } from '../types.js'; import type { UmbWebhookDetailModel } from '../../types.js'; import { UMB_WEBHOOK_ENTITY_TYPE } from '../../entity.js'; -import type { UmbCollectionDataSource } from '@umbraco-cms/backoffice/collection'; import { WebhookResource } from '@umbraco-cms/backoffice/external/backend-api'; import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; @@ -12,7 +11,7 @@ import { tryExecuteAndNotify } from '@umbraco-cms/backoffice/resources'; * @class UmbWebhookCollectionServerDataSource * @implements {UmbCollectionDataSource} */ -export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSource { +export class UmbWebhookCollectionServerDataSource implements UmbWebhookCollectionServerDataSource { #host: UmbControllerHost; /** @@ -26,19 +25,19 @@ export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSo /** * Gets the Wwbhook collection filtered by the given filter. - * @param {UmbWebhookeCollectionFilterModel} filter + * @param {UmbWebhookCollectionFilterModel} filter * @return {*} - * @memberof UmbWebhookeCollectionServerDataSource + * @memberof UmbWebhookCollectionServerDataSource */ - async getCollection(filter: UmbWebhookCollectionFilterModel) { - const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhookItem({ ids: [""] })); //WebhookResource.getWebhook(filter)); + async getCollection(_filter: UmbWebhookCollectionFilterModel) { + const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhookItem({ ids: [''] })); - /*if (data) { - const items = data.items.map((item) => { + if (data) { + const items = data.map((item) => { const model: UmbWebhookDetailModel = { - unique: '', //item.id.toLowerCase(), - //name: item.name, entityType: UMB_WEBHOOK_ENTITY_TYPE, + unique: item.url, //item.id.toLowerCase(), + name: item.name, url: item.url, enabled: item.enabled, events: item.events.split(','), @@ -48,8 +47,8 @@ export class UmbWebhookCollectionServerDataSource implements UmbCollectionDataSo return model; }); - return { data: { items, total: data.total } }; - }*/ + return { data: { items, total: data.length } }; + } return { error }; } diff --git a/src/packages/webhooks/types.ts b/src/packages/webhooks/types.ts index e3f11eadf6..aba4dc31ba 100644 --- a/src/packages/webhooks/types.ts +++ b/src/packages/webhooks/types.ts @@ -3,8 +3,9 @@ import type { UmbWebhookEntityType } from './entity.js'; export interface UmbWebhookDetailModel { entityType: UmbWebhookEntityType; unique: string; + name: string; enabled: boolean; url: string; events: string[] | null; types: string[] | null; -} \ No newline at end of file +} From ce227075309c311bd679f95bd3bb1fa41fd5037a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:47:18 +0100 Subject: [PATCH 31/44] remove global context --- .../global-contexts/app-webhook.context.ts | 40 ------------------- .../webhooks/global-contexts/index.ts | 1 - .../webhooks/global-contexts/manifests.ts | 10 ----- src/packages/webhooks/manifests.ts | 2 - 4 files changed, 53 deletions(-) delete mode 100644 src/packages/webhooks/global-contexts/app-webhook.context.ts delete mode 100644 src/packages/webhooks/global-contexts/index.ts delete mode 100644 src/packages/webhooks/global-contexts/manifests.ts diff --git a/src/packages/webhooks/global-contexts/app-webhook.context.ts b/src/packages/webhooks/global-contexts/app-webhook.context.ts deleted file mode 100644 index 971d1edc8f..0000000000 --- a/src/packages/webhooks/global-contexts/app-webhook.context.ts +++ /dev/null @@ -1,40 +0,0 @@ -import { UmbWebhookCollectionRepository } from '../collection/index.js'; -import type { UmbWebhookDetailModel } from '../types.js'; -import { UmbObjectState } from '@umbraco-cms/backoffice/observable-api'; -import type { UmbControllerHost } from '@umbraco-cms/backoffice/controller-api'; -import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; -import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; -import type { UmbApi } from '@umbraco-cms/backoffice/extension-api'; - -export class UmbAppWebhookContext extends UmbBaseController implements UmbApi { - #webhookCollectionRepository: UmbWebhookCollectionRepository; - #webhooks: Array = []; - #appWebhook = new UmbObjectState(undefined); - appWebhook = this.#appWebhook.asObservable(); - - constructor(host: UmbControllerHost) { - super(host); - this.provideContext(UMB_APP_WEBHOOK_CONTEXT, this); - this.#webhookCollectionRepository = new UmbWebhookCollectionRepository(this); - this.#observeWebhooks(); - } - - setLanguage(unique: string) { - const webhook = this.#webhooks.find((x) => x.unique === unique); - this.#appWebhook.update(webhook); - } - - async #observeWebhooks() { - const { data } = await this.#webhookCollectionRepository.requestCollection({ skip: 0, take: 100 }); - - // TODO: make this observable / update when webhooks are added/removed/updated - if (data) { - this.#webhooks = data.items; - } - } -} - -// Default export to enable this as a globalContext extension js: -export default UmbAppWebhookContext; - -export const UMB_APP_WEBHOOK_CONTEXT = new UmbContextToken('UmbAppWebhookContext'); diff --git a/src/packages/webhooks/global-contexts/index.ts b/src/packages/webhooks/global-contexts/index.ts deleted file mode 100644 index 868bf754a7..0000000000 --- a/src/packages/webhooks/global-contexts/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './app-webhook.context.js'; diff --git a/src/packages/webhooks/global-contexts/manifests.ts b/src/packages/webhooks/global-contexts/manifests.ts deleted file mode 100644 index a38ca4af40..0000000000 --- a/src/packages/webhooks/global-contexts/manifests.ts +++ /dev/null @@ -1,10 +0,0 @@ -import type { ManifestGlobalContext } from '@umbraco-cms/backoffice/extension-registry'; - -export const manifests: Array = [ - { - type: 'globalContext', - alias: 'Umb.GlobalContext.AppWebhook', - name: 'App Webhook Context', - js: () => import('./app-webhook.context.js'), - }, -]; diff --git a/src/packages/webhooks/manifests.ts b/src/packages/webhooks/manifests.ts index ccfa411c5d..3b431ec455 100644 --- a/src/packages/webhooks/manifests.ts +++ b/src/packages/webhooks/manifests.ts @@ -3,7 +3,6 @@ import { manifests as treeManifests } from './menu-item/manifests.js'; //import { manifests as entityActions } from './entity-actions/manifests.js'; import { manifests as workspaceManifests } from './workspace/manifests.js'; import { manifests as collectionManifests } from './collection/manifests.js'; -import { manifests as globalContextManifests } from './global-contexts/manifests.js'; export const manifests = [ ...repositoryManifests, @@ -11,5 +10,4 @@ export const manifests = [ ...treeManifests, ...workspaceManifests, ...collectionManifests, - ...globalContextManifests, ]; From 91eb661048c9bc7969e463410ff0aa1a11c1bb0a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:59:27 +0100 Subject: [PATCH 32/44] fix interface implementation --- src/packages/webhooks/workspace/webhooks.context.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts index 98b77c4c6d..410cb938a2 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -7,8 +7,8 @@ import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'; // TODO: Revisit usage of workspace for this case... export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { - public readonly workspaceAlias: string = 'Umb.Workspace.Webhooks'; - #repository: UmbWebhookRepository; + public readonly workspaceAlias = 'Umb.Workspace.Webhooks'; + #repository; getEntityType() { return 'webhooks'; @@ -18,7 +18,7 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um return 'Webhooks'; } - getEntityId() { + getUnique() { return undefined; } From 1bb00aea29a44f97ffaa44a985acd4317659d0d2 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 09:59:37 +0100 Subject: [PATCH 33/44] remove outcommented lines --- src/packages/webhooks/index.ts | 3 +-- src/packages/webhooks/repository/index.ts | 1 - 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/packages/webhooks/index.ts b/src/packages/webhooks/index.ts index 734e11ca45..997c7147e3 100644 --- a/src/packages/webhooks/index.ts +++ b/src/packages/webhooks/index.ts @@ -2,6 +2,5 @@ import './components/index.js'; export * from './repository/index.js'; export * from './collection/index.js'; -export * from './global-contexts/index.js'; -export type { UmbWebhookDetailModel } from './types.js'; \ No newline at end of file +export type { UmbWebhookDetailModel } from './types.js'; diff --git a/src/packages/webhooks/repository/index.ts b/src/packages/webhooks/repository/index.ts index 8dbf9566cc..e8facb4cb3 100644 --- a/src/packages/webhooks/repository/index.ts +++ b/src/packages/webhooks/repository/index.ts @@ -1,2 +1 @@ export * from './webhooks.repository.js'; -//export * from './sources/index.js'; From 4e96328b3d675103d4d6497b4530995d2c407c9e Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:11:26 +0100 Subject: [PATCH 34/44] register the webhooks package globally --- src/apps/backoffice/backoffice.element.ts | 1 + src/packages/webhooks/workspace/webhooks/manifests.ts | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/apps/backoffice/backoffice.element.ts b/src/apps/backoffice/backoffice.element.ts index 567d7e254c..14f41066b3 100644 --- a/src/apps/backoffice/backoffice.element.ts +++ b/src/apps/backoffice/backoffice.element.ts @@ -36,6 +36,7 @@ const CORE_PACKAGES = [ import('../../packages/tiny-mce/umbraco-package.js'), import('../../packages/umbraco-news/umbraco-package.js'), import('../../packages/user/umbraco-package.js'), + import('../../packages/webhooks/umbraco-package.js'), ]; @customElement('umb-backoffice') diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts index ea6fb00a28..dadefac2e2 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -35,7 +35,7 @@ const workspaceViews: Array = [ }, ], }, - { + /*{ type: 'workspaceView', alias: 'Umb.WorkspaceView.Webhooks.Search', name: 'Webhooks Root Workspace Logs View', @@ -52,7 +52,7 @@ const workspaceViews: Array = [ match: workspace.alias, }, ], - }, + },*/ ]; const workspaceActions: Array = []; From 70f19d00a9998f1cbdb39160b80a77990915faa8 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:22:55 +0100 Subject: [PATCH 35/44] move files around to align with other workspaces and fix webhook root alias --- src/packages/webhooks/workspace/manifests.ts | 5 ++-- .../workspace/webhooks-root/manifests.ts | 15 +++++++++++ .../webhook-root-workspace.element.ts | 2 +- .../webhooks/workspace/webhooks/manifests.ts | 26 +++---------------- .../overview => webhooks/views}/index.ts | 0 .../overview => webhooks/views}/manifests.ts | 0 .../views}/webhook-overview-view.element.ts | 0 .../{ => webhooks}/webhooks.context.ts | 2 +- 8 files changed, 24 insertions(+), 26 deletions(-) create mode 100644 src/packages/webhooks/workspace/webhooks-root/manifests.ts rename src/packages/webhooks/workspace/{webhooks => webhooks-root}/webhook-root-workspace.element.ts (85%) rename src/packages/webhooks/workspace/{views/overview => webhooks/views}/index.ts (100%) rename src/packages/webhooks/workspace/{views/overview => webhooks/views}/manifests.ts (100%) rename src/packages/webhooks/workspace/{views/overview => webhooks/views}/webhook-overview-view.element.ts (100%) rename src/packages/webhooks/workspace/{ => webhooks}/webhooks.context.ts (94%) diff --git a/src/packages/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts index e9db618b71..65905cc8c4 100644 --- a/src/packages/webhooks/workspace/manifests.ts +++ b/src/packages/webhooks/workspace/manifests.ts @@ -1,3 +1,4 @@ -import { manifests as webhookRootManifests } from './webhooks/manifests.js'; +import { manifests as webhookRootManifests } from './webhooks-root/manifests.js'; +import { manifests as webhookManifests } from './webhooks/manifests.js'; -export const manifests = [...webhookRootManifests]; +export const manifests = [...webhookRootManifests, ...webhookManifests]; diff --git a/src/packages/webhooks/workspace/webhooks-root/manifests.ts b/src/packages/webhooks/workspace/webhooks-root/manifests.ts new file mode 100644 index 0000000000..f4ddb81daa --- /dev/null +++ b/src/packages/webhooks/workspace/webhooks-root/manifests.ts @@ -0,0 +1,15 @@ +import type { ManifestWorkspace } from '@umbraco-cms/backoffice/extension-registry'; + +const workspaceAlias = 'Umb.Workspace.Webhooks'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: workspaceAlias, + name: 'Webhook Root Workspace', + js: () => import('./webhook-root-workspace.element.js'), + meta: { + entityType: 'webhook-root', + }, +}; + +export const manifests = [workspace]; diff --git a/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts similarity index 85% rename from src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts rename to src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts index 46c5376431..176eded82f 100644 --- a/src/packages/webhooks/workspace/webhooks/webhook-root-workspace.element.ts +++ b/src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts @@ -5,7 +5,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; @customElement('umb-webhook-root-workspace') export class UmbWebhookRootWorkspaceElement extends UmbLitElement { render() { - return html` + return html` ; `; } diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts index dadefac2e2..0745de328e 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -1,27 +1,11 @@ -import type { - ManifestWorkspace, - ManifestWorkspaceAction, - ManifestWorkspaceView, -} from '@umbraco-cms/backoffice/extension-registry'; - -const workspaceAlias = 'Umb.Workspace.Webhooks'; - -const workspace: ManifestWorkspace = { - type: 'workspace', - alias: workspaceAlias, - name: 'Webhook Root Workspace', - js: () => import('./webhook-root-workspace.element.js'), - meta: { - entityType: 'webhooks', - }, -}; +import type { ManifestWorkspaceView } from '@umbraco-cms/backoffice/extension-registry'; const workspaceViews: Array = [ { type: 'workspaceView', alias: 'Umb.WorkspaceView.Webhooks.Overview', name: 'Webhooks Root Workspace Overview View', - js: () => import('../views/overview/index.js'), + js: () => import('./views/index.js'), weight: 300, meta: { label: 'Overview', @@ -31,7 +15,7 @@ const workspaceViews: Array = [ conditions: [ { alias: 'Umb.Condition.WorkspaceAlias', - match: workspace.alias, + match: 'Umb.Workspace.Webhooks', }, ], }, @@ -55,6 +39,4 @@ const workspaceViews: Array = [ },*/ ]; -const workspaceActions: Array = []; - -export const manifests = [workspace, ...workspaceViews, ...workspaceActions]; +export const manifests = [...workspaceViews]; diff --git a/src/packages/webhooks/workspace/views/overview/index.ts b/src/packages/webhooks/workspace/webhooks/views/index.ts similarity index 100% rename from src/packages/webhooks/workspace/views/overview/index.ts rename to src/packages/webhooks/workspace/webhooks/views/index.ts diff --git a/src/packages/webhooks/workspace/views/overview/manifests.ts b/src/packages/webhooks/workspace/webhooks/views/manifests.ts similarity index 100% rename from src/packages/webhooks/workspace/views/overview/manifests.ts rename to src/packages/webhooks/workspace/webhooks/views/manifests.ts diff --git a/src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts b/src/packages/webhooks/workspace/webhooks/views/webhook-overview-view.element.ts similarity index 100% rename from src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts rename to src/packages/webhooks/workspace/webhooks/views/webhook-overview-view.element.ts diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks/webhooks.context.ts similarity index 94% rename from src/packages/webhooks/workspace/webhooks.context.ts rename to src/packages/webhooks/workspace/webhooks/webhooks.context.ts index 410cb938a2..0182c35877 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks/webhooks.context.ts @@ -1,4 +1,4 @@ -import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; +import { UmbWebhookRepository } from '../../repository/webhooks.repository.js'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; From 96eea403e92e39167fc542b0ea9df246d0adffb1 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 10:31:05 +0100 Subject: [PATCH 36/44] register collection repository and use correct parameters to show list of webhooks --- src/packages/webhooks/collection/manifests.ts | 8 +++++--- .../repository/webhook-collection.server.data-source.ts | 4 ++-- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/packages/webhooks/collection/manifests.ts b/src/packages/webhooks/collection/manifests.ts index 5d01250700..913d773738 100644 --- a/src/packages/webhooks/collection/manifests.ts +++ b/src/packages/webhooks/collection/manifests.ts @@ -1,5 +1,7 @@ -import { UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS } from './repository/index.js'; -import { manifests as collectionRepositoryManifests } from './repository/manifests.js'; +import { + manifests as collectionRepositoryManifests, + UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS, +} from './repository/manifests.js'; import { manifests as collectionViewManifests } from './views/manifests.js'; import { manifests as collectionActionManifests } from './action/manifests.js'; import type { ManifestCollection } from '@umbraco-cms/backoffice/extension-registry'; @@ -18,7 +20,7 @@ const collectionManifest: ManifestCollection = { export const manifests = [ collectionManifest, - //...collectionRepositoryManifests, + ...collectionRepositoryManifests, ...collectionViewManifests, ...collectionActionManifests, ]; diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts index 974168e63b..2a59759ad9 100644 --- a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts +++ b/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts @@ -30,13 +30,13 @@ export class UmbWebhookCollectionServerDataSource implements UmbWebhookCollectio * @memberof UmbWebhookCollectionServerDataSource */ async getCollection(_filter: UmbWebhookCollectionFilterModel) { - const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhookItem({ ids: [''] })); + const { data, error } = await tryExecuteAndNotify(this.#host, WebhookResource.getWebhookItem({})); if (data) { const items = data.map((item) => { const model: UmbWebhookDetailModel = { entityType: UMB_WEBHOOK_ENTITY_TYPE, - unique: item.url, //item.id.toLowerCase(), + unique: item.url, name: item.name, url: item.url, enabled: item.enabled, From 0aef3befeb97a46f79b05505b9898c0711c88bb5 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:02:15 +0100 Subject: [PATCH 37/44] remove unknown alias property --- .../workspace/logviewer/logviewer-workspace.element.ts | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts index d817b96bcc..c0aed6bc80 100644 --- a/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts +++ b/src/packages/log-viewer/workspace/logviewer/logviewer-workspace.element.ts @@ -33,10 +33,7 @@ export class UmbLogViewerWorkspaceElement extends UmbLitElement { } render() { - return html` - - - `; + return html` `; } static styles = [ From fe3415909653a47ebe547bfb8d35fc8def205b8a Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:02:25 +0100 Subject: [PATCH 38/44] move around to register webhooks workspace context --- src/packages/webhooks/index.ts | 3 ++- src/packages/webhooks/menu-item/manifests.ts | 2 +- src/packages/webhooks/workspace/index.ts | 1 + src/packages/webhooks/workspace/manifests.ts | 3 +-- .../webhook-overview-view.element.ts | 4 +-- .../workspace/webhooks-root/manifests.ts | 15 ----------- .../webhook-root-workspace.element.ts | 20 -------------- .../{webhooks => }/webhooks.context.ts | 3 +-- .../webhooks/workspace/webhooks/manifests.ts | 26 ++++++++++++++----- .../workspace/webhooks/views/index.ts | 4 --- .../workspace/webhooks/views/manifests.ts | 13 ---------- .../webhooks/webhook-workspace.element.ts | 23 ++++++++++++++++ 12 files changed, 49 insertions(+), 68 deletions(-) create mode 100644 src/packages/webhooks/workspace/index.ts rename src/packages/webhooks/workspace/{webhooks/views => views/overview}/webhook-overview-view.element.ts (75%) delete mode 100644 src/packages/webhooks/workspace/webhooks-root/manifests.ts delete mode 100644 src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts rename src/packages/webhooks/workspace/{webhooks => }/webhooks.context.ts (90%) delete mode 100644 src/packages/webhooks/workspace/webhooks/views/index.ts delete mode 100644 src/packages/webhooks/workspace/webhooks/views/manifests.ts create mode 100644 src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts diff --git a/src/packages/webhooks/index.ts b/src/packages/webhooks/index.ts index 997c7147e3..fa830d4b75 100644 --- a/src/packages/webhooks/index.ts +++ b/src/packages/webhooks/index.ts @@ -2,5 +2,6 @@ import './components/index.js'; export * from './repository/index.js'; export * from './collection/index.js'; +export * from './workspace/index.js'; -export type { UmbWebhookDetailModel } from './types.js'; +export type * from './types.js'; diff --git a/src/packages/webhooks/menu-item/manifests.ts b/src/packages/webhooks/menu-item/manifests.ts index eaf52d8312..e4d502e06a 100644 --- a/src/packages/webhooks/menu-item/manifests.ts +++ b/src/packages/webhooks/menu-item/manifests.ts @@ -8,7 +8,7 @@ const menuItem: ManifestMenuItem = { meta: { label: 'Webhooks', icon: 'icon-webhook', - entityType: 'webhook-root', + entityType: 'webhooks', menus: ['Umb.Menu.Settings'], }, }; diff --git a/src/packages/webhooks/workspace/index.ts b/src/packages/webhooks/workspace/index.ts new file mode 100644 index 0000000000..cf96ef5bba --- /dev/null +++ b/src/packages/webhooks/workspace/index.ts @@ -0,0 +1 @@ +export * from './webhooks.context.js'; diff --git a/src/packages/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts index 65905cc8c4..9b0d6f690f 100644 --- a/src/packages/webhooks/workspace/manifests.ts +++ b/src/packages/webhooks/workspace/manifests.ts @@ -1,4 +1,3 @@ -import { manifests as webhookRootManifests } from './webhooks-root/manifests.js'; import { manifests as webhookManifests } from './webhooks/manifests.js'; -export const manifests = [...webhookRootManifests, ...webhookManifests]; +export const manifests = [...webhookManifests]; diff --git a/src/packages/webhooks/workspace/webhooks/views/webhook-overview-view.element.ts b/src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts similarity index 75% rename from src/packages/webhooks/workspace/webhooks/views/webhook-overview-view.element.ts rename to src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts index 0a48d3711d..431370de55 100644 --- a/src/packages/webhooks/workspace/webhooks/views/webhook-overview-view.element.ts +++ b/src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts @@ -5,9 +5,7 @@ import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; @customElement('umb-webook-root-workspace') export class UmbWebhookRootWorkspaceElement extends UmbLitElement { render() { - return html` - ; - `; + return html` `; } } diff --git a/src/packages/webhooks/workspace/webhooks-root/manifests.ts b/src/packages/webhooks/workspace/webhooks-root/manifests.ts deleted file mode 100644 index f4ddb81daa..0000000000 --- a/src/packages/webhooks/workspace/webhooks-root/manifests.ts +++ /dev/null @@ -1,15 +0,0 @@ -import type { ManifestWorkspace } from '@umbraco-cms/backoffice/extension-registry'; - -const workspaceAlias = 'Umb.Workspace.Webhooks'; - -const workspace: ManifestWorkspace = { - type: 'workspace', - alias: workspaceAlias, - name: 'Webhook Root Workspace', - js: () => import('./webhook-root-workspace.element.js'), - meta: { - entityType: 'webhook-root', - }, -}; - -export const manifests = [workspace]; diff --git a/src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts b/src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts deleted file mode 100644 index 176eded82f..0000000000 --- a/src/packages/webhooks/workspace/webhooks-root/webhook-root-workspace.element.ts +++ /dev/null @@ -1,20 +0,0 @@ -import { UMB_WEBHOOK_COLLECTION_ALIAS } from '../../collection/index.js'; -import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; -import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; - -@customElement('umb-webhook-root-workspace') -export class UmbWebhookRootWorkspaceElement extends UmbLitElement { - render() { - return html` - ; - `; - } -} - -export default UmbWebhookRootWorkspaceElement; - -declare global { - interface HTMLElementTagNameMap { - 'umb-webhook-root-workspace': UmbWebhookRootWorkspaceElement; - } -} diff --git a/src/packages/webhooks/workspace/webhooks/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts similarity index 90% rename from src/packages/webhooks/workspace/webhooks/webhooks.context.ts rename to src/packages/webhooks/workspace/webhooks.context.ts index 0182c35877..2d5aaa3cd4 100644 --- a/src/packages/webhooks/workspace/webhooks/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -1,11 +1,10 @@ -import { UmbWebhookRepository } from '../../repository/webhooks.repository.js'; +import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import type { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'; -// TODO: Revisit usage of workspace for this case... export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { public readonly workspaceAlias = 'Umb.Workspace.Webhooks'; #repository; diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhooks/workspace/webhooks/manifests.ts index 0745de328e..53bd82f2a8 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhooks/workspace/webhooks/manifests.ts @@ -1,11 +1,23 @@ -import type { ManifestWorkspaceView } from '@umbraco-cms/backoffice/extension-registry'; +import type { ManifestWorkspace, ManifestWorkspaceView } from '@umbraco-cms/backoffice/extension-registry'; + +const workspaceAlias = 'Umb.Workspace.Webhooks'; + +const workspace: ManifestWorkspace = { + type: 'workspace', + alias: workspaceAlias, + name: 'Webhook Root Workspace', + js: () => import('./webhook-workspace.element.js'), + meta: { + entityType: 'webhooks', + }, +}; const workspaceViews: Array = [ { type: 'workspaceView', alias: 'Umb.WorkspaceView.Webhooks.Overview', name: 'Webhooks Root Workspace Overview View', - js: () => import('./views/index.js'), + js: () => import('../views/overview/webhook-overview-view.element.js'), weight: 300, meta: { label: 'Overview', @@ -15,15 +27,15 @@ const workspaceViews: Array = [ conditions: [ { alias: 'Umb.Condition.WorkspaceAlias', - match: 'Umb.Workspace.Webhooks', + match: workspace.alias, }, ], }, - /*{ + { type: 'workspaceView', alias: 'Umb.WorkspaceView.Webhooks.Search', name: 'Webhooks Root Workspace Logs View', - js: () => import('../views/logs/index.js'), + js: () => import('../views/overview/webhook-overview-view.element.js'), weight: 200, meta: { label: 'Logs', @@ -36,7 +48,7 @@ const workspaceViews: Array = [ match: workspace.alias, }, ], - },*/ + }, ]; -export const manifests = [...workspaceViews]; +export const manifests = [workspace, ...workspaceViews]; diff --git a/src/packages/webhooks/workspace/webhooks/views/index.ts b/src/packages/webhooks/workspace/webhooks/views/index.ts deleted file mode 100644 index 391c5b22ac..0000000000 --- a/src/packages/webhooks/workspace/webhooks/views/index.ts +++ /dev/null @@ -1,4 +0,0 @@ -import './components/index.js'; -import { UmbWebhookRootWorkspaceElement } from './webhook-overview-view.element.js'; - -export default UmbWebhookRootWorkspaceElement; diff --git a/src/packages/webhooks/workspace/webhooks/views/manifests.ts b/src/packages/webhooks/workspace/webhooks/views/manifests.ts deleted file mode 100644 index ea8427e117..0000000000 --- a/src/packages/webhooks/workspace/webhooks/views/manifests.ts +++ /dev/null @@ -1,13 +0,0 @@ -import type { ManifestWorkspace } from '@umbraco-cms/backoffice/extension-registry'; - -const workspace: ManifestWorkspace = { - type: 'workspace', - alias: 'Umb.Workspace.WebhookRoot', - name: 'Webhook Root Workspace', - js: () => import('./webhook-overview-view.element.js'), - meta: { - entityType: 'webhook-root', - }, -}; - -export const manifests = [workspace]; diff --git a/src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts b/src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts new file mode 100644 index 0000000000..bb2fcd10d4 --- /dev/null +++ b/src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts @@ -0,0 +1,23 @@ +import { UmbWebhooksWorkspaceContext } from '../webhooks.context.js'; +import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; +import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; + +@customElement('umb-webhook-workspace') +export class UmbWebhookWorkspaceElement extends UmbLitElement { + #webhooksWorkspaceContext = new UmbWebhooksWorkspaceContext(this); + + render() { + return html` + `; + } +} + +export default UmbWebhookWorkspaceElement; + +declare global { + interface HTMLElementTagNameMap { + 'umb-webhook-workspace': UmbWebhookWorkspaceElement; + } +} From e1b12c3df21dda4409a3ea14bd70c39b86433f09 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:44:30 +0100 Subject: [PATCH 39/44] align naming --- src/packages/webhooks/collection/action/manifests.ts | 2 +- src/packages/webhooks/collection/manifests.ts | 2 +- src/packages/webhooks/collection/views/manifests.ts | 2 +- src/packages/webhooks/entity.ts | 4 +--- src/packages/webhooks/umbraco-package.ts | 6 +++--- src/packages/webhooks/workspace/webhooks.context.ts | 9 ++------- 6 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/packages/webhooks/collection/action/manifests.ts b/src/packages/webhooks/collection/action/manifests.ts index bfaabbb79a..e6861fae97 100644 --- a/src/packages/webhooks/collection/action/manifests.ts +++ b/src/packages/webhooks/collection/action/manifests.ts @@ -14,7 +14,7 @@ export const createManifest: ManifestCollectionAction = { conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Webhook', + match: 'Umb.Collection.Webhooks', }, ], }; diff --git a/src/packages/webhooks/collection/manifests.ts b/src/packages/webhooks/collection/manifests.ts index 913d773738..a1a884c82c 100644 --- a/src/packages/webhooks/collection/manifests.ts +++ b/src/packages/webhooks/collection/manifests.ts @@ -6,7 +6,7 @@ import { manifests as collectionViewManifests } from './views/manifests.js'; import { manifests as collectionActionManifests } from './action/manifests.js'; import type { ManifestCollection } from '@umbraco-cms/backoffice/extension-registry'; -export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhook'; +export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhooks'; const collectionManifest: ManifestCollection = { type: 'collection', diff --git a/src/packages/webhooks/collection/views/manifests.ts b/src/packages/webhooks/collection/views/manifests.ts index 2eed3f5374..75a8dda29d 100644 --- a/src/packages/webhooks/collection/views/manifests.ts +++ b/src/packages/webhooks/collection/views/manifests.ts @@ -16,7 +16,7 @@ const tableCollectionView: ManifestCollectionView = { conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Webhook', + match: 'Umb.Collection.Webhooks', }, ], }; diff --git a/src/packages/webhooks/entity.ts b/src/packages/webhooks/entity.ts index 90e4c7b9ed..b6742fd63b 100644 --- a/src/packages/webhooks/entity.ts +++ b/src/packages/webhooks/entity.ts @@ -1,5 +1,3 @@ -export const UMB_WEBHOOK_ENTITY_TYPE = 'webhook'; -export const UMB_WEBHOOK_ROOT_ENTITY_TYPE = 'webhook-root'; +export const UMB_WEBHOOK_ENTITY_TYPE = 'webhooks'; export type UmbWebhookEntityType = typeof UMB_WEBHOOK_ENTITY_TYPE; -export type UmbWebhookRootEntityType = typeof UMB_WEBHOOK_ROOT_ENTITY_TYPE; diff --git a/src/packages/webhooks/umbraco-package.ts b/src/packages/webhooks/umbraco-package.ts index a5c24dd8b6..035cc47070 100644 --- a/src/packages/webhooks/umbraco-package.ts +++ b/src/packages/webhooks/umbraco-package.ts @@ -1,8 +1,8 @@ -export const name = 'Umbraco.Core.Webhook'; +export const name = 'Umbraco.Core.Webhooks'; export const extensions = [ { - name: 'Webhook Bundle', - alias: 'Umb.Bundle.Webhook', + name: 'Webhooks Bundle', + alias: 'Umb.Bundle.Webhooks', type: 'bundle', js: () => import('./manifests.js'), }, diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts index 2d5aaa3cd4..449105d31b 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -1,3 +1,4 @@ +import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity.js'; import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; @@ -10,19 +11,13 @@ export class UmbWebhooksWorkspaceContext extends UmbBaseController implements Um #repository; getEntityType() { - return 'webhooks'; - } - - getEntityName() { - return 'Webhooks'; + return UMB_WEBHOOK_ENTITY_TYPE; } getUnique() { return undefined; } - currentPage = 1; - constructor(host: UmbControllerHostElement) { super(host); this.provideContext(UMB_WORKSPACE_CONTEXT, this); From e23798752a1e19b561bd4e97e39a9ff3fc7e2ef3 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 11:48:19 +0100 Subject: [PATCH 40/44] fix lint errors --- src/packages/webhooks/repository/webhooks.repository.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/packages/webhooks/repository/webhooks.repository.ts b/src/packages/webhooks/repository/webhooks.repository.ts index 4593765abf..51d7820caf 100644 --- a/src/packages/webhooks/repository/webhooks.repository.ts +++ b/src/packages/webhooks/repository/webhooks.repository.ts @@ -1,6 +1,6 @@ import { UmbContextConsumerController } from '@umbraco-cms/backoffice/context-api'; -import { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { UmbNotificationContext } from '@umbraco-cms/backoffice/notification'; +import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; +import type { UmbNotificationContext } from '@umbraco-cms/backoffice/notification'; import { UMB_NOTIFICATION_CONTEXT } from '@umbraco-cms/backoffice/notification'; // Move to documentation / JSdoc @@ -22,6 +22,5 @@ export class UmbWebhookRepository { async requestWebhooks({ skip, take } = { skip: 0, take: 1000 }) { await this.#init; - } } From e23515c8d7822772c2aafd60e4d6560279b40556 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:04:22 +0100 Subject: [PATCH 41/44] fix errors after merge --- src/mocks/data/webhooks.data.ts | 5 ++--- src/packages/webhooks/workspace/webhooks.context.ts | 4 ++-- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/mocks/data/webhooks.data.ts b/src/mocks/data/webhooks.data.ts index a46cc4cb9b..9685f3612e 100644 --- a/src/mocks/data/webhooks.data.ts +++ b/src/mocks/data/webhooks.data.ts @@ -1,13 +1,12 @@ -import { UmbData } from './data.js'; +import { UmbMockDBBase } from './utils/mock-db-base.js'; //import { // WebhooksResponseModel, //} from '@umbraco-cms/backoffice/backend-api'; -class UmbWebhooksData extends UmbData { +class UmbWebhooksData extends UmbMockDBBase { constructor(data: any[]) { super(data); } - } export const umbWebhooksData = { diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhooks/workspace/webhooks.context.ts index 449105d31b..9d6f760934 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhooks/workspace/webhooks.context.ts @@ -1,12 +1,12 @@ import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity.js'; import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; -import { UmbBaseController } from '@umbraco-cms/backoffice/class-api'; +import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import type { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'; -export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface { +export class UmbWebhooksWorkspaceContext extends UmbControllerBase implements UmbWorkspaceContextInterface { public readonly workspaceAlias = 'Umb.Workspace.Webhooks'; #repository; From 5c71e80776d8c51c48f62036b032b4822af1d999 Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:37:19 +0100 Subject: [PATCH 42/44] rename 'webhooks' to 'webhook' (singular) --- src/apps/backoffice/backoffice.element.ts | 2 +- .../collection/action/manifests.ts | 2 +- .../{webhooks => webhook}/collection/index.ts | 0 .../collection/manifests.ts | 2 +- .../collection/repository/index.ts | 0 .../collection/repository/manifests.ts | 0 .../collection/repository/types.ts | 0 .../webhook-collection.repository.ts | 0 .../webhook-collection.server.data-source.ts | 0 .../{webhooks => webhook}/collection/types.ts | 0 .../collection/views/index.ts | 0 .../collection/views/manifests.ts | 2 +- ...ook-table-boolean-column-layout.element.ts | 0 ...le-entity-actions-column-layout.element.ts | 0 ...ebhook-table-name-column-layout.element.ts | 0 .../webhook-table-collection-view.element.ts | 0 src/packages/webhook/entity.ts | 4 +++ src/packages/{webhooks => webhook}/index.ts | 1 - src/packages/webhook/manifests.ts | 5 ++++ .../menu-item/manifests.ts | 7 ++--- src/packages/{webhooks => webhook}/types.ts | 0 src/packages/webhook/umbraco-package.ts | 9 +++++++ src/packages/webhook/workspace/index.ts | 1 + src/packages/webhook/workspace/manifests.ts | 3 +++ .../overview/webhook-overview-view.element.ts | 0 .../workspace/webhook.context.ts} | 15 ++++------- .../workspace/webhook}/manifests.ts | 15 +++++------ .../webhook}/webhook-workspace.element.ts | 8 ++++-- src/packages/webhooks/entity.ts | 3 --- src/packages/webhooks/manifests.ts | 13 ---------- src/packages/webhooks/repository/index.ts | 1 - src/packages/webhooks/repository/manifests.ts | 4 --- .../repository/webhooks.repository.ts | 26 ------------------- src/packages/webhooks/umbraco-package.ts | 9 ------- src/packages/webhooks/workspace/index.ts | 1 - src/packages/webhooks/workspace/manifests.ts | 3 --- 36 files changed, 48 insertions(+), 88 deletions(-) rename src/packages/{webhooks => webhook}/collection/action/manifests.ts (94%) rename src/packages/{webhooks => webhook}/collection/index.ts (100%) rename src/packages/{webhooks => webhook}/collection/manifests.ts (99%) rename src/packages/{webhooks => webhook}/collection/repository/index.ts (100%) rename src/packages/{webhooks => webhook}/collection/repository/manifests.ts (100%) rename src/packages/{webhooks => webhook}/collection/repository/types.ts (100%) rename src/packages/{webhooks => webhook}/collection/repository/webhook-collection.repository.ts (100%) rename src/packages/{webhooks => webhook}/collection/repository/webhook-collection.server.data-source.ts (100%) rename src/packages/{webhooks => webhook}/collection/types.ts (100%) rename src/packages/{webhooks => webhook}/collection/views/index.ts (100%) rename src/packages/{webhooks => webhook}/collection/views/manifests.ts (94%) rename src/packages/{webhooks => webhook}/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts (100%) rename src/packages/{webhooks => webhook}/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts (100%) rename src/packages/{webhooks => webhook}/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts (100%) rename src/packages/{webhooks => webhook}/collection/views/table/webhook-table-collection-view.element.ts (100%) create mode 100644 src/packages/webhook/entity.ts rename src/packages/{webhooks => webhook}/index.ts (78%) create mode 100644 src/packages/webhook/manifests.ts rename src/packages/{webhooks => webhook}/menu-item/manifests.ts (65%) rename src/packages/{webhooks => webhook}/types.ts (100%) create mode 100644 src/packages/webhook/umbraco-package.ts create mode 100644 src/packages/webhook/workspace/index.ts create mode 100644 src/packages/webhook/workspace/manifests.ts rename src/packages/{webhooks => webhook}/workspace/views/overview/webhook-overview-view.element.ts (100%) rename src/packages/{webhooks/workspace/webhooks.context.ts => webhook/workspace/webhook.context.ts} (57%) rename src/packages/{webhooks/workspace/webhooks => webhook/workspace/webhook}/manifests.ts (74%) rename src/packages/{webhooks/workspace/webhooks => webhook/workspace/webhook}/webhook-workspace.element.ts (65%) delete mode 100644 src/packages/webhooks/entity.ts delete mode 100644 src/packages/webhooks/manifests.ts delete mode 100644 src/packages/webhooks/repository/index.ts delete mode 100644 src/packages/webhooks/repository/manifests.ts delete mode 100644 src/packages/webhooks/repository/webhooks.repository.ts delete mode 100644 src/packages/webhooks/umbraco-package.ts delete mode 100644 src/packages/webhooks/workspace/index.ts delete mode 100644 src/packages/webhooks/workspace/manifests.ts diff --git a/src/apps/backoffice/backoffice.element.ts b/src/apps/backoffice/backoffice.element.ts index 14f41066b3..923ebbc225 100644 --- a/src/apps/backoffice/backoffice.element.ts +++ b/src/apps/backoffice/backoffice.element.ts @@ -36,7 +36,7 @@ const CORE_PACKAGES = [ import('../../packages/tiny-mce/umbraco-package.js'), import('../../packages/umbraco-news/umbraco-package.js'), import('../../packages/user/umbraco-package.js'), - import('../../packages/webhooks/umbraco-package.js'), + import('../../packages/webhook/umbraco-package.js'), ]; @customElement('umb-backoffice') diff --git a/src/packages/webhooks/collection/action/manifests.ts b/src/packages/webhook/collection/action/manifests.ts similarity index 94% rename from src/packages/webhooks/collection/action/manifests.ts rename to src/packages/webhook/collection/action/manifests.ts index e6861fae97..bfaabbb79a 100644 --- a/src/packages/webhooks/collection/action/manifests.ts +++ b/src/packages/webhook/collection/action/manifests.ts @@ -14,7 +14,7 @@ export const createManifest: ManifestCollectionAction = { conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Webhooks', + match: 'Umb.Collection.Webhook', }, ], }; diff --git a/src/packages/webhooks/collection/index.ts b/src/packages/webhook/collection/index.ts similarity index 100% rename from src/packages/webhooks/collection/index.ts rename to src/packages/webhook/collection/index.ts diff --git a/src/packages/webhooks/collection/manifests.ts b/src/packages/webhook/collection/manifests.ts similarity index 99% rename from src/packages/webhooks/collection/manifests.ts rename to src/packages/webhook/collection/manifests.ts index a1a884c82c..913d773738 100644 --- a/src/packages/webhooks/collection/manifests.ts +++ b/src/packages/webhook/collection/manifests.ts @@ -6,7 +6,7 @@ import { manifests as collectionViewManifests } from './views/manifests.js'; import { manifests as collectionActionManifests } from './action/manifests.js'; import type { ManifestCollection } from '@umbraco-cms/backoffice/extension-registry'; -export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhooks'; +export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhook'; const collectionManifest: ManifestCollection = { type: 'collection', diff --git a/src/packages/webhooks/collection/repository/index.ts b/src/packages/webhook/collection/repository/index.ts similarity index 100% rename from src/packages/webhooks/collection/repository/index.ts rename to src/packages/webhook/collection/repository/index.ts diff --git a/src/packages/webhooks/collection/repository/manifests.ts b/src/packages/webhook/collection/repository/manifests.ts similarity index 100% rename from src/packages/webhooks/collection/repository/manifests.ts rename to src/packages/webhook/collection/repository/manifests.ts diff --git a/src/packages/webhooks/collection/repository/types.ts b/src/packages/webhook/collection/repository/types.ts similarity index 100% rename from src/packages/webhooks/collection/repository/types.ts rename to src/packages/webhook/collection/repository/types.ts diff --git a/src/packages/webhooks/collection/repository/webhook-collection.repository.ts b/src/packages/webhook/collection/repository/webhook-collection.repository.ts similarity index 100% rename from src/packages/webhooks/collection/repository/webhook-collection.repository.ts rename to src/packages/webhook/collection/repository/webhook-collection.repository.ts diff --git a/src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts b/src/packages/webhook/collection/repository/webhook-collection.server.data-source.ts similarity index 100% rename from src/packages/webhooks/collection/repository/webhook-collection.server.data-source.ts rename to src/packages/webhook/collection/repository/webhook-collection.server.data-source.ts diff --git a/src/packages/webhooks/collection/types.ts b/src/packages/webhook/collection/types.ts similarity index 100% rename from src/packages/webhooks/collection/types.ts rename to src/packages/webhook/collection/types.ts diff --git a/src/packages/webhooks/collection/views/index.ts b/src/packages/webhook/collection/views/index.ts similarity index 100% rename from src/packages/webhooks/collection/views/index.ts rename to src/packages/webhook/collection/views/index.ts diff --git a/src/packages/webhooks/collection/views/manifests.ts b/src/packages/webhook/collection/views/manifests.ts similarity index 94% rename from src/packages/webhooks/collection/views/manifests.ts rename to src/packages/webhook/collection/views/manifests.ts index 75a8dda29d..2eed3f5374 100644 --- a/src/packages/webhooks/collection/views/manifests.ts +++ b/src/packages/webhook/collection/views/manifests.ts @@ -16,7 +16,7 @@ const tableCollectionView: ManifestCollectionView = { conditions: [ { alias: UMB_COLLECTION_ALIAS_CONDITION, - match: 'Umb.Collection.Webhooks', + match: 'Umb.Collection.Webhook', }, ], }; diff --git a/src/packages/webhooks/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts b/src/packages/webhook/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts similarity index 100% rename from src/packages/webhooks/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts rename to src/packages/webhook/collection/views/table/column-layouts/boolean/webhook-table-boolean-column-layout.element.ts diff --git a/src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts b/src/packages/webhook/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts similarity index 100% rename from src/packages/webhooks/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts rename to src/packages/webhook/collection/views/table/column-layouts/entity-actions/webhook-table-entity-actions-column-layout.element.ts diff --git a/src/packages/webhooks/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts b/src/packages/webhook/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts similarity index 100% rename from src/packages/webhooks/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts rename to src/packages/webhook/collection/views/table/column-layouts/name/webhook-table-name-column-layout.element.ts diff --git a/src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts b/src/packages/webhook/collection/views/table/webhook-table-collection-view.element.ts similarity index 100% rename from src/packages/webhooks/collection/views/table/webhook-table-collection-view.element.ts rename to src/packages/webhook/collection/views/table/webhook-table-collection-view.element.ts diff --git a/src/packages/webhook/entity.ts b/src/packages/webhook/entity.ts new file mode 100644 index 0000000000..f78d477122 --- /dev/null +++ b/src/packages/webhook/entity.ts @@ -0,0 +1,4 @@ +export const UMB_WEBHOOK_ENTITY_TYPE = 'webhook'; +export const UMB_WEBHOOK_WORKSPACE = 'Umb.Workspace.Webhook'; + +export type UmbWebhookEntityType = typeof UMB_WEBHOOK_ENTITY_TYPE; diff --git a/src/packages/webhooks/index.ts b/src/packages/webhook/index.ts similarity index 78% rename from src/packages/webhooks/index.ts rename to src/packages/webhook/index.ts index fa830d4b75..85eed50a10 100644 --- a/src/packages/webhooks/index.ts +++ b/src/packages/webhook/index.ts @@ -1,6 +1,5 @@ import './components/index.js'; -export * from './repository/index.js'; export * from './collection/index.js'; export * from './workspace/index.js'; diff --git a/src/packages/webhook/manifests.ts b/src/packages/webhook/manifests.ts new file mode 100644 index 0000000000..f5ebb840c6 --- /dev/null +++ b/src/packages/webhook/manifests.ts @@ -0,0 +1,5 @@ +import { manifests as treeManifests } from './menu-item/manifests.js'; +import { manifests as workspaceManifests } from './workspace/manifests.js'; +import { manifests as collectionManifests } from './collection/manifests.js'; + +export const manifests = [...treeManifests, ...workspaceManifests, ...collectionManifests]; diff --git a/src/packages/webhooks/menu-item/manifests.ts b/src/packages/webhook/menu-item/manifests.ts similarity index 65% rename from src/packages/webhooks/menu-item/manifests.ts rename to src/packages/webhook/menu-item/manifests.ts index e4d502e06a..fd32d80af7 100644 --- a/src/packages/webhooks/menu-item/manifests.ts +++ b/src/packages/webhook/menu-item/manifests.ts @@ -1,14 +1,15 @@ import type { ManifestMenuItem } from '@umbraco-cms/backoffice/extension-registry'; +import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity'; const menuItem: ManifestMenuItem = { type: 'menuItem', - alias: 'Umb.MenuItem.Webhooks', - name: 'Webhooks Menu Item', + alias: 'Umb.MenuItem.Webhook', + name: 'Webhook Menu Item', weight: 100, meta: { label: 'Webhooks', icon: 'icon-webhook', - entityType: 'webhooks', + entityType: UMB_WEBHOOK_ENTITY_TYPE, menus: ['Umb.Menu.Settings'], }, }; diff --git a/src/packages/webhooks/types.ts b/src/packages/webhook/types.ts similarity index 100% rename from src/packages/webhooks/types.ts rename to src/packages/webhook/types.ts diff --git a/src/packages/webhook/umbraco-package.ts b/src/packages/webhook/umbraco-package.ts new file mode 100644 index 0000000000..a5c24dd8b6 --- /dev/null +++ b/src/packages/webhook/umbraco-package.ts @@ -0,0 +1,9 @@ +export const name = 'Umbraco.Core.Webhook'; +export const extensions = [ + { + name: 'Webhook Bundle', + alias: 'Umb.Bundle.Webhook', + type: 'bundle', + js: () => import('./manifests.js'), + }, +]; diff --git a/src/packages/webhook/workspace/index.ts b/src/packages/webhook/workspace/index.ts new file mode 100644 index 0000000000..897634ac15 --- /dev/null +++ b/src/packages/webhook/workspace/index.ts @@ -0,0 +1 @@ +export * from './webhook.context.js'; diff --git a/src/packages/webhook/workspace/manifests.ts b/src/packages/webhook/workspace/manifests.ts new file mode 100644 index 0000000000..64e980a76e --- /dev/null +++ b/src/packages/webhook/workspace/manifests.ts @@ -0,0 +1,3 @@ +import { manifests as webhookManifests } from './webhook/manifests.js'; + +export const manifests = [...webhookManifests]; diff --git a/src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts b/src/packages/webhook/workspace/views/overview/webhook-overview-view.element.ts similarity index 100% rename from src/packages/webhooks/workspace/views/overview/webhook-overview-view.element.ts rename to src/packages/webhook/workspace/views/overview/webhook-overview-view.element.ts diff --git a/src/packages/webhooks/workspace/webhooks.context.ts b/src/packages/webhook/workspace/webhook.context.ts similarity index 57% rename from src/packages/webhooks/workspace/webhooks.context.ts rename to src/packages/webhook/workspace/webhook.context.ts index 9d6f760934..8172f2a6f7 100644 --- a/src/packages/webhooks/workspace/webhooks.context.ts +++ b/src/packages/webhook/workspace/webhook.context.ts @@ -1,14 +1,12 @@ -import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity.js'; -import { UmbWebhookRepository } from '../repository/webhooks.repository.js'; +import { UMB_WEBHOOK_ENTITY_TYPE, UMB_WEBHOOK_WORKSPACE } from '../entity.js'; import type { UmbControllerHostElement } from '@umbraco-cms/backoffice/controller-api'; import { UmbControllerBase } from '@umbraco-cms/backoffice/class-api'; import { UmbContextToken } from '@umbraco-cms/backoffice/context-api'; import type { UmbWorkspaceContextInterface } from '@umbraco-cms/backoffice/workspace'; import { UMB_WORKSPACE_CONTEXT } from '@umbraco-cms/backoffice/workspace'; -export class UmbWebhooksWorkspaceContext extends UmbControllerBase implements UmbWorkspaceContextInterface { - public readonly workspaceAlias = 'Umb.Workspace.Webhooks'; - #repository; +export class UmbWebhookWorkspaceContext extends UmbControllerBase implements UmbWorkspaceContextInterface { + public readonly workspaceAlias = UMB_WEBHOOK_WORKSPACE; getEntityType() { return UMB_WEBHOOK_ENTITY_TYPE; @@ -22,11 +20,8 @@ export class UmbWebhooksWorkspaceContext extends UmbControllerBase implements Um super(host); this.provideContext(UMB_WORKSPACE_CONTEXT, this); // TODO: Revisit usage of workspace for this case... currently no other workspace context provides them self with their own token. - this.provideContext(UMB_APP_WEBHOOKS_CONTEXT, this); - this.#repository = new UmbWebhookRepository(host); + this.provideContext(UMB_APP_WEBHOOK_CONTEXT, this); } } -export const UMB_APP_WEBHOOKS_CONTEXT = new UmbContextToken( - UmbWebhooksWorkspaceContext.name, -); +export const UMB_APP_WEBHOOK_CONTEXT = new UmbContextToken(UmbWebhookWorkspaceContext.name); diff --git a/src/packages/webhooks/workspace/webhooks/manifests.ts b/src/packages/webhook/workspace/webhook/manifests.ts similarity index 74% rename from src/packages/webhooks/workspace/webhooks/manifests.ts rename to src/packages/webhook/workspace/webhook/manifests.ts index 53bd82f2a8..164e767189 100644 --- a/src/packages/webhooks/workspace/webhooks/manifests.ts +++ b/src/packages/webhook/workspace/webhook/manifests.ts @@ -1,22 +1,21 @@ +import { UMB_WEBHOOK_ENTITY_TYPE, UMB_WEBHOOK_WORKSPACE } from '../../entity.js'; import type { ManifestWorkspace, ManifestWorkspaceView } from '@umbraco-cms/backoffice/extension-registry'; -const workspaceAlias = 'Umb.Workspace.Webhooks'; - const workspace: ManifestWorkspace = { type: 'workspace', - alias: workspaceAlias, + alias: UMB_WEBHOOK_WORKSPACE, name: 'Webhook Root Workspace', js: () => import('./webhook-workspace.element.js'), meta: { - entityType: 'webhooks', + entityType: UMB_WEBHOOK_ENTITY_TYPE, }, }; const workspaceViews: Array = [ { type: 'workspaceView', - alias: 'Umb.WorkspaceView.Webhooks.Overview', - name: 'Webhooks Root Workspace Overview View', + alias: 'Umb.WorkspaceView.Webhook.Overview', + name: 'Webhook Root Workspace Overview View', js: () => import('../views/overview/webhook-overview-view.element.js'), weight: 300, meta: { @@ -33,8 +32,8 @@ const workspaceViews: Array = [ }, { type: 'workspaceView', - alias: 'Umb.WorkspaceView.Webhooks.Search', - name: 'Webhooks Root Workspace Logs View', + alias: 'Umb.WorkspaceView.Webhook.Search', + name: 'Webhook Root Workspace Logs View', js: () => import('../views/overview/webhook-overview-view.element.js'), weight: 200, meta: { diff --git a/src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts b/src/packages/webhook/workspace/webhook/webhook-workspace.element.ts similarity index 65% rename from src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts rename to src/packages/webhook/workspace/webhook/webhook-workspace.element.ts index bb2fcd10d4..53679499cd 100644 --- a/src/packages/webhooks/workspace/webhooks/webhook-workspace.element.ts +++ b/src/packages/webhook/workspace/webhook/webhook-workspace.element.ts @@ -1,10 +1,14 @@ -import { UmbWebhooksWorkspaceContext } from '../webhooks.context.js'; +import { UmbWebhookWorkspaceContext } from '../webhook.context.js'; import { html, customElement } from '@umbraco-cms/backoffice/external/lit'; import { UmbLitElement } from '@umbraco-cms/backoffice/lit-element'; @customElement('umb-webhook-workspace') export class UmbWebhookWorkspaceElement extends UmbLitElement { - #webhooksWorkspaceContext = new UmbWebhooksWorkspaceContext(this); + /** + * The context for the webhook workspace. + * This is used to provide the workspace with the necessary data and services even though it does not have any references. + */ + #webhookWorkspaceContext = new UmbWebhookWorkspaceContext(this); render() { return html` context -> repository -> (store) -> data source -// All methods should be async and return a promise. Some methods might return an observable as part of the promise response. -export class UmbWebhookRepository { - #host: UmbControllerHostElement; - #notificationService?: UmbNotificationContext; - #init; - - constructor(host: UmbControllerHostElement) { - this.#host = host; - - this.#init = new UmbContextConsumerController(this.#host, UMB_NOTIFICATION_CONTEXT, (instance) => { - this.#notificationService = instance; - }).asPromise(); - } - - async requestWebhooks({ skip, take } = { skip: 0, take: 1000 }) { - await this.#init; - } -} diff --git a/src/packages/webhooks/umbraco-package.ts b/src/packages/webhooks/umbraco-package.ts deleted file mode 100644 index 035cc47070..0000000000 --- a/src/packages/webhooks/umbraco-package.ts +++ /dev/null @@ -1,9 +0,0 @@ -export const name = 'Umbraco.Core.Webhooks'; -export const extensions = [ - { - name: 'Webhooks Bundle', - alias: 'Umb.Bundle.Webhooks', - type: 'bundle', - js: () => import('./manifests.js'), - }, -]; diff --git a/src/packages/webhooks/workspace/index.ts b/src/packages/webhooks/workspace/index.ts deleted file mode 100644 index cf96ef5bba..0000000000 --- a/src/packages/webhooks/workspace/index.ts +++ /dev/null @@ -1 +0,0 @@ -export * from './webhooks.context.js'; diff --git a/src/packages/webhooks/workspace/manifests.ts b/src/packages/webhooks/workspace/manifests.ts deleted file mode 100644 index 9b0d6f690f..0000000000 --- a/src/packages/webhooks/workspace/manifests.ts +++ /dev/null @@ -1,3 +0,0 @@ -import { manifests as webhookManifests } from './webhooks/manifests.js'; - -export const manifests = [...webhookManifests]; From 73c6b4bbf630078195321759d72bad4abe224def Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:37:25 +0100 Subject: [PATCH 43/44] generate global export --- package.json | 1 + tsconfig.json | 1 + 2 files changed, 2 insertions(+) diff --git a/package.json b/package.json index fec9e8be0d..7e553a4a3d 100644 --- a/package.json +++ b/package.json @@ -83,6 +83,7 @@ "./user": "./dist-cms/packages/user/user/index.js", "./utils": "./dist-cms/packages/core/utils/index.js", "./variant": "./dist-cms/packages/core/variant/index.js", + "./webhook": "./dist-cms/packages/webhook/index.js", "./workspace": "./dist-cms/packages/core/workspace/index.js", "./external/backend-api": "./dist-cms/external/backend-api/index.js", "./external/dompurify": "./dist-cms/external/dompurify/index.js", diff --git a/tsconfig.json b/tsconfig.json index d685b5fa3d..2a82dbb81e 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -101,6 +101,7 @@ "@umbraco-cms/backoffice/user": ["./src/packages/user/user/index.ts"], "@umbraco-cms/backoffice/utils": ["./src/packages/core/utils/index.ts"], "@umbraco-cms/backoffice/variant": ["./src/packages/core/variant/index.ts"], + "@umbraco-cms/backoffice/webhook": ["./src/packages/webhook/index.ts"], "@umbraco-cms/backoffice/workspace": ["./src/packages/core/workspace/index.ts"], "@umbraco-cms/backoffice/external/backend-api": ["./src/external/backend-api/index.ts"], "@umbraco-cms/backoffice/external/dompurify": ["./src/external/dompurify/index.ts"], From 620dd0d5839f2b7c78c17f94c601a462fe72dfce Mon Sep 17 00:00:00 2001 From: Jacob Overgaard <752371+iOvergaard@users.noreply.github.com> Date: Thu, 29 Feb 2024 13:43:14 +0100 Subject: [PATCH 44/44] fix lint error --- src/packages/webhook/menu-item/manifests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/packages/webhook/menu-item/manifests.ts b/src/packages/webhook/menu-item/manifests.ts index fd32d80af7..cba613ace3 100644 --- a/src/packages/webhook/menu-item/manifests.ts +++ b/src/packages/webhook/menu-item/manifests.ts @@ -1,5 +1,5 @@ +import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity.js'; import type { ManifestMenuItem } from '@umbraco-cms/backoffice/extension-registry'; -import { UMB_WEBHOOK_ENTITY_TYPE } from '../entity'; const menuItem: ManifestMenuItem = { type: 'menuItem',