@escalated-dev/escalated 0.7.0 → 0.7.1

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 (179) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +31 -0
  3. package/package.json +12 -6
  4. package/src/components/ActiveChatsPanel.vue +246 -0
  5. package/src/components/ActivityTimeline.stories.js +55 -55
  6. package/src/components/ActivityTimeline.vue +83 -83
  7. package/src/components/AdminDashboard.stories.js +1423 -1095
  8. package/src/components/AgentLoadIndicator.stories.js +37 -37
  9. package/src/components/AgentLoadIndicator.vue +49 -49
  10. package/src/components/AgentPerformanceCard.vue +44 -44
  11. package/src/components/ArticleEditor.vue +82 -82
  12. package/src/components/AssigneeSelect.vue +37 -37
  13. package/src/components/AttachmentList.vue +13 -1
  14. package/src/components/AuditLogEntry.vue +95 -95
  15. package/src/components/BulkActionBar.vue +166 -166
  16. package/src/components/CategoryTree.vue +89 -89
  17. package/src/components/ChartWidget.vue +46 -46
  18. package/src/components/ChatActionBar.vue +226 -0
  19. package/src/components/ChatBubble.vue +162 -0
  20. package/src/components/ChatComposer.vue +308 -0
  21. package/src/components/ChatQueue.vue +222 -0
  22. package/src/components/ChatThread.vue +197 -0
  23. package/src/components/CollisionWarning.stories.js +30 -30
  24. package/src/components/CollisionWarning.vue +68 -68
  25. package/src/components/ConditionalFieldRules.vue +135 -135
  26. package/src/components/ContextPanel.vue +66 -66
  27. package/src/components/ContextPanelSection.vue +65 -65
  28. package/src/components/CustomFieldRenderer.vue +159 -159
  29. package/src/components/EscalatedLayout.vue +29 -6
  30. package/src/components/FileDropzone.vue +57 -57
  31. package/src/components/FollowButton.stories.js +30 -30
  32. package/src/components/FollowButton.vue +88 -88
  33. package/src/components/KeyboardShortcutHelp.vue +213 -213
  34. package/src/components/KnowledgePanel.vue +122 -122
  35. package/src/components/KpiCard.stories.js +32 -32
  36. package/src/components/KpiCard.vue +88 -88
  37. package/src/components/MacroDropdown.vue +150 -150
  38. package/src/components/MentionDropdown.vue +154 -0
  39. package/src/components/MetricComparison.vue +89 -0
  40. package/src/components/PercentileChart.vue +67 -0
  41. package/src/components/PeriodSelector.vue +98 -0
  42. package/src/components/PermissionMatrix.vue +107 -107
  43. package/src/components/PinnedNotes.vue +129 -129
  44. package/src/components/PluginSlot.vue +68 -62
  45. package/src/components/PresenceIndicator.vue +46 -2
  46. package/src/components/PriorityBadge.stories.js +33 -33
  47. package/src/components/PriorityBadge.vue +46 -46
  48. package/src/components/ReplyComposer.vue +81 -18
  49. package/src/components/ReplyThread.vue +40 -2
  50. package/src/components/ReportChart.vue +395 -0
  51. package/src/components/ReportExportButton.vue +108 -0
  52. package/src/components/SatisfactionRating.vue +180 -180
  53. package/src/components/SaveViewDialog.vue +172 -0
  54. package/src/components/SavedViewSidebar.vue +208 -0
  55. package/src/components/ScheduleEditor.vue +104 -104
  56. package/src/components/SideConversation.vue +165 -165
  57. package/src/components/SideConversationList.vue +147 -147
  58. package/src/components/SkillTagManager.vue +79 -79
  59. package/src/components/SlaComplianceChart.vue +46 -53
  60. package/src/components/SlaTimer.stories.js +35 -35
  61. package/src/components/SlaTimer.vue +62 -62
  62. package/src/components/SnoozeButton.vue +247 -0
  63. package/src/components/StatsCard.stories.js +24 -24
  64. package/src/components/StatsCard.vue +58 -58
  65. package/src/components/StatusBadge.stories.js +53 -53
  66. package/src/components/StatusBadge.vue +78 -78
  67. package/src/components/TagSelect.vue +84 -84
  68. package/src/components/TicketFilters.vue +270 -225
  69. package/src/components/TicketLinkPanel.vue +193 -193
  70. package/src/components/TicketList.vue +655 -594
  71. package/src/components/TicketMergeDialog.vue +157 -157
  72. package/src/components/TicketSplitDialog.vue +98 -0
  73. package/src/components/TotpInput.stories.js +9 -9
  74. package/src/components/TotpInput.vue +81 -81
  75. package/src/components/TwoFactorSetup.vue +113 -113
  76. package/src/components/VariableTokenInput.vue +111 -0
  77. package/src/components/WorkflowActionConfig.vue +287 -0
  78. package/src/components/WorkflowActionList.vue +350 -0
  79. package/src/components/WorkflowConditionBuilder.vue +265 -0
  80. package/src/components/WorkflowTriggerSelector.vue +125 -0
  81. package/src/composables/useChat.js +187 -0
  82. package/src/composables/useI18n.js +80 -80
  83. package/src/composables/useKeyboardShortcuts.js +46 -46
  84. package/src/composables/useMentions.js +134 -0
  85. package/src/composables/usePluginExtensions.js +159 -159
  86. package/src/composables/usePluginHooks.js +65 -65
  87. package/src/composables/useRealtime.js +182 -0
  88. package/src/defineEscalatedPlugin.js +76 -76
  89. package/src/index.js +84 -72
  90. package/src/locales/ar.json +727 -0
  91. package/src/locales/de.json +678 -430
  92. package/src/locales/en.json +717 -455
  93. package/src/locales/es.json +679 -430
  94. package/src/locales/fr.json +680 -431
  95. package/src/locales/index.js +12 -2
  96. package/src/locales/it.json +727 -0
  97. package/src/locales/ja.json +727 -0
  98. package/src/locales/ko.json +727 -0
  99. package/src/locales/nl.json +727 -0
  100. package/src/locales/pl.json +727 -0
  101. package/src/locales/pt-BR.json +727 -0
  102. package/src/locales/ru.json +727 -0
  103. package/src/locales/tr.json +727 -0
  104. package/src/locales/zh-CN.json +727 -0
  105. package/src/pages/Admin/ApiTokens/Index.vue +381 -381
  106. package/src/pages/Admin/AuditLog/Index.vue +154 -154
  107. package/src/pages/Admin/BusinessHours/Form.vue +172 -172
  108. package/src/pages/Admin/BusinessHours/Index.vue +113 -113
  109. package/src/pages/Admin/CannedResponses/Index.vue +127 -127
  110. package/src/pages/Admin/Capacity/Index.vue +134 -134
  111. package/src/pages/Admin/CustomFields/Form.vue +195 -195
  112. package/src/pages/Admin/CustomFields/Index.vue +134 -134
  113. package/src/pages/Admin/CustomObjects/Form.vue +202 -202
  114. package/src/pages/Admin/CustomObjects/Index.vue +127 -127
  115. package/src/pages/Admin/CustomObjects/Records.vue +228 -228
  116. package/src/pages/Admin/Departments/Form.vue +75 -75
  117. package/src/pages/Admin/Departments/Index.vue +110 -109
  118. package/src/pages/Admin/EscalationRules/Form.vue +157 -157
  119. package/src/pages/Admin/EscalationRules/Index.vue +178 -178
  120. package/src/pages/Admin/Import/Connect.vue +0 -1
  121. package/src/pages/Admin/Import/Index.vue +1 -1
  122. package/src/pages/Admin/Import/Progress.vue +1 -1
  123. package/src/pages/Admin/KnowledgeBase/Articles/Form.vue +142 -142
  124. package/src/pages/Admin/KnowledgeBase/Articles/Index.vue +195 -195
  125. package/src/pages/Admin/KnowledgeBase/Categories/Index.vue +193 -193
  126. package/src/pages/Admin/Macros/Index.vue +448 -448
  127. package/src/pages/Admin/Plugins/Index.vue +327 -327
  128. package/src/pages/Admin/Reports/AgentDetail.vue +132 -0
  129. package/src/pages/Admin/Reports/AgentMetrics.vue +115 -115
  130. package/src/pages/Admin/Reports/AgentRanking.vue +246 -0
  131. package/src/pages/Admin/Reports/Cohorts.vue +180 -0
  132. package/src/pages/Admin/Reports/Comparison.vue +141 -0
  133. package/src/pages/Admin/Reports/CsatReport.vue +127 -127
  134. package/src/pages/Admin/Reports/Dashboard.vue +36 -21
  135. package/src/pages/Admin/Reports/ResolutionTimes.vue +164 -0
  136. package/src/pages/Admin/Reports/ResponseTimes.vue +164 -0
  137. package/src/pages/Admin/Reports/SlaReport.vue +162 -166
  138. package/src/pages/Admin/Reports/SlaTrends.vue +183 -0
  139. package/src/pages/Admin/Reports.vue +206 -206
  140. package/src/pages/Admin/Roles/Form.vue +71 -71
  141. package/src/pages/Admin/Roles/Index.vue +122 -122
  142. package/src/pages/Admin/Settings/CsatSettings.vue +165 -165
  143. package/src/pages/Admin/Settings/DataRetention.vue +182 -182
  144. package/src/pages/Admin/Settings/EmailSettings.vue +243 -243
  145. package/src/pages/Admin/Settings/Sandbox.vue +135 -135
  146. package/src/pages/Admin/Settings/SsoSettings.vue +218 -218
  147. package/src/pages/Admin/Settings/TwoFactor.vue +110 -110
  148. package/src/pages/Admin/Settings.vue +1008 -468
  149. package/src/pages/Admin/Skills/Form.vue +53 -53
  150. package/src/pages/Admin/Skills/Index.vue +94 -94
  151. package/src/pages/Admin/SlaPolicies/Form.vue +118 -118
  152. package/src/pages/Admin/SlaPolicies/Index.vue +121 -120
  153. package/src/pages/Admin/Statuses/Form.vue +114 -114
  154. package/src/pages/Admin/Statuses/Index.vue +153 -153
  155. package/src/pages/Admin/Tags/Index.vue +191 -191
  156. package/src/pages/Admin/Tickets/Index.vue +126 -91
  157. package/src/pages/Admin/Tickets/Show.vue +29 -0
  158. package/src/pages/Admin/Webhooks/DeliveryLog.vue +120 -120
  159. package/src/pages/Admin/Webhooks/Form.vue +110 -110
  160. package/src/pages/Admin/Webhooks/Index.vue +136 -136
  161. package/src/pages/Admin/Workflows/Builder.vue +207 -0
  162. package/src/pages/Admin/Workflows/Index.vue +235 -0
  163. package/src/pages/Admin/Workflows/Logs.vue +286 -0
  164. package/src/pages/Agent/TicketIndex.vue +112 -88
  165. package/src/pages/Agent/TicketShow.vue +192 -60
  166. package/src/pages/Customer/Create.vue +1 -1
  167. package/src/pages/Customer/Index.vue +31 -31
  168. package/src/pages/Customer/KnowledgeBase/Article.vue +4 -2
  169. package/src/pages/Customer/KnowledgeBase/Index.vue +151 -151
  170. package/src/pages/Customer/Show.vue +69 -63
  171. package/src/pages/Guest/Create.vue +40 -15
  172. package/src/pages/Guest/Show.vue +124 -93
  173. package/src/plugin.js +25 -0
  174. package/src/utils/mentionHighlight.js +24 -0
  175. package/src/utils/sanitizeHtml.js +78 -64
  176. package/src/widget/EscalatedWidget.vue +804 -0
  177. package/src/widget/index.js +254 -0
  178. package/src/pages/Admin/Automations/Form.vue +0 -184
  179. package/src/pages/Admin/Automations/Index.vue +0 -129
