@webiny/webhooks 6.4.12-beta.5 → 6.4.12-beta.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/admin/WebhookRoutes.js +14 -11
- package/admin/WebhookRoutes.js.map +1 -1
- package/admin/Webhooks.js +1 -1
- package/admin/Webhooks.js.map +1 -1
- package/admin/features/createWebhook/abstractions.d.ts +1 -0
- package/admin/features/createWebhook/abstractions.js.map +1 -1
- package/admin/features/updateWebhook/abstractions.d.ts +1 -0
- package/admin/features/updateWebhook/abstractions.js.map +1 -1
- package/admin/presentation/SigningSecret/SigningSecretActions.d.ts +11 -0
- package/admin/presentation/SigningSecret/SigningSecretActions.js +35 -0
- package/admin/presentation/SigningSecret/SigningSecretActions.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js.map +1 -1
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -1
- package/admin/presentation/WebhookForm/WebhookFormPresenter.d.ts +3 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js +31 -16
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -1
- package/admin/presentation/WebhookForm/abstractions.d.ts +2 -0
- package/admin/presentation/WebhookForm/abstractions.js.map +1 -1
- package/admin/presentation/WebhookForm/components/WebhookFormView.js +11 -4
- package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -1
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.d.ts +3 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js +17 -2
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js.map +1 -1
- package/admin/presentation/WebhookSettings/abstractions.d.ts +3 -0
- package/admin/presentation/WebhookSettings/abstractions.js.map +1 -1
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js +22 -3
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js.map +1 -1
- package/admin/shared/signingSecret.d.ts +2 -0
- package/admin/shared/signingSecret.js +8 -0
- package/admin/shared/signingSecret.js.map +1 -0
- package/api/features/CreateWebhook/schema.js +5 -2
- package/api/features/CreateWebhook/schema.js.map +1 -1
- package/api/features/GetWebhook/GetWebhookUseCase.js +7 -1
- package/api/features/GetWebhook/GetWebhookUseCase.js.map +1 -1
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.d.ts +2 -2
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js +1 -1
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js.map +1 -1
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.d.ts +15 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.js +25 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsUseCase.js.map +1 -0
- package/api/features/GetWebhookSettings/{abstractions.d.ts → abstractions/GetWebhookSettingsRepository.d.ts} +2 -2
- package/api/features/GetWebhookSettings/{abstractions.js → abstractions/GetWebhookSettingsRepository.js} +1 -1
- package/api/features/GetWebhookSettings/abstractions/GetWebhookSettingsRepository.js.map +1 -0
- package/api/features/GetWebhookSettings/abstractions/GetWebhookSettingsUseCase.d.ts +17 -0
- package/api/features/GetWebhookSettings/abstractions/GetWebhookSettingsUseCase.js +5 -0
- package/api/features/GetWebhookSettings/abstractions/GetWebhookSettingsUseCase.js.map +1 -0
- package/api/features/GetWebhookSettings/feature.js +2 -0
- package/api/features/GetWebhookSettings/feature.js.map +1 -1
- package/api/features/ListWebhooks/ListWebhooksUseCase.js +10 -1
- package/api/features/ListWebhooks/ListWebhooksUseCase.js.map +1 -1
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.d.ts +1 -1
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js +1 -1
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/SendWebhookTask/SendWebhookTask.d.ts +1 -1
- package/api/features/SendWebhookTask/SendWebhookTask.js +16 -2
- package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.d.ts +1 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js +1 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js.map +1 -1
- package/api/features/UpdateWebhook/schema.js +5 -2
- package/api/features/UpdateWebhook/schema.js.map +1 -1
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.d.ts +1 -1
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +1 -1
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js.map +1 -1
- package/api/features/UpdateWebhookSettings/schema.js +4 -1
- package/api/features/UpdateWebhookSettings/schema.js.map +1 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.d.ts +1 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.js +1 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.js.map +1 -1
- package/api/graphql/WebhookCrudSchema.js +1 -0
- package/api/graphql/WebhookCrudSchema.js.map +1 -1
- package/api/graphql/WebhookSettingsSchema.js +2 -2
- package/api/graphql/WebhookSettingsSchema.js.map +1 -1
- package/api/utils/isValidEndpointUrl.js +29 -3
- package/api/utils/isValidEndpointUrl.js.map +1 -1
- package/api/utils/isValidSigningSecret.d.ts +8 -0
- package/api/utils/isValidSigningSecret.js +11 -0
- package/api/utils/isValidSigningSecret.js.map +1 -0
- package/package.json +22 -22
- package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +0 -9
- package/admin/presentation/WebhookForm/components/SigningSecret.js +0 -47
- package/admin/presentation/WebhookForm/components/SigningSecret.js.map +0 -1
- package/api/features/GetWebhookSettings/abstractions.js.map +0 -1
package/admin/WebhookRoutes.js
CHANGED
|
@@ -7,7 +7,7 @@ import { WebhookFormView } from "./presentation/WebhookForm/components/WebhookFo
|
|
|
7
7
|
import { WebhookSettingsView } from "./presentation/WebhookSettings/components/WebhookSettingsView.js";
|
|
8
8
|
import { WebhookDeliveriesPage } from "./presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js";
|
|
9
9
|
import { Routes } from "./routes.js";
|
|
10
|
-
const { Menu
|
|
10
|
+
const { Menu, Route } = AdminConfig;
|
|
11
11
|
const beta = /*#__PURE__*/ react.createElement(Menu.Link.Badge, {
|
|
12
12
|
text: "BETA"
|
|
13
13
|
});
|
|
@@ -25,12 +25,23 @@ const WebhookRoutes = ()=>{
|
|
|
25
25
|
element: /*#__PURE__*/ react.createElement(AdminLayout, {
|
|
26
26
|
title: "Delivery Log"
|
|
27
27
|
}, /*#__PURE__*/ react.createElement(WebhookDeliveriesPage, null))
|
|
28
|
-
}), /*#__PURE__*/ react.createElement(
|
|
28
|
+
}), /*#__PURE__*/ react.createElement(HasPermission, {
|
|
29
|
+
entity: "webhook",
|
|
30
|
+
action: "edit"
|
|
31
|
+
}, /*#__PURE__*/ react.createElement(Route, {
|
|
29
32
|
route: Routes.Settings,
|
|
30
33
|
element: /*#__PURE__*/ react.createElement(AdminLayout, {
|
|
31
34
|
title: "Webhook Settings"
|
|
32
35
|
}, /*#__PURE__*/ react.createElement(WebhookSettingsView, null))
|
|
33
|
-
}), /*#__PURE__*/ react.createElement(
|
|
36
|
+
}), /*#__PURE__*/ react.createElement(Menu, {
|
|
37
|
+
name: "webhooks.settings",
|
|
38
|
+
parent: "settings.system",
|
|
39
|
+
element: /*#__PURE__*/ react.createElement(Menu.Link, {
|
|
40
|
+
badge: beta,
|
|
41
|
+
text: "Webhooks",
|
|
42
|
+
to: getLink(Routes.Settings)
|
|
43
|
+
})
|
|
44
|
+
})), /*#__PURE__*/ react.createElement(Route, {
|
|
34
45
|
route: Routes.Form,
|
|
35
46
|
element: /*#__PURE__*/ react.createElement(AdminLayout, {
|
|
36
47
|
title: "Webhooks"
|
|
@@ -47,14 +58,6 @@ const WebhookRoutes = ()=>{
|
|
|
47
58
|
element: /*#__PURE__*/ react.createElement(ReactComponent, null)
|
|
48
59
|
})
|
|
49
60
|
})
|
|
50
|
-
}), /*#__PURE__*/ react.createElement(Menu, {
|
|
51
|
-
name: "webhooks.settings",
|
|
52
|
-
parent: "settings.system",
|
|
53
|
-
element: /*#__PURE__*/ react.createElement(Menu.Link, {
|
|
54
|
-
badge: beta,
|
|
55
|
-
text: "Webhooks",
|
|
56
|
-
to: getLink(Routes.Settings)
|
|
57
|
-
})
|
|
58
61
|
})));
|
|
59
62
|
};
|
|
60
63
|
export { WebhookRoutes };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/WebhookRoutes.js","sources":["../../src/admin/WebhookRoutes.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { AdminLayout } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookDeliveryIcon } from \"@webiny/icons/webhook.svg\";\nimport { HasPermission } from \"./presentation/security/HasPermission.js\";\nimport { WebhookListView } from \"./presentation/WebhookList/components/WebhookListView.js\";\nimport { WebhookFormView } from \"./presentation/WebhookForm/components/WebhookFormView.js\";\nimport { WebhookSettingsView } from \"./presentation/WebhookSettings/components/WebhookSettingsView.js\";\nimport { WebhookDeliveriesPage } from \"./presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst beta = <Menu.Link.Badge text=\"BETA\" />;\n\nexport const WebhookRoutes = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <HasPermission entity=\"webhook\">\n <Route\n route={Routes.List}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhookListView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Deliveries}\n element={\n <AdminLayout title=\"Delivery Log\">\n <WebhookDeliveriesPage />\n </AdminLayout>\n }\n />\n <Route\n
|
|
1
|
+
{"version":3,"file":"admin/WebhookRoutes.js","sources":["../../src/admin/WebhookRoutes.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { AdminLayout } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookDeliveryIcon } from \"@webiny/icons/webhook.svg\";\nimport { HasPermission } from \"./presentation/security/HasPermission.js\";\nimport { WebhookListView } from \"./presentation/WebhookList/components/WebhookListView.js\";\nimport { WebhookFormView } from \"./presentation/WebhookForm/components/WebhookFormView.js\";\nimport { WebhookSettingsView } from \"./presentation/WebhookSettings/components/WebhookSettingsView.js\";\nimport { WebhookDeliveriesPage } from \"./presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js\";\nimport { Routes } from \"./routes.js\";\n\nconst { Menu, Route } = AdminConfig;\n\nconst beta = <Menu.Link.Badge text=\"BETA\" />;\n\nexport const WebhookRoutes = () => {\n const { getLink } = useRouter();\n\n return (\n <AdminConfig>\n <HasPermission entity=\"webhook\">\n <Route\n route={Routes.List}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhookListView />\n </AdminLayout>\n }\n />\n <Route\n route={Routes.Deliveries}\n element={\n <AdminLayout title=\"Delivery Log\">\n <WebhookDeliveriesPage />\n </AdminLayout>\n }\n />\n {/* Settings hold the signing secret; only users who can edit webhooks may see them. */}\n <HasPermission entity=\"webhook\" action=\"edit\">\n <Route\n route={Routes.Settings}\n element={\n <AdminLayout title=\"Webhook Settings\">\n <WebhookSettingsView />\n </AdminLayout>\n }\n />\n <Menu\n name=\"webhooks.settings\"\n parent=\"settings.system\"\n element={\n <Menu.Link badge={beta} text=\"Webhooks\" to={getLink(Routes.Settings)} />\n }\n />\n </HasPermission>\n <Route\n route={Routes.Form}\n element={\n <AdminLayout title=\"Webhooks\">\n <WebhookFormView />\n </AdminLayout>\n }\n />\n <Menu\n name=\"webhooks.deliveries\"\n parent=\"dev-tools\"\n element={\n <Menu.Link\n text=\"Webhooks\"\n badge={beta}\n to={getLink(Routes.Deliveries)}\n icon={\n <Menu.Link.Icon\n label=\"Webhooks\"\n element={<WebhookDeliveryIcon />}\n />\n }\n />\n }\n />\n </HasPermission>\n </AdminConfig>\n );\n};\n"],"names":["Menu","Route","AdminConfig","beta","WebhookRoutes","getLink","useRouter","HasPermission","Routes","AdminLayout","WebhookListView","WebhookDeliveriesPage","WebhookSettingsView","WebhookFormView","WebhookDeliveryIcon"],"mappings":";;;;;;;;;AAYA,MAAM,EAAEA,IAAI,EAAEC,KAAK,EAAE,GAAGC;AAExB,MAAMC,OAAO,WAAPA,GAAO,oBAACH,KAAK,IAAI,CAAC,KAAK;IAAC,MAAK;;AAE5B,MAAMI,gBAAgB;IACzB,MAAM,EAAEC,OAAO,EAAE,GAAGC;IAEpB,OAAO,WAAP,GACI,oBAACJ,aAAWA,MAAAA,WAAAA,GACR,oBAACK,eAAaA;QAAC,QAAO;qBAClB,oBAACN,OAAAA;QACG,OAAOO,OAAO,IAAI;QAClB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACC,iBAAeA;sBAI5B,oBAACT,OAAAA;QACG,OAAOO,OAAO,UAAU;QACxB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACE,uBAAqBA;sBAKlC,oBAACJ,eAAaA;QAAC,QAAO;QAAU,QAAO;qBACnC,oBAACN,OAAAA;QACG,OAAOO,OAAO,QAAQ;QACtB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACG,qBAAmBA;sBAIhC,oBAACZ,MAAAA;QACG,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YAAC,OAAOG;YAAM,MAAK;YAAW,IAAIE,QAAQG,OAAO,QAAQ;;uBAI/E,oBAACP,OAAAA;QACG,OAAOO,OAAO,IAAI;QAClB,uBACI,oBAACC,aAAWA;YAAC,OAAM;yBACf,oBAACI,iBAAeA;sBAI5B,oBAACb,MAAAA;QACG,MAAK;QACL,QAAO;QACP,uBACI,oBAACA,KAAK,IAAI;YACN,MAAK;YACL,OAAOG;YACP,IAAIE,QAAQG,OAAO,UAAU;YAC7B,oBACI,oBAACR,KAAK,IAAI,CAAC,IAAI;gBACX,OAAM;gBACN,uBAAS,oBAACc,gBAAmBA;;;;AASjE"}
|
package/admin/Webhooks.js
CHANGED
|
@@ -18,7 +18,7 @@ import { WebhookFormPresenterFeature } from "./presentation/WebhookForm/index.js
|
|
|
18
18
|
import { WebhookSettingsPresenterFeature } from "./presentation/WebhookSettings/index.js";
|
|
19
19
|
import { WebhookRoutes } from "./WebhookRoutes.js";
|
|
20
20
|
import { WEBHOOK_PERMISSIONS_SCHEMA } from "./permissions.js";
|
|
21
|
-
const { Security
|
|
21
|
+
const { Security } = AdminConfig;
|
|
22
22
|
const Webhooks = ()=>/*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(RegisterFeature, {
|
|
23
23
|
feature: ListWebhooksFeature
|
|
24
24
|
}), /*#__PURE__*/ react.createElement(RegisterFeature, {
|
package/admin/Webhooks.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/Webhooks.js","sources":["../../src/admin/Webhooks.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { ListWebhooksFeature } from \"./features/ListWebhooks/index.js\";\nimport { GetWebhookFeature } from \"./features/getWebhook/index.js\";\nimport { CreateWebhookFeature } from \"./features/createWebhook/index.js\";\nimport { UpdateWebhookFeature } from \"./features/updateWebhook/index.js\";\nimport { DeleteWebhookFeature } from \"./features/deleteWebhook/index.js\";\nimport { ListWebhookDeliveriesFeature } from \"./features/listWebhookDeliveries/index.js\";\nimport { TriggerWebhookFeature } from \"./features/triggerWebhook/index.js\";\nimport { ResendWebhookDeliveryFeature } from \"./features/resendWebhookDelivery/index.js\";\nimport { ListAvailableEventsFeature } from \"./features/listAvailableEvents/index.js\";\nimport { GetWebhookSettingsFeature } from \"./features/getWebhookSettings/index.js\";\nimport { UpdateWebhookSettingsFeature } from \"./features/updateWebhookSettings/index.js\";\nimport { WebhookPermissionsFeature } from \"./features/permissions/index.js\";\nimport { WebhookListPresenterFeature } from \"./presentation/WebhookList/index.js\";\nimport { WebhookFormPresenterFeature } from \"./presentation/WebhookForm/index.js\";\nimport { WebhookSettingsPresenterFeature } from \"./presentation/WebhookSettings/index.js\";\nimport { WebhookRoutes } from \"./WebhookRoutes.js\";\nimport { WEBHOOK_PERMISSIONS_SCHEMA } from \"~/admin/permissions.js\";\n\nconst { Security } = AdminConfig;\n\nexport const Webhooks = () => {\n return (\n <>\n {/* Headless features. */}\n <RegisterFeature feature={ListWebhooksFeature} />\n <RegisterFeature feature={GetWebhookFeature} />\n <RegisterFeature feature={CreateWebhookFeature} />\n <RegisterFeature feature={UpdateWebhookFeature} />\n <RegisterFeature feature={DeleteWebhookFeature} />\n <RegisterFeature feature={ListWebhookDeliveriesFeature} />\n <RegisterFeature feature={TriggerWebhookFeature} />\n <RegisterFeature feature={ResendWebhookDeliveryFeature} />\n <RegisterFeature feature={ListAvailableEventsFeature} />\n <RegisterFeature feature={GetWebhookSettingsFeature} />\n <RegisterFeature feature={UpdateWebhookSettingsFeature} />\n <RegisterFeature feature={WebhookPermissionsFeature} />\n {/* Presentation features. */}\n <RegisterFeature feature={WebhookListPresenterFeature} />\n <RegisterFeature feature={WebhookFormPresenterFeature} />\n <RegisterFeature feature={WebhookSettingsPresenterFeature} />\n {/* Routes + menu. */}\n <WebhookRoutes />\n {/* Security permissions UI. */}\n <AdminConfig>\n <Security.Permissions\n name=\"webhooks\"\n title=\"Webhooks\"\n description=\"Manage webhook permissions.\"\n icon={<WebhookIcon />}\n schema={WEBHOOK_PERMISSIONS_SCHEMA}\n />\n </AdminConfig>\n </>\n );\n};\n"],"names":["Security","AdminConfig","Webhooks","RegisterFeature","ListWebhooksFeature","GetWebhookFeature","CreateWebhookFeature","UpdateWebhookFeature","DeleteWebhookFeature","ListWebhookDeliveriesFeature","TriggerWebhookFeature","ResendWebhookDeliveryFeature","ListAvailableEventsFeature","GetWebhookSettingsFeature","UpdateWebhookSettingsFeature","WebhookPermissionsFeature","WebhookListPresenterFeature","WebhookFormPresenterFeature","WebhookSettingsPresenterFeature","WebhookRoutes","WebhookIcon","WEBHOOK_PERMISSIONS_SCHEMA"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,EAAEA,
|
|
1
|
+
{"version":3,"file":"admin/Webhooks.js","sources":["../../src/admin/Webhooks.tsx"],"sourcesContent":["import React from \"react\";\nimport { AdminConfig } from \"@webiny/app-admin\";\nimport { RegisterFeature } from \"@webiny/app-admin\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { ListWebhooksFeature } from \"./features/ListWebhooks/index.js\";\nimport { GetWebhookFeature } from \"./features/getWebhook/index.js\";\nimport { CreateWebhookFeature } from \"./features/createWebhook/index.js\";\nimport { UpdateWebhookFeature } from \"./features/updateWebhook/index.js\";\nimport { DeleteWebhookFeature } from \"./features/deleteWebhook/index.js\";\nimport { ListWebhookDeliveriesFeature } from \"./features/listWebhookDeliveries/index.js\";\nimport { TriggerWebhookFeature } from \"./features/triggerWebhook/index.js\";\nimport { ResendWebhookDeliveryFeature } from \"./features/resendWebhookDelivery/index.js\";\nimport { ListAvailableEventsFeature } from \"./features/listAvailableEvents/index.js\";\nimport { GetWebhookSettingsFeature } from \"./features/getWebhookSettings/index.js\";\nimport { UpdateWebhookSettingsFeature } from \"./features/updateWebhookSettings/index.js\";\nimport { WebhookPermissionsFeature } from \"./features/permissions/index.js\";\nimport { WebhookListPresenterFeature } from \"./presentation/WebhookList/index.js\";\nimport { WebhookFormPresenterFeature } from \"./presentation/WebhookForm/index.js\";\nimport { WebhookSettingsPresenterFeature } from \"./presentation/WebhookSettings/index.js\";\nimport { WebhookRoutes } from \"./WebhookRoutes.js\";\nimport { WEBHOOK_PERMISSIONS_SCHEMA } from \"~/admin/permissions.js\";\n\nconst { Security } = AdminConfig;\n\nexport const Webhooks = () => {\n return (\n <>\n {/* Headless features. */}\n <RegisterFeature feature={ListWebhooksFeature} />\n <RegisterFeature feature={GetWebhookFeature} />\n <RegisterFeature feature={CreateWebhookFeature} />\n <RegisterFeature feature={UpdateWebhookFeature} />\n <RegisterFeature feature={DeleteWebhookFeature} />\n <RegisterFeature feature={ListWebhookDeliveriesFeature} />\n <RegisterFeature feature={TriggerWebhookFeature} />\n <RegisterFeature feature={ResendWebhookDeliveryFeature} />\n <RegisterFeature feature={ListAvailableEventsFeature} />\n <RegisterFeature feature={GetWebhookSettingsFeature} />\n <RegisterFeature feature={UpdateWebhookSettingsFeature} />\n <RegisterFeature feature={WebhookPermissionsFeature} />\n {/* Presentation features. */}\n <RegisterFeature feature={WebhookListPresenterFeature} />\n <RegisterFeature feature={WebhookFormPresenterFeature} />\n <RegisterFeature feature={WebhookSettingsPresenterFeature} />\n {/* Routes + menu. */}\n <WebhookRoutes />\n {/* Security permissions UI. */}\n <AdminConfig>\n <Security.Permissions\n name=\"webhooks\"\n title=\"Webhooks\"\n description=\"Manage webhook permissions.\"\n icon={<WebhookIcon />}\n schema={WEBHOOK_PERMISSIONS_SCHEMA}\n />\n </AdminConfig>\n </>\n );\n};\n"],"names":["Security","AdminConfig","Webhooks","RegisterFeature","ListWebhooksFeature","GetWebhookFeature","CreateWebhookFeature","UpdateWebhookFeature","DeleteWebhookFeature","ListWebhookDeliveriesFeature","TriggerWebhookFeature","ResendWebhookDeliveryFeature","ListAvailableEventsFeature","GetWebhookSettingsFeature","UpdateWebhookSettingsFeature","WebhookPermissionsFeature","WebhookListPresenterFeature","WebhookFormPresenterFeature","WebhookSettingsPresenterFeature","WebhookRoutes","WebhookIcon","WEBHOOK_PERMISSIONS_SCHEMA"],"mappings":";;;;;;;;;;;;;;;;;;;;AAsBA,MAAM,EAAEA,QAAQ,EAAE,GAAGC;AAEd,MAAMC,WAAW,IACb,WAAP,GACI,wDAEI,oBAACC,iBAAeA;QAAC,SAASC;sBAC1B,oBAACD,iBAAeA;QAAC,SAASE;sBAC1B,oBAACF,iBAAeA;QAAC,SAASG;sBAC1B,oBAACH,iBAAeA;QAAC,SAASI;sBAC1B,oBAACJ,iBAAeA;QAAC,SAASK;sBAC1B,oBAACL,iBAAeA;QAAC,SAASM;sBAC1B,oBAACN,iBAAeA;QAAC,SAASO;sBAC1B,oBAACP,iBAAeA;QAAC,SAASQ;sBAC1B,oBAACR,iBAAeA;QAAC,SAASS;sBAC1B,oBAACT,iBAAeA;QAAC,SAASU;sBAC1B,oBAACV,iBAAeA;QAAC,SAASW;sBAC1B,oBAACX,iBAAeA;QAAC,SAASY;sBAE1B,oBAACZ,iBAAeA;QAAC,SAASa;sBAC1B,oBAACb,iBAAeA;QAAC,SAASc;sBAC1B,oBAACd,iBAAeA;QAAC,SAASe;sBAE1B,oBAACC,eAAaA,OAAAA,WAAAA,GAEd,oBAAClB,aAAWA,MAAAA,WAAAA,GACR,oBAACD,SAAS,WAAW;QACjB,MAAK;QACL,OAAM;QACN,aAAY;QACZ,oBAAM,oBAACoB,gBAAWA;QAClB,QAAQC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/features/createWebhook/abstractions.js","sources":["../../../../src/admin/features/createWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface CreateWebhookInput {\n name: string;\n endpointUrl: string;\n events: string[];\n slug?: string;\n description?: string;\n enabled?: boolean;\n}\n\nexport interface ICreateWebhookGateway {\n execute(input: CreateWebhookInput): Promise<Webhook>;\n}\n\nexport const CreateWebhookGateway =\n createAbstraction<ICreateWebhookGateway>(\"CreateWebhookGateway\");\n\nexport namespace CreateWebhookGateway {\n export type Interface = ICreateWebhookGateway;\n}\n\nexport interface ICreateWebhookUseCase {\n execute(input: CreateWebhookInput): Promise<Webhook>;\n}\n\nexport const CreateWebhookUseCase =\n createAbstraction<ICreateWebhookUseCase>(\"CreateWebhookUseCase\");\n\nexport namespace CreateWebhookUseCase {\n export type Interface = ICreateWebhookUseCase;\n}\n"],"names":["CreateWebhookGateway","createAbstraction","CreateWebhookUseCase"],"mappings":";
|
|
1
|
+
{"version":3,"file":"admin/features/createWebhook/abstractions.js","sources":["../../../../src/admin/features/createWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface CreateWebhookInput {\n name: string;\n endpointUrl: string;\n events: string[];\n slug?: string;\n description?: string;\n enabled?: boolean;\n signingSecret?: string;\n}\n\nexport interface ICreateWebhookGateway {\n execute(input: CreateWebhookInput): Promise<Webhook>;\n}\n\nexport const CreateWebhookGateway =\n createAbstraction<ICreateWebhookGateway>(\"CreateWebhookGateway\");\n\nexport namespace CreateWebhookGateway {\n export type Interface = ICreateWebhookGateway;\n}\n\nexport interface ICreateWebhookUseCase {\n execute(input: CreateWebhookInput): Promise<Webhook>;\n}\n\nexport const CreateWebhookUseCase =\n createAbstraction<ICreateWebhookUseCase>(\"CreateWebhookUseCase\");\n\nexport namespace CreateWebhookUseCase {\n export type Interface = ICreateWebhookUseCase;\n}\n"],"names":["CreateWebhookGateway","createAbstraction","CreateWebhookUseCase"],"mappings":";AAiBO,MAAMA,uBACTC,kBAAyC;AAUtC,MAAMC,uBACTD,kBAAyC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/features/updateWebhook/abstractions.js","sources":["../../../../src/admin/features/updateWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface UpdateWebhookInput {\n name?: string;\n slug?: string;\n endpointUrl?: string;\n description?: string;\n enabled?: boolean;\n events?: string[];\n}\n\nexport interface IUpdateWebhookGateway {\n execute(id: string, input: UpdateWebhookInput): Promise<Webhook>;\n}\n\nexport const UpdateWebhookGateway =\n createAbstraction<IUpdateWebhookGateway>(\"UpdateWebhookGateway\");\n\nexport namespace UpdateWebhookGateway {\n export type Interface = IUpdateWebhookGateway;\n}\n\nexport interface IUpdateWebhookUseCase {\n execute(id: string, input: UpdateWebhookInput): Promise<Webhook>;\n}\n\nexport const UpdateWebhookUseCase =\n createAbstraction<IUpdateWebhookUseCase>(\"UpdateWebhookUseCase\");\n\nexport namespace UpdateWebhookUseCase {\n export type Interface = IUpdateWebhookUseCase;\n}\n"],"names":["UpdateWebhookGateway","createAbstraction","UpdateWebhookUseCase"],"mappings":";
|
|
1
|
+
{"version":3,"file":"admin/features/updateWebhook/abstractions.js","sources":["../../../../src/admin/features/updateWebhook/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\nexport interface UpdateWebhookInput {\n name?: string;\n slug?: string;\n endpointUrl?: string;\n description?: string;\n enabled?: boolean;\n events?: string[];\n signingSecret?: string;\n}\n\nexport interface IUpdateWebhookGateway {\n execute(id: string, input: UpdateWebhookInput): Promise<Webhook>;\n}\n\nexport const UpdateWebhookGateway =\n createAbstraction<IUpdateWebhookGateway>(\"UpdateWebhookGateway\");\n\nexport namespace UpdateWebhookGateway {\n export type Interface = IUpdateWebhookGateway;\n}\n\nexport interface IUpdateWebhookUseCase {\n execute(id: string, input: UpdateWebhookInput): Promise<Webhook>;\n}\n\nexport const UpdateWebhookUseCase =\n createAbstraction<IUpdateWebhookUseCase>(\"UpdateWebhookUseCase\");\n\nexport namespace UpdateWebhookUseCase {\n export type Interface = IUpdateWebhookUseCase;\n}\n"],"names":["UpdateWebhookGateway","createAbstraction","UpdateWebhookUseCase"],"mappings":";AAiBO,MAAMA,uBACTC,kBAAyC;AAUtC,MAAMC,uBACTD,kBAAyC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface SigningSecretActionsProps {
|
|
3
|
+
getValue: () => string;
|
|
4
|
+
onGenerate: () => void;
|
|
5
|
+
}
|
|
6
|
+
/**
|
|
7
|
+
* Rendered under a "Signing Secret" field: generates a new random secret, or copies the current
|
|
8
|
+
* one so it can be configured on the receiver.
|
|
9
|
+
*/
|
|
10
|
+
export declare const SigningSecretActions: ({ getValue, onGenerate }: SigningSecretActionsProps) => React.JSX.Element;
|
|
11
|
+
export {};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import react, { useCallback } from "react";
|
|
2
|
+
import { Button } from "@webiny/admin-ui";
|
|
3
|
+
import { useSnackbar } from "@webiny/app-admin/hooks/index.js";
|
|
4
|
+
const SigningSecretActions = ({ getValue, onGenerate })=>{
|
|
5
|
+
const { showSnackbar } = useSnackbar();
|
|
6
|
+
const handleCopy = useCallback(async ()=>{
|
|
7
|
+
const secret = getValue();
|
|
8
|
+
if (!secret) return void showSnackbar("There is no signing secret to copy.");
|
|
9
|
+
try {
|
|
10
|
+
await navigator.clipboard.writeText(secret);
|
|
11
|
+
showSnackbar("Signing secret copied to clipboard.");
|
|
12
|
+
} catch {
|
|
13
|
+
showSnackbar("Could not copy the signing secret. Copy it from the field instead.");
|
|
14
|
+
}
|
|
15
|
+
}, [
|
|
16
|
+
getValue,
|
|
17
|
+
showSnackbar
|
|
18
|
+
]);
|
|
19
|
+
return /*#__PURE__*/ react.createElement("div", {
|
|
20
|
+
className: "flex gap-sm"
|
|
21
|
+
}, /*#__PURE__*/ react.createElement(Button, {
|
|
22
|
+
variant: "secondary",
|
|
23
|
+
size: "sm",
|
|
24
|
+
text: "Generate",
|
|
25
|
+
onClick: onGenerate
|
|
26
|
+
}), /*#__PURE__*/ react.createElement(Button, {
|
|
27
|
+
variant: "secondary",
|
|
28
|
+
size: "sm",
|
|
29
|
+
text: "Copy",
|
|
30
|
+
onClick: ()=>void handleCopy()
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
export { SigningSecretActions };
|
|
34
|
+
|
|
35
|
+
//# sourceMappingURL=SigningSecretActions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"admin/presentation/SigningSecret/SigningSecretActions.js","sources":["../../../../src/admin/presentation/SigningSecret/SigningSecretActions.tsx"],"sourcesContent":["import React, { useCallback } from \"react\";\nimport { Button } from \"@webiny/admin-ui\";\nimport { useSnackbar } from \"@webiny/app-admin/hooks/index.js\";\n\ninterface SigningSecretActionsProps {\n getValue: () => string;\n onGenerate: () => void;\n}\n\n/**\n * Rendered under a \"Signing Secret\" field: generates a new random secret, or copies the current\n * one so it can be configured on the receiver.\n */\nexport const SigningSecretActions = ({ getValue, onGenerate }: SigningSecretActionsProps) => {\n const { showSnackbar } = useSnackbar();\n\n const handleCopy = useCallback(async () => {\n const secret = getValue();\n if (!secret) {\n showSnackbar(\"There is no signing secret to copy.\");\n return;\n }\n try {\n await navigator.clipboard.writeText(secret);\n showSnackbar(\"Signing secret copied to clipboard.\");\n } catch {\n showSnackbar(\"Could not copy the signing secret. Copy it from the field instead.\");\n }\n }, [getValue, showSnackbar]);\n\n return (\n <div className=\"flex gap-sm\">\n <Button variant=\"secondary\" size=\"sm\" text=\"Generate\" onClick={onGenerate} />\n <Button variant=\"secondary\" size=\"sm\" text=\"Copy\" onClick={() => void handleCopy()} />\n </div>\n );\n};\n"],"names":["SigningSecretActions","getValue","onGenerate","showSnackbar","useSnackbar","handleCopy","useCallback","secret","navigator","Button"],"mappings":";;;AAaO,MAAMA,uBAAuB,CAAC,EAAEC,QAAQ,EAAEC,UAAU,EAA6B;IACpF,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAMC,aAAaC,YAAY;QAC3B,MAAMC,SAASN;QACf,IAAI,CAACM,QAAQ,YACTJ,aAAa;QAGjB,IAAI;YACA,MAAMK,UAAU,SAAS,CAAC,SAAS,CAACD;YACpCJ,aAAa;QACjB,EAAE,OAAM;YACJA,aAAa;QACjB;IACJ,GAAG;QAACF;QAAUE;KAAa;IAE3B,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACM,QAAMA;QAAC,SAAQ;QAAY,MAAK;QAAK,MAAK;QAAW,SAASP;sBAC/D,oBAACO,QAAMA;QAAC,SAAQ;QAAY,MAAK;QAAK,MAAK;QAAO,SAAS,IAAM,KAAKJ;;AAGlF"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Loader, Separator, Text } from \"@webiny/admin-ui\";\nimport type { IWebhookDeliveriesPagePresenter } from \"../abstractions.js\";\n\ninterface DeliveryBottomInfoBarProps {\n presenter: IWebhookDeliveriesPagePresenter;\n}\n\nexport const DeliveryBottomInfoBar = observer(function DeliveryBottomInfoBar({\n presenter\n}: DeliveryBottomInfoBarProps) {\n const { vm } = presenter;\n const { pagination } = vm.list;\n\n if (pagination.loading && vm.list.rows.length === 0) {\n return null;\n }\n\n return (\n <div className=\"sticky bottom-0 z-5 bg-neutral-base w-full transform translate-z-0 overflow-hidden\">\n <Separator />\n <div className=\"h-xl px-md py-sm flex items-center justify-between\">\n <DeliveryMeta\n loading={pagination.loading}\n currentCount={pagination.currentCount}\n totalCount={pagination.totalCount}\n />\n <DeliveryLoadingStatus loading={pagination.loadingMore} />\n </div>\n </div>\n );\n});\n\ninterface DeliveryMetaProps {\n loading: boolean;\n currentCount: number;\n totalCount: number;\n}\n\nconst DeliveryMeta = ({ loading, currentCount, totalCount }: DeliveryMetaProps) => {\n if (loading) {\n return null;\n }\n\n const label = totalCount === 1 ? \"delivery\" : \"deliveries\";\n\n return (\n <Text size=\"sm\" as=\"div\" className=\"text-neutral-strong\">\n {`Showing ${currentCount} out of ${totalCount} ${label}.`}\n </Text>\n );\n};\n\ninterface DeliveryLoadingStatusProps {\n loading: boolean;\n}\n\nconst DeliveryLoadingStatus = ({ loading }: DeliveryLoadingStatusProps) => {\n if (!loading) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-sm\">\n <Text size=\"sm\" as=\"div\" className=\"text-neutral-strong\">\n Loading more deliveries...\n </Text>\n <Loader size=\"xs\" />\n </div>\n );\n};\n"],"names":["DeliveryBottomInfoBar","observer","presenter","vm","pagination","Separator","DeliveryMeta","DeliveryLoadingStatus","loading","currentCount","totalCount","label","Text","Loader"],"mappings":";;;AASO,MAAMA,8CAAwBC,SAAS,SAA+B,EACzEC,SAAS,EACgB;IACzB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,EAAEE,UAAU,EAAE,GAAGD,GAAG,IAAI;IAE9B,IAAIC,WAAW,OAAO,IAAID,AAAwB,MAAxBA,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EACzC,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACE,WAASA,OAAAA,WAAAA,GACV,oBAAC;QAAI,WAAU;qBACX,oBAACC,
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.tsx"],"sourcesContent":["import React from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { Loader, Separator, Text } from \"@webiny/admin-ui\";\nimport type { IWebhookDeliveriesPagePresenter } from \"../abstractions.js\";\n\ninterface DeliveryBottomInfoBarProps {\n presenter: IWebhookDeliveriesPagePresenter;\n}\n\nexport const DeliveryBottomInfoBar = observer(function DeliveryBottomInfoBar({\n presenter\n}: DeliveryBottomInfoBarProps) {\n const { vm } = presenter;\n const { pagination } = vm.list;\n\n if (pagination.loading && vm.list.rows.length === 0) {\n return null;\n }\n\n return (\n <div className=\"sticky bottom-0 z-5 bg-neutral-base w-full transform translate-z-0 overflow-hidden\">\n <Separator />\n <div className=\"h-xl px-md py-sm flex items-center justify-between\">\n <DeliveryMeta\n loading={pagination.loading}\n currentCount={pagination.currentCount}\n totalCount={pagination.totalCount}\n />\n <DeliveryLoadingStatus loading={pagination.loadingMore} />\n </div>\n </div>\n );\n});\n\ninterface DeliveryMetaProps {\n loading: boolean;\n currentCount: number;\n totalCount: number;\n}\n\nconst DeliveryMeta = ({ loading, currentCount, totalCount }: DeliveryMetaProps) => {\n if (loading) {\n return null;\n }\n\n const label = totalCount === 1 ? \"delivery\" : \"deliveries\";\n\n return (\n <Text size=\"sm\" as=\"div\" className=\"text-neutral-strong\">\n {`Showing ${currentCount} out of ${totalCount} ${label}.`}\n </Text>\n );\n};\n\ninterface DeliveryLoadingStatusProps {\n loading: boolean;\n}\n\nconst DeliveryLoadingStatus = ({ loading }: DeliveryLoadingStatusProps) => {\n if (!loading) {\n return null;\n }\n\n return (\n <div className=\"flex items-center gap-sm\">\n <Text size=\"sm\" as=\"div\" className=\"text-neutral-strong\">\n Loading more deliveries...\n </Text>\n <Loader size=\"xs\" />\n </div>\n );\n};\n"],"names":["DeliveryBottomInfoBar","observer","presenter","vm","pagination","Separator","DeliveryMeta","DeliveryLoadingStatus","loading","currentCount","totalCount","label","Text","Loader"],"mappings":";;;AASO,MAAMA,8CAAwBC,SAAS,SAA+B,EACzEC,SAAS,EACgB;IACzB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,EAAEE,UAAU,EAAE,GAAGD,GAAG,IAAI;IAE9B,IAAIC,WAAW,OAAO,IAAID,AAAwB,MAAxBA,GAAG,IAAI,CAAC,IAAI,CAAC,MAAM,EACzC,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACE,WAASA,OAAAA,WAAAA,GACV,oBAAC;QAAI,WAAU;qBACX,oBAACC,cAAAA;QACG,SAASF,WAAW,OAAO;QAC3B,cAAcA,WAAW,YAAY;QACrC,YAAYA,WAAW,UAAU;sBAErC,oBAACG,uBAAAA;QAAsB,SAASH,WAAW,WAAW;;AAItE;AAQA,MAAME,eAAe,CAAC,EAAEE,OAAO,EAAEC,YAAY,EAAEC,UAAU,EAAqB;IAC1E,IAAIF,SACA,OAAO;IAGX,MAAMG,QAAQD,AAAe,MAAfA,aAAmB,aAAa;IAE9C,OAAO,WAAP,GACI,oBAACE,MAAIA;QAAC,MAAK;QAAK,IAAG;QAAM,WAAU;OAC9B,CAAC,QAAQ,EAAEH,aAAa,QAAQ,EAAEC,WAAW,CAAC,EAAEC,MAAM,CAAC,CAAC;AAGrE;AAMA,MAAMJ,wBAAwB,CAAC,EAAEC,OAAO,EAA8B;IAClE,IAAI,CAACA,SACD,OAAO;IAGX,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACI,MAAIA;QAAC,MAAK;QAAK,IAAG;QAAM,WAAU;OAAsB,6CAGzD,oBAACC,QAAMA;QAAC,MAAK;;AAGzB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.tsx"],"sourcesContent":["import React, { useMemo, useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport { Separator } from \"@webiny/admin-ui\";\nimport { Skeleton } from \"@webiny/admin-ui\";\nimport { Button, Heading, Text } from \"@webiny/admin-ui\";\nimport { ListWebhookDeliveriesFeature } from \"~/admin/features/listWebhookDeliveries/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { ResendWebhookDeliveryFeature } from \"~/admin/features/resendWebhookDelivery/feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { WebhookDeliveriesPagePresenterFeature } from \"../feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { DeliveryFilters } from \"./DeliveryFilters.js\";\nimport { DeliveryList } from \"./DeliveryList.js\";\nimport { WebhookDefinitionsButton } from \"~/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js\";\n\nconst Loader = () => {\n return (\n <div className=\"flex flex-col gap-sm p-md\">\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n </div>\n );\n};\n\nconst WebhookDeliveriesPageInner = observer(function WebhookDeliveriesPageInner() {\n const { presenter } = useFeature(WebhookDeliveriesPagePresenterFeature);\n const { route } = useRoute(Routes.Deliveries);\n const webhookId = route?.params?.webhookId;\n\n useEffect(() => {\n void presenter.init(webhookId);\n }, [presenter, webhookId]);\n\n const { vm } = presenter;\n\n if (vm.error) {\n return (\n <div className=\"flex flex-col items-center gap-sm p-md\">\n <Text>{vm.error}</Text>\n <Button variant=\"secondary\" onClick={() => void presenter.init()}>\n Retry\n </Button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-main-content\">\n <div className=\"flex items-center justify-between py-sm px-md\">\n <Heading level={5}>Webhook Deliveries</Heading>\n <WebhookDefinitionsButton />\n </div>\n <Separator />\n <div className={\"p-sm\"}>\n <DeliveryFilters presenter={presenter} />\n </div>\n <Separator />\n {vm.loading ? <Loader /> : <DeliveryList presenter={presenter} />}\n </div>\n );\n});\n\nexport const WebhookDeliveriesPage = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhookDeliveriesFeature.register(child);\n ListAvailableEventsFeature.register(child);\n ResendWebhookDeliveryFeature.register(child);\n ListWebhooksFeature.register(child);\n WebhookDeliveriesPagePresenterFeature.register(child);\n return child;\n }, [container]);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookDeliveriesPageInner />\n </DiContainerProvider>\n );\n};\n"],"names":["Loader","Skeleton","WebhookDeliveriesPageInner","observer","presenter","useFeature","WebhookDeliveriesPagePresenterFeature","route","useRoute","Routes","webhookId","useEffect","vm","Text","Button","Heading","WebhookDefinitionsButton","Separator","DeliveryFilters","DeliveryList","WebhookDeliveriesPage","container","useContainer","scopedContainer","useMemo","child","ListWebhookDeliveriesFeature","ListAvailableEventsFeature","ResendWebhookDeliveryFeature","ListWebhooksFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMA,SAAS,IACJ,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;;AAKhC,MAAMC,mDAA6BC,SAAS;IACxC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,UAAU;IAC5C,MAAMC,YAAYH,OAAO,QAAQ;IAEjCI,UAAU;QACDP,UAAU,IAAI,CAACM;IACxB,GAAG;QAACN;QAAWM;KAAU;IAEzB,MAAM,EAAEE,EAAE,EAAE,GAAGR;IAEf,IAAIQ,GAAG,KAAK,EACR,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,MAAIA,MAAED,GAAG,KAAK,iBACf,oBAACE,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAM,KAAKV,UAAU,IAAI;OAAI;IAO9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACW,SAAOA;QAAC,OAAO;OAAG,qCACnB,oBAACC,0BAAwBA,QAAAA,WAAAA,GAE7B,oBAACC,WAASA,OAAAA,WAAAA,GACV,oBAAC;QAAI,WAAW;qBACZ,oBAACC,iBAAeA;QAAC,WAAWd;uBAEhC,oBAACa,WAASA,OACTL,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACZ,
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js","sources":["../../../../../src/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.tsx"],"sourcesContent":["import React, { useMemo, useEffect } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport { Separator } from \"@webiny/admin-ui\";\nimport { Skeleton } from \"@webiny/admin-ui\";\nimport { Button, Heading, Text } from \"@webiny/admin-ui\";\nimport { ListWebhookDeliveriesFeature } from \"~/admin/features/listWebhookDeliveries/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { ResendWebhookDeliveryFeature } from \"~/admin/features/resendWebhookDelivery/feature.js\";\nimport { ListWebhooksFeature } from \"~/admin/features/ListWebhooks/feature.js\";\nimport { WebhookDeliveriesPagePresenterFeature } from \"../feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { DeliveryFilters } from \"./DeliveryFilters.js\";\nimport { DeliveryList } from \"./DeliveryList.js\";\nimport { WebhookDefinitionsButton } from \"~/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js\";\n\nconst Loader = () => {\n return (\n <div className=\"flex flex-col gap-sm p-md\">\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n <Skeleton className=\"h-8 w-full\" />\n </div>\n );\n};\n\nconst WebhookDeliveriesPageInner = observer(function WebhookDeliveriesPageInner() {\n const { presenter } = useFeature(WebhookDeliveriesPagePresenterFeature);\n const { route } = useRoute(Routes.Deliveries);\n const webhookId = route?.params?.webhookId;\n\n useEffect(() => {\n void presenter.init(webhookId);\n }, [presenter, webhookId]);\n\n const { vm } = presenter;\n\n if (vm.error) {\n return (\n <div className=\"flex flex-col items-center gap-sm p-md\">\n <Text>{vm.error}</Text>\n <Button variant=\"secondary\" onClick={() => void presenter.init()}>\n Retry\n </Button>\n </div>\n );\n }\n\n return (\n <div className=\"flex flex-col h-main-content\">\n <div className=\"flex items-center justify-between py-sm px-md\">\n <Heading level={5}>Webhook Deliveries</Heading>\n <WebhookDefinitionsButton />\n </div>\n <Separator />\n <div className={\"p-sm\"}>\n <DeliveryFilters presenter={presenter} />\n </div>\n <Separator />\n {vm.loading ? <Loader /> : <DeliveryList presenter={presenter} />}\n </div>\n );\n});\n\nexport const WebhookDeliveriesPage = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n ListWebhookDeliveriesFeature.register(child);\n ListAvailableEventsFeature.register(child);\n ResendWebhookDeliveryFeature.register(child);\n ListWebhooksFeature.register(child);\n WebhookDeliveriesPagePresenterFeature.register(child);\n return child;\n }, [container]);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookDeliveriesPageInner />\n </DiContainerProvider>\n );\n};\n"],"names":["Loader","Skeleton","WebhookDeliveriesPageInner","observer","presenter","useFeature","WebhookDeliveriesPagePresenterFeature","route","useRoute","Routes","webhookId","useEffect","vm","Text","Button","Heading","WebhookDefinitionsButton","Separator","DeliveryFilters","DeliveryList","WebhookDeliveriesPage","container","useContainer","scopedContainer","useMemo","child","ListWebhookDeliveriesFeature","ListAvailableEventsFeature","ResendWebhookDeliveryFeature","ListWebhooksFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;AAgBA,MAAMA,SAAS,IACJ,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;sBACpB,oBAACA,UAAQA;QAAC,WAAU;;AAKhC,MAAMC,mDAA6BC,SAAS;IACxC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,UAAU;IAC5C,MAAMC,YAAYH,OAAO,QAAQ;IAEjCI,UAAU;QACDP,UAAU,IAAI,CAACM;IACxB,GAAG;QAACN;QAAWM;KAAU;IAEzB,MAAM,EAAEE,EAAE,EAAE,GAAGR;IAEf,IAAIQ,GAAG,KAAK,EACR,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACC,MAAIA,MAAED,GAAG,KAAK,iBACf,oBAACE,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAM,KAAKV,UAAU,IAAI;OAAI;IAO9E,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACW,SAAOA;QAAC,OAAO;OAAG,qCACnB,oBAACC,0BAAwBA,QAAAA,WAAAA,GAE7B,oBAACC,WAASA,OAAAA,WAAAA,GACV,oBAAC;QAAI,WAAW;qBACZ,oBAACC,iBAAeA;QAAC,WAAWd;uBAEhC,oBAACa,WAASA,OACTL,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACZ,QAAAA,QAAAA,WAAAA,GAAY,oBAACmB,cAAYA;QAAC,WAAWf;;AAGhE;AAEO,MAAMgB,wBAAwB;IACjC,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBC,QAAQ;QAC5B,MAAMC,QAAQJ,UAAU,oBAAoB;QAC5CK,6BAA6B,QAAQ,CAACD;QACtCE,2BAA2B,QAAQ,CAACF;QACpCG,6BAA6B,QAAQ,CAACH;QACtCI,oBAAoB,QAAQ,CAACJ;QAC7BnB,sCAAsC,QAAQ,CAACmB;QAC/C,OAAOA;IACX,GAAG;QAACJ;KAAU;IAEd,OAAO,WAAP,GACI,oBAACS,qBAAmBA;QAAC,WAAWP;qBAC5B,oBAACrB,kDAA0BA;AAGvC"}
|
|
@@ -25,6 +25,9 @@ declare class WebhookFormPresenterImpl implements IWebhookFormPresenter {
|
|
|
25
25
|
get vm(): IWebhookFormViewModel;
|
|
26
26
|
constructor(formModelFactory: FormModelFactory.Interface, getWebhookUseCase: GetWebhookUseCase.Interface, createWebhookUseCase: CreateWebhookUseCase.Interface, updateWebhookUseCase: UpdateWebhookUseCase.Interface, deleteWebhookUseCase: DeleteWebhookUseCase.Interface, listAvailableEventsUseCase: ListAvailableEventsUseCase.Interface, permissions: WebhookPermissions.Interface);
|
|
27
27
|
private buildForm;
|
|
28
|
+
private baseLayoutRows;
|
|
29
|
+
generateSigningSecret(): void;
|
|
30
|
+
getSigningSecret(): string;
|
|
28
31
|
private entityFieldName;
|
|
29
32
|
private addEventFields;
|
|
30
33
|
private collectEvents;
|
|
@@ -7,6 +7,7 @@ import { UpdateWebhookUseCase } from "../../features/updateWebhook/abstractions.
|
|
|
7
7
|
import { DeleteWebhookUseCase } from "../../features/deleteWebhook/abstractions.js";
|
|
8
8
|
import { ListAvailableEventsUseCase } from "../../features/listAvailableEvents/abstractions.js";
|
|
9
9
|
import { WebhookPermissions } from "../../features/permissions/abstractions.js";
|
|
10
|
+
import { INVALID_SIGNING_SECRET_MESSAGE, generateSigningSecret, isValidSigningSecret } from "../../shared/signingSecret.js";
|
|
10
11
|
import { FormModelFactory } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
11
12
|
class WebhookFormPresenterImpl {
|
|
12
13
|
get vm() {
|
|
@@ -43,7 +44,8 @@ class WebhookFormPresenterImpl {
|
|
|
43
44
|
});
|
|
44
45
|
}
|
|
45
46
|
buildForm() {
|
|
46
|
-
|
|
47
|
+
const canEdit = this.permissions.canEdit("webhook");
|
|
48
|
+
const form = this.formModelFactory.create({
|
|
47
49
|
fields: (fields)=>({
|
|
48
50
|
name: fields.text().label("Name").required("Name is required"),
|
|
49
51
|
slug: fields.text().label("Slug").required("Slug is required").computedUntilDirty((form)=>{
|
|
@@ -52,15 +54,31 @@ class WebhookFormPresenterImpl {
|
|
|
52
54
|
}).schema(z.string().min(3, "Slug must be at least 3 characters long")),
|
|
53
55
|
endpointUrl: fields.text().label("Endpoint URL").required("Endpoint URL is required").placeholder("https://"),
|
|
54
56
|
description: fields.text().label("Description").renderer("textarea"),
|
|
55
|
-
enabled: fields.boolean().label("Enabled").defaultValue(false)
|
|
57
|
+
enabled: fields.boolean().label("Enabled").defaultValue(false),
|
|
58
|
+
signingSecret: fields.text().label("Signing Secret").placeholder(canEdit ? "Leave empty to use the global signing secret" : "Visible only to users who can edit webhooks").description("Signs this webhook's payloads so the receiver can verify them. Overrides the global signing secret.").schema(z.string().optional().refine(isValidSigningSecret, {
|
|
59
|
+
message: INVALID_SIGNING_SECRET_MESSAGE
|
|
60
|
+
}))
|
|
56
61
|
}),
|
|
57
|
-
layout: (layout)=>
|
|
58
|
-
layout.row("name", "slug"),
|
|
59
|
-
layout.row("endpointUrl"),
|
|
60
|
-
layout.row("description"),
|
|
61
|
-
layout.row("enabled")
|
|
62
|
-
]
|
|
62
|
+
layout: (layout)=>this.baseLayoutRows(layout)
|
|
63
63
|
});
|
|
64
|
+
form.field("signingSecret").setDisabled(!canEdit);
|
|
65
|
+
return form;
|
|
66
|
+
}
|
|
67
|
+
baseLayoutRows(layout) {
|
|
68
|
+
return [
|
|
69
|
+
layout.row("name", "slug"),
|
|
70
|
+
layout.row("endpointUrl"),
|
|
71
|
+
layout.row("description"),
|
|
72
|
+
layout.row("enabled"),
|
|
73
|
+
layout.row("signingSecret"),
|
|
74
|
+
layout.element("signingSecretActions", {})
|
|
75
|
+
];
|
|
76
|
+
}
|
|
77
|
+
generateSigningSecret() {
|
|
78
|
+
this._form.field("signingSecret").setValue(generateSigningSecret());
|
|
79
|
+
}
|
|
80
|
+
getSigningSecret() {
|
|
81
|
+
return String(this._form.field("signingSecret").getValue() ?? "");
|
|
64
82
|
}
|
|
65
83
|
entityFieldName(appLabel, entityLabel) {
|
|
66
84
|
const slug = `${appLabel}_${entityLabel}`.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
@@ -97,12 +115,7 @@ class WebhookFormPresenterImpl {
|
|
|
97
115
|
return result;
|
|
98
116
|
});
|
|
99
117
|
this._form.setLayout((layout)=>{
|
|
100
|
-
const rows =
|
|
101
|
-
layout.row("name", "slug"),
|
|
102
|
-
layout.row("endpointUrl"),
|
|
103
|
-
layout.row("description"),
|
|
104
|
-
layout.row("enabled")
|
|
105
|
-
];
|
|
118
|
+
const rows = this.baseLayoutRows(layout);
|
|
106
119
|
for (const [appLabel, entities] of grouped){
|
|
107
120
|
rows.push(layout.separator());
|
|
108
121
|
rows.push(layout.element("sectionHeading", {
|
|
@@ -169,7 +182,8 @@ class WebhookFormPresenterImpl {
|
|
|
169
182
|
endpointUrl: data.endpointUrl,
|
|
170
183
|
description: data.description || void 0,
|
|
171
184
|
enabled: data.enabled,
|
|
172
|
-
events: this.collectEvents()
|
|
185
|
+
events: this.collectEvents(),
|
|
186
|
+
signingSecret: data.signingSecret || ""
|
|
173
187
|
};
|
|
174
188
|
if (this._isNew) {
|
|
175
189
|
const created = await this.createWebhookUseCase.execute(merged);
|
|
@@ -222,7 +236,8 @@ class WebhookFormPresenterImpl {
|
|
|
222
236
|
slug: webhook.slug,
|
|
223
237
|
endpointUrl: webhook.endpointUrl,
|
|
224
238
|
description: webhook.description ?? "",
|
|
225
|
-
enabled: webhook.enabled
|
|
239
|
+
enabled: webhook.enabled,
|
|
240
|
+
signingSecret: webhook.signingSecret ?? ""
|
|
226
241
|
});
|
|
227
242
|
this._form.field("slug").setDisabled(true);
|
|
228
243
|
this.distributeEvents(webhook.events);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/WebhookFormPresenter.js","sources":["../../../../src/admin/presentation/WebhookForm/WebhookFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { WebhookEvent } from \"~/admin/shared/types.js\";\nimport {\n WebhookFormPresenter as Abstraction,\n type IWebhookFormPresenter,\n type IWebhookFormViewModel\n} from \"./abstractions.js\";\nimport { GetWebhookUseCase } from \"~/admin/features/getWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/admin/features/createWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/admin/features/updateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { ListAvailableEventsUseCase } from \"~/admin/features/listAvailableEvents/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\nimport {\n FormModelFactory,\n type IFormModel,\n type ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nclass WebhookFormPresenterImpl implements IWebhookFormPresenter {\n private _loading = false;\n private _saving = false;\n private _isNew = false;\n private _webhook: Webhook | null = null;\n private _webhookId: string | null = null;\n private _form: IFormModel;\n private _entityFieldNames: string[] = [];\n private _entityGroups: Map<string, Map<string, WebhookEvent[]>> = new Map();\n\n public get vm(): IWebhookFormViewModel {\n return {\n loading: this._loading,\n saving: this._saving,\n isNew: this._isNew,\n webhook: this._webhook,\n permissions: {\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n },\n form: this._form.vm\n };\n }\n\n public constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly getWebhookUseCase: GetWebhookUseCase.Interface,\n private readonly createWebhookUseCase: CreateWebhookUseCase.Interface,\n private readonly updateWebhookUseCase: UpdateWebhookUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly listAvailableEventsUseCase: ListAvailableEventsUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n this._form = this.buildForm();\n\n makeAutoObservable(this, { vm: computed });\n }\n\n private buildForm(): IFormModel {\n return this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required\"),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required\")\n .computedUntilDirty(form => {\n const name = String(form.field(\"name\").getValue() ?? \"\");\n return name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n })\n .schema(z.string().min(3, \"Slug must be at least 3 characters long\")),\n endpointUrl: fields\n .text()\n .label(\"Endpoint URL\")\n .required(\"Endpoint URL is required\")\n .placeholder(\"https://\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\"),\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false)\n }),\n layout: layout => [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ]\n });\n }\n\n private entityFieldName(appLabel: string, entityLabel: string): string {\n const slug = `${appLabel}_${entityLabel}`\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return `events_${slug}`;\n }\n\n private addEventFields(events: WebhookEvent[]): void {\n const grouped = new Map<string, Map<string, WebhookEvent[]>>();\n for (const event of events) {\n let appMap = grouped.get(event.appLabel);\n if (!appMap) {\n appMap = new Map();\n grouped.set(event.appLabel, appMap);\n }\n const existing = appMap.get(event.entityLabel) ?? [];\n existing.push(event);\n appMap.set(event.entityLabel, existing);\n }\n\n this._entityGroups = grouped;\n this._entityFieldNames = [];\n\n this._form.fields(fields => {\n const result: Record<string, ReturnType<typeof fields.object>> = {};\n\n for (const [appLabel, entities] of grouped) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n this._entityFieldNames.push(fieldName);\n\n result[fieldName] = fields\n .object()\n .label(entityLabel)\n .renderer(\"objectAccordionSingle\", { open: false })\n .fields(f => {\n return {\n selected: f\n .text()\n .list()\n .options(\n entityEvents.map(e => ({\n label: e.label,\n value: e.eventName\n }))\n )\n .renderer(\"checkboxes\")\n };\n });\n }\n }\n\n return result;\n });\n\n this._form.setLayout(layout => {\n const rows: ILayoutNodeBuilder[] = [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\")\n ];\n\n for (const [appLabel, entities] of grouped) {\n rows.push(layout.separator());\n rows.push(layout.element(\"sectionHeading\", { label: appLabel }));\n\n for (const [entityLabel] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n rows.push(layout.object(fieldName, inner => [inner.row(\"selected\")]));\n }\n }\n\n return rows;\n });\n\n this._form.addRule(form => {\n if (this._entityFieldNames.length === 0) {\n return [];\n }\n for (const fieldName of this._entityFieldNames) {\n const objectField = form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n return [];\n }\n }\n\n return [{ path: \"Events\", message: \"At least one event must be selected.\" }];\n });\n }\n\n private collectEvents(): string[] {\n const allEvents: string[] = [];\n\n for (const fieldName of this._entityFieldNames) {\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n allEvents.push(...values);\n }\n }\n\n return allEvents;\n }\n\n private distributeEvents(webhookEvents: string[]): void {\n const eventSet = new Set(webhookEvents);\n\n for (const [appLabel, entities] of this._entityGroups) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n\n const selected = entityEvents\n .filter(e => eventSet.has(e.eventName))\n .map(e => e.eventName);\n selectedField.setValue(selected);\n }\n }\n }\n\n public async save(): Promise<boolean> {\n const data = await this._form.submit<Record<string, unknown>>();\n if (data === false) {\n return false;\n }\n\n runInAction(() => {\n this._saving = true;\n });\n\n try {\n const merged = {\n name: data.name as string,\n slug: data.slug as string,\n endpointUrl: data.endpointUrl as string,\n description: (data.description as string) || undefined,\n enabled: data.enabled as boolean,\n events: this.collectEvents()\n };\n\n if (this._isNew) {\n const created = await this.createWebhookUseCase.execute(merged);\n\n runInAction(() => {\n this._webhook = created;\n this._webhookId = created.id;\n this._isNew = false;\n this._form.field(\"slug\").setDisabled(true);\n });\n } else {\n const updated = await this.updateWebhookUseCase.execute(this._webhookId!, merged);\n\n runInAction(() => {\n this._webhook = updated;\n });\n }\n } finally {\n runInAction(() => {\n this._saving = false;\n });\n }\n\n return true;\n }\n\n public async deleteWebhook(): Promise<void> {\n if (!this._webhookId || this._isNew) {\n return;\n }\n await this.deleteWebhookUseCase.execute(this._webhookId);\n }\n\n public async init(id: string): Promise<void> {\n this._loading = true;\n this._isNew = id === \"new\";\n this._webhookId = id === \"new\" ? null : id;\n\n const eventsPromise = this.listAvailableEventsUseCase.execute();\n\n if (!this._isNew) {\n const [webhook, events] = await Promise.all([\n this.getWebhookUseCase.execute(id),\n eventsPromise\n ]);\n\n runInAction(() => {\n this._webhook = webhook;\n this._form = this.buildForm();\n this.addEventFields(events);\n this._form.setData({\n name: webhook.name,\n slug: webhook.slug,\n endpointUrl: webhook.endpointUrl,\n description: webhook.description ?? \"\",\n enabled: webhook.enabled\n });\n this._form.field(\"slug\").setDisabled(true);\n this.distributeEvents(webhook.events);\n this._loading = false;\n });\n } else {\n const events = await eventsPromise;\n\n runInAction(() => {\n this._form = this.buildForm();\n this.addEventFields(events);\n this._loading = false;\n });\n }\n }\n}\n\nexport const WebhookFormPresenter = Abstraction.createImplementation({\n implementation: WebhookFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n GetWebhookUseCase,\n CreateWebhookUseCase,\n UpdateWebhookUseCase,\n DeleteWebhookUseCase,\n ListAvailableEventsUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookFormPresenterImpl","formModelFactory","getWebhookUseCase","createWebhookUseCase","updateWebhookUseCase","deleteWebhookUseCase","listAvailableEventsUseCase","permissions","Map","makeAutoObservable","computed","fields","form","name","String","z","layout","appLabel","entityLabel","slug","events","grouped","event","appMap","existing","result","entities","entityEvents","fieldName","f","e","rows","inner","objectField","selectedField","values","allEvents","webhookEvents","eventSet","Set","selected","data","runInAction","merged","undefined","created","updated","id","eventsPromise","webhook","Promise","WebhookFormPresenter","Abstraction","FormModelFactory","GetWebhookUseCase","CreateWebhookUseCase","UpdateWebhookUseCase","DeleteWebhookUseC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AAAO,UAAPA;QACd,IAAI,CAAC,UAAU,GAAGA,AAAO,UAAPA,KAAe,OAAOA;QAExC,MAAMC,gBAAgB,IAAI,CAAC,0BAA0B,CAAC,OAAO;QAE7D,IAAK,IAAI,CAAC,MAAM,EAqBT;YACH,MAAM5B,SAAS,MAAM4B;YAErBN,YAAY;gBACR,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,cAAc,CAACtB;gBACpB,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ,OA7BkB;YACd,MAAM,CAAC6B,SAAS7B,OAAO,GAAG,MAAM8B,QAAQ,GAAG,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACH;gBAC/BC;aACH;YAEDN,YAAY;gBACR,IAAI,CAAC,QAAQ,GAAGO;gBAChB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,cAAc,CAAC7B;gBACpB,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;oBACf,MAAM6B,QAAQ,IAAI;oBAClB,MAAMA,QAAQ,IAAI;oBAClB,aAAaA,QAAQ,WAAW;oBAChC,aAAaA,QAAQ,WAAW,IAAI;oBACpC,SAASA,QAAQ,OAAO;gBAC5B;gBACA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,CAAC;gBACrC,IAAI,CAAC,gBAAgB,CAACA,QAAQ,MAAM;gBACpC,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ;IASJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBpD;IAChB,cAAc;QACVqD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/WebhookFormPresenter.js","sources":["../../../../src/admin/presentation/WebhookForm/WebhookFormPresenter.ts"],"sourcesContent":["import { computed, makeAutoObservable, runInAction } from \"mobx\";\nimport { z } from \"zod\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { WebhookEvent } from \"~/admin/shared/types.js\";\nimport {\n WebhookFormPresenter as Abstraction,\n type IWebhookFormPresenter,\n type IWebhookFormViewModel\n} from \"./abstractions.js\";\nimport { GetWebhookUseCase } from \"~/admin/features/getWebhook/abstractions.js\";\nimport { CreateWebhookUseCase } from \"~/admin/features/createWebhook/abstractions.js\";\nimport { UpdateWebhookUseCase } from \"~/admin/features/updateWebhook/abstractions.js\";\nimport { DeleteWebhookUseCase } from \"~/admin/features/deleteWebhook/abstractions.js\";\nimport { ListAvailableEventsUseCase } from \"~/admin/features/listAvailableEvents/abstractions.js\";\nimport { WebhookPermissions } from \"~/admin/features/permissions/abstractions.js\";\nimport {\n generateSigningSecret,\n INVALID_SIGNING_SECRET_MESSAGE,\n isValidSigningSecret\n} from \"~/admin/shared/signingSecret.js\";\nimport {\n FormModelFactory,\n type IFormModel,\n type ILayoutBuilder,\n type ILayoutNodeBuilder\n} from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nclass WebhookFormPresenterImpl implements IWebhookFormPresenter {\n private _loading = false;\n private _saving = false;\n private _isNew = false;\n private _webhook: Webhook | null = null;\n private _webhookId: string | null = null;\n private _form: IFormModel;\n private _entityFieldNames: string[] = [];\n private _entityGroups: Map<string, Map<string, WebhookEvent[]>> = new Map();\n\n public get vm(): IWebhookFormViewModel {\n return {\n loading: this._loading,\n saving: this._saving,\n isNew: this._isNew,\n webhook: this._webhook,\n permissions: {\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n },\n form: this._form.vm\n };\n }\n\n public constructor(\n private readonly formModelFactory: FormModelFactory.Interface,\n private readonly getWebhookUseCase: GetWebhookUseCase.Interface,\n private readonly createWebhookUseCase: CreateWebhookUseCase.Interface,\n private readonly updateWebhookUseCase: UpdateWebhookUseCase.Interface,\n private readonly deleteWebhookUseCase: DeleteWebhookUseCase.Interface,\n private readonly listAvailableEventsUseCase: ListAvailableEventsUseCase.Interface,\n private readonly permissions: WebhookPermissions.Interface\n ) {\n this._form = this.buildForm();\n\n makeAutoObservable(this, { vm: computed });\n }\n\n private buildForm(): IFormModel {\n const canEdit = this.permissions.canEdit(\"webhook\");\n const form = this.formModelFactory.create({\n fields: fields => ({\n name: fields.text().label(\"Name\").required(\"Name is required\"),\n slug: fields\n .text()\n .label(\"Slug\")\n .required(\"Slug is required\")\n .computedUntilDirty(form => {\n const name = String(form.field(\"name\").getValue() ?? \"\");\n return name\n .trim()\n .toLowerCase()\n .replace(/[^a-z0-9\\s-]/g, \"\")\n .replace(/\\s+/g, \"-\");\n })\n .schema(z.string().min(3, \"Slug must be at least 3 characters long\")),\n endpointUrl: fields\n .text()\n .label(\"Endpoint URL\")\n .required(\"Endpoint URL is required\")\n .placeholder(\"https://\"),\n description: fields.text().label(\"Description\").renderer(\"textarea\"),\n enabled: fields.boolean().label(\"Enabled\").defaultValue(false),\n signingSecret: fields\n .text()\n .label(\"Signing Secret\")\n .placeholder(\n canEdit\n ? \"Leave empty to use the global signing secret\"\n : \"Visible only to users who can edit webhooks\"\n )\n .description(\n \"Signs this webhook's payloads so the receiver can verify them. Overrides the global signing secret.\"\n )\n .schema(\n z.string().optional().refine(isValidSigningSecret, {\n message: INVALID_SIGNING_SECRET_MESSAGE\n })\n )\n }),\n layout: layout => this.baseLayoutRows(layout)\n });\n /* Users who can't edit webhooks don't get the secret, so the field would only mislead. */\n form.field(\"signingSecret\").setDisabled(!canEdit);\n return form;\n }\n\n private baseLayoutRows(layout: ILayoutBuilder): ILayoutNodeBuilder[] {\n return [\n layout.row(\"name\", \"slug\"),\n layout.row(\"endpointUrl\"),\n layout.row(\"description\"),\n layout.row(\"enabled\"),\n layout.row(\"signingSecret\"),\n layout.element(\"signingSecretActions\", {})\n ];\n }\n\n public generateSigningSecret(): void {\n this._form.field(\"signingSecret\").setValue(generateSigningSecret());\n }\n\n public getSigningSecret(): string {\n return String(this._form.field(\"signingSecret\").getValue() ?? \"\");\n }\n\n private entityFieldName(appLabel: string, entityLabel: string): string {\n const slug = `${appLabel}_${entityLabel}`\n .toLowerCase()\n .replace(/[^a-z0-9]+/g, \"_\")\n .replace(/^_|_$/g, \"\");\n return `events_${slug}`;\n }\n\n private addEventFields(events: WebhookEvent[]): void {\n const grouped = new Map<string, Map<string, WebhookEvent[]>>();\n for (const event of events) {\n let appMap = grouped.get(event.appLabel);\n if (!appMap) {\n appMap = new Map();\n grouped.set(event.appLabel, appMap);\n }\n const existing = appMap.get(event.entityLabel) ?? [];\n existing.push(event);\n appMap.set(event.entityLabel, existing);\n }\n\n this._entityGroups = grouped;\n this._entityFieldNames = [];\n\n this._form.fields(fields => {\n const result: Record<string, ReturnType<typeof fields.object>> = {};\n\n for (const [appLabel, entities] of grouped) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n this._entityFieldNames.push(fieldName);\n\n result[fieldName] = fields\n .object()\n .label(entityLabel)\n .renderer(\"objectAccordionSingle\", { open: false })\n .fields(f => {\n return {\n selected: f\n .text()\n .list()\n .options(\n entityEvents.map(e => ({\n label: e.label,\n value: e.eventName\n }))\n )\n .renderer(\"checkboxes\")\n };\n });\n }\n }\n\n return result;\n });\n\n this._form.setLayout(layout => {\n const rows: ILayoutNodeBuilder[] = this.baseLayoutRows(layout);\n\n for (const [appLabel, entities] of grouped) {\n rows.push(layout.separator());\n rows.push(layout.element(\"sectionHeading\", { label: appLabel }));\n\n for (const [entityLabel] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n rows.push(layout.object(fieldName, inner => [inner.row(\"selected\")]));\n }\n }\n\n return rows;\n });\n\n this._form.addRule(form => {\n if (this._entityFieldNames.length === 0) {\n return [];\n }\n for (const fieldName of this._entityFieldNames) {\n const objectField = form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n return [];\n }\n }\n\n return [{ path: \"Events\", message: \"At least one event must be selected.\" }];\n });\n }\n\n private collectEvents(): string[] {\n const allEvents: string[] = [];\n\n for (const fieldName of this._entityFieldNames) {\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n const values = selectedField.getValue<string[]>();\n if (values && values.length > 0) {\n allEvents.push(...values);\n }\n }\n\n return allEvents;\n }\n\n private distributeEvents(webhookEvents: string[]): void {\n const eventSet = new Set(webhookEvents);\n\n for (const [appLabel, entities] of this._entityGroups) {\n for (const [entityLabel, entityEvents] of entities) {\n const fieldName = this.entityFieldName(appLabel, entityLabel);\n const objectField = this._form.field(fieldName).as(\"object\");\n const selectedField = objectField.children.get(\"selected\");\n if (!selectedField) {\n continue;\n }\n\n const selected = entityEvents\n .filter(e => eventSet.has(e.eventName))\n .map(e => e.eventName);\n selectedField.setValue(selected);\n }\n }\n }\n\n public async save(): Promise<boolean> {\n const data = await this._form.submit<Record<string, unknown>>();\n if (data === false) {\n return false;\n }\n\n runInAction(() => {\n this._saving = true;\n });\n\n try {\n const merged = {\n name: data.name as string,\n slug: data.slug as string,\n endpointUrl: data.endpointUrl as string,\n description: (data.description as string) || undefined,\n enabled: data.enabled as boolean,\n events: this.collectEvents(),\n /* Empty means the webhook uses the global signing secret. */\n signingSecret: (data.signingSecret as string) || \"\"\n };\n\n if (this._isNew) {\n const created = await this.createWebhookUseCase.execute(merged);\n\n runInAction(() => {\n this._webhook = created;\n this._webhookId = created.id;\n this._isNew = false;\n this._form.field(\"slug\").setDisabled(true);\n });\n } else {\n const updated = await this.updateWebhookUseCase.execute(this._webhookId!, merged);\n\n runInAction(() => {\n this._webhook = updated;\n });\n }\n } finally {\n runInAction(() => {\n this._saving = false;\n });\n }\n\n return true;\n }\n\n public async deleteWebhook(): Promise<void> {\n if (!this._webhookId || this._isNew) {\n return;\n }\n await this.deleteWebhookUseCase.execute(this._webhookId);\n }\n\n public async init(id: string): Promise<void> {\n this._loading = true;\n this._isNew = id === \"new\";\n this._webhookId = id === \"new\" ? null : id;\n\n const eventsPromise = this.listAvailableEventsUseCase.execute();\n\n if (!this._isNew) {\n const [webhook, events] = await Promise.all([\n this.getWebhookUseCase.execute(id),\n eventsPromise\n ]);\n\n runInAction(() => {\n this._webhook = webhook;\n this._form = this.buildForm();\n this.addEventFields(events);\n this._form.setData({\n name: webhook.name,\n slug: webhook.slug,\n endpointUrl: webhook.endpointUrl,\n description: webhook.description ?? \"\",\n enabled: webhook.enabled,\n signingSecret: webhook.signingSecret ?? \"\"\n });\n this._form.field(\"slug\").setDisabled(true);\n this.distributeEvents(webhook.events);\n this._loading = false;\n });\n } else {\n const events = await eventsPromise;\n\n runInAction(() => {\n this._form = this.buildForm();\n this.addEventFields(events);\n this._loading = false;\n });\n }\n }\n}\n\nexport const WebhookFormPresenter = Abstraction.createImplementation({\n implementation: WebhookFormPresenterImpl,\n dependencies: [\n FormModelFactory,\n GetWebhookUseCase,\n CreateWebhookUseCase,\n UpdateWebhookUseCase,\n DeleteWebhookUseCase,\n ListAvailableEventsUseCase,\n WebhookPermissions\n ]\n});\n"],"names":["WebhookFormPresenterImpl","formModelFactory","getWebhookUseCase","createWebhookUseCase","updateWebhookUseCase","deleteWebhookUseCase","listAvailableEventsUseCase","permissions","Map","makeAutoObservable","computed","canEdit","form","fields","name","String","z","isValidSigningSecret","INVALID_SIGNING_SECRET_MESSAGE","layout","generateSigningSecret","appLabel","entityLabel","slug","events","grouped","event","appMap","existing","result","entities","entityEvents","fieldName","f","e","rows","inner","objectField","selectedField","values","allEvents","webhookEvents","eventSet","Set","selected","data","runInAction","merged","undefined","created","updated","id","eventsPromise","webhook","Promise","WebhookFormPresenter","Abstraction","FormModelFactory","GetWebhookUseCase","CreateWebhookUseCase","UpdateWebhookUseCase","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;;;AA2BA,MAAMA;IAUF,IAA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AAaA,QAAQ,WAAW,IAAI;oBACpC,SAASA,QAAQ,OAAO;oBACxB,eAAeA,QAAQ,aAAa,IAAI;gBAC5C;gBACA,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,QAAQ,WAAW,CAAC;gBACrC,IAAI,CAAC,gBAAgB,CAACA,QAAQ,MAAM;gBACpC,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ;IASJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgBxD;IAChB,cAAc;QACVyD;QACAC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -16,6 +16,8 @@ export interface IWebhookFormPresenter {
|
|
|
16
16
|
init(id: string): void;
|
|
17
17
|
save(): Promise<boolean>;
|
|
18
18
|
deleteWebhook(): Promise<void>;
|
|
19
|
+
generateSigningSecret(): void;
|
|
20
|
+
getSigningSecret(): string;
|
|
19
21
|
}
|
|
20
22
|
export declare const WebhookFormPresenter: import("@webiny/di").Abstraction<IWebhookFormPresenter>;
|
|
21
23
|
export declare namespace WebhookFormPresenter {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/abstractions.js","sources":["../../../../src/admin/presentation/WebhookForm/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IFormVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport interface IWebhookFormViewModel {\n loading: boolean;\n saving: boolean;\n isNew: boolean;\n webhook: Webhook | null;\n permissions: {\n canEdit: boolean;\n canDelete: boolean;\n };\n form: IFormVM;\n}\n\nexport interface IWebhookFormPresenter {\n vm: IWebhookFormViewModel;\n init(id: string): void;\n save(): Promise<boolean>;\n deleteWebhook(): Promise<void>;\n}\n\nexport const WebhookFormPresenter =\n createAbstraction<IWebhookFormPresenter>(\"WebhookFormPresenter\");\n\nexport namespace WebhookFormPresenter {\n export type Interface = IWebhookFormPresenter;\n export type ViewModel = IWebhookFormViewModel;\n}\n"],"names":["WebhookFormPresenter","createAbstraction"],"mappings":";
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/abstractions.js","sources":["../../../../src/admin/presentation/WebhookForm/abstractions.ts"],"sourcesContent":["import { createAbstraction } from \"@webiny/feature/admin\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IFormVM } from \"@webiny/app-admin/features/formModel/abstractions.js\";\n\nexport interface IWebhookFormViewModel {\n loading: boolean;\n saving: boolean;\n isNew: boolean;\n webhook: Webhook | null;\n permissions: {\n canEdit: boolean;\n canDelete: boolean;\n };\n form: IFormVM;\n}\n\nexport interface IWebhookFormPresenter {\n vm: IWebhookFormViewModel;\n init(id: string): void;\n save(): Promise<boolean>;\n deleteWebhook(): Promise<void>;\n generateSigningSecret(): void;\n getSigningSecret(): string;\n}\n\nexport const WebhookFormPresenter =\n createAbstraction<IWebhookFormPresenter>(\"WebhookFormPresenter\");\n\nexport namespace WebhookFormPresenter {\n export type Interface = IWebhookFormPresenter;\n export type ViewModel = IWebhookFormViewModel;\n}\n"],"names":["WebhookFormPresenter","createAbstraction"],"mappings":";AAyBO,MAAMA,uBACTC,kBAAyC"}
|
|
@@ -11,11 +11,19 @@ import { DeleteWebhookFeature } from "../../../features/deleteWebhook/feature.js
|
|
|
11
11
|
import { ListAvailableEventsFeature } from "../../../features/listAvailableEvents/feature.js";
|
|
12
12
|
import { WebhookPermissionsFeature } from "../../../features/permissions/feature.js";
|
|
13
13
|
import { Routes } from "../../../routes.js";
|
|
14
|
-
import {
|
|
14
|
+
import { SigningSecretActions } from "../../SigningSecret/SigningSecretActions.js";
|
|
15
15
|
import { HasPermission } from "../../security/HasPermission.js";
|
|
16
16
|
const SectionHeading = ({ field })=>/*#__PURE__*/ react.createElement("span", {
|
|
17
17
|
className: "text-md font-semibold"
|
|
18
18
|
}, String(field.label ?? ""));
|
|
19
|
+
const WebhookFormView_WebhookSigningSecretActions = observer(function() {
|
|
20
|
+
const { presenter } = useFeature(WebhookFormPresenterFeature);
|
|
21
|
+
if (!presenter.vm.permissions.canEdit) return null;
|
|
22
|
+
return /*#__PURE__*/ react.createElement(SigningSecretActions, {
|
|
23
|
+
getValue: ()=>presenter.getSigningSecret(),
|
|
24
|
+
onGenerate: ()=>presenter.generateSigningSecret()
|
|
25
|
+
});
|
|
26
|
+
});
|
|
19
27
|
const WebhookFormView_WebhookFormViewInner = observer(function() {
|
|
20
28
|
const { presenter } = useFeature(WebhookFormPresenterFeature);
|
|
21
29
|
const { goToRoute } = useRouter();
|
|
@@ -25,7 +33,8 @@ const WebhookFormView_WebhookFormViewInner = observer(function() {
|
|
|
25
33
|
const defaultRenderers = useFieldRenderers();
|
|
26
34
|
const renderers = useMemo(()=>({
|
|
27
35
|
...defaultRenderers,
|
|
28
|
-
"element:sectionHeading": SectionHeading
|
|
36
|
+
"element:sectionHeading": SectionHeading,
|
|
37
|
+
"element:signingSecretActions": WebhookFormView_WebhookSigningSecretActions
|
|
29
38
|
}), [
|
|
30
39
|
defaultRenderers
|
|
31
40
|
]);
|
|
@@ -58,8 +67,6 @@ const WebhookFormView_WebhookFormViewInner = observer(function() {
|
|
|
58
67
|
name: "Webhook",
|
|
59
68
|
form: vm.form,
|
|
60
69
|
renderers: renderers
|
|
61
|
-
}), /*#__PURE__*/ react.createElement(SigningSecret, {
|
|
62
|
-
presenter: presenter
|
|
63
70
|
})), /*#__PURE__*/ react.createElement(SimpleFormFooter, {
|
|
64
71
|
className: "border-t-sm border-t-neutral-dimmed pt-lg"
|
|
65
72
|
}, /*#__PURE__*/ react.createElement(Button, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/components/WebhookFormView.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/WebhookFormView.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport {\n FormErrors,\n useRouter,\n useFieldRenderers,\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent,\n SimpleFormFooter,\n FormView\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { WebhookFormPresenterFeature } from \"../feature.js\";\nimport { GetWebhookFeature } from \"~/admin/features/getWebhook/feature.js\";\nimport { CreateWebhookFeature } from \"~/admin/features/createWebhook/feature.js\";\nimport { UpdateWebhookFeature } from \"~/admin/features/updateWebhook/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport {
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/components/WebhookFormView.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/WebhookFormView.tsx"],"sourcesContent":["import React, { useEffect, useMemo, useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport {\n FormErrors,\n useRouter,\n useFieldRenderers,\n SimpleForm,\n SimpleFormHeader,\n SimpleFormContent,\n SimpleFormFooter,\n FormView\n} from \"@webiny/app-admin\";\nimport { Button, OverlayLoader } from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { WebhookFormPresenterFeature } from \"../feature.js\";\nimport { GetWebhookFeature } from \"~/admin/features/getWebhook/feature.js\";\nimport { CreateWebhookFeature } from \"~/admin/features/createWebhook/feature.js\";\nimport { UpdateWebhookFeature } from \"~/admin/features/updateWebhook/feature.js\";\nimport { DeleteWebhookFeature } from \"~/admin/features/deleteWebhook/feature.js\";\nimport { ListAvailableEventsFeature } from \"~/admin/features/listAvailableEvents/feature.js\";\nimport { WebhookPermissionsFeature } from \"~/admin/features/permissions/feature.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport { SigningSecretActions } from \"~/admin/presentation/SigningSecret/SigningSecretActions.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\n\nconst SectionHeading = ({ field }: { field: any }) => {\n return <span className=\"text-md font-semibold\">{String(field.label ?? \"\")}</span>;\n};\n\nconst WebhookSigningSecretActions = observer(function WebhookSigningSecretActions() {\n const { presenter } = useFeature(WebhookFormPresenterFeature);\n if (!presenter.vm.permissions.canEdit) {\n return null;\n }\n return (\n <SigningSecretActions\n getValue={() => presenter.getSigningSecret()}\n onGenerate={() => presenter.generateSigningSecret()}\n />\n );\n});\n\nconst WebhookFormViewInner = observer(function WebhookFormViewInner() {\n const { presenter } = useFeature(WebhookFormPresenterFeature);\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Form);\n const toast = useToast();\n const id = route.params.id;\n const defaultRenderers = useFieldRenderers();\n\n const renderers = useMemo(() => {\n return {\n ...defaultRenderers,\n \"element:sectionHeading\": SectionHeading,\n \"element:signingSecretActions\": WebhookSigningSecretActions\n };\n }, [defaultRenderers]);\n\n useEffect(() => {\n void presenter.init(id);\n }, [presenter, id]);\n\n const saveForm = useCallback(async () => {\n const res = await presenter.save();\n if (res) {\n toast.showSuccessToast({ title: \"Webhook saved successfully!\" });\n }\n }, [presenter]);\n\n const { vm } = presenter;\n\n return (\n <SimpleForm>\n {vm.loading ? <OverlayLoader text={\"Loading...\"} /> : null}\n {vm.saving ? <OverlayLoader text={\"Saving...\"} /> : null}\n {vm.form.errors.length > 0 ? (\n <div className={\"mb-lg\"}>\n <FormErrors form={vm.form} />\n </div>\n ) : null}\n <SimpleFormHeader\n title={vm.isNew ? \"Create Webhook\" : (vm.webhook?.name ?? \"Edit Webhook\")}\n />\n <SimpleFormContent>\n <FormView name=\"Webhook\" form={vm.form} renderers={renderers} />\n </SimpleFormContent>\n <SimpleFormFooter className={\"border-t-sm border-t-neutral-dimmed pt-lg\"}>\n <Button variant=\"secondary\" onClick={() => goToRoute(Routes.List)}>\n Cancel\n </Button>\n <HasPermission entity=\"webhook\" action=\"edit\">\n <Button variant=\"primary\" onClick={saveForm} disabled={vm.saving}>\n {vm.saving ? \"Saving...\" : \"Save\"}\n </Button>\n </HasPermission>\n </SimpleFormFooter>\n </SimpleForm>\n );\n});\n\nexport const WebhookFormView = () => {\n const container = useContainer();\n\n const scopedContainer = useMemo(() => {\n const child = container.createChildContainer();\n GetWebhookFeature.register(child);\n CreateWebhookFeature.register(child);\n UpdateWebhookFeature.register(child);\n DeleteWebhookFeature.register(child);\n ListAvailableEventsFeature.register(child);\n WebhookPermissionsFeature.register(child);\n WebhookFormPresenterFeature.register(child);\n return child;\n }, []);\n\n return (\n <DiContainerProvider container={scopedContainer}>\n <WebhookFormViewInner />\n </DiContainerProvider>\n );\n};\n"],"names":["SectionHeading","field","String","WebhookSigningSecretActions","observer","presenter","useFeature","WebhookFormPresenterFeature","SigningSecretActions","WebhookFormViewInner","goToRoute","useRouter","route","useRoute","Routes","toast","useToast","id","defaultRenderers","useFieldRenderers","renderers","useMemo","useEffect","saveForm","useCallback","res","vm","SimpleForm","OverlayLoader","FormErrors","SimpleFormHeader","SimpleFormContent","FormView","SimpleFormFooter","Button","HasPermission","WebhookFormView","container","useContainer","scopedContainer","child","GetWebhookFeature","CreateWebhookFeature","UpdateWebhookFeature","DeleteWebhookFeature","ListAvailableEventsFeature","WebhookPermissionsFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;;;AA0BA,MAAMA,iBAAiB,CAAC,EAAEC,KAAK,EAAkB,GACtC,WAAP,GAAO,oBAAC;QAAK,WAAU;OAAyBC,OAAOD,MAAM,KAAK,IAAI;AAG1E,MAAME,8CAA8BC,SAAS;IACzC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,IAAI,CAACF,UAAU,EAAE,CAAC,WAAW,CAAC,OAAO,EACjC,OA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K;QAAU,MAAMN,GAAG,IAAI;QAAE,WAAWN;uBAEvD,oBAACa,kBAAgBA;QAAC,WAAW;qBACzB,oBAACC,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAMxB,UAAUI,OAAO,IAAI;OAAG,yBAGnE,oBAACqB,eAAaA;QAAC,QAAO;QAAU,QAAO;qBACnC,oBAACD,QAAMA;QAAC,SAAQ;QAAU,SAASX;QAAU,UAAUG,GAAG,MAAM;OAC3DA,GAAG,MAAM,GAAG,cAAc;AAMnD;AAEO,MAAMU,kBAAkB;IAC3B,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBlB,QAAQ;QAC5B,MAAMmB,QAAQH,UAAU,oBAAoB;QAC5CI,kBAAkB,QAAQ,CAACD;QAC3BE,qBAAqB,QAAQ,CAACF;QAC9BG,qBAAqB,QAAQ,CAACH;QAC9BI,qBAAqB,QAAQ,CAACJ;QAC9BK,2BAA2B,QAAQ,CAACL;QACpCM,0BAA0B,QAAQ,CAACN;QACnCjC,4BAA4B,QAAQ,CAACiC;QACrC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACO,qBAAmBA;QAAC,WAAWR;qBAC5B,oBAAC9B,sCAAoBA;AAGjC"}
|
|
@@ -8,10 +8,13 @@ declare class WebhookSettingsPresenterImpl implements IWebhookSettingsPresenter
|
|
|
8
8
|
private readonly updateWebhookSettingsUseCase;
|
|
9
9
|
private _loading;
|
|
10
10
|
private _saving;
|
|
11
|
+
private _error;
|
|
11
12
|
private _form;
|
|
12
13
|
get vm(): IWebhookSettingsViewModel;
|
|
13
14
|
constructor(formModelFactory: FormModelFactory.Interface, getWebhookSettingsUseCase: GetWebhookSettingsUseCase.Interface, updateWebhookSettingsUseCase: UpdateWebhookSettingsUseCase.Interface);
|
|
14
15
|
private buildForm;
|
|
16
|
+
generateSigningSecret(): void;
|
|
17
|
+
getSigningSecret(): string;
|
|
15
18
|
save(): Promise<boolean>;
|
|
16
19
|
init(): Promise<void>;
|
|
17
20
|
}
|