From c95f92514d863a0e32885dc7b07faa732fad033d Mon Sep 17 00:00:00 2001 From: Aidan Saunders Date: Wed, 5 Jul 2023 00:10:46 +0100 Subject: [PATCH] AdminUI: Convert Mail Accounts page civicrm/admin/mailSettings Make MailSettings available to SearchKit --- CRM/Mailing/xml/Menu/Mailing.xml | 9 +- ext/civi_mail/Civi/Api4/MailSettings.php | 2 +- .../ang/afsearchMailAccounts.aff.html | 3 + .../ang/afsearchMailAccounts.aff.json | 19 ++ .../SavedSearch_Manage_Mail_Accounts.mgd.php | 194 ++++++++++++++++++ 5 files changed, 225 insertions(+), 2 deletions(-) create mode 100644 ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.html create mode 100644 ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json create mode 100644 ext/civicrm_admin_ui/managed/SavedSearch_Manage_Mail_Accounts.mgd.php diff --git a/CRM/Mailing/xml/Menu/Mailing.xml b/CRM/Mailing/xml/Menu/Mailing.xml index 34dcdaabff8b..5e6b7b474e7d 100644 --- a/CRM/Mailing/xml/Menu/Mailing.xml +++ b/CRM/Mailing/xml/Menu/Mailing.xml @@ -40,11 +40,18 @@ civicrm/admin/mailSettings Mail Accounts CRM_Admin_Page_MailSettings - Configure email account setting. + List email accounts. access CiviCRM,access CiviMail CiviMail 420 + + civicrm/admin/mailSettings/edit + Mail Accounts + CRM_Admin_Form_MailSettings + access CiviCRM,access CiviMail + 420 + civicrm/admin/setting/preferences/mailing CiviMail Component Settings diff --git a/ext/civi_mail/Civi/Api4/MailSettings.php b/ext/civi_mail/Civi/Api4/MailSettings.php index 89bc970e9904..1d1bc01c5d53 100644 --- a/ext/civi_mail/Civi/Api4/MailSettings.php +++ b/ext/civi_mail/Civi/Api4/MailSettings.php @@ -13,7 +13,7 @@ /** * MailSettings entity. * - * @searchable none + * @searchable secondary * @since 5.19 * @package Civi\Api4 */ diff --git a/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.html b/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.html new file mode 100644 index 000000000000..d7ec641d68fa --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.html @@ -0,0 +1,3 @@ +
+ +
diff --git a/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json b/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json new file mode 100644 index 000000000000..19168345dae0 --- /dev/null +++ b/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json @@ -0,0 +1,19 @@ +{ + "type": "search", + "title": "Mail Accounts", + "icon": "fa-list-alt", + "server_route": "civicrm/admin/mailSettings", + "permission": "administer CiviCRM", + "requires": [], + "description": "", + "is_dashlet": false, + "is_public": false, + "is_token": false, + "entity_type": null, + "join_entity": null, + "contact_summary": null, + "summary_contact_type": null, + "redirect": null, + "create_submission": null, + "navigation": null +} diff --git a/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Mail_Accounts.mgd.php b/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Mail_Accounts.mgd.php new file mode 100644 index 000000000000..e76d2daa7268 --- /dev/null +++ b/ext/civicrm_admin_ui/managed/SavedSearch_Manage_Mail_Accounts.mgd.php @@ -0,0 +1,194 @@ + 'SavedSearch_Mail_Accounts', + 'entity' => 'SavedSearch', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Mail_Accounts', + 'label' => E::ts('Mail Accounts'), + 'form_values' => NULL, + 'mapping_id' => NULL, + 'search_custom_id' => NULL, + 'api_entity' => 'MailSettings', + 'api_params' => [ + 'version' => 4, + 'select' => [ + 'name', + 'server', + 'username', + 'localpart', + 'domain', + 'return_path', + 'protocol:label', + 'source', + 'is_ssl', + 'is_default', + ], + 'orderBy' => [], + 'where' => [], + 'groupBy' => [], + 'join' => [], + 'having' => [], + ], + 'expires_date' => NULL, + 'description' => NULL, + ], + 'match' => [ + 'name', + ], + ], + ], + [ + 'name' => 'SavedSearch_Mail_Accounts_SearchDisplay_Mail_Accounts_Table_1', + 'entity' => 'SearchDisplay', + 'cleanup' => 'always', + 'update' => 'unmodified', + 'params' => [ + 'version' => 4, + 'values' => [ + 'name' => 'Mail_Accounts_Table_1', + 'label' => E::ts('Mail Accounts Table 1'), + 'saved_search_id.name' => 'Mail_Accounts', + 'type' => 'table', + 'settings' => [ + 'description' => NULL, + 'sort' => [], + 'limit' => 50, + 'pager' => [], + 'placeholder' => 5, + 'columns' => [ + [ + 'type' => 'field', + 'key' => 'name', + 'dataType' => 'String', + 'label' => E::ts('Name'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'server', + 'dataType' => 'String', + 'label' => E::ts('Server'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'username', + 'dataType' => 'String', + 'label' => E::ts('Username'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'localpart', + 'dataType' => 'String', + 'label' => E::ts('Localpart'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'domain', + 'dataType' => 'String', + 'label' => E::ts('Domain'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'return_path', + 'dataType' => 'String', + 'label' => E::ts('Return-Path'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'protocol:label', + 'dataType' => 'String', + 'label' => E::ts('Protocol'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'source', + 'dataType' => 'String', + 'label' => E::ts('Mail Folder'), + 'sortable' => TRUE, + ], + [ + 'type' => 'field', + 'key' => 'is_ssl', + 'dataType' => 'Boolean', + 'label' => E::ts('Use SSL?'), + 'sortable' => TRUE, + ], + [ + 'type' => 'html', + 'key' => 'is_default', + 'dataType' => 'Boolean', + 'label' => E::ts('Used For'), + 'sortable' => TRUE, + 'rewrite' => '{if "[is_default]" == "' . E::ts('Yes') . '"}' . E::ts('Bounce Processing (Default)') . '{else}' . E::ts('Email-to-Activity') . '{/if}', + ], + [ + 'text' => '', + 'style' => 'default', + 'size' => 'btn-xs', + 'icon' => 'fa-bars', + 'links' => [ + [ + 'entity' => 'MailSettings', + 'action' => 'update', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-pencil', + 'text' => E::ts('Edit'), + 'style' => 'default', + 'path' => '', + 'condition' => [], + ], + [ + 'entity' => 'MailSettings', + 'action' => 'delete', + 'join' => '', + 'target' => 'crm-popup', + 'icon' => 'fa-trash', + 'text' => E::ts('Delete'), + 'style' => 'danger', + 'path' => '', + 'condition' => [ + 'is_default', + '=', + FALSE, + ], + ], + ], + 'type' => 'menu', + 'alignment' => 'text-right', + ], + ], + 'actions' => FALSE, + 'classes' => [ + 'table', + 'table-striped', + ], + 'addButton' => [ + 'path' => 'civicrm/admin/mailSettings/edit?action=add&reset=1', + 'text' => E::ts('Add Mail Account'), + 'icon' => 'fa-plus', + ], + ], + 'acl_bypass' => FALSE, + ], + 'match' => [ + 'name', + 'saved_search_id', + ], + ], + ], +];