@@ -0,0 +1,134 @@
1
+ import { ref, onUnmounted } from 'vue';
2
+
3
+ /**
4
+ * Composable that detects `@` typed in a text input/textarea,
5
+ * fetches agent suggestions from the API (debounced), and provides
6
+ * an insert function to replace the mention token.
7
+ *
8
+ * @param {Object} options
9
+ * @param {string} [options.searchEndpoint] - API endpoint for agent search (default: route-based)
10
+ * @param {number} [options.debounce=250] - Debounce delay in ms
11
+ * @returns {Object}
12
+ */
13
+ export function useMentions(options = {}) {
14
+ const { debounce = 250 } = options;
15
+
16
+ const suggestions = ref([]);
17
+ const isActive = ref(false);
18
+ const query = ref('');
19
+ const mentionStart = ref(null); // cursor position where `@` was typed
20
+ const loading = ref(false);
21
+
22
+ let timer = null;
23
+
24
+ function clearTimer() {
25
+ if (timer !== null) {
26
+ window.clearTimeout(timer);
27
+ timer = null;
28
+ }
29
+ }
30
+
31
+ /**
32
+ * Call this on every input/keyup event with the textarea element
33
+ * and the current text value.
34
+ */
35
+ function onTextChange(textareaEl, text) {
36
+ if (!textareaEl) return;
37
+
38
+ const cursorPos = textareaEl.selectionStart;
39
+ const textBeforeCursor = text.slice(0, cursorPos);
40
+
41
+ // Find the last `@` that starts a mention (preceded by whitespace or start of string)
42
+ const mentionMatch = textBeforeCursor.match(/(?:^|[\s(])@([a-zA-Z0-9_ ]*)$/);
43
+
44
+ if (mentionMatch) {
45
+ const searchQuery = mentionMatch[1];
46
+ // The @ is at cursorPos minus the matched group minus 1 for the @
47
+ mentionStart.value = cursorPos - searchQuery.length - 1;
48
+ query.value = searchQuery;
49
+ isActive.value = true;
50
+ debouncedFetch(searchQuery);
51
+ } else {
52
+ close();
53
+ }
54
+ }
55
+
56
+ function debouncedFetch(searchQuery) {
57
+ clearTimer();
58
+
59
+ if (searchQuery.length < 1) {
60
+ fetchSuggestions('');
61
+ return;
62
+ }
63
+
64
+ timer = window.setTimeout(() => {
65
+ fetchSuggestions(searchQuery);
66
+ }, debounce);
67
+ }
68
+
69
+ async function fetchSuggestions(searchQuery) {
70
+ loading.value = true;
71
+ try {
72
+ const endpoint = options.searchEndpoint || '/support/admin/agents/search';
73
+ const url = `${endpoint}?q=${encodeURIComponent(searchQuery)}`;
74
+ const response = await fetch(url, {
75
+ headers: {
76
+ Accept: 'application/json',
77
+ 'X-Requested-With': 'XMLHttpRequest',
78
+ 'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]')?.content || '',
79
+ },
80
+ });
81
+ if (response.ok) {
82
+ suggestions.value = await response.json();
83
+ } else {
84
+ suggestions.value = [];
85
+ }
86
+ } catch {
87
+ suggestions.value = [];
88
+ } finally {
89
+ loading.value = false;
90
+ }
91
+ }
92
+
93
+ /**
94
+ * Insert the selected agent mention into the text.
95
+ * Returns the new text value with the mention inserted.
96
+ *
97
+ * @param {string} currentText - Current textarea value
98
+ * @param {Object} agent - Agent object with `name` property
99
+ * @returns {string} Updated text
100
+ */
101
+ function insertMention(currentText, agent) {
102
+ if (mentionStart.value === null) return currentText;
103
+
104
+ const before = currentText.slice(0, mentionStart.value);
105
+ const cursorPos = mentionStart.value + 1 + query.value.length;
106
+ const after = currentText.slice(cursorPos);
107
+
108
+ const mentionText = `@{${agent.name}} `;
109
+ const newText = before + mentionText + after;
110
+
111
+ close();
112
+ return newText;
113
+ }
114
+
115
+ function close() {
116
+ isActive.value = false;
117
+ suggestions.value = [];
118
+ query.value = '';
119
+ mentionStart.value = null;
120
+ clearTimer();
121
+ }
122
+
123
+ onUnmounted(clearTimer);
124
+
125
+ return {
126
+ suggestions,
127
+ isActive,
128
+ query,
129
+ loading,
130
+ onTextChange,
131
+ insertMention,
132
+ close,
133
+ };
134
+ }
@@ -1,159 +1,159 @@
1
- import { computed } from 'vue';
2
- import { usePage } from '@inertiajs/vue3';
3
-
4
- /**
5
- * Composable for reading plugin extensions from Inertia shared props.
6
- *
7
- * The Laravel backend (escalated-laravel) shares plugin UI extensions via
8
- * `$page.props.escalated.plugins`, which contains:
9
- * - menuItems: Array of navigation items injected by plugins
10
- * - dashboardWidgets: Array of widget definitions for the agent dashboard
11
- * - pageComponents: Object mapping slot names to arrays of component definitions
12
- *
13
- * @returns {Object} Plugin extension data and helper functions
14
- */
15
- export function usePluginExtensions() {
16
- const page = usePage();
17
-
18
- const pluginData = computed(() => page.props?.escalated?.plugins || {});
19
-
20
- /**
21
- * Menu items injected by plugins, sorted by position.
22
- * Each item: { label, route, icon, position, permission, badge, submenu }
23
- */
24
- const menuItems = computed(() => {
25
- const items = pluginData.value.menuItems || [];
26
- return [...items].sort((a, b) => (a.position || 100) - (b.position || 100));
27
- });
28
-
29
- /**
30
- * Dashboard widgets injected by plugins, sorted by position.
31
- * Each widget: { id, title, component, plugin, data, position, width }
32
- */
33
- const dashboardWidgets = computed(() => {
34
- const widgets = pluginData.value.dashboardWidgets || [];
35
- return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
36
- });
37
-
38
- /**
39
- * Ticket actions injected by plugins (e.g., "Escalate to Jira", "Send Approval").
40
- * Each action: { id, label, icon, handler, position, permission, context }
41
- * context: 'agent' | 'admin' | 'both'
42
- */
43
- const ticketActions = computed(() => {
44
- const actions = pluginData.value.ticketActions || [];
45
- return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
46
- });
47
-
48
- /**
49
- * Sidebar panels injected by plugins for the ticket detail context panel.
50
- * Each panel: { id, title, component, plugin, position, collapsed, icon }
51
- */
52
- const sidebarPanels = computed(() => {
53
- const panels = pluginData.value.sidebarPanels || [];
54
- return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
55
- });
56
-
57
- /**
58
- * Custom ticket fields injected by plugins for ticket creation/edit forms.
59
- * Each field: { id, label, type, name, options, required, position, plugin }
60
- * type: 'text' | 'textarea' | 'select' | 'checkbox' | 'date' | 'number'
61
- */
62
- const ticketFields = computed(() => {
63
- const fields = pluginData.value.ticketFields || [];
64
- return [...fields].sort((a, b) => (a.position || 100) - (b.position || 100));
65
- });
66
-
67
- /**
68
- * Reply composer actions injected by plugins (e.g., "AI Suggest", "Insert KB Article").
69
- * Each action: { id, label, icon, handler, component, plugin, position }
70
- */
71
- const composerActions = computed(() => {
72
- const actions = pluginData.value.composerActions || [];
73
- return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
74
- });
75
-
76
- /**
77
- * Report widgets injected by plugins for the admin reports page.
78
- * Each widget: { id, title, component, plugin, data, position, width }
79
- */
80
- const reportWidgets = computed(() => {
81
- const widgets = pluginData.value.reportWidgets || [];
82
- return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
83
- });
84
-
85
- /**
86
- * Settings panels injected by plugins for the admin settings page.
87
- * Each panel: { id, title, component, plugin, position, icon }
88
- */
89
- const settingsPanels = computed(() => {
90
- const panels = pluginData.value.settingsPanels || [];
91
- return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
92
- });
93
-
94
- /**
95
- * Notification channels registered by plugins (e.g., Slack, SMS, WhatsApp).
96
- * Each channel: { id, label, icon, plugin, configComponent }
97
- */
98
- const notificationChannels = computed(() => {
99
- const channels = pluginData.value.notificationChannels || [];
100
- return [...channels].sort((a, b) => (a.position || 100) - (b.position || 100));
101
- });
102
-
103
- /**
104
- * Custom ticket list columns injected by plugins.
105
- * Each column: { id, label, key, component, plugin, position, width }
106
- */
107
- const ticketListColumns = computed(() => {
108
- const columns = pluginData.value.ticketListColumns || [];
109
- return [...columns].sort((a, b) => (a.position || 100) - (b.position || 100));
110
- });
111
-
112
- /**
113
- * Get plugin components for a specific page slot, sorted by position.
114
- *
115
- * @param {string} pageName - The page name (e.g. 'dashboard', 'ticket.show')
116
- * @param {string} slotName - The slot name (e.g. 'header', 'sidebar', 'footer')
117
- * @returns {Array} Sorted array of component definitions for the given slot
118
- */
119
- function getPageComponents(pageName, slotName) {
120
- const key = `${pageName}.${slotName}`;
121
- const components = pluginData.value.pageComponents || {};
122
- return [...(components[key] || [])].sort((a, b) => (a.position || 100) - (b.position || 100));
123
- }
124
-
125
- /**
126
- * Check whether any plugins have registered extensions.
127
- */
128
- const hasPlugins = computed(() => {
129
- return (
130
- menuItems.value.length > 0 ||
131
- dashboardWidgets.value.length > 0 ||
132
- Object.keys(pluginData.value.pageComponents || {}).length > 0 ||
133
- ticketActions.value.length > 0 ||
134
- sidebarPanels.value.length > 0 ||
135
- ticketFields.value.length > 0 ||
136
- composerActions.value.length > 0 ||
137
- reportWidgets.value.length > 0 ||
138
- settingsPanels.value.length > 0 ||
139
- notificationChannels.value.length > 0 ||
140
- ticketListColumns.value.length > 0
141
- );
142
- });
143
-
144
- return {
145
- pluginData,
146
- menuItems,
147
- dashboardWidgets,
148
- ticketActions,
149
- sidebarPanels,
150
- ticketFields,
151
- composerActions,
152
- reportWidgets,
153
- settingsPanels,
154
- notificationChannels,
155
- ticketListColumns,
156
- getPageComponents,
157
- hasPlugins,
158
- };
159
- }
1
+ import { computed } from 'vue';
2
+ import { usePage } from '@inertiajs/vue3';
3
+
4
+ /**
5
+ * Composable for reading plugin extensions from Inertia shared props.
6
+ *
7
+ * The Laravel backend (escalated-laravel) shares plugin UI extensions via
8
+ * `$page.props.escalated.plugins`, which contains:
9
+ * - menuItems: Array of navigation items injected by plugins
10
+ * - dashboardWidgets: Array of widget definitions for the agent dashboard
11
+ * - pageComponents: Object mapping slot names to arrays of component definitions
12
+ *
13
+ * @returns {Object} Plugin extension data and helper functions
14
+ */
15
+ export function usePluginExtensions() {
16
+ const page = usePage();
17
+
18
+ const pluginData = computed(() => page.props?.escalated?.plugins || {});
19
+
20
+ /**
21
+ * Menu items injected by plugins, sorted by position.
22
+ * Each item: { label, route, icon, position, permission, badge, submenu }
23
+ */
24
+ const menuItems = computed(() => {
25
+ const items = pluginData.value.menuItems || [];
26
+ return [...items].sort((a, b) => (a.position || 100) - (b.position || 100));
27
+ });
28
+
29
+ /**
30
+ * Dashboard widgets injected by plugins, sorted by position.
31
+ * Each widget: { id, title, component, plugin, data, position, width }
32
+ */
33
+ const dashboardWidgets = computed(() => {
34
+ const widgets = pluginData.value.dashboardWidgets || [];
35
+ return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
36
+ });
37
+
38
+ /**
39
+ * Ticket actions injected by plugins (e.g., "Escalate to Jira", "Send Approval").
40
+ * Each action: { id, label, icon, handler, position, permission, context }
41
+ * context: 'agent' | 'admin' | 'both'
42
+ */
43
+ const ticketActions = computed(() => {
44
+ const actions = pluginData.value.ticketActions || [];
45
+ return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
46
+ });
47
+
48
+ /**
49
+ * Sidebar panels injected by plugins for the ticket detail context panel.
50
+ * Each panel: { id, title, component, plugin, position, collapsed, icon }
51
+ */
52
+ const sidebarPanels = computed(() => {
53
+ const panels = pluginData.value.sidebarPanels || [];
54
+ return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
55
+ });
56
+
57
+ /**
58
+ * Custom ticket fields injected by plugins for ticket creation/edit forms.
59
+ * Each field: { id, label, type, name, options, required, position, plugin }
60
+ * type: 'text' | 'textarea' | 'select' | 'checkbox' | 'date' | 'number'
61
+ */
62
+ const ticketFields = computed(() => {
63
+ const fields = pluginData.value.ticketFields || [];
64
+ return [...fields].sort((a, b) => (a.position || 100) - (b.position || 100));
65
+ });
66
+
67
+ /**
68
+ * Reply composer actions injected by plugins (e.g., "AI Suggest", "Insert KB Article").
69
+ * Each action: { id, label, icon, handler, component, plugin, position }
70
+ */
71
+ const composerActions = computed(() => {
72
+ const actions = pluginData.value.composerActions || [];
73
+ return [...actions].sort((a, b) => (a.position || 100) - (b.position || 100));
74
+ });
75
+
76
+ /**
77
+ * Report widgets injected by plugins for the admin reports page.
78
+ * Each widget: { id, title, component, plugin, data, position, width }
79
+ */
80
+ const reportWidgets = computed(() => {
81
+ const widgets = pluginData.value.reportWidgets || [];
82
+ return [...widgets].sort((a, b) => (a.position || 100) - (b.position || 100));
83
+ });
84
+
85
+ /**
86
+ * Settings panels injected by plugins for the admin settings page.
87
+ * Each panel: { id, title, component, plugin, position, icon }
88
+ */
89
+ const settingsPanels = computed(() => {
90
+ const panels = pluginData.value.settingsPanels || [];
91
+ return [...panels].sort((a, b) => (a.position || 100) - (b.position || 100));
92
+ });
93
+
94
+ /**
95
+ * Notification channels registered by plugins (e.g., Slack, SMS, WhatsApp).
96
+ * Each channel: { id, label, icon, plugin, configComponent }
97
+ */
98
+ const notificationChannels = computed(() => {
99
+ const channels = pluginData.value.notificationChannels || [];
100
+ return [...channels].sort((a, b) => (a.position || 100) - (b.position || 100));
101
+ });
102
+
103
+ /**
104
+ * Custom ticket list columns injected by plugins.
105
+ * Each column: { id, label, key, component, plugin, position, width }
106
+ */
107
+ const ticketListColumns = computed(() => {
108
+ const columns = pluginData.value.ticketListColumns || [];
109
+ return [...columns].sort((a, b) => (a.position || 100) - (b.position || 100));
110
+ });
111
+
112
+ /**
113
+ * Get plugin components for a specific page slot, sorted by position.
114
+ *
115
+ * @param {string} pageName - The page name (e.g. 'dashboard', 'ticket.show')
116
+ * @param {string} slotName - The slot name (e.g. 'header', 'sidebar', 'footer')
117
+ * @returns {Array} Sorted array of component definitions for the given slot
118
+ */
119
+ function getPageComponents(pageName, slotName) {
120
+ const key = `${pageName}.${slotName}`;
121
+ const components = pluginData.value.pageComponents || {};
122
+ return [...(components[key] || [])].sort((a, b) => (a.position || 100) - (b.position || 100));
123
+ }
124
+
125
+ /**
126
+ * Check whether any plugins have registered extensions.
127
+ */
128
+ const hasPlugins = computed(() => {
129
+ return (
130
+ menuItems.value.length > 0 ||
131
+ dashboardWidgets.value.length > 0 ||
132
+ Object.keys(pluginData.value.pageComponents || {}).length > 0 ||
133
+ ticketActions.value.length > 0 ||
134
+ sidebarPanels.value.length > 0 ||
135
+ ticketFields.value.length > 0 ||
136
+ composerActions.value.length > 0 ||
137
+ reportWidgets.value.length > 0 ||
138
+ settingsPanels.value.length > 0 ||
139
+ notificationChannels.value.length > 0 ||
140
+ ticketListColumns.value.length > 0
141
+ );
142
+ });
143
+
144
+ return {
145
+ pluginData,
146
+ menuItems,
147
+ dashboardWidgets,
148
+ ticketActions,
149
+ sidebarPanels,
150
+ ticketFields,
151
+ composerActions,
152
+ reportWidgets,
153
+ settingsPanels,
154
+ notificationChannels,
155
+ ticketListColumns,
156
+ getPageComponents,
157
+ hasPlugins,
158
+ };
159
+ }
@@ -1,65 +1,65 @@
1
- import { getCurrentInstance } from 'vue';
2
-
3
- /**
4
- * Composable for dispatching and consuming plugin hooks.
5
- *
6
- * Hooks allow plugins to react to events (e.g., ticket.created, ticket.replied)
7
- * and to filter/modify data before it's processed (e.g., reply.beforeSubmit).
8
- *
9
- * Action hooks: fire-and-forget, all handlers run
10
- * Filter hooks: chain handlers, each can modify the value
11
- *
12
- * @returns {Object} Hook dispatch functions
13
- */
14
- export function usePluginHooks() {
15
- const instance = getCurrentInstance();
16
- const hookRegistry = instance?.appContext?.config?.globalProperties?.$escalatedHooks || {};
17
-
18
- /**
19
- * Dispatch an action hook. All registered handlers are called.
20
- * @param {string} event - Hook name (e.g., 'ticket.created')
21
- * @param {...any} args - Arguments passed to handlers
22
- */
23
- async function dispatch(event, ...args) {
24
- const handlers = hookRegistry[event] || [];
25
- for (const { handler } of handlers) {
26
- try {
27
- await handler(...args);
28
- } catch (err) {
29
- console.warn(`[Escalated] Plugin hook "${event}" error:`, err);
30
- }
31
- }
32
- }
33
-
34
- /**
35
- * Dispatch a filter hook. Each handler receives the value and can return a modified version.
36
- * @param {string} event - Hook name (e.g., 'reply.beforeSubmit')
37
- * @param {*} value - The value to filter
38
- * @param {...any} args - Additional arguments passed to handlers
39
- * @returns {*} The filtered value
40
- */
41
- async function filter(event, value, ...args) {
42
- const handlers = hookRegistry[event] || [];
43
- let result = value;
44
- for (const { handler } of handlers) {
45
- try {
46
- const modified = await handler(result, ...args);
47
- if (modified !== undefined) result = modified;
48
- } catch (err) {
49
- console.warn(`[Escalated] Plugin filter "${event}" error:`, err);
50
- }
51
- }
52
- return result;
53
- }
54
-
55
- /**
56
- * Check if any handlers are registered for a given hook.
57
- * @param {string} event - Hook name
58
- * @returns {boolean}
59
- */
60
- function hasHook(event) {
61
- return (hookRegistry[event] || []).length > 0;
62
- }
63
-
64
- return { dispatch, filter, hasHook };
65
- }
1
+ import { getCurrentInstance } from 'vue';
2
+
3
+ /**
4
+ * Composable for dispatching and consuming plugin hooks.
5
+ *
6
+ * Hooks allow plugins to react to events (e.g., ticket.created, ticket.replied)
7
+ * and to filter/modify data before it's processed (e.g., reply.beforeSubmit).
8
+ *
9
+ * Action hooks: fire-and-forget, all handlers run
10
+ * Filter hooks: chain handlers, each can modify the value
11
+ *
12
+ * @returns {Object} Hook dispatch functions
13
+ */
14
+ export function usePluginHooks() {
15
+ const instance = getCurrentInstance();
16
+ const hookRegistry = instance?.appContext?.config?.globalProperties?.$escalatedHooks || {};
17
+
18
+ /**
19
+ * Dispatch an action hook. All registered handlers are called.
20
+ * @param {string} event - Hook name (e.g., 'ticket.created')
21
+ * @param {...any} args - Arguments passed to handlers
22
+ */
23
+ async function dispatch(event, ...args) {
24
+ const handlers = hookRegistry[event] || [];
25
+ for (const { handler } of handlers) {
26
+ try {
27
+ await handler(...args);
28
+ } catch (err) {
29
+ console.warn(`[Escalated] Plugin hook "${event}" error:`, err);
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * Dispatch a filter hook. Each handler receives the value and can return a modified version.
36
+ * @param {string} event - Hook name (e.g., 'reply.beforeSubmit')
37
+ * @param {*} value - The value to filter
38
+ * @param {...any} args - Additional arguments passed to handlers
39
+ * @returns {*} The filtered value
40
+ */
41
+ async function filter(event, value, ...args) {
42
+ const handlers = hookRegistry[event] || [];
43
+ let result = value;
44
+ for (const { handler } of handlers) {
45
+ try {
46
+ const modified = await handler(result, ...args);
47
+ if (modified !== undefined) result = modified;
48
+ } catch (err) {
49
+ console.warn(`[Escalated] Plugin filter "${event}" error:`, err);
50
+ }
51
+ }
52
+ return result;
53
+ }
54
+
55
+ /**
56
+ * Check if any handlers are registered for a given hook.
57
+ * @param {string} event - Hook name
58
+ * @returns {boolean}
59
+ */
60
+ function hasHook(event) {
61
+ return (hookRegistry[event] || []).length > 0;
62
+ }
63
+
64
+ return { dispatch, filter, hasHook };
65
+ }