Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: Webhooks workspace #962

Merged
merged 51 commits into from
Feb 29, 2024
Merged
Show file tree
Hide file tree
Changes from 48 commits
Commits
Show all changes
51 commits
Select commit Hold shift + click to select a range
cbab06e
Add webhooks workspace
bjarnef Nov 3, 2023
06ac012
Update workspace alias for log viewer
bjarnef Nov 3, 2023
b7b1e6c
Rename entity type
bjarnef Nov 3, 2023
da2610e
Comment import of components
bjarnef Nov 3, 2023
7c0b555
Add repository and context
bjarnef Nov 3, 2023
30dad4c
Export repository
bjarnef Nov 5, 2023
533ac91
Set workspace context
bjarnef Nov 5, 2023
6bbddc4
Include webhooks
bjarnef Nov 5, 2023
5aeb024
Add webhooks package
bjarnef Nov 5, 2023
1aafc82
Add webhook handlers
bjarnef Nov 5, 2023
312e0d8
Fix typo
bjarnef Nov 5, 2023
4a39b06
Set webhooks context
bjarnef Nov 5, 2023
e4cb9e6
Update logs icon
bjarnef Nov 5, 2023
740aac2
Prepare table data
bjarnef Nov 5, 2023
bc0d3a0
Fix renamed repository
bjarnef Nov 5, 2023
5208f42
Revert "Update workspace alias for log viewer"
bjarnef Nov 6, 2023
7cdc643
Merge branch 'main' into feature/webhooks-workspace
bjarnef Nov 26, 2023
d1e8747
Merge branch 'main' into feature/webhooks-workspace
bjarnef Nov 28, 2023
82f5a11
Merge branch 'main' of github.com:umbraco/Umbraco.CMS.Backoffice into…
bjarnef Feb 26, 2024
590405b
Add webhook models
bjarnef Feb 26, 2024
6426c10
Move workspace
bjarnef Feb 26, 2024
79ed1ef
Update using new collection view
bjarnef Feb 26, 2024
43f0219
Update manifests
bjarnef Feb 26, 2024
267967b
Add package bundle
bjarnef Feb 26, 2024
9259cdd
Update icon
bjarnef Feb 26, 2024
e40ce60
Include handlers
bjarnef Feb 26, 2024
228e0ae
Adjust table collection for webhook
bjarnef Feb 26, 2024
e65fb99
Adjust manifest files
bjarnef Feb 26, 2024
d2ecd49
Correction
bjarnef Feb 26, 2024
03ce138
Rename
bjarnef Feb 27, 2024
f650de8
Merge branch 'main' of github.com:umbraco/Umbraco.CMS.Backoffice into…
bjarnef Feb 27, 2024
b9055f3
Overview workspace
bjarnef Feb 27, 2024
d1fbb46
Merge remote-tracking branch 'origin/main' into pr/bjarnef/962
iOvergaard Feb 29, 2024
2f70fc5
reset language manifests file
iOvergaard Feb 29, 2024
a1333db
fix models
iOvergaard Feb 29, 2024
ce22707
remove global context
iOvergaard Feb 29, 2024
91eb661
fix interface implementation
iOvergaard Feb 29, 2024
1bb00ae
remove outcommented lines
iOvergaard Feb 29, 2024
4e96328
register the webhooks package globally
iOvergaard Feb 29, 2024
70f19d0
move files around to align with other workspaces and fix webhook root…
iOvergaard Feb 29, 2024
96eea40
register collection repository and use correct parameters to show lis…
iOvergaard Feb 29, 2024
0aef3be
remove unknown alias property
iOvergaard Feb 29, 2024
fe34159
move around to register webhooks workspace context
iOvergaard Feb 29, 2024
e1b12c3
align naming
iOvergaard Feb 29, 2024
e237987
fix lint errors
iOvergaard Feb 29, 2024
e9cff58
Merge branch 'main' of https://github.com/umbraco/Umbraco.CMS.Backoff…
iOvergaard Feb 29, 2024
08d7e35
Merge remote-tracking branch 'origin/main' into pr/bjarnef/962
iOvergaard Feb 29, 2024
e23515c
fix errors after merge
iOvergaard Feb 29, 2024
5c71e80
rename 'webhooks' to 'webhook' (singular)
iOvergaard Feb 29, 2024
73c6b4b
generate global export
iOvergaard Feb 29, 2024
620dd0d
fix lint error
iOvergaard Feb 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/apps/backoffice/backoffice.element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/da-dk.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,7 @@ export default {
settingsGroup: 'Indstillinger',
templatingGroup: 'Design og layout',
thirdPartyGroup: 'Tredjepart',
webhooks: 'Webhooks',
},
update: {
updateAvailable: 'Ny opdatering er klar',
Expand Down
1 change: 1 addition & 0 deletions src/assets/lang/en-us.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1782,6 +1782,7 @@ export default {
settingsGroup: 'Settings',
templatingGroup: 'Templating',
thirdPartyGroup: 'Third Party',
webhooks: 'Webhooks',
},
update: {
updateAvailable: 'New update ready',
Expand Down
2 changes: 2 additions & 0 deletions src/mocks/browser-handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -52,6 +53,7 @@ const handlers = [
...installHandlers,
...languageHandlers,
...logViewerHandlers,
...webhookHandlers,
...mediaHandlers,
...mediaTypeHandlers,
...memberGroupHandlers,
Expand Down
14 changes: 14 additions & 0 deletions src/mocks/data/webhooks.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
import { UmbMockDBBase } from './utils/mock-db-base.js';
//import {
// WebhooksResponseModel,
//} from '@umbraco-cms/backoffice/backend-api';

class UmbWebhooksData extends UmbMockDBBase<any> {
constructor(data: any[]) {
super(data);
}
}

export const umbWebhooksData = {
//webhooks: new UmbWebhooksData(webhooks),
};
3 changes: 2 additions & 1 deletion src/mocks/handlers/log-viewer.handlers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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));
Expand Down
6 changes: 6 additions & 0 deletions src/mocks/handlers/webhook.handlers.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const { rest } = window.MockServiceWorker;
//import { umbracoPath } from '@umbraco-cms/backoffice/utils';

export const handlers = [

];
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,7 @@ export class UmbLogViewerWorkspaceElement extends UmbLitElement {
}

render() {
return html`
<umb-workspace-editor alias="Umb.Workspace.LogViewer" headline="Log Viewer" .enforceNoFooter=${true}>
</umb-workspace-editor>
`;
return html` <umb-workspace-editor headline="Log Viewer" .enforceNoFooter=${true}> </umb-workspace-editor> `;
}

static styles = [
Expand Down
22 changes: 22 additions & 0 deletions src/packages/webhooks/collection/action/manifests.ts
Original file line number Diff line number Diff line change
@@ -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.Webhooks',
},
],
};

