From 36cd224f9769120f694d790ed7dea9819b3edcce Mon Sep 17 00:00:00 2001 From: Matthew Wire <mjw@mjwconsult.co.uk> Date: Fri, 7 Mar 2025 23:07:29 +0000 Subject: [PATCH] Add SearchKit-based webhooks list --- ...archPaymentProcessorWebhookDetail.aff.html | 3 + ...earchPaymentProcessorWebhookDetail.aff.php | 12 ++ ang/afsearchPaymentProcessorWebhooks.aff.html | 13 ++ ang/afsearchPaymentProcessorWebhooks.aff.php | 12 ++ ...n_afsearchPaymentProcessorWebhooks.mgd.php | 27 +++ ...ch_Paymentprocessor_Webhook_Detail.mgd.php | 101 +++++++++++ ...ch_Paymentprocessor_Webhook_Search.mgd.php | 169 ++++++++++++++++++ 7 files changed, 337 insertions(+) create mode 100644 ang/afsearchPaymentProcessorWebhookDetail.aff.html create mode 100644 ang/afsearchPaymentProcessorWebhookDetail.aff.php create mode 100644 ang/afsearchPaymentProcessorWebhooks.aff.html create mode 100644 ang/afsearchPaymentProcessorWebhooks.aff.php create mode 100644 managed/Navigation_afsearchPaymentProcessorWebhooks.mgd.php create mode 100644 managed/SavedSearch_Paymentprocessor_Webhook_Detail.mgd.php create mode 100644 managed/SavedSearch_Paymentprocessor_Webhook_Search.mgd.php diff --git a/ang/afsearchPaymentProcessorWebhookDetail.aff.html b/ang/afsearchPaymentProcessorWebhookDetail.aff.html new file mode 100644 index 0000000..f713f56 --- /dev/null +++ b/ang/afsearchPaymentProcessorWebhookDetail.aff.html @@ -0,0 +1,3 @@ +<div af-fieldset=""> + <crm-search-display-list search-name="Paymentprocessor_Webhook_Detail" display-name="Paymentprocessor_Webhook_Detail" filters="{id: routeParams.id}"></crm-search-display-list> +</div> diff --git a/ang/afsearchPaymentProcessorWebhookDetail.aff.php b/ang/afsearchPaymentProcessorWebhookDetail.aff.php new file mode 100644 index 0000000..e41f8bb --- /dev/null +++ b/ang/afsearchPaymentProcessorWebhookDetail.aff.php @@ -0,0 +1,12 @@ +<?php +use CRM_Mjwshared_ExtensionUtil as E; + +return [ + 'type' => 'search', + 'title' => E::ts('Payment Processor Webhook Detail'), + 'icon' => 'fa-list-alt', + 'server_route' => 'civicrm/paymentprocessorwebhooks/detail', + 'permission' => [ + 'edit contributions', + ], +]; diff --git a/ang/afsearchPaymentProcessorWebhooks.aff.html b/ang/afsearchPaymentProcessorWebhooks.aff.html new file mode 100644 index 0000000..2f0f4df --- /dev/null +++ b/ang/afsearchPaymentProcessorWebhooks.aff.html @@ -0,0 +1,13 @@ +<div af-fieldset=""> + <div class="af-container af-layout-inline"> + <af-field name="status" /> + <af-field name="payment_processor_id" defn="{input_attrs: {multiple: true}}" /> + <af-field name="event_id" /> + <af-field name="identifier" /> + <af-field name="message" /> + <af-field name="data" /> + <af-field name="created_date" defn="{input_type: 'Select', search_range: true, input_attrs: {}}" /> + <af-field name="processed_date" defn="{input_type: 'Select', search_range: true, input_attrs: {}}" /> + </div> + <crm-search-display-table search-name="Paymentprocessor_Webhook_Search" display-name="Paymentprocessor_Webhook_Search"></crm-search-display-table> +</div> diff --git a/ang/afsearchPaymentProcessorWebhooks.aff.php b/ang/afsearchPaymentProcessorWebhooks.aff.php new file mode 100644 index 0000000..d2276b1 --- /dev/null +++ b/ang/afsearchPaymentProcessorWebhooks.aff.php @@ -0,0 +1,12 @@ +<?php +use CRM_Mjwshared_ExtensionUtil as E; + +return [ + 'type' => 'search', + 'title' => E::ts('Payment Processor Webhooks'), + 'icon' => 'fa-list-alt', + 'server_route' => 'civicrm/paymentprocessorwebhooks', + 'permission' => [ + 'edit contributions', + ], +]; diff --git a/managed/Navigation_afsearchPaymentProcessorWebhooks.mgd.php b/managed/Navigation_afsearchPaymentProcessorWebhooks.mgd.php new file mode 100644 index 0000000..7bc3011 --- /dev/null +++ b/managed/Navigation_afsearchPaymentProcessorWebhooks.mgd.php @@ -0,0 +1,27 @@ +<?php +use CRM_Mjwshared_ExtensionUtil as E; + +return [ + [ + 'name' => 'Navigation_afsearchPaymentProcessorWebhooks', + 'entity' => 'Navigation', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'label' => E::ts('Payment Processor Webhooks'), + 'name' => 'afsearchPaymentProcessorWebhooks', + 'url' => 'civicrm/paymentprocessorwebhooks', + 'icon' => 'crm-i fa-list-alt', + 'permission' => [ + 'edit contributions', + ], + 'permission_operator' => 'AND', + 'parent_id.name' => 'CiviContribute', + 'weight' => 19, + ], + 'match' => ['name', 'domain_id'], + ], + ], +]; diff --git a/managed/SavedSearch_Paymentprocessor_Webhook_Detail.mgd.php b/managed/SavedSearch_Paymentprocessor_Webhook_Detail.mgd.php new file mode 100644 index 0000000..b660788 --- /dev/null +++ b/managed/SavedSearch_Paymentprocessor_Webhook_Detail.mgd.php @@ -0,0 +1,101 @@ +<?php +use CRM_Mjwshared_ExtensionUtil as E; + +return [ + [ + 'name' => 'SavedSearch_Paymentprocessor_Webhook_Detail', + 'entity' => 'SavedSearch', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Paymentprocessor_Webhook_Detail', + 'label' => E::ts('Paymentprocessor Webhook Detail'), + 'api_entity' => 'PaymentprocessorWebhook', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'id', + 'data', + 'identifier', + 'message', + 'trigger', + 'status', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [], + 'join' => [], + 'having' => [], + ], + ], + 'match' => ['name'], + ], + ], + [ + 'name' => 'SavedSearch_Paymentprocessor_Webhook_Detail_SearchDisplay_Paymentprocessor_Webhook_Detail', + 'entity' => 'SearchDisplay', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Paymentprocessor_Webhook_Detail', + 'label' => E::ts('Paymentprocessor Webhook Detail'), + 'saved_search_id.name' => 'Paymentprocessor_Webhook_Detail', + 'type' => 'list', + 'settings' => [ + 'style' => 'ul', + 'limit' => 1, + 'sort' => [], + 'pager' => FALSE, + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'id', + 'dataType' => 'Integer', + 'label' => E::ts('ID'), + ], + [ + 'type' => 'field', + 'key' => 'identifier', + 'dataType' => 'String', + 'label' => E::ts('Identifier'), + ], + [ + 'type' => 'field', + 'key' => 'message', + 'dataType' => 'String', + 'break' => FALSE, + 'label' => E::ts('Message'), + ], + [ + 'type' => 'field', + 'key' => 'trigger', + 'dataType' => 'String', + 'label' => E::ts('Trigger'), + ], + [ + 'type' => 'field', + 'key' => 'status', + 'dataType' => 'String', + 'label' => E::ts('Status'), + ], + [ + 'type' => 'html', + 'key' => 'data', + 'dataType' => 'Text', + 'label' => E::ts('Data'), + ], + ], + 'placeholder' => 0, + ], + ], + 'match' => [ + 'saved_search_id', + 'name', + ], + ], + ], +]; diff --git a/managed/SavedSearch_Paymentprocessor_Webhook_Search.mgd.php b/managed/SavedSearch_Paymentprocessor_Webhook_Search.mgd.php new file mode 100644 index 0000000..220e79a --- /dev/null +++ b/managed/SavedSearch_Paymentprocessor_Webhook_Search.mgd.php @@ -0,0 +1,169 @@ +<?php +use CRM_Mjwshared_ExtensionUtil as E; + +return [ + [ + 'name' => 'SavedSearch_Paymentprocessor_Webhook_Search', + 'entity' => 'SavedSearch', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Paymentprocessor_Webhook_Search', + 'label' => E::ts('Paymentprocessor Webhook Search'), + 'api_entity' => 'PaymentprocessorWebhook', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'id', + 'status', + 'created_date', + 'processed_date', + 'payment_processor_id:label', + 'event_id', + 'message', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [], + 'join' => [], + 'having' => [], + ], + ], + 'match' => ['name'], + ], + ], + [ + 'name' => 'SavedSearch_Paymentprocessor_Webhook_Search_SearchDisplay_Paymentprocessor_Webhook_Search', + 'entity' => 'SearchDisplay', + 'cleanup' => 'unused', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Paymentprocessor_Webhook_Search', + 'label' => E::ts('Paymentprocessor Webhook Search'), + 'saved_search_id.name' => 'Paymentprocessor_Webhook_Search', + 'type' => 'table', + 'settings' => [ + 'description' => E::ts(NULL), + 'sort' => [ + ['created_date', 'DESC'], + ], + 'limit' => 50, + 'pager' => [], + 'placeholder' => 5, + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'id', + 'dataType' => 'Integer', + 'label' => E::ts('ID'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'status', + 'dataType' => 'String', + 'label' => E::ts('Status'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'created_date', + 'dataType' => 'Timestamp', + 'label' => E::ts('Created Date'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'processed_date', + 'dataType' => 'Timestamp', + 'label' => E::ts('Processed Date'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'payment_processor_id:label', + 'dataType' => 'Integer', + 'label' => E::ts('Payment Processor'), + 'sortable' => TRUE, + 'rewrite' => '[payment_processor_id:label] ([payment_processor_id])', + ], + [ + 'type' => 'field', + 'key' => 'event_id', + 'dataType' => 'String', + 'label' => E::ts('Event ID'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'message', + 'dataType' => 'String', + 'label' => E::ts('Message'), + 'sortable' => TRUE, + ], + [ + 'size' => 'btn-xs', + 'links' => [ + [ + 'path' => 'civicrm/paymentprocessorwebhooks/detail#?id=[id]', + 'icon' => 'fa-clipboard-list', + 'text' => E::ts('Detail'), + 'style' => 'default', + 'condition' => [], + 'task' => '', + 'entity' => '', + 'action' => '', + 'join' => '', + 'target' => 'crm-popup', + ], + [ + 'task' => 'retry', + 'entity' => 'PaymentprocessorWebhook', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-rectangle-refresh', + 'text' => E::ts('Retry'), + 'style' => 'default', + 'path' => '', + 'action' => '', + 'condition' => [], + ], + [ + 'task' => 'delete', + 'entity' => 'PaymentprocessorWebhook', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-trash', + 'text' => E::ts('Delete'), + 'style' => 'danger', + 'path' => '', + 'action' => '', + 'condition' => [], + ], + ], + 'type' => 'buttons', + 'alignment' => 'text-right', + ], + ], + 'actions' => TRUE, + 'classes' => ['table', 'table-striped'], + 'actions_display_mode' => 'menu', + 'cssRules' => [ + ['bg-success', 'status', '=', 'success'], + ['bg-danger', 'status', '=', 'error'], + ['bg-info', 'status', '=', 'new'], + ], + 'headerCount' => TRUE, + ], + ], + 'match' => [ + 'saved_search_id', + 'name', + ], + ], + ], +]; -- GitLab