From 6b8256967e9cb2705370678a0b1d64fc81fbf606 Mon Sep 17 00:00:00 2001 From: Daniil Bratukhin Date: Tue, 29 Oct 2024 17:37:26 -0300 Subject: [PATCH] refactor(foxy-webhook-form): add support for optional resource info in logs and statuses --- src/elements/public/WebhookForm/WebhookForm.test.ts | 10 ++++++++++ src/elements/public/WebhookForm/WebhookForm.ts | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/elements/public/WebhookForm/WebhookForm.test.ts b/src/elements/public/WebhookForm/WebhookForm.test.ts index d323e4d1..3764c226 100644 --- a/src/elements/public/WebhookForm/WebhookForm.test.ts +++ b/src/elements/public/WebhookForm/WebhookForm.test.ts @@ -209,6 +209,11 @@ describe('WebhookForm', () => { 'first', 'https://demo.api/hapi/webhook_statuses?webhook_id=0&order=date_created+desc' ); + + expect(control).to.have.deep.property('itemProps', {}); + element.resourceUri = 'https://demo.api/hapi/transactions/0'; + await element.requestUpdate(); + expect(control).to.have.deep.property('itemProps', { layout: 'resource' }); }); it('includes only resource-specific statuses when resource uri is set', async () => { @@ -248,6 +253,11 @@ describe('WebhookForm', () => { 'first', 'https://demo.api/hapi/webhook_logs?webhook_id=0&order=date_created+desc' ); + + expect(control).to.have.deep.property('itemProps', {}); + element.resourceUri = 'https://demo.api/hapi/transactions/0'; + await element.requestUpdate(); + expect(control).to.have.deep.property('itemProps', { layout: 'resource' }); }); it('includes only resource-specific logs when resource uri is set', async () => { diff --git a/src/elements/public/WebhookForm/WebhookForm.ts b/src/elements/public/WebhookForm/WebhookForm.ts index 2f375ec4..6fa17ada 100644 --- a/src/elements/public/WebhookForm/WebhookForm.ts +++ b/src/elements/public/WebhookForm/WebhookForm.ts @@ -134,6 +134,7 @@ export class WebhookForm extends TranslatableMixin(InternalForm, 'webhook-form') limit="10" item="foxy-webhook-status-card" .getPageHref=${this.getStatusPageHref} + .itemProps=${this.resourceUri ? { layout: 'resource' } : {}} > @@ -143,6 +144,7 @@ export class WebhookForm extends TranslatableMixin(InternalForm, 'webhook-form') limit="10" item="foxy-webhook-log-card" .getPageHref=${this.getLogPageHref} + .itemProps=${this.resourceUri ? { layout: 'resource' } : {}} >