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 15 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 package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
iOvergaard marked this conversation as resolved.
Show resolved Hide resolved
"./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",
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 @@ -1751,6 +1751,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 @@ -1741,6 +1741,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 @@ -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';
Expand Down Expand Up @@ -60,6 +61,7 @@ const handlers = [
...cultureHandlers,
...redirectManagementHandlers,
...logViewerHandlers,
...webhookHandlers,
...packageHandlers,
...rteEmbedHandlers,
...stylesheetHandlers,
Expand Down
15 changes: 15 additions & 0 deletions src/mocks/data/webhooks.data.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import { UmbData } from './data.js';
//import {
// WebhooksResponseModel,
//} from '@umbraco-cms/backoffice/backend-api';

class UmbWebhooksData extends UmbData<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,7 +33,7 @@ export class UmbLogViewerWorkspaceElement extends UmbLitElement {

render() {
return html`
<umb-workspace-editor alias="Umb.Workspace.Dictionary" headline="Log Viewer" .enforceNoFooter=${true}>
<umb-workspace-editor alias="Umb.Workspace.LogViewer" headline="Log Viewer" .enforceNoFooter=${true}>
</umb-workspace-editor>
`;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@ export class UmbLanguageRootWorkspaceElement extends UmbLitElement {
label="Add language"
look="outline"
color="default"
href="section/settings/workspace/language/create"></uui-button>
href="section/settings/workspace/language/create">
</uui-button>

<!--- TODO: investigate if it's possible to use a collection component here --->
<umb-table .config=${this._tableConfig} .columns=${this._tableColumns} .items=${this._tableItems}></umb-table>
Expand Down
2 changes: 2 additions & 0 deletions src/packages/settings/manifests.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -11,6 +12,7 @@ export const manifests = [
...dataTypeManifests,
...extensionManifests,
...languageManifests,
...webhooksManifests,
...relationTypeManifests,
...settingsMenuManifests,
...settingsSectionManifests,
Expand Down
1 change: 1 addition & 0 deletions src/packages/settings/webhooks/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './repository/index.js';
4 changes: 4 additions & 0 deletions src/packages/settings/webhooks/manifests.ts
Original file line number Diff line number Diff line change
@@ -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];
16 changes: 16 additions & 0 deletions src/packages/settings/webhooks/menu-item/manifests.ts
Original file line number Diff line number Diff line change
@@ -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];
2 changes: 2 additions & 0 deletions src/packages/settings/webhooks/repository/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
export * from './webhooks.repository.js';
//export * from './sources/index.js';
27 changes: 27 additions & 0 deletions src/packages/settings/webhooks/repository/webhooks.repository.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
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 UmbWebhookRepository {
#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();
}

async requestWebhooks({ skip, take } = { skip: 0, take: 1000 }) {
await this.#init;

}
}
3 changes: 3 additions & 0 deletions src/packages/settings/webhooks/workspace/manifests.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import { manifests as webhooksRootManifests } from './webhooks/manifests.js';

export const manifests = [...webhooksRootManifests];
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
//import './components/index.js';
import { UmbWebhooksOverviewViewElement } from './webhooks-view.element.js';

export default UmbWebhooksOverviewViewElement;
Original file line number Diff line number Diff line change
@@ -0,0 +1,132 @@
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<UmbTableColumn> = [
{
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

Check failure on line 41 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Member 's' implicitly has an 'any' type.
private _tableItems: Array<UmbTableItem> = [];

#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();

Check failure on line 61 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'asObservable' does not exist on type 'void'.

if (asObservable) {
this.observe(asObservable(), (webhook) => this.#createTableItems(webhooks));

Check failure on line 64 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Cannot find name 'webhooks'. Did you mean 'webhook'?
}
}

#createTableItems(webhooks: Array<LanguageResponseModel>) {
this._tableItems = webhooks.map((webhook) => {
return {
id: webhook.id ?? '',

Check failure on line 71 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'id' does not exist on type 'LanguageResponseModel'.
icon: 'umb:anchor',
data: [
{
columnAlias: 'enabled',
value: webhook.enabled,

Check failure on line 76 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'enabled' does not exist on type 'LanguageResponseModel'.
},
{
columnAlias: 'events',
value: webhook.events,

Check failure on line 80 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'events' does not exist on type 'LanguageResponseModel'.
},
{
columnAlias: 'url',
value: webhook.url,

Check failure on line 84 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'url' does not exist on type 'LanguageResponseModel'.
},
{
columnAlias: 'types',
value: webhook.types,

Check failure on line 88 in src/packages/settings/webhooks/workspace/views/overview/webhooks-view.element.ts

View workflow job for this annotation

GitHub Actions / build (20)

Property 'types' does not exist on type 'LanguageResponseModel'.
},
{
columnAlias: 'delete',
value: webhook,
},
],
};
});
}

render() {
return html`
<umb-body-layout main-no-padding headline="Languages">
<umb-body-layout header-transparent>
<uui-button
slot="header"
label="Add webhook"
look="outline"
color="default"
href="section/settings/workspace/webhook/create">
</uui-button>

<!--- TODO: investigate if it's possible to use a collection component here --->
<umb-table .config=${this._tableConfig} .columns=${this._tableColumns} .items=${this._tableItems}></umb-table>
</umb-body-layout>
</umb-body-layout>
`;
}

static styles = [
css`
:host {
display: block;
margin: var(--uui-size-layout-1);
}
`,
];
}

declare global {
interface HTMLElementTagNameMap {
'umb-webhooks-overview-view': UmbWebhooksOverviewViewElement;
}
}
40 changes: 40 additions & 0 deletions src/packages/settings/webhooks/workspace/webhooks.context.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
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';

// TODO: Revisit usage of workspace for this case...
export class UmbWebhooksWorkspaceContext extends UmbBaseController implements UmbWorkspaceContextInterface {
public readonly workspaceAlias: string = 'Umb.Workspace.Webhooks';
#repository: UmbWebhookRepository;

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 UmbWebhookRepository(host);
}

onChangeState = () => {

};
}

export const UMB_APP_WEBHOOKS_CONTEXT_TOKEN = new UmbContextToken<UmbWebhooksWorkspaceContext>(
UmbWebhooksWorkspaceContext.name,
);
Loading
Loading