@webiny/webhooks 6.4.0-beta.2 → 6.4.0-beta.4
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 +32 -3
- package/admin/WebhookRoutes.js.map +1 -1
- package/admin/Webhooks.js +10 -2
- package/admin/Webhooks.js.map +1 -1
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.js +41 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsGateway.js.map +1 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.d.ts +11 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.js +18 -0
- package/admin/features/getWebhookSettings/GetWebhookSettingsUseCase.js.map +1 -0
- package/admin/features/getWebhookSettings/abstractions.d.ts +15 -0
- package/admin/features/getWebhookSettings/abstractions.js +6 -0
- package/admin/features/getWebhookSettings/abstractions.js.map +1 -0
- package/admin/features/getWebhookSettings/feature.d.ts +3 -0
- package/admin/features/getWebhookSettings/feature.js +19 -0
- package/admin/features/getWebhookSettings/feature.js.map +1 -0
- package/admin/features/getWebhookSettings/index.d.ts +2 -0
- package/admin/features/getWebhookSettings/index.js +2 -0
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesGateway.js +1 -1
- package/admin/features/listWebhookDeliveries/ListWebhookDeliveriesGateway.js.map +1 -1
- package/admin/features/listWebhookDeliveries/abstractions.d.ts +6 -1
- package/admin/features/listWebhookDeliveries/abstractions.js.map +1 -1
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.d.ts +12 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.js +44 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsGateway.js.map +1 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.d.ts +11 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.js +18 -0
- package/admin/features/updateWebhookSettings/UpdateWebhookSettingsUseCase.js.map +1 -0
- package/admin/features/updateWebhookSettings/abstractions.d.ts +19 -0
- package/admin/features/updateWebhookSettings/abstractions.js +6 -0
- package/admin/features/updateWebhookSettings/abstractions.js.map +1 -0
- package/admin/features/updateWebhookSettings/feature.d.ts +3 -0
- package/admin/features/updateWebhookSettings/feature.js +19 -0
- package/admin/features/updateWebhookSettings/feature.js.map +1 -0
- package/admin/features/updateWebhookSettings/index.d.ts +2 -0
- package/admin/features/updateWebhookSettings/index.js +2 -0
- package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/WebhookDeliveriesDataSource.d.ts +1 -2
- package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/WebhookDeliveriesDataSource.js +5 -7
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesDataSource.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.d.ts +41 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js +223 -0
- package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.d.ts +42 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.js +5 -0
- package/admin/presentation/WebhookDeliveriesPage/abstractions.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryAccordionRow.d.ts +11 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryAccordionRow.js +36 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryAccordionRow.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js +43 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryDetailContent.d.ts +7 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryDetailContent.js +76 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryDetailContent.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js +85 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.d.ts +9 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js +61 -0
- package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.d.ts +2 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js +16 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.d.ts +2 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +73 -0
- package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.d.ts +1 -0
- package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.js +13 -0
- package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.d.ts +3 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.js +17 -0
- package/admin/presentation/WebhookDeliveriesPage/feature.js.map +1 -0
- package/admin/presentation/WebhookDeliveriesPage/index.d.ts +5 -0
- package/admin/presentation/WebhookDeliveriesPage/index.js +1 -0
- package/admin/presentation/WebhookForm/WebhookFormPresenter.d.ts +9 -5
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js +144 -60
- package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -1
- package/admin/presentation/WebhookForm/abstractions.d.ts +2 -13
- package/admin/presentation/WebhookForm/abstractions.js.map +1 -1
- package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +5 -2
- package/admin/presentation/WebhookForm/components/SigningSecret.js +7 -3
- package/admin/presentation/WebhookForm/components/SigningSecret.js.map +1 -1
- package/admin/presentation/WebhookForm/components/WebhookFormView.js +49 -41
- package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -1
- package/admin/presentation/WebhookList/WebhookListPresenter.d.ts +26 -2
- package/admin/presentation/WebhookList/WebhookListPresenter.js +36 -34
- package/admin/presentation/WebhookList/WebhookListPresenter.js.map +1 -1
- package/admin/presentation/WebhookList/abstractions.d.ts +25 -7
- package/admin/presentation/WebhookList/abstractions.js.map +1 -1
- package/admin/presentation/WebhookList/components/CreateWebhookButton.d.ts +2 -0
- package/admin/presentation/WebhookList/components/CreateWebhookButton.js +22 -0
- package/admin/presentation/WebhookList/components/CreateWebhookButton.js.map +1 -0
- package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.d.ts +2 -0
- package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js +16 -0
- package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js.map +1 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.d.ts +9 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.js +170 -0
- package/admin/presentation/WebhookList/components/WebhookListContent.js.map +1 -0
- package/admin/presentation/WebhookList/components/WebhookListView.js +10 -133
- package/admin/presentation/WebhookList/components/WebhookListView.js.map +1 -1
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.d.ts +21 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js +91 -0
- package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js.map +1 -0
- package/admin/presentation/WebhookSettings/abstractions.d.ts +16 -0
- package/admin/presentation/WebhookSettings/abstractions.js +5 -0
- package/admin/presentation/WebhookSettings/abstractions.js.map +1 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.d.ts +2 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js +56 -0
- package/admin/presentation/WebhookSettings/components/WebhookSettingsView.js.map +1 -0
- package/admin/presentation/WebhookSettings/feature.d.ts +3 -0
- package/admin/presentation/WebhookSettings/feature.js +17 -0
- package/admin/presentation/WebhookSettings/feature.js.map +1 -0
- package/admin/presentation/WebhookSettings/index.d.ts +2 -0
- package/admin/presentation/WebhookSettings/index.js +2 -0
- package/admin/routes.d.ts +4 -0
- package/admin/routes.js +11 -0
- package/admin/routes.js.map +1 -1
- package/admin/shared/types.d.ts +4 -0
- package/api/WebhooksFeature.js +10 -0
- package/api/WebhooksFeature.js.map +1 -1
- package/api/domain/WebhookDelivery.d.ts +0 -1
- package/api/domain/WebhookSettings.d.ts +4 -0
- package/api/domain/WebhookSettings.js +0 -0
- package/api/domain/constants.d.ts +2 -1
- package/api/domain/constants.js +3 -2
- package/api/domain/constants.js.map +1 -1
- package/api/domain/errors.d.ts +7 -2
- package/api/domain/errors.js +16 -3
- package/api/domain/errors.js.map +1 -1
- package/api/features/CreateWebhook/CreateWebhookUseCase.d.ts +3 -3
- package/api/features/CreateWebhook/CreateWebhookUseCase.js +10 -19
- package/api/features/CreateWebhook/CreateWebhookUseCase.js.map +1 -1
- package/api/features/CreateWebhook/abstractions.d.ts +1 -1
- package/api/features/CreateWebhook/abstractions.js.map +1 -1
- package/api/features/CreateWebhook/schema.d.ts +10 -0
- package/api/features/CreateWebhook/schema.js +16 -0
- package/api/features/CreateWebhook/schema.js.map +1 -0
- package/api/features/CreateWebhookDelivery/CreateWebhookDeliveryRepository.d.ts +1 -1
- package/api/features/CreateWebhookDelivery/CreateWebhookDeliveryRepository.js +3 -1
- package/api/features/CreateWebhookDelivery/CreateWebhookDeliveryRepository.js.map +1 -1
- package/api/features/CreateWebhookDelivery/abstractions.d.ts +1 -1
- package/api/features/CreateWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.d.ts +3 -3
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js +8 -3
- package/api/features/DeleteWebhook/DeleteWebhookUseCase.js.map +1 -1
- package/api/features/DeleteWebhook/abstractions.d.ts +2 -2
- package/api/features/DeleteWebhook/abstractions.js.map +1 -1
- package/api/features/DeleteWebhook/schema.d.ts +4 -0
- package/api/features/DeleteWebhook/schema.js +7 -0
- package/api/features/DeleteWebhook/schema.js.map +1 -0
- package/api/features/GetWebhook/GetWebhookUseCase.d.ts +2 -2
- package/api/features/GetWebhook/GetWebhookUseCase.js +7 -2
- package/api/features/GetWebhook/GetWebhookUseCase.js.map +1 -1
- package/api/features/GetWebhook/abstractions.d.ts +2 -2
- package/api/features/GetWebhook/abstractions.js.map +1 -1
- package/api/features/GetWebhook/schema.d.ts +4 -0
- package/api/features/GetWebhook/schema.js +7 -0
- package/api/features/GetWebhook/schema.js.map +1 -0
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.d.ts +2 -2
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js +7 -2
- package/api/features/GetWebhookDelivery/GetWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/GetWebhookDelivery/abstractions.d.ts +2 -2
- package/api/features/GetWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/GetWebhookDelivery/schema.d.ts +4 -0
- package/api/features/GetWebhookDelivery/schema.js +7 -0
- package/api/features/GetWebhookDelivery/schema.js.map +1 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.d.ts +19 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js +57 -0
- package/api/features/GetWebhookSettings/GetWebhookSettingsRepository.js.map +1 -0
- package/api/features/GetWebhookSettings/abstractions.d.ts +13 -0
- package/api/features/GetWebhookSettings/abstractions.js +5 -0
- package/api/features/GetWebhookSettings/abstractions.js.map +1 -0
- package/api/features/GetWebhookSettings/feature.d.ts +4 -0
- package/api/features/GetWebhookSettings/feature.js +11 -0
- package/api/features/GetWebhookSettings/feature.js.map +1 -0
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.d.ts +2 -2
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js +4 -1
- package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesUseCase.js.map +1 -1
- package/api/features/ListWebhookDeliveries/abstractions.d.ts +2 -2
- package/api/features/ListWebhookDeliveries/abstractions.js.map +1 -1
- package/api/features/ListWebhookDeliveries/schema.d.ts +7 -0
- package/api/features/ListWebhookDeliveries/schema.js +10 -0
- package/api/features/ListWebhookDeliveries/schema.js.map +1 -0
- package/api/features/ListWebhooks/ListWebhooksUseCase.d.ts +2 -2
- package/api/features/ListWebhooks/ListWebhooksUseCase.js +4 -1
- package/api/features/ListWebhooks/ListWebhooksUseCase.js.map +1 -1
- package/api/features/ListWebhooks/abstractions.d.ts +2 -2
- package/api/features/ListWebhooks/abstractions.js.map +1 -1
- package/api/features/ListWebhooks/schema.d.ts +7 -0
- package/api/features/ListWebhooks/schema.js +10 -0
- package/api/features/ListWebhooks/schema.js.map +1 -0
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.d.ts +8 -6
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js +16 -6
- package/api/features/ResendWebhookDelivery/ResendWebhookDeliveryUseCase.js.map +1 -1
- package/api/features/ResendWebhookDelivery/abstractions.d.ts +2 -2
- package/api/features/ResendWebhookDelivery/abstractions.js.map +1 -1
- package/api/features/ResendWebhookDelivery/schema.d.ts +4 -0
- package/api/features/ResendWebhookDelivery/schema.js +7 -0
- package/api/features/ResendWebhookDelivery/schema.js.map +1 -0
- package/api/features/SendWebhookTask/SendWebhookTask.d.ts +7 -3
- package/api/features/SendWebhookTask/SendWebhookTask.js +46 -34
- package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
- package/api/features/SendWebhookTask/types.d.ts +1 -0
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.d.ts +3 -1
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js +17 -6
- package/api/features/TriggerWebhook/TriggerWebhookUseCase.js.map +1 -1
- package/api/features/TriggerWebhook/abstractions.d.ts +2 -2
- package/api/features/TriggerWebhook/abstractions.js.map +1 -1
- package/api/features/TriggerWebhook/schema.d.ts +5 -0
- package/api/features/TriggerWebhook/schema.js +8 -0
- package/api/features/TriggerWebhook/schema.js.map +1 -0
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.d.ts +4 -4
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js +9 -33
- package/api/features/UpdateWebhook/UpdateWebhookUseCase.js.map +1 -1
- package/api/features/UpdateWebhook/abstractions.d.ts +0 -1
- package/api/features/UpdateWebhook/abstractions.js.map +1 -1
- package/api/features/UpdateWebhook/schema.d.ts +9 -0
- package/api/features/UpdateWebhook/schema.js +15 -0
- package/api/features/UpdateWebhook/schema.js.map +1 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.d.ts +21 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +62 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js.map +1 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.d.ts +14 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.js +27 -0
- package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsUseCase.js.map +1 -0
- package/api/features/UpdateWebhookSettings/abstractions.d.ts +27 -0
- package/api/features/UpdateWebhookSettings/abstractions.js +6 -0
- package/api/features/UpdateWebhookSettings/abstractions.js.map +1 -0
- package/api/features/UpdateWebhookSettings/feature.d.ts +4 -0
- package/api/features/UpdateWebhookSettings/feature.js +13 -0
- package/api/features/UpdateWebhookSettings/feature.js.map +1 -0
- package/api/features/UpdateWebhookSettings/schema.d.ts +5 -0
- package/api/features/UpdateWebhookSettings/schema.js +9 -0
- package/api/features/UpdateWebhookSettings/schema.js.map +1 -0
- package/api/features/WebhookDeliver/WebhookDeliver.d.ts +13 -0
- package/api/features/WebhookDeliver/WebhookDeliver.js +79 -0
- package/api/features/WebhookDeliver/WebhookDeliver.js.map +1 -0
- package/api/features/WebhookDeliver/abstractions.d.ts +24 -0
- package/api/features/WebhookDeliver/abstractions.js +5 -0
- package/api/features/WebhookDeliver/abstractions.js.map +1 -0
- package/api/features/WebhookDeliver/feature.d.ts +4 -0
- package/api/features/WebhookDeliver/feature.js +11 -0
- package/api/features/WebhookDeliver/feature.js.map +1 -0
- package/api/features/WebhookDeliver/index.d.ts +2 -0
- package/api/features/WebhookDeliver/index.js +2 -0
- package/api/features/WebhookDispatcher/WebhookDispatcher.d.ts +3 -1
- package/api/features/WebhookDispatcher/WebhookDispatcher.js +9 -4
- package/api/features/WebhookDispatcher/WebhookDispatcher.js.map +1 -1
- package/api/features/WebhookSignPayload/WebhookSignPayload.d.ts +1 -0
- package/api/features/WebhookSignPayload/WebhookSignPayload.js +7 -1
- package/api/features/WebhookSignPayload/WebhookSignPayload.js.map +1 -1
- package/api/graphql/WebhookCrudSchema.js +1 -2
- package/api/graphql/WebhookCrudSchema.js.map +1 -1
- package/api/graphql/WebhookDeliverySchema.js +12 -8
- package/api/graphql/WebhookDeliverySchema.js.map +1 -1
- package/api/graphql/WebhookEventSchema.js +2 -0
- package/api/graphql/WebhookEventSchema.js.map +1 -1
- package/api/graphql/WebhookSettingsSchema.d.ts +8 -0
- package/api/graphql/WebhookSettingsSchema.js +62 -0
- package/api/graphql/WebhookSettingsSchema.js.map +1 -0
- package/api/models/WebhookDeliveryModel.js +4 -4
- package/api/models/WebhookDeliveryModel.js.map +1 -1
- package/api/models/WebhookModel.js +1 -1
- package/api/models/WebhookModel.js.map +1 -1
- package/api/models/WebhookSettingsModel.d.ts +8 -0
- package/api/models/WebhookSettingsModel.js +28 -0
- package/api/models/WebhookSettingsModel.js.map +1 -0
- package/api/utils/isValidEndpointUrl.d.ts +1 -0
- package/api/utils/isValidEndpointUrl.js +13 -0
- package/api/utils/isValidEndpointUrl.js.map +1 -0
- package/exports/api/webhooks.d.ts +0 -1
- package/exports/api/webhooks.js +0 -1
- package/package.json +27 -23
- package/admin/SecurityPermission.d.ts +0 -2
- package/admin/SecurityPermission.js +0 -15
- package/admin/SecurityPermission.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesDataSource.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.d.ts +0 -19
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js +0 -77
- package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/abstractions.d.ts +0 -22
- package/admin/presentation/WebhookDeliveries/abstractions.js +0 -5
- package/admin/presentation/WebhookDeliveries/abstractions.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.d.ts +0 -11
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js +0 -73
- package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.d.ts +0 -8
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js +0 -119
- package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/feature.d.ts +0 -3
- package/admin/presentation/WebhookDeliveries/feature.js +0 -17
- package/admin/presentation/WebhookDeliveries/feature.js.map +0 -1
- package/admin/presentation/WebhookDeliveries/index.d.ts +0 -2
- package/admin/presentation/WebhookDeliveries/index.js +0 -2
- package/admin/presentation/WebhookForm/components/EventsSelector.d.ts +0 -12
- package/admin/presentation/WebhookForm/components/EventsSelector.js +0 -44
- package/admin/presentation/WebhookForm/components/EventsSelector.js.map +0 -1
|
@@ -14,14 +14,11 @@ class WebhookFormPresenterImpl {
|
|
|
14
14
|
saving: this._saving,
|
|
15
15
|
isNew: this._isNew,
|
|
16
16
|
webhook: this._webhook,
|
|
17
|
-
showDeliveries: this._showDeliveries,
|
|
18
|
-
availableEvents: this._availableEvents,
|
|
19
17
|
permissions: {
|
|
20
18
|
canEdit: this.permissions.canEdit("webhook"),
|
|
21
19
|
canDelete: this.permissions.canDelete("webhook")
|
|
22
20
|
},
|
|
23
|
-
form: this._form.vm
|
|
24
|
-
selectedEvents: Array.from(this._selectedEvents)
|
|
21
|
+
form: this._form.vm
|
|
25
22
|
};
|
|
26
23
|
}
|
|
27
24
|
constructor(formModelFactory, getWebhookUseCase, createWebhookUseCase, updateWebhookUseCase, deleteWebhookUseCase, listAvailableEventsUseCase, permissions){
|
|
@@ -36,59 +33,9 @@ class WebhookFormPresenterImpl {
|
|
|
36
33
|
this._saving = false;
|
|
37
34
|
this._isNew = false;
|
|
38
35
|
this._webhook = null;
|
|
39
|
-
this._showDeliveries = false;
|
|
40
|
-
this._availableEvents = [];
|
|
41
36
|
this._webhookId = null;
|
|
42
|
-
this.
|
|
43
|
-
this.
|
|
44
|
-
save: async ()=>{
|
|
45
|
-
const data = await this._form.submit();
|
|
46
|
-
if (false === data) return;
|
|
47
|
-
this._saving = true;
|
|
48
|
-
try {
|
|
49
|
-
const merged = {
|
|
50
|
-
name: data.name,
|
|
51
|
-
slug: data.slug,
|
|
52
|
-
endpointUrl: data.endpointUrl,
|
|
53
|
-
description: data.description || void 0,
|
|
54
|
-
enabled: data.enabled,
|
|
55
|
-
events: Array.from(this._selectedEvents)
|
|
56
|
-
};
|
|
57
|
-
if (this._isNew) {
|
|
58
|
-
const created = await this.createWebhookUseCase.execute(merged);
|
|
59
|
-
runInAction(()=>{
|
|
60
|
-
this._webhook = created;
|
|
61
|
-
this._webhookId = created.id;
|
|
62
|
-
this._isNew = false;
|
|
63
|
-
this._form.field("slug").setDisabled(true);
|
|
64
|
-
});
|
|
65
|
-
} else {
|
|
66
|
-
const updated = await this.updateWebhookUseCase.execute(this._webhookId, merged);
|
|
67
|
-
runInAction(()=>{
|
|
68
|
-
this._webhook = updated;
|
|
69
|
-
});
|
|
70
|
-
}
|
|
71
|
-
} finally{
|
|
72
|
-
runInAction(()=>{
|
|
73
|
-
this._saving = false;
|
|
74
|
-
});
|
|
75
|
-
}
|
|
76
|
-
},
|
|
77
|
-
deleteWebhook: async ()=>{
|
|
78
|
-
if (!this._webhookId || this._isNew) return;
|
|
79
|
-
await this.deleteWebhookUseCase.execute(this._webhookId);
|
|
80
|
-
},
|
|
81
|
-
openDeliveries: ()=>{
|
|
82
|
-
this._showDeliveries = true;
|
|
83
|
-
},
|
|
84
|
-
closeDeliveries: ()=>{
|
|
85
|
-
this._showDeliveries = false;
|
|
86
|
-
},
|
|
87
|
-
toggleEvent: (eventName)=>{
|
|
88
|
-
if (this._selectedEvents.has(eventName)) this._selectedEvents.delete(eventName);
|
|
89
|
-
else this._selectedEvents.add(eventName);
|
|
90
|
-
}
|
|
91
|
-
};
|
|
37
|
+
this._entityFieldNames = [];
|
|
38
|
+
this._entityGroups = new Map();
|
|
92
39
|
this._form = this.buildForm();
|
|
93
40
|
makeAutoObservable(this, {
|
|
94
41
|
vm: computed
|
|
@@ -98,7 +45,10 @@ class WebhookFormPresenterImpl {
|
|
|
98
45
|
return this.formModelFactory.create({
|
|
99
46
|
fields: (fields)=>({
|
|
100
47
|
name: fields.text().label("Name").required("Name is required"),
|
|
101
|
-
slug: fields.text().label("Slug").required("Slug is required")
|
|
48
|
+
slug: fields.text().label("Slug").required("Slug is required").computedUntilDirty((form)=>{
|
|
49
|
+
const name = String(form.field("name").getValue() ?? "");
|
|
50
|
+
return name.trim().toLowerCase().replace(/[^a-z0-9\s-]/g, "").replace(/\s+/g, "-");
|
|
51
|
+
}),
|
|
102
52
|
endpointUrl: fields.text().label("Endpoint URL").required("Endpoint URL is required").placeholder("https://"),
|
|
103
53
|
description: fields.text().label("Description").renderer("textarea"),
|
|
104
54
|
enabled: fields.boolean().label("Enabled").defaultValue(false)
|
|
@@ -111,6 +61,140 @@ class WebhookFormPresenterImpl {
|
|
|
111
61
|
]
|
|
112
62
|
});
|
|
113
63
|
}
|
|
64
|
+
entityFieldName(appLabel, entityLabel) {
|
|
65
|
+
const slug = `${appLabel}_${entityLabel}`.toLowerCase().replace(/[^a-z0-9]+/g, "_").replace(/^_|_$/g, "");
|
|
66
|
+
return `events_${slug}`;
|
|
67
|
+
}
|
|
68
|
+
addEventFields(events) {
|
|
69
|
+
const grouped = new Map();
|
|
70
|
+
for (const event of events){
|
|
71
|
+
let appMap = grouped.get(event.appLabel);
|
|
72
|
+
if (!appMap) {
|
|
73
|
+
appMap = new Map();
|
|
74
|
+
grouped.set(event.appLabel, appMap);
|
|
75
|
+
}
|
|
76
|
+
const existing = appMap.get(event.entityLabel) ?? [];
|
|
77
|
+
existing.push(event);
|
|
78
|
+
appMap.set(event.entityLabel, existing);
|
|
79
|
+
}
|
|
80
|
+
this._entityGroups = grouped;
|
|
81
|
+
this._entityFieldNames = [];
|
|
82
|
+
this._form.fields((fields)=>{
|
|
83
|
+
const result = {};
|
|
84
|
+
for (const [appLabel, entities] of grouped)for (const [entityLabel, entityEvents] of entities){
|
|
85
|
+
const fieldName = this.entityFieldName(appLabel, entityLabel);
|
|
86
|
+
this._entityFieldNames.push(fieldName);
|
|
87
|
+
result[fieldName] = fields.object().label(entityLabel).renderer("objectAccordionSingle", {
|
|
88
|
+
open: false
|
|
89
|
+
}).fields((f)=>({
|
|
90
|
+
selected: f.text().list().options(entityEvents.map((e)=>({
|
|
91
|
+
label: e.label,
|
|
92
|
+
value: e.eventName
|
|
93
|
+
}))).renderer("checkboxes")
|
|
94
|
+
}));
|
|
95
|
+
}
|
|
96
|
+
return result;
|
|
97
|
+
});
|
|
98
|
+
this._form.setLayout((layout)=>{
|
|
99
|
+
const rows = [
|
|
100
|
+
layout.row("name", "slug"),
|
|
101
|
+
layout.row("endpointUrl"),
|
|
102
|
+
layout.row("description"),
|
|
103
|
+
layout.row("enabled")
|
|
104
|
+
];
|
|
105
|
+
for (const [appLabel, entities] of grouped){
|
|
106
|
+
rows.push(layout.separator());
|
|
107
|
+
rows.push(layout.element("sectionHeading", {
|
|
108
|
+
label: appLabel
|
|
109
|
+
}));
|
|
110
|
+
for (const [entityLabel] of entities){
|
|
111
|
+
const fieldName = this.entityFieldName(appLabel, entityLabel);
|
|
112
|
+
rows.push(layout.object(fieldName, (inner)=>[
|
|
113
|
+
inner.row("selected")
|
|
114
|
+
]));
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
return rows;
|
|
118
|
+
});
|
|
119
|
+
this._form.addRule((form)=>{
|
|
120
|
+
if (0 === this._entityFieldNames.length) return [];
|
|
121
|
+
for (const fieldName of this._entityFieldNames){
|
|
122
|
+
const objectField = form.field(fieldName).as("object");
|
|
123
|
+
const selectedField = objectField.children.get("selected");
|
|
124
|
+
if (!selectedField) continue;
|
|
125
|
+
const values = selectedField.getValue();
|
|
126
|
+
if (values && values.length > 0) return [];
|
|
127
|
+
}
|
|
128
|
+
return [
|
|
129
|
+
{
|
|
130
|
+
path: "Events",
|
|
131
|
+
message: "At least one event must be selected."
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
});
|
|
135
|
+
}
|
|
136
|
+
collectEvents() {
|
|
137
|
+
const allEvents = [];
|
|
138
|
+
for (const fieldName of this._entityFieldNames){
|
|
139
|
+
const objectField = this._form.field(fieldName).as("object");
|
|
140
|
+
const selectedField = objectField.children.get("selected");
|
|
141
|
+
if (!selectedField) continue;
|
|
142
|
+
const values = selectedField.getValue();
|
|
143
|
+
if (values && values.length > 0) allEvents.push(...values);
|
|
144
|
+
}
|
|
145
|
+
return allEvents;
|
|
146
|
+
}
|
|
147
|
+
distributeEvents(webhookEvents) {
|
|
148
|
+
const eventSet = new Set(webhookEvents);
|
|
149
|
+
for (const [appLabel, entities] of this._entityGroups)for (const [entityLabel, entityEvents] of entities){
|
|
150
|
+
const fieldName = this.entityFieldName(appLabel, entityLabel);
|
|
151
|
+
const objectField = this._form.field(fieldName).as("object");
|
|
152
|
+
const selectedField = objectField.children.get("selected");
|
|
153
|
+
if (!selectedField) continue;
|
|
154
|
+
const selected = entityEvents.filter((e)=>eventSet.has(e.eventName)).map((e)=>e.eventName);
|
|
155
|
+
selectedField.setValue(selected);
|
|
156
|
+
}
|
|
157
|
+
}
|
|
158
|
+
async save() {
|
|
159
|
+
const data = await this._form.submit();
|
|
160
|
+
if (false === data) return false;
|
|
161
|
+
runInAction(()=>{
|
|
162
|
+
this._saving = true;
|
|
163
|
+
});
|
|
164
|
+
try {
|
|
165
|
+
const merged = {
|
|
166
|
+
name: data.name,
|
|
167
|
+
slug: data.slug,
|
|
168
|
+
endpointUrl: data.endpointUrl,
|
|
169
|
+
description: data.description || void 0,
|
|
170
|
+
enabled: data.enabled,
|
|
171
|
+
events: this.collectEvents()
|
|
172
|
+
};
|
|
173
|
+
if (this._isNew) {
|
|
174
|
+
const created = await this.createWebhookUseCase.execute(merged);
|
|
175
|
+
runInAction(()=>{
|
|
176
|
+
this._webhook = created;
|
|
177
|
+
this._webhookId = created.id;
|
|
178
|
+
this._isNew = false;
|
|
179
|
+
this._form.field("slug").setDisabled(true);
|
|
180
|
+
});
|
|
181
|
+
} else {
|
|
182
|
+
const updated = await this.updateWebhookUseCase.execute(this._webhookId, merged);
|
|
183
|
+
runInAction(()=>{
|
|
184
|
+
this._webhook = updated;
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
} finally{
|
|
188
|
+
runInAction(()=>{
|
|
189
|
+
this._saving = false;
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
return true;
|
|
193
|
+
}
|
|
194
|
+
async deleteWebhook() {
|
|
195
|
+
if (!this._webhookId || this._isNew) return;
|
|
196
|
+
await this.deleteWebhookUseCase.execute(this._webhookId);
|
|
197
|
+
}
|
|
114
198
|
async init(id) {
|
|
115
199
|
this._loading = true;
|
|
116
200
|
this._isNew = "new" === id;
|
|
@@ -119,8 +203,8 @@ class WebhookFormPresenterImpl {
|
|
|
119
203
|
if (this._isNew) {
|
|
120
204
|
const events = await eventsPromise;
|
|
121
205
|
runInAction(()=>{
|
|
122
|
-
this._availableEvents = events;
|
|
123
206
|
this._form = this.buildForm();
|
|
207
|
+
this.addEventFields(events);
|
|
124
208
|
this._loading = false;
|
|
125
209
|
});
|
|
126
210
|
} else {
|
|
@@ -130,8 +214,8 @@ class WebhookFormPresenterImpl {
|
|
|
130
214
|
]);
|
|
131
215
|
runInAction(()=>{
|
|
132
216
|
this._webhook = webhook;
|
|
133
|
-
this._availableEvents = events;
|
|
134
217
|
this._form = this.buildForm();
|
|
218
|
+
this.addEventFields(events);
|
|
135
219
|
this._form.setData({
|
|
136
220
|
name: webhook.name,
|
|
137
221
|
slug: webhook.slug,
|
|
@@ -140,7 +224,7 @@ class WebhookFormPresenterImpl {
|
|
|
140
224
|
enabled: webhook.enabled
|
|
141
225
|
});
|
|
142
226
|
this._form.field("slug").setDisabled(true);
|
|
143
|
-
this.
|
|
227
|
+
this.distributeEvents(webhook.events);
|
|
144
228
|
this._loading = false;
|
|
145
229
|
});
|
|
146
230
|
}
|
|
@@ -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 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 type IWebhookFormActions\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} 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 _showDeliveries = false;\n private _availableEvents: WebhookEvent[] = [];\n private _webhookId: string | null = null;\n private _form;\n private _selectedEvents: Set<string> = new Set();\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 showDeliveries: this._showDeliveries,\n availableEvents: this._availableEvents,\n permissions: {\n canEdit: this.permissions.canEdit(\"webhook\"),\n canDelete: this.permissions.canDelete(\"webhook\")\n },\n form: this._form.vm,\n selectedEvents: Array.from(this._selectedEvents)\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.text().label(\"Slug\").required(\"Slug is required\"),\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 public actions: IWebhookFormActions = {\n save: async () => {\n const data = await this._form.submit<Record<string, unknown>>();\n if (data === false) {\n return;\n }\n\n this._saving = true;\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: Array.from(this._selectedEvents)\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(\n this._webhookId!,\n merged\n );\n\n runInAction(() => {\n this._webhook = updated;\n });\n }\n } finally {\n runInAction(() => {\n this._saving = false;\n });\n }\n },\n deleteWebhook: async () => {\n if (!this._webhookId || this._isNew) {\n return;\n }\n await this.deleteWebhookUseCase.execute(this._webhookId);\n },\n openDeliveries: () => {\n this._showDeliveries = true;\n },\n closeDeliveries: () => {\n this._showDeliveries = false;\n },\n toggleEvent: (eventName: string) => {\n if (this._selectedEvents.has(eventName)) {\n this._selectedEvents.delete(eventName);\n } else {\n this._selectedEvents.add(eventName);\n }\n }\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._availableEvents = events;\n this._form = this.buildForm();\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._selectedEvents = new Set(webhook.events);\n this._loading = false;\n });\n } else {\n const events = await eventsPromise;\n\n runInAction(() => {\n this._availableEvents = events;\n this._form = this.buildForm();\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","Array","formModelFactory","getWebhookUseCase","createWebhookUseCase","updateWebhookUseCase","deleteWebhookUseCase","listAvailableEventsUseCase","permissions","Set","data","merged","undefined","created","runInAction","updated","eventName","makeAutoObservable","computed","fields","layout","id","eventsPromise","events","webhook","Promise","WebhookFormPresenter","Abstraction","FormModelFactory","GetWebhookUseCase","CreateWebhookUseCase","UpdateWebhookUseCase","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;AAoBA,MAAMA;IAWF,IAAW,KAA4B;QACnC,OAAO;YACH,SAAS,IAAI,CAAC,QAAQ;YACtB,QAAQ,IAAI,CAAC,OAAO;YACpB,OAAO,IAAI,CAAC,MAAM;YAClB,SAAS,IAAI,CAAC,QAAQ;YACtB,gBAAgB,IAAI,CAAC,eAAe;YACpC,iBAAiB,IAAI,CAAC,gBAAgB;YACtC,aAAa;gBACT,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAClC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YAC1C;YACA,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE;YACnB,gBAAgBC,MAAM,IAAI,CAAC,IAAI,CAAC,eAAe;QACnD;IACJ;IAEA,YACqBC,gBAA4C,EAC5CC,iBAA8C,EAC9CC,oBAAoD,EACpDC,oBAAoD,EACpDC,oBAAoD,EACpDC,0BAAgE,EAChEC,WAAyC,CAC5D;aAPmBN,gBAAgB,GAAhBA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACA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AgB,IAAI,CAAC,0BAA0B,CAAC,OAAO;QAE7D,IAAK,IAAI,CAAC,MAAM,EAqBT;YACH,MAAMC,SAAS,MAAMD;YAErBR,YAAY;gBACR,IAAI,CAAC,gBAAgB,GAAGS;gBACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ,OA7BkB;YACd,MAAM,CAACC,SAASD,OAAO,GAAG,MAAME,QAAQ,GAAG,CAAC;gBACxC,IAAI,CAAC,iBAAiB,CAAC,OAAO,CAACJ;gBAC/BC;aACH;YAEDR,YAAY;gBACR,IAAI,CAAC,QAAQ,GAAGU;gBAChB,IAAI,CAAC,gBAAgB,GAAGD;gBACxB,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;gBAC3B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC;oBACf,MAAMC,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,eAAe,GAAG,IAAIf,IAAIe,QAAQ,MAAM;gBAC7C,IAAI,CAAC,QAAQ,GAAG;YACpB;QACJ;IASJ;AACJ;AAEO,MAAME,4CAAuBC,qBAAAA,oBAAgC,CAAC;IACjE,gBAAgB3B;IAChB,cAAc;QACV4B;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 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 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","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","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;AAoBA,MAAMA;IAUF,IAAW,KAA4B;QACnC,OAAO;YACH,SAAS,IAAI,CAAC,QAAQ;YACtB,QAAQ,IAAI,CAAC,OAAO;YACpB,OAAO,IAAI,CAAC,MAAM;YAClB,SAAS,IAAI,CAAC,QAAQ;YACtB,aAAa;gBACT,SAAS,IAAI,CAAC,WAAW,CAAC,OAAO,CAAC;gBAClC,WAAW,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC;YAC1C;YACA,MAAM,IAAI,CAAC,KAAK,CAAC,EAAE;QACvB;IACJ;IAEA,YACqBC,gBAA4C,EAC5CC,iBAA8C,EAC9CC,oBAAoD,EACpDC,oBAAoD,EACpDC,oBAAoD,EACpDC,0BAAgE,EAChEC,WAAyC,CAC5D;aAPmBN,gBAAgB,GAAhBA;aACAC,iBAAiB,GAAjBA;aACAC,oBAAoB,GAApBA;aACAC,oBAAoB,GAApBA;aACAC,oBAAoB,GAApBA;aACAC,0BAA0B,GAA1BA;aACAC,WAAW,GAAXA;aA9Bb,QAAQ,GAAG;aACX,OAAO,GAAG;aACV,MAAM,GAAG;aACT,QAAQ,GAAmB;aAC3B,UAAU,GAAkB;aAE5B,iBAAiB,GAAa,EAAE;aAChC,aAAa,GAA6C,IAAIC;QAyBlE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,SAAS;QAE3BC,mBAAmB,IAAI,EAAE;YAAE,IAAIC;QAAS;IAC5C;IAEQ,YAAwB;QAC5B,OAAO,IAAI,CAAC,gBAAgB,CAAC,MAAM,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AC;QACAC;QACAC;QACAC;QACAC;QACAC;KACH;AACL"}
|
|
@@ -1,35 +1,24 @@
|
|
|
1
1
|
import type { Webhook } from "../../../admin/shared/types.js";
|
|
2
|
-
import type { WebhookEvent } from "../../../admin/shared/types.js";
|
|
3
2
|
import type { IFormVM } from "@webiny/app-admin/features/formModel/abstractions.js";
|
|
4
3
|
export interface IWebhookFormViewModel {
|
|
5
4
|
loading: boolean;
|
|
6
5
|
saving: boolean;
|
|
7
6
|
isNew: boolean;
|
|
8
7
|
webhook: Webhook | null;
|
|
9
|
-
showDeliveries: boolean;
|
|
10
|
-
availableEvents: WebhookEvent[];
|
|
11
8
|
permissions: {
|
|
12
9
|
canEdit: boolean;
|
|
13
10
|
canDelete: boolean;
|
|
14
11
|
};
|
|
15
12
|
form: IFormVM;
|
|
16
|
-
selectedEvents: string[];
|
|
17
|
-
}
|
|
18
|
-
export interface IWebhookFormActions {
|
|
19
|
-
save(): Promise<void>;
|
|
20
|
-
deleteWebhook(): Promise<void>;
|
|
21
|
-
openDeliveries(): void;
|
|
22
|
-
closeDeliveries(): void;
|
|
23
|
-
toggleEvent(eventName: string): void;
|
|
24
13
|
}
|
|
25
14
|
export interface IWebhookFormPresenter {
|
|
26
15
|
vm: IWebhookFormViewModel;
|
|
27
|
-
actions: IWebhookFormActions;
|
|
28
16
|
init(id: string): void;
|
|
17
|
+
save(): Promise<boolean>;
|
|
18
|
+
deleteWebhook(): Promise<void>;
|
|
29
19
|
}
|
|
30
20
|
export declare const WebhookFormPresenter: import("@webiny/di").Abstraction<IWebhookFormPresenter>;
|
|
31
21
|
export declare namespace WebhookFormPresenter {
|
|
32
22
|
type Interface = IWebhookFormPresenter;
|
|
33
23
|
type ViewModel = IWebhookFormViewModel;
|
|
34
|
-
type Actions = IWebhookFormActions;
|
|
35
24
|
}
|
|
@@ -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 {
|
|
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":";AAuBO,MAAMA,uBACTC,kBAAyC"}
|
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import type { IWebhookFormPresenter } from "../abstractions.js";
|
|
2
3
|
interface SigningSecretProps {
|
|
3
|
-
|
|
4
|
+
presenter: IWebhookFormPresenter;
|
|
4
5
|
}
|
|
5
|
-
export declare const SigningSecret: ({
|
|
6
|
+
export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & {
|
|
7
|
+
displayName: string;
|
|
8
|
+
};
|
|
6
9
|
export {};
|
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
import react, { useCallback, useState } from "react";
|
|
2
|
+
import { observer } from "mobx-react-lite";
|
|
2
3
|
import { IconButton, Text } from "@webiny/admin-ui";
|
|
3
4
|
import { useSnackbar } from "@webiny/app-admin/hooks/index.js";
|
|
4
5
|
import { ReactComponent } from "@webiny/icons/visibility.svg";
|
|
5
6
|
import { ReactComponent as visibility_off_svg_ReactComponent } from "@webiny/icons/visibility_off.svg";
|
|
6
7
|
import { ReactComponent as content_copy_svg_ReactComponent } from "@webiny/icons/content_copy.svg";
|
|
7
|
-
const
|
|
8
|
+
const SigningSecret_SigningSecret = observer(function({ presenter }) {
|
|
9
|
+
const { vm } = presenter;
|
|
8
10
|
const [revealed, setRevealed] = useState(false);
|
|
9
11
|
const { showSnackbar } = useSnackbar();
|
|
12
|
+
if (vm.isNew || !vm.webhook?.signingSecret) return null;
|
|
13
|
+
const secret = vm.webhook.signingSecret;
|
|
10
14
|
const handleCopy = useCallback(async ()=>{
|
|
11
15
|
await navigator.clipboard.writeText(secret);
|
|
12
16
|
showSnackbar("Signing secret copied to clipboard.");
|
|
@@ -37,7 +41,7 @@ const SigningSecret = ({ secret })=>{
|
|
|
37
41
|
onClick: ()=>void handleCopy(),
|
|
38
42
|
"aria-label": "Copy secret"
|
|
39
43
|
})));
|
|
40
|
-
};
|
|
41
|
-
export { SigningSecret };
|
|
44
|
+
});
|
|
45
|
+
export { SigningSecret_SigningSecret as SigningSecret };
|
|
42
46
|
|
|
43
47
|
//# sourceMappingURL=SigningSecret.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/components/SigningSecret.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/SigningSecret.tsx"],"sourcesContent":["import React, { useState, useCallback } from \"react\";\nimport { IconButton, Text } from \"@webiny/admin-ui\";\nimport { useSnackbar } from \"@webiny/app-admin/hooks/index.js\";\nimport { ReactComponent as VisibilityIcon } from \"@webiny/icons/visibility.svg\";\nimport { ReactComponent as VisibilityOffIcon } from \"@webiny/icons/visibility_off.svg\";\nimport { ReactComponent as CopyIcon } from \"@webiny/icons/content_copy.svg\";\n\ninterface SigningSecretProps {\n
|
|
1
|
+
{"version":3,"file":"admin/presentation/WebhookForm/components/SigningSecret.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/SigningSecret.tsx"],"sourcesContent":["import React, { useState, useCallback } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { IconButton, Text } from \"@webiny/admin-ui\";\nimport { useSnackbar } from \"@webiny/app-admin/hooks/index.js\";\nimport { ReactComponent as VisibilityIcon } from \"@webiny/icons/visibility.svg\";\nimport { ReactComponent as VisibilityOffIcon } from \"@webiny/icons/visibility_off.svg\";\nimport { ReactComponent as CopyIcon } from \"@webiny/icons/content_copy.svg\";\nimport type { IWebhookFormPresenter } from \"../abstractions.js\";\n\ninterface SigningSecretProps {\n presenter: IWebhookFormPresenter;\n}\n\nexport const SigningSecret = observer(function SigningSecret({ presenter }: SigningSecretProps) {\n const { vm } = presenter;\n const [revealed, setRevealed] = useState(false);\n const { showSnackbar } = useSnackbar();\n\n if (vm.isNew || !vm.webhook?.signingSecret) {\n return null;\n }\n\n const secret = vm.webhook.signingSecret;\n\n const handleCopy = useCallback(async () => {\n await navigator.clipboard.writeText(secret);\n showSnackbar(\"Signing secret copied to clipboard.\");\n }, [secret, showSnackbar]);\n\n return (\n <div className=\"flex flex-col gap-xs\">\n <Text size=\"sm\" className=\"text-neutral-strong\">\n Signing Secret\n </Text>\n <div className=\"flex items-center gap-sm rounded-sm border-sm border-neutral-muted px-sm py-xs\">\n <Text size=\"sm\" className=\"flex-1 font-mono select-all\">\n {revealed ? secret : \"•\".repeat(24)}\n </Text>\n <IconButton\n icon={revealed ? <VisibilityOffIcon /> : <VisibilityIcon />}\n variant=\"secondary\"\n size=\"sm\"\n onClick={() => setRevealed(prev => !prev)}\n aria-label={revealed ? \"Hide secret\" : \"Reveal secret\"}\n />\n <IconButton\n icon={<CopyIcon />}\n variant=\"secondary\"\n size=\"sm\"\n onClick={() => void handleCopy()}\n aria-label=\"Copy secret\"\n />\n </div>\n </div>\n );\n});\n"],"names":["SigningSecret","observer","presenter","vm","revealed","setRevealed","useState","showSnackbar","useSnackbar","secret","handleCopy","useCallback","navigator","Text","IconButton","VisibilityOffIcon","VisibilityIcon","prev","CopyIcon"],"mappings":";;;;;;;AAaO,MAAMA,8BAAgBC,SAAS,SAAuB,EAAEC,SAAS,EAAsB;IAC1F,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,CAACE,UAAUC,YAAY,GAAGC,SAAS;IACzC,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,IAAIL,GAAG,KAAK,IAAI,CAACA,GAAG,OAAO,EAAE,eACzB,OAAO;IAGX,MAAMM,SAASN,GAAG,OAAO,CAAC,aAAa;IAEvC,MAAMO,aAAaC,YAAY;QAC3B,MAAMC,UAAU,SAAS,CAAC,SAAS,CAACH;QACpCF,aAAa;IACjB,GAAG;QAACE;QAAQF;KAAa;IAEzB,OAAO,WAAP,GACI,oBAAC;QAAI,WAAU;qBACX,oBAACM,MAAIA;QAAC,MAAK;QAAK,WAAU;OAAsB,iCAGhD,oBAAC;QAAI,WAAU;qBACX,oBAACA,MAAIA;QAAC,MAAK;QAAK,WAAU;OACrBT,WAAWK,SAAS,IAAI,MAAM,CAAC,oBAEpC,oBAACK,YAAUA;QACP,MAAMV,WAAW,WAAXA,GAAW,oBAACW,mCAAiBA,QAAAA,WAAAA,GAAM,oBAACC,gBAAcA;QACxD,SAAQ;QACR,MAAK;QACL,SAAS,IAAMX,YAAYY,CAAAA,OAAQ,CAACA;QACpC,cAAYb,WAAW,gBAAgB;sBAE3C,oBAACU,YAAUA;QACP,oBAAM,oBAACI,iCAAQA;QACf,SAAQ;QACR,MAAK;QACL,SAAS,IAAM,KAAKR;QACpB,cAAW;;AAK/B"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import react, { useEffect, useMemo } from "react";
|
|
1
|
+
import react, { useCallback, useEffect, useMemo } from "react";
|
|
2
2
|
import { observer } from "mobx-react-lite";
|
|
3
3
|
import { DiContainerProvider, useContainer, useFeature, useRoute } from "@webiny/app";
|
|
4
|
-
import { useRouter } from "@webiny/app-admin";
|
|
5
|
-
import { Button,
|
|
6
|
-
import { FormView } from "@webiny/app-admin/features/formModel/FormView.js";
|
|
4
|
+
import { FormErrors, FormView, SimpleForm, SimpleFormContent, SimpleFormFooter, SimpleFormHeader, useFieldRenderers, useRouter } from "@webiny/app-admin";
|
|
5
|
+
import { Button, OverlayLoader, useToast } from "@webiny/admin-ui";
|
|
7
6
|
import { WebhookFormPresenterFeature } from "../feature.js";
|
|
8
7
|
import { GetWebhookFeature } from "../../../features/getWebhook/feature.js";
|
|
9
8
|
import { CreateWebhookFeature } from "../../../features/createWebhook/feature.js";
|
|
@@ -12,59 +11,68 @@ import { DeleteWebhookFeature } from "../../../features/deleteWebhook/feature.js
|
|
|
12
11
|
import { ListAvailableEventsFeature } from "../../../features/listAvailableEvents/feature.js";
|
|
13
12
|
import { WebhookPermissionsFeature } from "../../../features/permissions/feature.js";
|
|
14
13
|
import { Routes } from "../../../routes.js";
|
|
15
|
-
import { EventsSelector } from "./EventsSelector.js";
|
|
16
14
|
import { SigningSecret } from "./SigningSecret.js";
|
|
17
|
-
import {
|
|
15
|
+
import { HasPermission } from "../../security/HasPermission.js";
|
|
16
|
+
const SectionHeading = ({ field })=>/*#__PURE__*/ react.createElement("span", {
|
|
17
|
+
className: "text-md font-semibold"
|
|
18
|
+
}, String(field.label ?? ""));
|
|
18
19
|
const WebhookFormView_WebhookFormViewInner = observer(function() {
|
|
19
20
|
const { presenter } = useFeature(WebhookFormPresenterFeature);
|
|
20
21
|
const { goToRoute } = useRouter();
|
|
21
22
|
const { route } = useRoute(Routes.Form);
|
|
23
|
+
const toast = useToast();
|
|
22
24
|
const id = route.params.id;
|
|
25
|
+
const defaultRenderers = useFieldRenderers();
|
|
26
|
+
const renderers = useMemo(()=>({
|
|
27
|
+
...defaultRenderers,
|
|
28
|
+
"element:sectionHeading": SectionHeading
|
|
29
|
+
}), [
|
|
30
|
+
defaultRenderers
|
|
31
|
+
]);
|
|
23
32
|
useEffect(()=>{
|
|
24
33
|
presenter.init(id);
|
|
25
34
|
}, [
|
|
26
35
|
presenter,
|
|
27
36
|
id
|
|
28
37
|
]);
|
|
29
|
-
const
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
}
|
|
38
|
+
const saveForm = useCallback(async ()=>{
|
|
39
|
+
const res = await presenter.save();
|
|
40
|
+
if (res) toast.showSuccessToast({
|
|
41
|
+
title: "Webhook saved successfully!"
|
|
42
|
+
});
|
|
43
|
+
}, [
|
|
44
|
+
presenter
|
|
45
|
+
]);
|
|
46
|
+
const { vm } = presenter;
|
|
47
|
+
return /*#__PURE__*/ react.createElement(SimpleForm, null, vm.loading ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
48
|
+
text: "Loading..."
|
|
49
|
+
}) : null, vm.saving ? /*#__PURE__*/ react.createElement(OverlayLoader, {
|
|
50
|
+
text: "Saving..."
|
|
51
|
+
}) : null, vm.form.errors.length > 0 ? /*#__PURE__*/ react.createElement("div", {
|
|
52
|
+
className: "mb-lg"
|
|
53
|
+
}, /*#__PURE__*/ react.createElement(FormErrors, {
|
|
54
|
+
form: vm.form
|
|
55
|
+
})) : null, /*#__PURE__*/ react.createElement(SimpleFormHeader, {
|
|
56
|
+
title: vm.isNew ? "Create Webhook" : vm.webhook?.name ?? "Edit Webhook"
|
|
57
|
+
}), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(FormView, {
|
|
58
|
+
name: "Webhook",
|
|
59
|
+
form: vm.form,
|
|
60
|
+
renderers: renderers
|
|
61
|
+
}), /*#__PURE__*/ react.createElement(SigningSecret, {
|
|
62
|
+
presenter: presenter
|
|
63
|
+
})), /*#__PURE__*/ react.createElement(SimpleFormFooter, {
|
|
64
|
+
className: "border-t-sm border-t-neutral-dimmed pt-lg"
|
|
65
|
+
}, /*#__PURE__*/ react.createElement(Button, {
|
|
43
66
|
variant: "secondary",
|
|
44
67
|
onClick: ()=>goToRoute(Routes.List)
|
|
45
|
-
}, "Cancel"),
|
|
68
|
+
}, "Cancel"), /*#__PURE__*/ react.createElement(HasPermission, {
|
|
69
|
+
entity: "webhook",
|
|
70
|
+
action: "edit"
|
|
71
|
+
}, /*#__PURE__*/ react.createElement(Button, {
|
|
46
72
|
variant: "primary",
|
|
47
|
-
onClick:
|
|
73
|
+
onClick: saveForm,
|
|
48
74
|
disabled: vm.saving
|
|
49
|
-
}, vm.saving ? "Saving..." : "Save")))
|
|
50
|
-
className: "flex-1 overflow-auto p-md"
|
|
51
|
-
}, /*#__PURE__*/ react.createElement("div", {
|
|
52
|
-
className: "flex flex-col gap-lg max-w-[720px]"
|
|
53
|
-
}, /*#__PURE__*/ react.createElement(FormView, {
|
|
54
|
-
name: "Webhook",
|
|
55
|
-
form: vm.form
|
|
56
|
-
}), /*#__PURE__*/ react.createElement(EventsSelector, {
|
|
57
|
-
availableEvents: vm.availableEvents,
|
|
58
|
-
selectedEvents: vm.selectedEvents,
|
|
59
|
-
onToggle: actions.toggleEvent,
|
|
60
|
-
disabled: !vm.permissions.canEdit
|
|
61
|
-
}), !vm.isNew && vm.webhook?.signingSecret && /*#__PURE__*/ react.createElement(SigningSecret, {
|
|
62
|
-
secret: vm.webhook.signingSecret
|
|
63
|
-
})))), vm.showDeliveries && vm.webhook && /*#__PURE__*/ react.createElement(WebhookDeliveriesDrawer, {
|
|
64
|
-
webhookId: vm.webhook.id,
|
|
65
|
-
open: vm.showDeliveries,
|
|
66
|
-
onClose: ()=>actions.closeDeliveries()
|
|
67
|
-
}));
|
|
75
|
+
}, vm.saving ? "Saving..." : "Save"))));
|
|
68
76
|
});
|
|
69
77
|
const WebhookFormView = ()=>{
|
|
70
78
|
const container = useContainer();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"admin/presentation/WebhookForm/components/WebhookFormView.js","sources":["../../../../../src/admin/presentation/WebhookForm/components/WebhookFormView.tsx"],"sourcesContent":["import React, { useMemo,
|
|
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 { SigningSecret } from \"./SigningSecret.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 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 };\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 <SigningSecret presenter={presenter} />\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","WebhookFormViewInner","observer","presenter","useFeature","WebhookFormPresenterFeature","goToRoute","useRouter","route","useRoute","Routes","toast","useToast","id","defaultRenderers","useFieldRenderers","renderers","useMemo","useEffect","saveForm","useCallback","res","vm","SimpleForm","OverlayLoader","FormErrors","SimpleFormHeader","SimpleFormContent","FormView","SigningSecret","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,uCAAuBC,SAAS;IAClC,MAAM,EAAEC,SAAS,EAAE,GAAGC,WAAWC;IACjC,MAAM,EAAEC,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,KAAK,EAAE,GAAGC,SAASC,OAAO,IAAI;IACtC,MAAMC,QAAQC;IACd,MAAMC,KAAKL,MAAM,MAAM,CAAC,EAAE;IAC1B,MAAMM,mBAAmBC;IAEzB,MAAMC,YAAYC,QAAQ,IACf;YACH,GAAGH,gBAAgB;YACnB,0BAA0BhB;QAC9B,IACD;QAACgB;KAAiB;IAErBI,UAAU;QACDf,UAAU,IAAI,CAACU;IACxB,GAAG;QAACV;QAAWU;KAAG;IAElB,MAAMM,WAAWC,YAAY;QACzB,MAAMC,MAAM,MAAMlB,UAAU,IAAI;QAChC,IAAIkB,KACAV,MAAM,gBAAgB,CAAC;YAAE,OAAO;QAA8B;IAEtE,GAAG;QAACR;KAAU;IAEd,MAAM,EAAEmB,EAAE,EAAE,GAAGnB;IAEf,OAAO,WAAP,GACI,oBAACoB,YAAUA,MACND,GAAG,OAAO,GAAG,WAAH,GAAG,oBAACE,eAAaA;QAAC,MAAM;SAAmB,MACrDF,GAAG,MAAM,GAAG,WAAH,GAAG,oBAACE,eAAaA;QAAC,MAAM;SAAkB,MACnDF,GAAG,IAAI,CAAC,MAAM,CAAC,MAAM,GAAG,IAAI,WAAJ,GACrB,oBAAC;QAAI,WAAW;qBACZ,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