export const manifests = [createManifest];
2 changes: 2 additions & 0 deletions src/packages/webhooks/collection/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { UmbWebhookCollectionRepository } from './repository/index.js';
export { UMB_WEBHOOK_COLLECTION_ALIAS } from './manifests.js';
26 changes: 26 additions & 0 deletions src/packages/webhooks/collection/manifests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
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';

export const UMB_WEBHOOK_COLLECTION_ALIAS = 'Umb.Collection.Webhooks';

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,
];
2 changes: 2 additions & 0 deletions src/packages/webhooks/collection/repository/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export { UMB_WEBHOOK_COLLECTION_REPOSITORY_ALIAS } from './manifests.js';
export { UmbWebhookCollectionRepository } from './webhook-collection.repository.js';
12 changes: 12 additions & 0 deletions src/packages/webhooks/collection/repository/manifests.ts
Original file line number Diff line number Diff line change
@@ -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];
8 changes: 8 additions & 0 deletions src/packages/webhooks/collection/repository/types.ts
Original file line number Diff line number Diff line change
@@ -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
>;
Original file line number Diff line number Diff line change
@@ -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;
Original file line number Diff line number Diff line change
@@ -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 { 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 UmbWebhookCollectionServerDataSource {
#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 {UmbWebhookCollectionFilterModel} filter
* @return {*}
* @memberof UmbWebhookCollectionServerDataSource
*/
async getCollection(_filter: UmbWebhookCollectionFilterModel) {
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,
name: item.name,
url: item.url,
enabled: item.enabled,
events: item.events.split(','),
types: item.types.split(','),
};

return model;
});

return { data: { items, total: data.length } };
}

return { error };
}
}
4 changes: 4 additions & 0 deletions src/packages/webhooks/collection/types.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
export interface UmbWebhookCollectionFilterModel {
skip?: number;
take?: number;
}
1 change: 1 addition & 0 deletions src/packages/webhooks/collection/views/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export { UMB_WEBHOOK_TABLE_COLLECTION_VIEW_ALIAS } from './manifests.js';
24 changes: 24 additions & 0 deletions src/packages/webhooks/collection/views/manifests.ts
Original file line number Diff line number Diff line change
@@ -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_WEBHOOK_TABLE_COLLECTION_VIEW_ALIAS = 'Umb.CollectionView.Webhook.Table';

const tableCollectionView: ManifestCollectionView = {
type: 'collectionView',
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',
pathName: 'table',
},
conditions: [
{
alias: UMB_COLLECTION_ALIAS_CONDITION,
match: 'Umb.Collection.Webhooks',
},
],
};

export const manifests = [tableCollectionView];
Original file line number Diff line number Diff line change
@@ -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-webhook-table-boolean-column-layout')
export class UmbWebhookTableBooleanColumnLayoutElement extends UmbLitElement {
@property({ attribute: false })
value = false;

render() {
return this.value ? html`<uui-icon name="icon-check"></uui-icon>` : nothing;
}
}

declare global {
interface HTMLElementTagNameMap {
'umb-webhook-table-boolean-column-layout': UmbWebhookTableBooleanColumnLayoutElement;
}
}
Original file line number Diff line number Diff line change
@@ -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`
<umb-dropdown .open=${this._isOpen} compact hide-expand>
<uui-symbol-more slot="label"></uui-symbol-more>
<umb-entity-action-list
@action-executed=${this.#onActionExecuted}
entity-type=${this.value.entityType}
unique=${ifDefined(this.value.unique)}></umb-entity-action-list>
</umb-dropdown>
`;
}
}

declare global {
interface HTMLElementTagNameMap {
'umb-webhook-table-entity-actions-column-layout': UmbWebhookTableEntityActionsColumnLayoutElement;
}
}
Original file line number Diff line number Diff line change
@@ -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-w-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`<a href=${'section/settings/workspace/language/edit/' + this.value.unique}>${this.value.name}</a>`;
}

static styles = [UmbTextStyles];
}

declare global {
interface HTMLElementTagNameMap {
'umb-language-table-name-column-layout': UmbLanguageTableNameColumnLayoutElement;
}
}
Loading
Loading