@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
@@ -1,136 +1,136 @@
1
- <script setup>
2
- import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
- import { Link, router } from '@inertiajs/vue3';
4
-
5
- defineProps({ webhooks: Array });
6
-
7
- function destroy(id) {
8
- if (confirm('Delete this webhook?')) {
9
- router.delete(route('escalated.admin.webhooks.destroy', id));
10
- }
11
- }
12
-
13
- function lastDeliveryStatus(webhook) {
14
- const last = webhook.deliveries?.[0];
15
- if (!last) return null;
16
- return last.response_code;
17
- }
18
- </script>
19
-
20
- <template>
21
- <EscalatedLayout title="Webhooks">
22
- <div class="mb-4 flex justify-end">
23
- <Link
24
- :href="route('escalated.admin.webhooks.create')"
25
- class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-4 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]"
26
- >
27
- Add Webhook
28
- </Link>
29
- </div>
30
- <div class="overflow-hidden rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]">
31
- <table class="min-w-full divide-y divide-[var(--esc-panel-border)]">
32
- <thead>
33
- <tr class="bg-[var(--esc-panel-hover)]">
34
- <th
35
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
36
- >
37
- URL
38
- </th>
39
- <th
40
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
41
- >
42
- Events
43
- </th>
44
- <th
45
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
46
- >
47
- Active
48
- </th>
49
- <th
50
- class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
51
- >
52
- Last Status
53
- </th>
54
- <th
55
- class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
56
- >
57
- Actions
58
- </th>
59
- </tr>
60
- </thead>
61
- <tbody class="divide-y divide-[var(--esc-panel-border)]">
62
- <tr v-if="!webhooks?.length">
63
- <td colspan="5" class="px-4 py-12 text-center">
64
- <svg
65
- class="mx-auto mb-3 h-8 w-8 text-[var(--esc-panel-text-muted)]"
66
- fill="none"
67
- stroke="currentColor"
68
- stroke-width="1.5"
69
- viewBox="0 0 24 24"
70
- >
71
- <path
72
- stroke-linecap="round"
73
- stroke-linejoin="round"
74
- d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m9.86-9.86a4.5 4.5 0 00-6.364 0l-4.5 4.5a4.5 4.5 0 001.242 7.244"
75
- />
76
- </svg>
77
- <p class="text-sm text-[var(--esc-panel-text-muted)]">No webhooks configured</p>
78
- <p class="mt-1 text-xs text-[var(--esc-panel-text-muted)]">
79
- Set up webhooks to send event notifications to external services
80
- </p>
81
- </td>
82
- </tr>
83
- <tr
84
- v-for="webhook in webhooks"
85
- :key="webhook.id"
86
- class="transition-colors hover:bg-[var(--esc-panel-hover)]"
87
- >
88
- <td
89
- class="px-4 py-3 text-sm font-mono text-[var(--esc-panel-text-secondary)] max-w-xs truncate"
90
- >
91
- {{ webhook.url }}
92
- </td>
93
- <td class="px-4 py-3 text-sm text-[var(--esc-panel-text-tertiary)]">
94
- {{ (webhook.events || []).length }} events
95
- </td>
96
- <td class="px-4 py-3 text-sm">
97
- <span :class="webhook.active ? 'text-emerald-400' : 'text-[var(--esc-panel-text-muted)]'">{{
98
- webhook.active ? 'Yes' : 'No'
99
- }}</span>
100
- </td>
101
- <td class="px-4 py-3 text-sm">
102
- <span
103
- v-if="lastDeliveryStatus(webhook)"
104
- :class="
105
- lastDeliveryStatus(webhook) >= 200 && lastDeliveryStatus(webhook) < 300
106
- ? 'text-emerald-400'
107
- : 'text-rose-400'
108
- "
109
- >
110
- {{ lastDeliveryStatus(webhook) }}
111
- </span>
112
- <span v-else class="text-[var(--esc-panel-text-muted)]">&mdash;</span>
113
- </td>
114
- <td class="px-4 py-3 text-right text-sm">
115
- <Link
116
- :href="route('escalated.admin.webhooks.deliveries', webhook.id)"
117
- class="text-[var(--esc-panel-text-tertiary)] hover:text-[var(--esc-panel-text-secondary)]"
118
- >
119
- Log
120
- </Link>
121
- <Link
122
- :href="route('escalated.admin.webhooks.edit', webhook.id)"
123
- class="ml-3 text-[var(--esc-panel-text-secondary)] hover:text-[var(--esc-panel-text)]"
124
- >
125
- Edit
126
- </Link>
127
- <button class="ml-3 text-rose-400 hover:text-rose-300" @click="destroy(webhook.id)">
128
- Delete
129
- </button>
130
- </td>
131
- </tr>
132
- </tbody>
133
- </table>
134
- </div>
135
- </EscalatedLayout>
136
- </template>
1
+ <script setup>
2
+ import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
+ import { Link, router } from '@inertiajs/vue3';
4
+
5
+ defineProps({ webhooks: Array });
6
+
7
+ function destroy(id) {
8
+ if (confirm('Delete this webhook?')) {
9
+ router.delete(route('escalated.admin.webhooks.destroy', id));
10
+ }
11
+ }
12
+
13
+ function lastDeliveryStatus(webhook) {
14
+ const last = webhook.deliveries?.[0];
15
+ if (!last) return null;
16
+ return last.response_code;
17
+ }
18
+ </script>
19
+
20
+ <template>
21
+ <EscalatedLayout title="Webhooks">
22
+ <div class="mb-4 flex justify-end">
23
+ <Link
24
+ :href="route('escalated.admin.webhooks.create')"
25
+ class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-4 py-2 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)]"
26
+ >
27
+ Add Webhook
28
+ </Link>
29
+ </div>
30
+ <div class="overflow-hidden rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)]">
31
+ <table class="min-w-full divide-y divide-[var(--esc-panel-border)]">
32
+ <thead>
33
+ <tr class="bg-[var(--esc-panel-hover)]">
34
+ <th
35
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
36
+ >
37
+ URL
38
+ </th>
39
+ <th
40
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
41
+ >
42
+ Events
43
+ </th>
44
+ <th
45
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
46
+ >
47
+ Active
48
+ </th>
49
+ <th
50
+ class="px-4 py-3 text-left text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
51
+ >
52
+ Last Status
53
+ </th>
54
+ <th
55
+ class="px-4 py-3 text-right text-[11px] font-semibold uppercase tracking-wider text-[var(--esc-panel-text-muted)]"
56
+ >
57
+ Actions
58
+ </th>
59
+ </tr>
60
+ </thead>
61
+ <tbody class="divide-y divide-[var(--esc-panel-border)]">
62
+ <tr v-if="!webhooks?.length">
63
+ <td colspan="5" class="px-4 py-12 text-center">
64
+ <svg
65
+ class="mx-auto mb-3 h-8 w-8 text-[var(--esc-panel-text-muted)]"
66
+ fill="none"
67
+ stroke="currentColor"
68
+ stroke-width="1.5"
69
+ viewBox="0 0 24 24"
70
+ >
71
+ <path
72
+ stroke-linecap="round"
73
+ stroke-linejoin="round"
74
+ d="M13.19 8.688a4.5 4.5 0 011.242 7.244l-4.5 4.5a4.5 4.5 0 01-6.364-6.364l1.757-1.757m9.86-9.86a4.5 4.5 0 00-6.364 0l-4.5 4.5a4.5 4.5 0 001.242 7.244"
75
+ />
76
+ </svg>
77
+ <p class="text-sm text-[var(--esc-panel-text-muted)]">No webhooks configured</p>
78
+ <p class="mt-1 text-xs text-[var(--esc-panel-text-muted)]">
79
+ Set up webhooks to send event notifications to external services
80
+ </p>
81
+ </td>
82
+ </tr>
83
+ <tr
84
+ v-for="webhook in webhooks"
85
+ :key="webhook.id"
86
+ class="transition-colors hover:bg-[var(--esc-panel-hover)]"
87
+ >
88
+ <td
89
+ class="px-4 py-3 text-sm font-mono text-[var(--esc-panel-text-secondary)] max-w-xs truncate"
90
+ >
91
+ {{ webhook.url }}
92
+ </td>
93
+ <td class="px-4 py-3 text-sm text-[var(--esc-panel-text-tertiary)]">
94
+ {{ (webhook.events || []).length }} events
95
+ </td>
96
+ <td class="px-4 py-3 text-sm">
97
+ <span :class="webhook.active ? 'text-emerald-400' : 'text-[var(--esc-panel-text-muted)]'">{{
98
+ webhook.active ? 'Yes' : 'No'
99
+ }}</span>
100
+ </td>
101
+ <td class="px-4 py-3 text-sm">
102
+ <span
103
+ v-if="lastDeliveryStatus(webhook)"
104
+ :class="
105
+ lastDeliveryStatus(webhook) >= 200 && lastDeliveryStatus(webhook) < 300
106
+ ? 'text-emerald-400'
107
+ : 'text-rose-400'
108
+ "
109
+ >
110
+ {{ lastDeliveryStatus(webhook) }}
111
+ </span>
112
+ <span v-else class="text-[var(--esc-panel-text-muted)]">&mdash;</span>
113
+ </td>
114
+ <td class="px-4 py-3 text-right text-sm">
115
+ <Link
116
+ :href="route('escalated.admin.webhooks.deliveries', webhook.id)"
117
+ class="text-[var(--esc-panel-text-tertiary)] hover:text-[var(--esc-panel-text-secondary)]"
118
+ >
119
+ Log
120
+ </Link>
121
+ <Link
122
+ :href="route('escalated.admin.webhooks.edit', webhook.id)"
123
+ class="ml-3 text-[var(--esc-panel-text-secondary)] hover:text-[var(--esc-panel-text)]"
124
+ >
125
+ Edit
126
+ </Link>
127
+ <button class="ml-3 text-rose-400 hover:text-rose-300" @click="destroy(webhook.id)">
128
+ Delete
129
+ </button>
130
+ </td>
131
+ </tr>
132
+ </tbody>
133
+ </table>
134
+ </div>
135
+ </EscalatedLayout>
136
+ </template>
@@ -0,0 +1,207 @@
1
+ <script setup>
2
+ import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
+ import WorkflowTriggerSelector from '../../../components/WorkflowTriggerSelector.vue';
4
+ import WorkflowConditionBuilder from '../../../components/WorkflowConditionBuilder.vue';
5
+ import WorkflowActionList from '../../../components/WorkflowActionList.vue';
6
+ import { useForm } from '@inertiajs/vue3';
7
+ import { ref, computed } from 'vue';
8
+
9
+ const props = defineProps({
10
+ workflow: { type: Object, default: null },
11
+ });
12
+
13
+ const form = useForm({
14
+ name: props.workflow?.name || '',
15
+ description: props.workflow?.description || '',
16
+ trigger: props.workflow?.trigger || '',
17
+ conditions: props.workflow?.conditions || { match: 'all', conditions: [] },
18
+ actions: props.workflow?.actions || [],
19
+ active: props.workflow?.active ?? true,
20
+ });
21
+
22
+ const expandedStep = ref(props.workflow ? null : 1);
23
+
24
+ function toggleStep(step) {
25
+ expandedStep.value = expandedStep.value === step ? null : step;
26
+ }
27
+
28
+ function submit() {
29
+ if (props.workflow) {
30
+ form.put(route('escalated.admin.workflows.update', props.workflow.id));
31
+ } else {
32
+ form.post(route('escalated.admin.workflows.store'));
33
+ }
34
+ }
35
+
36
+ const isValid = computed(() => {
37
+ return form.name && form.trigger && form.actions.length > 0;
38
+ });
39
+
40
+ const stepBorderColors = {
41
+ 1: 'border-l-blue-500',
42
+ 2: 'border-l-amber-500',
43
+ 3: 'border-l-emerald-500',
44
+ };
45
+
46
+ const stepDotColors = {
47
+ 1: 'bg-blue-500',
48
+ 2: 'bg-amber-500',
49
+ 3: 'bg-emerald-500',
50
+ };
51
+
52
+ const stepLabels = {
53
+ 1: 'Trigger Event',
54
+ 2: 'Conditions',
55
+ 3: 'Actions',
56
+ };
57
+
58
+ const stepDescriptions = {
59
+ 1: 'When this happens...',
60
+ 2: 'Only if these conditions are met...',
61
+ 3: 'Then do this...',
62
+ };
63
+
64
+ function stepHasData(step) {
65
+ switch (step) {
66
+ case 1:
67
+ return !!form.trigger;
68
+ case 2:
69
+ return form.conditions?.conditions?.length > 0;
70
+ case 3:
71
+ return form.actions?.length > 0;
72
+ default:
73
+ return false;
74
+ }
75
+ }
76
+ </script>
77
+
78
+ <template>
79
+ <EscalatedLayout :title="workflow ? 'Edit Workflow' : 'Create Workflow'">
80
+ <form class="mx-auto max-w-3xl space-y-6" @submit.prevent="submit">
81
+ <!-- Header -->
82
+ <div class="rounded-xl border border-[var(--esc-panel-border)] bg-[var(--esc-panel-surface)] p-6">
83
+ <div class="space-y-4">
84
+ <div>
85
+ <label class="block text-sm font-medium text-[var(--esc-panel-text-secondary)]"
86
+ >Workflow Name</label
87
+ >
88
+ <input
89
+ v-model="form.name"
90
+ type="text"
91
+ required
92
+ placeholder="e.g. Auto-assign urgent tickets"
93
+ class="mt-1 w-full rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-3 py-2 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
94
+ />
95
+ <p v-if="form.errors.name" class="mt-1 text-xs text-rose-400">{{ form.errors.name }}</p>
96
+ </div>
97
+ <div>
98
+ <label class="block text-sm font-medium text-[var(--esc-panel-text-secondary)]"
99
+ >Description</label
100
+ >
101
+ <textarea
102
+ v-model="form.description"
103
+ rows="2"
104
+ placeholder="What does this workflow do?"
105
+ class="mt-1 w-full resize-y rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] px-3 py-2 text-sm text-[var(--esc-panel-text-secondary)] focus:border-[var(--esc-panel-border-input)] focus:outline-none focus:ring-1 focus:ring-[var(--esc-panel-border-input)]"
106
+ />
107
+ </div>
108
+ <div>
109
+ <label class="flex items-center gap-2 text-sm text-[var(--esc-panel-text-secondary)]">
110
+ <input
111
+ v-model="form.active"
112
+ type="checkbox"
113
+ class="rounded border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-surface-alt)] text-cyan-500 focus:ring-cyan-500/20"
114
+ />
115
+ Active
116
+ </label>
117
+ </div>
118
+ </div>
119
+ </div>
120
+
121
+ <!-- Steps -->
122
+ <div class="relative space-y-4">
123
+ <!-- Vertical connector line -->
124
+ <div class="absolute top-0 bottom-0 left-6 w-px bg-[var(--esc-panel-border)]" />
125
+
126
+ <!-- Step 1: Trigger -->
127
+ <div
128
+ v-for="step in [1, 2, 3]"
129
+ :key="step"
130
+ class="relative rounded-xl border border-[var(--esc-panel-border)] border-l-4 bg-[var(--esc-panel-surface)] transition-all"
131
+ :class="stepBorderColors[step]"
132
+ >
133
+ <!-- Step dot -->
134
+ <div
135
+ class="absolute -left-[11px] top-4 flex h-5 w-5 items-center justify-center rounded-full"
136
+ :class="stepDotColors[step]"
137
+ >
138
+ <span v-if="stepHasData(step)" class="text-[10px] font-bold text-white">
139
+ <svg class="h-3 w-3" fill="none" stroke="currentColor" stroke-width="3" viewBox="0 0 24 24">
140
+ <path stroke-linecap="round" stroke-linejoin="round" d="M4.5 12.75l6 6 9-13.5" />
141
+ </svg>
142
+ </span>
143
+ <span v-else class="text-[10px] font-bold text-white">{{ step }}</span>
144
+ </div>
145
+
146
+ <!-- Step header -->
147
+ <button
148
+ type="button"
149
+ class="flex w-full items-center gap-3 px-6 py-4 text-left"
150
+ @click="toggleStep(step)"
151
+ >
152
+ <div class="flex-1">
153
+ <h3 class="text-sm font-semibold text-[var(--esc-panel-text-secondary)]">
154
+ {{ stepLabels[step] }}
155
+ <span
156
+ v-if="step === 2"
157
+ class="ml-1 text-xs font-normal text-[var(--esc-panel-text-muted)]"
158
+ >(optional)</span
159
+ >
160
+ </h3>
161
+ <p class="text-xs text-[var(--esc-panel-text-muted)]">{{ stepDescriptions[step] }}</p>
162
+ </div>
163
+ <svg
164
+ class="h-4 w-4 text-[var(--esc-panel-text-muted)] transition-transform"
165
+ :class="expandedStep === step ? 'rotate-180' : ''"
166
+ fill="none"
167
+ stroke="currentColor"
168
+ stroke-width="2"
169
+ viewBox="0 0 24 24"
170
+ >
171
+ <path stroke-linecap="round" stroke-linejoin="round" d="M19.5 8.25l-7.5 7.5-7.5-7.5" />
172
+ </svg>
173
+ </button>
174
+
175
+ <!-- Step content -->
176
+ <div v-if="expandedStep === step" class="border-t border-[var(--esc-panel-border)] px-6 py-4">
177
+ <!-- Trigger selector -->
178
+ <WorkflowTriggerSelector v-if="step === 1" v-model="form.trigger" />
179
+
180
+ <!-- Condition builder -->
181
+ <WorkflowConditionBuilder v-if="step === 2" v-model="form.conditions" />
182
+
183
+ <!-- Action list -->
184
+ <WorkflowActionList v-if="step === 3" v-model="form.actions" />
185
+ </div>
186
+ </div>
187
+ </div>
188
+
189
+ <!-- Footer buttons -->
190
+ <div class="flex items-center gap-3 pt-2">
191
+ <button
192
+ type="submit"
193
+ :disabled="form.processing || !isValid"
194
+ class="rounded-lg bg-gradient-to-r from-[var(--esc-panel-accent)] to-[var(--esc-panel-accent-secondary)] px-6 py-2.5 text-sm font-medium text-white shadow-lg shadow-[var(--esc-panel-bg)]/20 transition-all hover:from-[var(--esc-panel-accent-hover)] hover:to-[var(--esc-panel-accent-secondary-hover)] disabled:opacity-50"
195
+ >
196
+ {{ form.processing ? 'Saving...' : workflow ? 'Update Workflow' : 'Create Workflow' }}
197
+ </button>
198
+ <a
199
+ :href="route('escalated.admin.workflows.index')"
200
+ class="rounded-lg border border-[var(--esc-panel-border-input)] bg-[var(--esc-panel-hover)] px-4 py-2.5 text-sm font-medium text-[var(--esc-panel-text-secondary)] transition-colors hover:bg-[var(--esc-panel-hover)]"
201
+ >
202
+ Cancel
203
+ </a>
204
+ </div>
205
+ </form>
206
+ </EscalatedLayout>
207
+ </template>