@webiny/webhooks 0.0.0-unstable.7be00a75a9 → 0.0.0-unstable.7c2def32a7

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.
Files changed (130) hide show
  1. package/admin/WebhookRoutes.js +27 -17
  2. package/admin/WebhookRoutes.js.map +1 -1
  3. package/admin/Webhooks.js +0 -3
  4. package/admin/Webhooks.js.map +1 -1
  5. package/admin/features/ListWebhooks/ListWebhooksGateway.js +8 -2
  6. package/admin/features/ListWebhooks/ListWebhooksGateway.js.map +1 -1
  7. package/admin/features/ListWebhooks/abstractions.d.ts +1 -0
  8. package/admin/features/ListWebhooks/abstractions.js.map +1 -1
  9. package/admin/features/permissions/feature.d.ts +1 -1
  10. package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/WebhookDeliveriesDataSource.d.ts +2 -3
  11. package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/WebhookDeliveriesDataSource.js +5 -7
  12. package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesDataSource.js.map +1 -0
  13. package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.d.ts +9 -5
  14. package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js +67 -40
  15. package/admin/presentation/WebhookDeliveriesPage/WebhookDeliveriesPagePresenter.js.map +1 -1
  16. package/admin/presentation/WebhookDeliveriesPage/abstractions.d.ts +6 -3
  17. package/admin/presentation/WebhookDeliveriesPage/abstractions.js.map +1 -1
  18. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryAccordionRow.js.map +1 -0
  19. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryBottomInfoBar.d.ts +2 -2
  20. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryDetailContent.js.map +1 -0
  21. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.d.ts +2 -2
  22. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js +50 -18
  23. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryFilters.js.map +1 -1
  24. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.d.ts +2 -2
  25. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js +24 -8
  26. package/admin/presentation/WebhookDeliveriesPage/components/DeliveryList.js.map +1 -1
  27. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.d.ts +2 -0
  28. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js +16 -0
  29. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDefinitionsButton.js.map +1 -0
  30. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js +26 -17
  31. package/admin/presentation/WebhookDeliveriesPage/components/WebhookDeliveriesPage.js.map +1 -1
  32. package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.d.ts +1 -0
  33. package/admin/presentation/WebhookDeliveriesPage/components/statusVariant.js.map +1 -0
  34. package/admin/presentation/WebhookForm/WebhookFormPresenter.d.ts +1 -4
  35. package/admin/presentation/WebhookForm/WebhookFormPresenter.js +8 -12
  36. package/admin/presentation/WebhookForm/WebhookFormPresenter.js.map +1 -1
  37. package/admin/presentation/WebhookForm/abstractions.d.ts +1 -4
  38. package/admin/presentation/WebhookForm/abstractions.js.map +1 -1
  39. package/admin/presentation/WebhookForm/components/SigningSecret.d.ts +2 -2
  40. package/admin/presentation/WebhookForm/components/WebhookFormView.js +34 -36
  41. package/admin/presentation/WebhookForm/components/WebhookFormView.js.map +1 -1
  42. package/admin/presentation/WebhookList/WebhookListDataSource.d.ts +7 -8
  43. package/admin/presentation/WebhookList/WebhookListDataSource.js +23 -50
  44. package/admin/presentation/WebhookList/WebhookListDataSource.js.map +1 -1
  45. package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.d.ts +2 -0
  46. package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js +16 -0
  47. package/admin/presentation/WebhookList/components/WebhookDeliveriesButton.js.map +1 -0
  48. package/admin/presentation/WebhookList/components/WebhookListContent.d.ts +2 -2
  49. package/admin/presentation/WebhookList/components/WebhookListContent.js +20 -8
  50. package/admin/presentation/WebhookList/components/WebhookListContent.js.map +1 -1
  51. package/admin/presentation/WebhookList/components/WebhookListView.js +4 -1
  52. package/admin/presentation/WebhookList/components/WebhookListView.js.map +1 -1
  53. package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js +3 -1
  54. package/admin/presentation/WebhookSettings/WebhookSettingsPresenter.js.map +1 -1
  55. package/admin/routes.d.ts +3 -1
  56. package/admin/routes.js +4 -1
  57. package/admin/routes.js.map +1 -1
  58. package/api/features/DeleteWebhook/DeleteWebhookRepository.js +2 -1
  59. package/api/features/DeleteWebhook/DeleteWebhookRepository.js.map +1 -1
  60. package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js +7 -4
  61. package/api/features/ListWebhookDeliveries/ListWebhookDeliveriesRepository.js.map +1 -1
  62. package/api/features/ListWebhooks/ListWebhooksRepository.js +7 -4
  63. package/api/features/ListWebhooks/ListWebhooksRepository.js.map +1 -1
  64. package/api/features/SendWebhookTask/SendWebhookTask.d.ts +11 -6
  65. package/api/features/SendWebhookTask/SendWebhookTask.js +21 -12
  66. package/api/features/SendWebhookTask/SendWebhookTask.js.map +1 -1
  67. package/api/features/UpdateWebhook/UpdateWebhookRepository.js +3 -1
  68. package/api/features/UpdateWebhook/UpdateWebhookRepository.js.map +1 -1
  69. package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js +3 -1
  70. package/api/features/UpdateWebhookDelivery/UpdateWebhookDeliveryRepository.js.map +1 -1
  71. package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js +3 -1
  72. package/api/features/UpdateWebhookSettings/UpdateWebhookSettingsRepository.js.map +1 -1
  73. package/api/graphql/WebhookCrudSchema.d.ts +3 -2
  74. package/api/graphql/WebhookCrudSchema.js +17 -2
  75. package/api/graphql/WebhookCrudSchema.js.map +1 -1
  76. package/api/graphql/WebhookDeliverySchema.d.ts +3 -2
  77. package/api/graphql/WebhookDeliverySchema.js +6 -2
  78. package/api/graphql/WebhookDeliverySchema.js.map +1 -1
  79. package/api/graphql/WebhookEventSchema.d.ts +3 -2
  80. package/api/graphql/WebhookEventSchema.js +6 -2
  81. package/api/graphql/WebhookEventSchema.js.map +1 -1
  82. package/api/graphql/WebhookSettingsSchema.d.ts +3 -2
  83. package/api/graphql/WebhookSettingsSchema.js +6 -2
  84. package/api/graphql/WebhookSettingsSchema.js.map +1 -1
  85. package/api/graphql/WebhookTriggerSchema.d.ts +3 -2
  86. package/api/graphql/WebhookTriggerSchema.js +6 -2
  87. package/api/graphql/WebhookTriggerSchema.js.map +1 -1
  88. package/api/index.d.ts +3 -0
  89. package/api/index.js +6 -2
  90. package/api/index.js.map +1 -1
  91. package/api/models/WebhookDeliveryModel.d.ts +1 -1
  92. package/api/models/WebhookDeliveryModel.js +3 -3
  93. package/api/models/WebhookDeliveryModel.js.map +1 -1
  94. package/api/models/WebhookModel.d.ts +1 -1
  95. package/api/models/WebhookModel.js +4 -4
  96. package/api/models/WebhookModel.js.map +1 -1
  97. package/api/models/WebhookSettingsModel.d.ts +1 -1
  98. package/api/models/WebhookSettingsModel.js +3 -3
  99. package/api/models/WebhookSettingsModel.js.map +1 -1
  100. package/package.json +24 -23
  101. package/admin/presentation/WebhookDeliveries/WebhookDeliveriesDataSource.js.map +0 -1
  102. package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.d.ts +0 -21
  103. package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js +0 -57
  104. package/admin/presentation/WebhookDeliveries/WebhookDeliveriesPresenter.js.map +0 -1
  105. package/admin/presentation/WebhookDeliveries/abstractions.d.ts +0 -18
  106. package/admin/presentation/WebhookDeliveries/abstractions.js +0 -5
  107. package/admin/presentation/WebhookDeliveries/abstractions.js.map +0 -1
  108. package/admin/presentation/WebhookDeliveries/components/DeliveryAccordionRow.js.map +0 -1
  109. package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.d.ts +0 -11
  110. package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js +0 -32
  111. package/admin/presentation/WebhookDeliveries/components/DeliveryDetail.js.map +0 -1
  112. package/admin/presentation/WebhookDeliveries/components/DeliveryDetailContent.js.map +0 -1
  113. package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.d.ts +0 -9
  114. package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.js +0 -22
  115. package/admin/presentation/WebhookDeliveries/components/DeliveryDetailPanel.js.map +0 -1
  116. package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.d.ts +0 -8
  117. package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js +0 -119
  118. package/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js.map +0 -1
  119. package/admin/presentation/WebhookDeliveries/components/statusVariant.d.ts +0 -1
  120. package/admin/presentation/WebhookDeliveries/components/statusVariant.js.map +0 -1
  121. package/admin/presentation/WebhookDeliveries/feature.d.ts +0 -3
  122. package/admin/presentation/WebhookDeliveries/feature.js +0 -17
  123. package/admin/presentation/WebhookDeliveries/feature.js.map +0 -1
  124. package/admin/presentation/WebhookDeliveries/index.d.ts +0 -2
  125. package/admin/presentation/WebhookDeliveries/index.js +0 -2
  126. /package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/components/DeliveryAccordionRow.d.ts +0 -0
  127. /package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/components/DeliveryAccordionRow.js +0 -0
  128. /package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/components/DeliveryDetailContent.d.ts +0 -0
  129. /package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/components/DeliveryDetailContent.js +0 -0
  130. /package/admin/presentation/{WebhookDeliveries → WebhookDeliveriesPage}/components/statusVariant.js +0 -0
