AdminUI: Convert Mail Accounts page civicrm/admin/mailSettings
authorAidan Saunders <aidan.saunders@squiffle.uk>
Tue, 4 Jul 2023 23:10:46 +0000 (00:10 +0100)
committerAidan Saunders <aidan.saunders@squiffle.uk>
Wed, 5 Jul 2023 08:28:12 +0000 (09:28 +0100)
Make MailSettings available to SearchKit

CRM/Mailing/xml/Menu/Mailing.xml
ext/civi_mail/Civi/Api4/MailSettings.php
ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.html [new file with mode: 0644]
ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json [new file with mode: 0644]
ext/civicrm_admin_ui/managed/SavedSearch_Manage_Mail_Accounts.mgd.php [new file with mode: 0644]

index 34dcdaabff8bbe5586ae9241fdfaa7fc8d7957e5..5e6b7b474e7dde685aa439d5028bd68e82d8eab7 100644 (file)
     <path>civicrm/admin/mailSettings</path>
     <title>Mail Accounts</title>
     <page_callback>CRM_Admin_Page_MailSettings</page_callback>
-    <desc>Configure email account setting.</desc>
+    <desc>List email accounts.</desc>
     <access_arguments>access CiviCRM,access CiviMail</access_arguments>
     <adminGroup>CiviMail</adminGroup>
     <weight>420</weight>
   </item>
+  <item>
+    <path>civicrm/admin/mailSettings/edit</path>
+    <title>Mail Accounts</title>
+    <page_callback>CRM_Admin_Form_MailSettings</page_callback>
+    <access_arguments>access CiviCRM,access CiviMail</access_arguments>
+    <weight>420</weight>
+  </item>
   <item>
     <path>civicrm/admin/setting/preferences/mailing</path>
     <title>CiviMail Component Settings</title>
index 89bc970e99045fd63960cecca5b4c703003040e0..1d1bc01c5d530793c05c0f44848963ba683d7151 100644 (file)
@@ -13,7 +13,7 @@ namespace Civi\Api4;
 /**
  * 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 (file)
index 0000000..d7ec641
--- /dev/null
@@ -0,0 +1,3 @@
+<div af-fieldset="">
+  <crm-search-display-table search-name="Mail_Accounts" display-name="Mail_Accounts_Table_1"></crm-search-display-table>
+</div>
diff --git a/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json b/ext/civicrm_admin_ui/ang/afsearchMailAccounts.aff.json
new file mode 100644 (file)
index 0000000..1916834
--- /dev/null
@@ -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 (file)
index 0000000..e76d2da
--- /dev/null
@@ -0,0 +1,194 @@
+<?php
+
+use CRM_CivicrmAdminUi_ExtensionUtil as E;
+
+return [
+  [
+    'name' => '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 <strong>(Default)</strong>') . '{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',
+      ],
+    ],
+  ],
+];