@@ -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} 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 _showDeliveries = false;\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 showDeliveries: this._showDeliveries,\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<void> {\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: 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\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 openDeliveries(): void {\n this._showDeliveries = true;\n }\n\n public closeDeliveries(): void {\n this._showDeliveries = false;\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","merged","undefined","created","runInAction","updated","id","eventsPromise","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,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;aAhCb,QAA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AAM6B,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,gBAAgBnD;IAChB,cAAc;QACVoD;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 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","DeleteWebhookUseCase","ListAvailableEventsUseCase","WebhookPermissions"],"mappings":";;;;;;;;;;AAqBA,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,C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C,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"}
@@ -5,7 +5,6 @@ export interface IWebhookFormViewModel {
5
5
  saving: boolean;
6
6
  isNew: boolean;
7
7
  webhook: Webhook | null;
8
- showDeliveries: boolean;
9
8
  permissions: {
10
9
  canEdit: boolean;
11
10
  canDelete: boolean;
@@ -15,10 +14,8 @@ export interface IWebhookFormViewModel {
15
14
  export interface IWebhookFormPresenter {
16
15
  vm: IWebhookFormViewModel;
17
16
  init(id: string): void;
18
- save(): Promise<void>;
17
+ save(): Promise<boolean>;
19
18
  deleteWebhook(): Promise<void>;
20
- openDeliveries(): void;
21
- closeDeliveries(): void;
22
19
  }
23
20
  export declare const WebhookFormPresenter: import("@webiny/di").Abstraction<IWebhookFormPresenter>;
24
21
  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 showDeliveries: boolean;\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<void>;\n deleteWebhook(): Promise<void>;\n openDeliveries(): void;\n closeDeliveries(): 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":";AA0BO,MAAMA,uBACTC,kBAAyC"}
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"}
@@ -3,7 +3,7 @@ import type { IWebhookFormPresenter } from "../abstractions.js";
3
3
  interface SigningSecretProps {
4
4
  presenter: IWebhookFormPresenter;
5
5
  }
6
- export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & {
7
- displayName: string;
6
+ export declare const SigningSecret: (({ presenter }: SigningSecretProps) => React.JSX.Element | null) & React.NamedExoticComponent<SigningSecretProps> & {
7
+ readonly type: ({ presenter }: SigningSecretProps) => React.JSX.Element | null;
8
8
  };
9
9
  export {};
@@ -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 { FormErrors, useFieldRenderers, useRouter } from "@webiny/app-admin";
5
- import { Button, Heading, OverlayLoader, Separator } from "@webiny/admin-ui";
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";
@@ -14,14 +13,14 @@ import { WebhookPermissionsFeature } from "../../../features/permissions/feature
14
13
  import { Routes } from "../../../routes.js";
15
14
  import { SigningSecret } from "./SigningSecret.js";
16
15
  import { HasPermission } from "../../security/HasPermission.js";
17
- import { WebhookDeliveriesDrawer } from "../../WebhookDeliveries/components/WebhookDeliveriesDrawer.js";
18
- const SectionHeading = ({ field })=>/*#__PURE__*/ react.createElement(Heading, {
19
- level: 6
16
+ const SectionHeading = ({ field })=>/*#__PURE__*/ react.createElement("span", {
17
+ className: "text-md font-semibold"
20
18
  }, String(field.label ?? ""));
21
19
  const WebhookFormView_WebhookFormViewInner = observer(function() {
22
20
  const { presenter } = useFeature(WebhookFormPresenterFeature);
23
21
  const { goToRoute } = useRouter();
24
22
  const { route } = useRoute(Routes.Form);
23
+ const toast = useToast();
25
24
  const id = route.params.id;
26
25
  const defaultRenderers = useFieldRenderers();
27
26
  const renderers = useMemo(()=>({
@@ -36,20 +35,33 @@ const WebhookFormView_WebhookFormViewInner = observer(function() {
36
35
  presenter,
37
36
  id
38
37
  ]);
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
+ ]);
39
46
  const { vm } = presenter;
40
- if (vm.loading) return /*#__PURE__*/ react.createElement(OverlayLoader, null);
41
- return /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement("div", {
42
- className: "flex flex-col h-main-content"
43
- }, /*#__PURE__*/ react.createElement("div", {
44
- className: "flex items-center justify-between py-sm px-md"
45
- }, /*#__PURE__*/ react.createElement(Heading, {
46
- level: 5
47
- }, vm.isNew ? "Create Webhook" : vm.webhook?.name ?? "Edit Webhook"), /*#__PURE__*/ react.createElement("div", {
48
- className: "flex gap-sm"
49
- }, vm.isNew ? null : /*#__PURE__*/ react.createElement(Button, {
50
- variant: "secondary",
51
- onClick: ()=>presenter.openDeliveries()
52
- }, "Deliveries"), /*#__PURE__*/ react.createElement(Button, {
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, /*#__PURE__*/ react.createElement(FormErrors, {
52
+ form: vm.form,
53
+ className: "mb-lg"
54
+ }), /*#__PURE__*/ react.createElement(SimpleFormHeader, {
55
+ title: vm.isNew ? "Create Webhook" : vm.webhook?.name ?? "Edit Webhook"
56
+ }), /*#__PURE__*/ react.createElement(SimpleFormContent, null, /*#__PURE__*/ react.createElement(FormView, {
57
+ name: "Webhook",
58
+ form: vm.form,
59
+ renderers: renderers
60
+ }), /*#__PURE__*/ react.createElement(SigningSecret, {
61
+ presenter: presenter
62
+ })), /*#__PURE__*/ react.createElement(SimpleFormFooter, {
63
+ className: "border-t-sm border-t-neutral-dimmed pt-lg"
64
+ }, /*#__PURE__*/ react.createElement(Button, {
53
65
  variant: "secondary",
54
66
  onClick: ()=>goToRoute(Routes.List)
55
67
  }, "Cancel"), /*#__PURE__*/ react.createElement(HasPermission, {
@@ -57,23 +69,9 @@ const WebhookFormView_WebhookFormViewInner = observer(function() {
57
69
  action: "edit"
58
70
  }, /*#__PURE__*/ react.createElement(Button, {
59
71
  variant: "primary",
60
- onClick: ()=>void presenter.save(),
72
+ onClick: saveForm,
61
73
  disabled: vm.saving
62
- }, vm.saving ? "Saving..." : "Save")))), /*#__PURE__*/ react.createElement(Separator, null), /*#__PURE__*/ react.createElement("div", {
63
- className: "p-lg"
64
- }, /*#__PURE__*/ react.createElement(react.Fragment, null, /*#__PURE__*/ react.createElement(FormErrors, {
65
- form: vm.form
66
- }), /*#__PURE__*/ react.createElement(FormView, {
67
- name: "Webhook",
68
- form: vm.form,
69
- renderers: renderers
70
- }), /*#__PURE__*/ react.createElement(SigningSecret, {
71
- presenter: presenter
72
- })))), vm.showDeliveries && vm.webhook ? /*#__PURE__*/ react.createElement(WebhookDeliveriesDrawer, {
73
- webhookId: vm.webhook.id,
74
- open: vm.showDeliveries,
75
- onClose: ()=>presenter.closeDeliveries()
76
- }) : null);
74
+ }, vm.saving ? "Saving..." : "Save"))));
77
75
  });
78
76
  const WebhookFormView = ()=>{
79
77
  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, { useEffect, useMemo } from \"react\";\nimport { observer } from \"mobx-react-lite\";\nimport { DiContainerProvider, useContainer, useFeature, useRoute } from \"@webiny/app\";\nimport { FormErrors, useRouter, useFieldRenderers } from \"@webiny/app-admin\";\nimport { Button, Heading, OverlayLoader, Separator } from \"@webiny/admin-ui\";\nimport { FormView } from \"@webiny/app-admin/features/formModel/FormView.js\";\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\";\nimport { WebhookDeliveriesDrawer } from \"~/admin/presentation/WebhookDeliveries/components/WebhookDeliveriesDrawer.js\";\n\nconst SectionHeading = ({ field }: { field: any }) => {\n return <Heading level={6}>{String(field.label ?? \"\")}</Heading>;\n};\n\nconst WebhookFormViewInner = observer(function WebhookFormViewInner() {\n const { presenter } = useFeature(WebhookFormPresenterFeature);\n const { goToRoute } = useRouter();\n const { route } = useRoute(Routes.Form);\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 { vm } = presenter;\n\n if (vm.loading) {\n return <OverlayLoader />;\n }\n\n return (\n <>\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}>\n {vm.isNew ? \"Create Webhook\" : (vm.webhook?.name ?? \"Edit Webhook\")}\n </Heading>\n <div className=\"flex gap-sm\">\n {!vm.isNew ? (\n <Button variant=\"secondary\" onClick={() => presenter.openDeliveries()}>\n Deliveries\n </Button>\n ) : null}\n <Button variant=\"secondary\" onClick={() => goToRoute(Routes.List)}>\n Cancel\n </Button>\n <HasPermission entity=\"webhook\" action=\"edit\">\n <Button\n variant=\"primary\"\n onClick={() => void presenter.save()}\n disabled={vm.saving}\n >\n {vm.saving ? \"Saving...\" : \"Save\"}\n </Button>\n </HasPermission>\n </div>\n </div>\n <Separator />\n\n <div className=\"p-lg\">\n <>\n <FormErrors form={vm.form} />\n <FormView name=\"Webhook\" form={vm.form} renderers={renderers} />\n <SigningSecret presenter={presenter} />\n </>\n </div>\n </div>\n {vm.showDeliveries && vm.webhook ? (\n <WebhookDeliveriesDrawer\n webhookId={vm.webhook.id}\n open={vm.showDeliveries}\n onClose={() => presenter.closeDeliveries()}\n />\n ) : null}\n </>\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","Heading","String","WebhookFormViewInner","observer","presenter","useFeature","WebhookFormPresenterFeature","goToRoute","useRouter","route","useRoute","Routes","id","defaultRenderers","useFieldRenderers","renderers","useMemo","useEffect","vm","OverlayLoader","Button","HasPermission","Separator","FormErrors","FormView","SigningSecret","WebhookDeliveriesDrawer","WebhookFormView","container","useContainer","scopedContainer","child","GetWebhookFeature","CreateWebhookFeature","UpdateWebhookFeature","DeleteWebhookFeature","ListAvailableEventsFeature","WebhookPermissionsFeature","DiContainerProvider"],"mappings":";;;;;;;;;;;;;;;;;AAkBA,MAAMA,iBAAiB,CAAC,EAAEC,KAAK,EAAkB,GACtC,WAAP,GAAO,oBAACC,SAAOA;QAAC,OAAO;OAAIC,OAAOF,MAAM,KAAK,IAAI;AAGrD,MAAMG,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,KAAKH,MAAM,MAAM,CAAC,EAAE;IAC1B,MAAMI,mBAAmBC;IAEzB,MAAMC,YAAYC,QAAQ,IACf;YACH,GAAGH,gBAAgB;YACnB,0BAA0Bf;QAC9B,IACD;QAACe;KAAiB;IAErBI,UAAU;QACDb,UAAU,IAAI,CAACQ;IACxB,GAAG;QAACR;QAAWQ;KAAG;IAElB,MAAM,EAAEM,EAAE,EAAE,GAAGd;IAEf,IAAIc,GAAG,OAAO,EACV,OAAO,WAAP,GAAO,oBAACC,eAAaA;IAGzB,OAAO,WAAP,GACI,wDACI,oBAAC;QAAI,WAAU;qBACX,oBAAC;QAAI,WAAU;qBACX,oBAACnB,SAAOA;QAAC,OAAO;OACXkB,GAAG,KAAK,GAAG,mBAAoBA,GAAG,OAAO,EAAE,QAAQ,+BAExD,oBAAC;QAAI,WAAU;OACV,AAACA,GAAG,KAAK,GAIN,OAJS,WAAH,GACN,oBAACE,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAMhB,UAAU,cAAc;OAAI,eAGvE,cACJ,oBAACgB,QAAMA;QAAC,SAAQ;QAAY,SAAS,IAAMb,UAAUI,OAAO,IAAI;OAAG,yBAGnE,oBAACU,eAAaA;QAAC,QAAO;QAAU,QAAO;qBACnC,oBAACD,QAAMA;QACH,SAAQ;QACR,SAAS,IAAM,KAAKhB,UAAU,IAAI;QAClC,UAAUc,GAAG,MAAM;OAElBA,GAAG,MAAM,GAAG,cAAc,0BAK3C,oBAACI,WAASA,OAAAA,WAAAA,GAEV,oBAAC;QAAI,WAAU;qBACX,wDACI,oBAACC,YAAUA;QAAC,MAAML,GAAG,IAAI;sBACzB,oBAACM,UAAQA;QAAC,MAAK;QAAU,MAAMN,GAAG,IAAI;QAAE,WAAWH;sBACnD,oBAACU,eAAaA;QAAC,WAAWrB;WAIrCc,GAAG,cAAc,IAAIA,GAAG,OAAO,GAAG,WAAH,GAC5B,oBAACQ,yBAAuBA;QACpB,WAAWR,GAAG,OAAO,CAAC,EAAE;QACxB,MAAMA,GAAG,cAAc;QACvB,SAAS,IAAMd,UAAU,eAAe;SAE5C;AAGhB;AAEO,MAAMuB,kBAAkB;IAC3B,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBd,QAAQ;QAC5B,MAAMe,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;QACnCzB,4BAA4B,QAAQ,CAACyB;QACrC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACO,qBAAmBA;QAAC,WAAWR;qBAC5B,oBAAC5B,sCAAoBA;AAGjC"}
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 <FormErrors form={vm.form} className={\"mb-lg\"} />\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,OA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yBAGnE,oBAACsB,eAAaA;QAAC,QAAO;QAAU,QAAO;qBACnC,oBAACD,QAAMA;QAAC,SAAQ;QAAU,SAASZ;QAAU,UAAUG,GAAG,MAAM;OAC3DA,GAAG,MAAM,GAAG,cAAc;AAMnD;AAEO,MAAMW,kBAAkB;IAC3B,MAAMC,YAAYC;IAElB,MAAMC,kBAAkBnB,QAAQ;QAC5B,MAAMoB,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;QACnChC,4BAA4B,QAAQ,CAACgC;QACrC,OAAOA;IACX,GAAG,EAAE;IAEL,OAAO,WAAP,GACI,oBAACO,qBAAmBA;QAAC,WAAWR;qBAC5B,oBAACnC,sCAAoBA;AAGjC"}
@@ -1,15 +1,14 @@
1
- import type { IDataSource, IDataSourceQuery, IDataSourceMeta } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
1
+ import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
2
+ import type { FetchResult } from "@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js";
3
+ import type { IDataSourceQuery } from "@webiny/app-admin/presentation/listPresenter/abstractions.js";
2
4
  import type { Webhook } from "../../../admin/shared/types.js";
3
5
  import type { IListWebhooksUseCase } from "../../../admin/features/ListWebhooks/abstractions.js";
4
- export declare class WebhookListDataSource implements IDataSource<Webhook> {
6
+ export declare class WebhookListDataSource extends SimpleDataSource<Webhook> {
5
7
  private readonly listWebhooksUseCase;
6
8
  private _rows;
7
- private _meta;
8
- private _loading;
9
9
  constructor(listWebhooksUseCase: IListWebhooksUseCase);
10
10
  get rows(): Webhook[];
11
- get meta(): IDataSourceMeta;
12
- get loading(): boolean;
13
- query(params: IDataSourceQuery): Promise<void>;
14
- loadMore(params: IDataSourceQuery): Promise<void>;
11
+ fetch(params: IDataSourceQuery): Promise<FetchResult<Webhook>>;
12
+ onQueryResult(data: Webhook[]): void;
13
+ onLoadMoreResult(data: Webhook[]): void;
15
14
  }
@@ -1,65 +1,38 @@
1
- import { computed, makeAutoObservable, runInAction } from "mobx";
2
- class WebhookListDataSource {
1
+ import { makeObservable, observable } from "mobx";
2
+ import { SimpleDataSource } from "@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js";
3
+ class WebhookListDataSource extends SimpleDataSource {
3
4
  constructor(listWebhooksUseCase){
4
- this.listWebhooksUseCase = listWebhooksUseCase;
5
- this._rows = [];
6
- this._meta = {
7
- cursor: null,
8
- hasMoreItems: false,
9
- totalCount: 0
10
- };
11
- this._loading = false;
12
- makeAutoObservable(this, {
13
- listWebhooksUseCase: false,
14
- rows: computed
5
+ super(), this.listWebhooksUseCase = listWebhooksUseCase, this._rows = [];
6
+ makeObservable(this, {
7
+ _rows: observable
15
8
  });
16
9
  }
17
10
  get rows() {
18
11
  return this._rows;
19
12
  }
20
- get meta() {
21
- return this._meta;
22
- }
23
- get loading() {
24
- return this._loading;
25
- }
26
- async query(params) {
27
- this._loading = true;
13
+ async fetch(params) {
14
+ const sort = params.sort ? [
15
+ `${params.sort.field}_${params.sort.direction}`
16
+ ] : void 0;
28
17
  const result = await this.listWebhooksUseCase.execute({
29
18
  where: params.filters,
19
+ sort,
30
20
  limit: params.limit,
31
21
  after: params.cursor
32
22
  });
33
- runInAction(()=>{
34
- this._rows = result.items;
35
- this._meta = {
36
- cursor: result.meta.cursor,
37
- hasMoreItems: result.meta.hasMoreItems,
38
- totalCount: result.meta.totalCount
39
- };
40
- this._loading = false;
41
- });
23
+ return {
24
+ data: result.items,
25
+ meta: result.meta
26
+ };
42
27
  }
43
- async loadMore(params) {
44
- if (!this._meta.hasMoreItems || this._loading) return;
45
- this._loading = true;
46
- const result = await this.listWebhooksUseCase.execute({
47
- where: params.filters,
48
- limit: params.limit,
49
- after: this._meta.cursor ?? void 0
50
- });
51
- runInAction(()=>{
52
- this._rows = [
53
- ...this._rows,
54
- ...result.items
55
- ];
56
- this._meta = {
57
- cursor: result.meta.cursor,
58
- hasMoreItems: result.meta.hasMoreItems,
59
- totalCount: result.meta.totalCount
60
- };
61
- this._loading = false;
62
- });
28
+ onQueryResult(data) {
29
+ this._rows = data;
30
+ }
31
+ onLoadMoreResult(data) {
32
+ this._rows = [
33
+ ...this._rows,
34
+ ...data
35
+ ];
63
36
  }
64
37
  }
65
38
  export { WebhookListDataSource };
@@ -1 +1 @@
1
- {"version":3,"file":"admin/presentation/WebhookList/WebhookListDataSource.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListDataSource.ts"],"sourcesContent":["import { makeAutoObservable, runInAction, computed } from \"mobx\";\nimport type {\n IDataSource,\n IDataSourceQuery,\n IDataSourceMeta\n} from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IListWebhooksUseCase } from \"~/admin/features/ListWebhooks/abstractions.js\";\n\nexport class WebhookListDataSource implements IDataSource<Webhook> {\n private _rows: Webhook[] = [];\n private _meta: IDataSourceMeta = { cursor: null, hasMoreItems: false, totalCount: 0 };\n private _loading = false;\n\n constructor(private readonly listWebhooksUseCase: IListWebhooksUseCase) {\n makeAutoObservable<WebhookListDataSource, \"listWebhooksUseCase\">(this, {\n listWebhooksUseCase: false,\n rows: computed\n });\n }\n\n get rows(): Webhook[] {\n return this._rows;\n }\n\n get meta(): IDataSourceMeta {\n return this._meta;\n }\n\n get loading(): boolean {\n return this._loading;\n }\n\n async query(params: IDataSourceQuery): Promise<void> {\n this._loading = true;\n const result = await this.listWebhooksUseCase.execute({\n where: params.filters as { enabled?: boolean } | undefined,\n limit: params.limit,\n after: params.cursor\n });\n runInAction(() => {\n this._rows = result.items;\n this._meta = {\n cursor: result.meta.cursor,\n hasMoreItems: result.meta.hasMoreItems,\n totalCount: result.meta.totalCount\n };\n this._loading = false;\n });\n }\n\n async loadMore(params: IDataSourceQuery): Promise<void> {\n if (!this._meta.hasMoreItems || this._loading) {\n return;\n }\n this._loading = true;\n const result = await this.listWebhooksUseCase.execute({\n where: params.filters as { enabled?: boolean } | undefined,\n limit: params.limit,\n after: this._meta.cursor ?? undefined\n });\n runInAction(() => {\n this._rows = [...this._rows, ...result.items];\n this._meta = {\n cursor: result.meta.cursor,\n hasMoreItems: result.meta.hasMoreItems,\n totalCount: result.meta.totalCount\n };\n this._loading = false;\n });\n }\n}\n"],"names":["WebhookListDataSource","listWebhooksUseCase","makeAutoObservable","computed","params","result","runInAction","undefined"],"mappings":";AASO,MAAMA;IAKT,YAA6BC,mBAAyC,CAAE;aAA3CA,mBAAmB,GAAnBA;aAJrB,KAAK,GAAc,EAAE;aACrB,KAAK,GAAoB;YAAE,QAAQ;YAAM,cAAc;YAAO,YAAY;QAAE;aAC5E,QAAQ,GAAG;QAGfC,mBAAiE,IAAI,EAAE;YACnE,qBAAqB;YACrB,MAAMC;QACV;IACJ;IAEA,IAAI,OAAkB;QAClB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,OAAwB;QACxB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,IAAI,UAAmB;QACnB,OAAO,IAAI,CAAC,QAAQ;IACxB;IAEA,MAAM,MAAMC,MAAwB,EAAiB;QACjD,IAAI,CAAC,QAAQ,GAAG;QAChB,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAClD,OAAOD,OAAO,OAAO;YACrB,OAAOA,OAAO,KAAK;YACnB,OAAOA,OAAO,MAAM;QACxB;QACAE,YAAY;YACR,IAAI,CAAC,KAAK,GAAGD,OAAO,KAAK;YACzB,IAAI,CAAC,KAAK,GAAG;gBACT,QAAQA,OAAO,IAAI,CAAC,MAAM;gBAC1B,cAAcA,OAAO,IAAI,CAAC,YAAY;gBACtC,YAAYA,OAAO,IAAI,CAAC,UAAU;YACtC;YACA,IAAI,CAAC,QAAQ,GAAG;QACpB;IACJ;IAEA,MAAM,SAASD,MAAwB,EAAiB;QACpD,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,YAAY,IAAI,IAAI,CAAC,QAAQ,EACzC;QAEJ,IAAI,CAAC,QAAQ,GAAG;QAChB,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAClD,OAAOD,OAAO,OAAO;YACrB,OAAOA,OAAO,KAAK;YACnB,OAAO,IAAI,CAAC,KAAK,CAAC,MAAM,IAAIG;QAChC;QACAD,YAAY;YACR,IAAI,CAAC,KAAK,GAAG;mBAAI,IAAI,CAAC,KAAK;mBAAKD,OAAO,KAAK;aAAC;YAC7C,IAAI,CAAC,KAAK,GAAG;gBACT,QAAQA,OAAO,IAAI,CAAC,MAAM;gBAC1B,cAAcA,OAAO,IAAI,CAAC,YAAY;gBACtC,YAAYA,OAAO,IAAI,CAAC,UAAU;YACtC;YACA,IAAI,CAAC,QAAQ,GAAG;QACpB;IACJ;AACJ"}
1
+ {"version":3,"file":"admin/presentation/WebhookList/WebhookListDataSource.js","sources":["../../../../src/admin/presentation/WebhookList/WebhookListDataSource.ts"],"sourcesContent":["import { makeObservable, observable } from \"mobx\";\nimport { SimpleDataSource } from \"@webiny/app-admin/presentation/listPresenter/SimpleDataSource.js\";\nimport type { FetchResult } from \"@webiny/app-admin/presentation/listPresenter/FolderAwareDataSource.js\";\nimport type { IDataSourceQuery } from \"@webiny/app-admin/presentation/listPresenter/abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\nimport type { IListWebhooksUseCase } from \"~/admin/features/ListWebhooks/abstractions.js\";\n\nexport class WebhookListDataSource extends SimpleDataSource<Webhook> {\n private _rows: Webhook[] = [];\n\n constructor(private readonly listWebhooksUseCase: IListWebhooksUseCase) {\n super();\n makeObservable<WebhookListDataSource, \"_rows\">(this, {\n _rows: observable\n });\n }\n\n get rows(): Webhook[] {\n return this._rows;\n }\n\n async fetch(params: IDataSourceQuery): Promise<FetchResult<Webhook>> {\n const sort = params.sort ? [`${params.sort.field}_${params.sort.direction}`] : undefined;\n const result = await this.listWebhooksUseCase.execute({\n where: params.filters as { enabled?: boolean } | undefined,\n sort,\n limit: params.limit,\n after: params.cursor\n });\n return { data: result.items, meta: result.meta };\n }\n\n override onQueryResult(data: Webhook[]): void {\n this._rows = data;\n }\n\n override onLoadMoreResult(data: Webhook[]): void {\n this._rows = [...this._rows, ...data];\n }\n}\n"],"names":["WebhookListDataSource","SimpleDataSource","listWebhooksUseCase","makeObservable","observable","params","sort","undefined","result","data"],"mappings":";;AAOO,MAAMA,8BAA8BC;IAGvC,YAA6BC,mBAAyC,CAAE;QACpE,KAAK,SADoBA,mBAAmB,GAAnBA,qBAAAA,IAAAA,CAFrB,KAAK,GAAc,EAAE;QAIzBC,eAA+C,IAAI,EAAE;YACjD,OAAOC;QACX;IACJ;IAEA,IAAI,OAAkB;QAClB,OAAO,IAAI,CAAC,KAAK;IACrB;IAEA,MAAM,MAAMC,MAAwB,EAAiC;QACjE,MAAMC,OAAOD,OAAO,IAAI,GAAG;YAAC,GAAGA,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,EAAEA,OAAO,IAAI,CAAC,SAAS,EAAE;SAAC,GAAGE;QAC/E,MAAMC,SAAS,MAAM,IAAI,CAAC,mBAAmB,CAAC,OAAO,CAAC;YAClD,OAAOH,OAAO,OAAO;YACrBC;YACA,OAAOD,OAAO,KAAK;YACnB,OAAOA,OAAO,MAAM;QACxB;QACA,OAAO;YAAE,MAAMG,OAAO,KAAK;YAAE,MAAMA,OAAO,IAAI;QAAC;IACnD;IAES,cAAcC,IAAe,EAAQ;QAC1C,IAAI,CAAC,KAAK,GAAGA;IACjB;IAES,iBAAiBA,IAAe,EAAQ;QAC7C,IAAI,CAAC,KAAK,GAAG;eAAI,IAAI,CAAC,KAAK;eAAKA;SAAK;IACzC;AACJ"}
@@ -0,0 +1,2 @@
1
+ import React from "react";
2
+ export declare const WebhookDeliveriesButton: () => React.JSX.Element;
@@ -0,0 +1,16 @@
1
+ import react from "react";
2
+ import { useRouter } from "@webiny/app-admin";
3
+ import { Button } from "@webiny/admin-ui";
4
+ import { ReactComponent } from "@webiny/icons/list.svg";
5
+ import { Routes } from "../../../routes.js";
6
+ const WebhookDeliveriesButton = ()=>{
7
+ const { goToRoute } = useRouter();
8
+ return /*#__PURE__*/ react.createElement(Button, {
9
+ variant: "secondary",
10
+ onClick: ()=>goToRoute(Routes.Deliveries),
11
+ icon: /*#__PURE__*/ react.createElement(ReactComponent, null)
12
+ }, "All Deliveries");
13
+ };
14
+ export { WebhookDeliveriesButton };
15
+
16
+ //# sourceMappingURL=WebhookDeliveriesButton.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"admin/presentation/WebhookList/components/WebhookDeliveriesButton.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookDeliveriesButton.tsx"],"sourcesContent":["import React from \"react\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport { Button } from \"@webiny/admin-ui\";\nimport { ReactComponent as ListIcon } from \"@webiny/icons/list.svg\";\nimport { Routes } from \"~/admin/routes.js\";\n\nexport const WebhookDeliveriesButton = () => {\n const { goToRoute } = useRouter();\n\n return (\n <Button\n variant=\"secondary\"\n onClick={() => goToRoute(Routes.Deliveries)}\n icon={<ListIcon />}\n >\n All Deliveries\n </Button>\n );\n};\n"],"names":["WebhookDeliveriesButton","goToRoute","useRouter","Button","Routes","ListIcon"],"mappings":";;;;;AAMO,MAAMA,0BAA0B;IACnC,MAAM,EAAEC,SAAS,EAAE,GAAGC;IAEtB,OAAO,WAAP,GACI,oBAACC,QAAMA;QACH,SAAQ;QACR,SAAS,IAAMF,UAAUG,OAAO,UAAU;QAC1C,oBAAM,oBAACC,gBAAQA;OAClB;AAIT"}
@@ -3,7 +3,7 @@ import type { IWebhookListPresenter } from "../abstractions.js";
3
3
  interface WebhookListContentProps {
4
4
  presenter: IWebhookListPresenter;
5
5
  }
6
- export declare const WebhookListContent: (({ presenter }: WebhookListContentProps) => React.JSX.Element) & {
7
- displayName: string;
6
+ export declare const WebhookListContent: (({ presenter }: WebhookListContentProps) => React.JSX.Element) & React.NamedExoticComponent<WebhookListContentProps> & {
7
+ readonly type: ({ presenter }: WebhookListContentProps) => React.JSX.Element;
8
8
  };
9
9
  export {};
@@ -2,8 +2,8 @@ import react, { useCallback, useMemo } from "react";
2
2
  import debounce from "lodash/debounce.js";
3
3
  import { observer } from "mobx-react-lite";
4
4
  import { useRouter } from "@webiny/app-admin";
5
- import { DataTable, DropdownMenu, IconButton, Scrollbar, Tag, Text, TimeAgo } from "@webiny/admin-ui";
6
- import { useConfirmationDialog, useSnackbar } from "@webiny/app-admin/hooks/index.js";
5
+ import { Button, DataTable, DropdownMenu, IconButton, Scrollbar, Tag, Text, TimeAgo, useToast } from "@webiny/admin-ui";
6
+ import { useConfirmationDialog } from "@webiny/app-admin/hooks/index.js";
7
7
  import { HasPermission } from "../../security/HasPermission.js";
8
8
  import { ReactComponent } from "@webiny/icons/more_vert.svg";
9
9
  import { ReactComponent as edit_svg_ReactComponent } from "@webiny/icons/edit.svg";
@@ -14,7 +14,7 @@ import { Routes } from "../../../routes.js";
14
14
  const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
15
15
  const { vm } = presenter;
16
16
  const { goToRoute } = useRouter();
17
- const { showSnackbar } = useSnackbar();
17
+ const toast = useToast();
18
18
  const { showConfirmation: showDeleteConfirmation } = useConfirmationDialog({
19
19
  title: "Delete Webhook",
20
20
  message: "Are you sure you want to delete this webhook?"
@@ -84,6 +84,18 @@ const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
84
84
  enableSorting: true,
85
85
  size: 120
86
86
  },
87
+ deliveries: {
88
+ header: "Deliveries",
89
+ truncate: false,
90
+ cell: (row)=>/*#__PURE__*/ react.createElement(Button, {
91
+ variant: "secondary",
92
+ onClick: ()=>{
93
+ goToRoute(Routes.Deliveries, {
94
+ webhookId: row.id
95
+ });
96
+ }
97
+ }, "Deliveries")
98
+ },
87
99
  actions: {
88
100
  header: " ",
89
101
  cell: (row)=>/*#__PURE__*/ react.createElement(DropdownMenu, {
@@ -106,7 +118,9 @@ const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
106
118
  icon: /*#__PURE__*/ react.createElement(webhook_svg_ReactComponent, null),
107
119
  onClick: ()=>{
108
120
  presenter.triggerWebhook(row.id).then(()=>{
109
- showSnackbar("Test event triggered.");
121
+ toast.showSuccessToast({
122
+ title: "Test event triggered!"
123
+ });
110
124
  });
111
125
  },
112
126
  text: "Trigger Test"
@@ -114,6 +128,7 @@ const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
114
128
  entity: "webhook",
115
129
  action: "delete"
116
130
  }, /*#__PURE__*/ react.createElement(DropdownMenu.Separator, null), /*#__PURE__*/ react.createElement(DropdownMenu.Item, {
131
+ variant: "destructive",
117
132
  onClick: ()=>{
118
133
  showDeleteConfirmation(()=>presenter.deleteWebhook(row.id));
119
134
  },
@@ -126,10 +141,7 @@ const WebhookListContent_WebhookListContent = observer(function({ presenter }) {
126
141
  enableResizing: false
127
142
  }
128
143
  }), [
129
- presenter,
130
- goToRoute,
131
- showDeleteConfirmation,
132
- showSnackbar
144
+ presenter
133
145
  ]);
134
146
  if (!vm.list.pagination.loading && 0 === vm.list.rows.length) return /*#__PURE__*/ react.createElement("div", {
135
147
  className: "flex-1 overflow-hidden"
@@ -1 +1 @@
1
- {"version":3,"file":"admin/presentation/WebhookList/components/WebhookListContent.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListContent.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport type { DataTableSorting, OnDataTableSortingChange } from \"@webiny/admin-ui\";\nimport {\n DataTable,\n DropdownMenu,\n IconButton,\n Scrollbar,\n Tag,\n Text,\n TimeAgo\n} from \"@webiny/admin-ui\";\nimport { useConfirmationDialog, useSnackbar } from \"@webiny/app-admin/hooks/index.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as Edit } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as Delete } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport type { IWebhookListPresenter } from \"../abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\ninterface WebhookListContentProps {\n presenter: IWebhookListPresenter;\n}\n\nexport const WebhookListContent = observer(function WebhookListContent({\n presenter\n}: WebhookListContentProps) {\n const { vm } = presenter;\n const { goToRoute } = useRouter();\n const { showSnackbar } = useSnackbar();\n\n const { showConfirmation: showDeleteConfirmation } = useConfirmationDialog({\n title: \"Delete Webhook\",\n message: \"Are you sure you want to delete this webhook?\"\n });\n\n const loadMoreOnScroll = useMemo(\n () =>\n debounce(async ({ scrollFrame }: { scrollFrame: { top: number } }) => {\n if (scrollFrame.top > 0.8) {\n await presenter.loadMore();\n }\n }, 200),\n [presenter]\n );\n\n const sorting: DataTableSorting = useMemo(() => {\n const sort = vm.list.sort;\n if (!sort || !sort.field) {\n return [];\n }\n return [{ id: sort.field, desc: sort.direction === \"DESC\" }];\n }, [vm.list.sort]);\n\n const onSortingChange: OnDataTableSortingChange = useCallback(\n updater => {\n const next = typeof updater === \"function\" ? updater(sorting) : updater;\n if (next.length > 0) {\n const { id, desc } = next[0];\n presenter.sort.set(id, desc ? \"DESC\" : \"ASC\");\n }\n },\n [sorting, presenter.sort]\n );\n\n const columns = useMemo(\n () => ({\n name: {\n header: \"Name\",\n cell: (row: Webhook) => (\n <Text\n className=\"cursor-pointer text-primary hover:underline\"\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n >\n {row.name}\n </Text>\n ),\n enableSorting: true,\n size: 200\n },\n endpointUrl: {\n header: \"Endpoint\",\n cell: (row: Webhook) => (\n <Text className=\"font-mono text-sm truncate\">{row.endpointUrl}</Text>\n ),\n size: 250\n },\n enabled: {\n header: \"Status\",\n cell: (row: Webhook) => (\n <Tag\n variant={row.enabled ? \"success\" : \"neutral-muted\"}\n content={row.enabled ? \"Active\" : \"Disabled\"}\n />\n ),\n enableSorting: true,\n size: 100\n },\n createdOn: {\n header: \"Created\",\n cell: (row: Webhook) =>\n row.createdOn ? <TimeAgo datetime={row.createdOn} /> : <Text size=\"sm\">—</Text>,\n enableSorting: true,\n size: 120\n },\n actions: {\n header: \" \",\n cell: (row: Webhook) => (\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVerticalIcon />}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Actions\"\n />\n }\n >\n <DropdownMenu.Item\n icon={<Edit />}\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n text={\"Edit\"}\n />\n <HasPermission entity=\"webhook\" action=\"edit\">\n <DropdownMenu.Item\n icon={<WebhookIcon />}\n onClick={() => {\n void presenter.triggerWebhook(row.id).then(() => {\n showSnackbar(\"Test event triggered.\");\n });\n }}\n text={\"Trigger Test\"}\n />\n </HasPermission>\n <HasPermission entity=\"webhook\" action=\"delete\">\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n onClick={() => {\n showDeleteConfirmation(() => presenter.deleteWebhook(row.id));\n }}\n icon={<Delete />}\n text={\"Delete\"}\n />\n </HasPermission>\n </DropdownMenu>\n ),\n size: 56,\n enableSorting: false,\n enableHiding: false,\n enableResizing: false\n }\n }),\n [presenter, goToRoute, showDeleteConfirmation, showSnackbar]\n );\n\n if (!vm.list.pagination.loading && vm.list.rows.length === 0) {\n return (\n <div className=\"flex-1 overflow-hidden\">\n <div className=\"flex flex-col items-center justify-center h-full gap-md\">\n <Text className=\"text-neutral-strong\">No webhooks found.</Text>\n <CreateWebhookButton />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex-1 overflow-hidden\">\n <Scrollbar onScrollFrame={scrollFrame => loadMoreOnScroll({ scrollFrame })}>\n <DataTable<Webhook>\n columns={columns}\n data={vm.list.rows}\n loading={vm.list.pagination.loading}\n sorting={sorting}\n onSortingChange={onSortingChange}\n stickyHeader\n />\n </Scrollbar>\n </div>\n );\n});\n"],"names":["WebhookListContent","observer","presenter","vm","goToRoute","useRouter","showSnackbar","useSnackbar","showDeleteConfirmation","useConfirmationDialog","loadMoreOnScroll","useMemo","debounce","scrollFrame","sorting","sort","onSortingChange","useCallback","updater","next","id","desc","columns","row","Text","Routes","Tag","TimeAgo","DropdownMenu","IconButton","MoreVerticalIcon","Edit","HasPermission","WebhookIcon","Delete","CreateWebhookButton","Scrollbar","DataTable"],"mappings":";;;;;;;;;;;;;AA6BO,MAAMA,wCAAqBC,SAAS,SAA4B,EACnEC,SAAS,EACa;IACtB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,EAAEE,SAAS,EAAE,GAAGC;IACtB,MAAM,EAAEC,YAAY,EAAE,GAAGC;IAEzB,MAAM,EAAE,kBAAkBC,sBAAsB,EAAE,GAAGC,sBAAsB;QACvE,OAAO;QACP,SAAS;IACb;IAEA,MAAMC,mBAAmBC,QACrB,IACIC,SAAS,OAAO,EAAEC,WAAW,EAAoC;YAC7D,IAAIA,YAAY,GAAG,GAAG,KAClB,MAAMX,UAAU,QAAQ;QAEhC,GAAG,MACP;QAACA;KAAU;IAGf,MAAMY,UAA4BH,QAAQ;QACtC,MAAMI,OAAOZ,GAAG,IAAI,CAAC,IAAI;QACzB,IAAI,CAACY,QAAQ,CAACA,KAAK,KAAK,EACpB,OAAO,EAAE;QAEb,OAAO;YAAC;gBAAE,IAAIA,KAAK,KAAK;gBAAE,MAAMA,AAAmB,WAAnBA,KAAK,SAAS;YAAY;SAAE;IAChE,GAAG;QAACZ,GAAG,IAAI,CAAC,IAAI;KAAC;IAEjB,MAAMa,k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,"file":"admin/presentation/WebhookList/components/WebhookListContent.js","sources":["../../../../../src/admin/presentation/WebhookList/components/WebhookListContent.tsx"],"sourcesContent":["import React, { useCallback, useMemo } from \"react\";\nimport debounce from \"lodash/debounce.js\";\nimport { observer } from \"mobx-react-lite\";\nimport { useRouter } from \"@webiny/app-admin\";\nimport type { DataTableSorting, OnDataTableSortingChange } from \"@webiny/admin-ui\";\nimport {\n Button,\n DataTable,\n DropdownMenu,\n IconButton,\n Scrollbar,\n Tag,\n Text,\n TimeAgo\n} from \"@webiny/admin-ui\";\nimport { useToast } from \"@webiny/admin-ui\";\nimport { useConfirmationDialog } from \"@webiny/app-admin/hooks/index.js\";\nimport { HasPermission } from \"~/admin/presentation/security/HasPermission.js\";\nimport { ReactComponent as MoreVerticalIcon } from \"@webiny/icons/more_vert.svg\";\nimport { ReactComponent as Edit } from \"@webiny/icons/edit.svg\";\nimport { ReactComponent as Delete } from \"@webiny/icons/delete.svg\";\nimport { ReactComponent as WebhookIcon } from \"@webiny/icons/webhook.svg\";\nimport { CreateWebhookButton } from \"./CreateWebhookButton.js\";\nimport { Routes } from \"~/admin/routes.js\";\nimport type { IWebhookListPresenter } from \"../abstractions.js\";\nimport type { Webhook } from \"~/admin/shared/types.js\";\n\ninterface WebhookListContentProps {\n presenter: IWebhookListPresenter;\n}\n\nexport const WebhookListContent = observer(function WebhookListContent({\n presenter\n}: WebhookListContentProps) {\n const { vm } = presenter;\n const { goToRoute } = useRouter();\n const toast = useToast();\n\n const { showConfirmation: showDeleteConfirmation } = useConfirmationDialog({\n title: \"Delete Webhook\",\n message: \"Are you sure you want to delete this webhook?\"\n });\n\n const loadMoreOnScroll = useMemo(\n () =>\n debounce(async ({ scrollFrame }: { scrollFrame: { top: number } }) => {\n if (scrollFrame.top > 0.8) {\n await presenter.loadMore();\n }\n }, 200),\n [presenter]\n );\n\n const sorting: DataTableSorting = useMemo(() => {\n const sort = vm.list.sort;\n if (!sort || !sort.field) {\n return [];\n }\n return [{ id: sort.field, desc: sort.direction === \"DESC\" }];\n }, [vm.list.sort]);\n\n const onSortingChange: OnDataTableSortingChange = useCallback(\n updater => {\n const next = typeof updater === \"function\" ? updater(sorting) : updater;\n if (next.length > 0) {\n const { id, desc } = next[0];\n presenter.sort.set(id, desc ? \"DESC\" : \"ASC\");\n }\n },\n [sorting, presenter.sort]\n );\n\n const columns = useMemo(\n () => ({\n name: {\n header: \"Name\",\n cell: (row: Webhook) => (\n <Text\n className=\"cursor-pointer text-primary hover:underline\"\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n >\n {row.name}\n </Text>\n ),\n enableSorting: true,\n size: 200\n },\n endpointUrl: {\n header: \"Endpoint\",\n cell: (row: Webhook) => (\n <Text className=\"font-mono text-sm truncate\">{row.endpointUrl}</Text>\n ),\n size: 250\n },\n enabled: {\n header: \"Status\",\n cell: (row: Webhook) => (\n <Tag\n variant={row.enabled ? \"success\" : \"neutral-muted\"}\n content={row.enabled ? \"Active\" : \"Disabled\"}\n />\n ),\n enableSorting: true,\n size: 100\n },\n createdOn: {\n header: \"Created\",\n cell: (row: Webhook) =>\n row.createdOn ? <TimeAgo datetime={row.createdOn} /> : <Text size=\"sm\">—</Text>,\n enableSorting: true,\n size: 120\n },\n deliveries: {\n header: \"Deliveries\",\n truncate: false,\n cell: (row: Webhook) => {\n return (\n <Button\n variant={\"secondary\"}\n onClick={() => {\n goToRoute(Routes.Deliveries, { webhookId: row.id });\n }}\n >\n Deliveries\n </Button>\n );\n }\n },\n actions: {\n header: \" \",\n cell: (row: Webhook) => (\n <DropdownMenu\n trigger={\n <IconButton\n icon={<MoreVerticalIcon />}\n variant=\"ghost\"\n size=\"sm\"\n aria-label=\"Actions\"\n />\n }\n >\n <DropdownMenu.Item\n icon={<Edit />}\n onClick={() => goToRoute(Routes.Form, { id: row.id })}\n text={\"Edit\"}\n />\n <HasPermission entity=\"webhook\" action=\"edit\">\n <DropdownMenu.Item\n icon={<WebhookIcon />}\n onClick={() => {\n void presenter.triggerWebhook(row.id).then(() => {\n toast.showSuccessToast({ title: \"Test event triggered!\" });\n });\n }}\n text={\"Trigger Test\"}\n />\n </HasPermission>\n <HasPermission entity=\"webhook\" action=\"delete\">\n <DropdownMenu.Separator />\n <DropdownMenu.Item\n variant={\"destructive\"}\n onClick={() => {\n showDeleteConfirmation(() => presenter.deleteWebhook(row.id));\n }}\n icon={<Delete />}\n text={\"Delete\"}\n />\n </HasPermission>\n </DropdownMenu>\n ),\n size: 56,\n enableSorting: false,\n enableHiding: false,\n enableResizing: false\n }\n }),\n [presenter]\n );\n\n if (!vm.list.pagination.loading && vm.list.rows.length === 0) {\n return (\n <div className=\"flex-1 overflow-hidden\">\n <div className=\"flex flex-col items-center justify-center h-full gap-md\">\n <Text className=\"text-neutral-strong\">No webhooks found.</Text>\n <CreateWebhookButton />\n </div>\n </div>\n );\n }\n\n return (\n <div className=\"flex-1 overflow-hidden\">\n <Scrollbar onScrollFrame={scrollFrame => loadMoreOnScroll({ scrollFrame })}>\n <DataTable<Webhook>\n columns={columns}\n data={vm.list.rows}\n loading={vm.list.pagination.loading}\n sorting={sorting}\n onSortingChange={onSortingChange}\n stickyHeader\n />\n </Scrollbar>\n </div>\n );\n});\n"],"names":["WebhookListContent","observer","presenter","vm","goToRoute","useRouter","toast","useToast","showDeleteConfirmation","useConfirmationDialog","loadMoreOnScroll","useMemo","debounce","scrollFrame","sorting","sort","onSortingChange","useCallback","updater","next","id","desc","columns","row","Text","Routes","Tag","TimeAgo","Button","DropdownMenu","IconButton","MoreVerticalIcon","Edit","HasPermission","WebhookIcon","Delete","CreateWebhookButton","Scrollbar","DataTable"],"mappings":";;;;;;;;;;;;;AA+BO,MAAMA,wCAAqBC,SAAS,SAA4B,EACnEC,SAAS,EACa;IACtB,MAAM,EAAEC,EAAE,EAAE,GAAGD;IACf,MAAM,EAAEE,SAAS,EAAE,GAAGC;IACtB,MAAMC,QAAQC;IAEd,MAAM,EAAE,kBAAkBC,sBAAsB,EAAE,GAAGC,sBAAsB;Q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