@escalated-dev/escalated 0.4.0 → 0.6.0

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.
@@ -0,0 +1,197 @@
1
+ <script setup>
2
+ import EscalatedLayout from '../../../components/EscalatedLayout.vue';
3
+ import { router } from '@inertiajs/vue3';
4
+ import { ref, computed } from 'vue';
5
+
6
+ const props = defineProps({
7
+ plugins: { type: Array, default: () => [] },
8
+ });
9
+
10
+ const confirmingDelete = ref(null);
11
+ const uploading = ref(false);
12
+ const fileInput = ref(null);
13
+
14
+ const activePlugins = computed(() => props.plugins.filter(p => p.active));
15
+ const inactivePlugins = computed(() => props.plugins.filter(p => !p.active));
16
+
17
+ function togglePlugin(plugin) {
18
+ router.post(route('escalated.admin.plugins.toggle', plugin.id), {}, {
19
+ preserveScroll: true,
20
+ });
21
+ }
22
+
23
+ function confirmDelete(plugin) {
24
+ confirmingDelete.value = plugin.id;
25
+ }
26
+
27
+ function cancelDelete() {
28
+ confirmingDelete.value = null;
29
+ }
30
+
31
+ function deletePlugin(plugin) {
32
+ router.delete(route('escalated.admin.plugins.destroy', plugin.id), {
33
+ preserveScroll: true,
34
+ onSuccess: () => { confirmingDelete.value = null; },
35
+ });
36
+ }
37
+
38
+ function triggerUpload() {
39
+ fileInput.value?.click();
40
+ }
41
+
42
+ function handleUpload(event) {
43
+ const file = event.target.files?.[0];
44
+ if (!file) return;
45
+
46
+ uploading.value = true;
47
+ router.post(route('escalated.admin.plugins.upload'), { file }, {
48
+ forceFormData: true,
49
+ preserveScroll: true,
50
+ onFinish: () => {
51
+ uploading.value = false;
52
+ if (fileInput.value) fileInput.value.value = '';
53
+ },
54
+ });
55
+ }
56
+
57
+ function statusColor(plugin) {
58
+ if (plugin.active) return 'bg-emerald-500';
59
+ return 'bg-neutral-600';
60
+ }
61
+
62
+ function statusLabel(plugin) {
63
+ return plugin.active ? 'Active' : 'Inactive';
64
+ }
65
+ </script>
66
+
67
+ <template>
68
+ <EscalatedLayout title="Plugins">
69
+ <!-- Header -->
70
+ <div class="mb-6 flex items-center justify-between">
71
+ <div>
72
+ <p class="text-sm text-neutral-400">
73
+ {{ activePlugins.length }} active, {{ inactivePlugins.length }} inactive
74
+ </p>
75
+ </div>
76
+ <div>
77
+ <input ref="fileInput" type="file" accept=".zip" class="hidden" @change="handleUpload" />
78
+ <button @click="triggerUpload" :disabled="uploading"
79
+ class="rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-4 py-2 text-sm font-medium text-white shadow-lg shadow-black/20 transition-all hover:from-cyan-400 hover:to-violet-400 disabled:opacity-50">
80
+ <span v-if="uploading" class="flex items-center gap-2">
81
+ <svg class="h-4 w-4 animate-spin" fill="none" viewBox="0 0 24 24">
82
+ <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4" />
83
+ <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z" />
84
+ </svg>
85
+ Uploading...
86
+ </span>
87
+ <span v-else class="flex items-center gap-2">
88
+ <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
89
+ <path stroke-linecap="round" stroke-linejoin="round" d="M3 16.5v2.25A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75V16.5m-13.5-9L12 3m0 0l4.5 4.5M12 3v13.5" />
90
+ </svg>
91
+ Upload Plugin
92
+ </span>
93
+ </button>
94
+ </div>
95
+ </div>
96
+
97
+ <!-- Empty state -->
98
+ <div v-if="!plugins?.length" class="rounded-xl border border-white/[0.06] bg-neutral-900/60 px-6 py-16 text-center">
99
+ <svg class="mx-auto mb-4 h-12 w-12 text-neutral-700" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
100
+ <path stroke-linecap="round" stroke-linejoin="round" d="M14.25 6.087c0-.355.186-.676.401-.959.221-.29.349-.634.349-1.003 0-1.036-1.007-1.875-2.25-1.875s-2.25.84-2.25 1.875c0 .369.128.713.349 1.003.215.283.401.604.401.959v0a.64.64 0 01-.657.643 48.39 48.39 0 01-4.163-.3c.186 1.613.293 3.25.315 4.907a.656.656 0 01-.658.663v0c-.355 0-.676-.186-.959-.401a1.647 1.647 0 00-1.003-.349c-1.036 0-1.875 1.007-1.875 2.25s.84 2.25 1.875 2.25c.369 0 .713-.128 1.003-.349.283-.215.604-.401.959-.401v0c.31 0 .555.26.532.57a48.039 48.039 0 01-.642 5.056c1.518.19 3.058.309 4.616.354a.64.64 0 00.657-.643v0c0-.355-.186-.676-.401-.959a1.647 1.647 0 01-.349-1.003c0-1.035 1.008-1.875 2.25-1.875 1.243 0 2.25.84 2.25 1.875 0 .369-.128.713-.349 1.003-.215.283-.4.604-.4.959v0c0 .333.277.599.61.58a48.1 48.1 0 005.427-.63 48.05 48.05 0 00.582-4.717.532.532 0 00-.533-.57v0c-.355 0-.676.186-.959.401-.29.221-.634.349-1.003.349-1.035 0-1.875-1.007-1.875-2.25s.84-2.25 1.875-2.25c.37 0 .713.128 1.003.349.283.215.604.401.96.401v0a.656.656 0 00.658-.663 48.422 48.422 0 00-.37-5.36c-1.886.342-3.81.574-5.766.689a.578.578 0 01-.61-.58v0z" />
101
+ </svg>
102
+ <h3 class="text-sm font-medium text-neutral-300">No plugins installed</h3>
103
+ <p class="mt-1 text-xs text-neutral-500">Upload a plugin ZIP to extend Escalated with custom functionality.</p>
104
+ </div>
105
+
106
+ <!-- Plugin cards -->
107
+ <div v-else class="space-y-3">
108
+ <div v-for="plugin in plugins" :key="plugin.id"
109
+ class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-5 transition-colors hover:bg-neutral-900/80">
110
+ <div class="flex items-start justify-between gap-4">
111
+ <!-- Plugin info -->
112
+ <div class="min-w-0 flex-1">
113
+ <div class="flex items-center gap-3">
114
+ <h3 class="text-sm font-semibold text-white">{{ plugin.name }}</h3>
115
+ <span :class="['inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-[10px] font-semibold',
116
+ plugin.active
117
+ ? 'bg-emerald-500/10 text-emerald-400'
118
+ : 'bg-neutral-500/10 text-neutral-500']">
119
+ <span :class="['h-1.5 w-1.5 rounded-full', statusColor(plugin)]"></span>
120
+ {{ statusLabel(plugin) }}
121
+ </span>
122
+ <span v-if="plugin.version" class="text-[11px] text-neutral-600">v{{ plugin.version }}</span>
123
+ </div>
124
+ <p v-if="plugin.description" class="mt-1 text-sm text-neutral-400">{{ plugin.description }}</p>
125
+ <div class="mt-2 flex flex-wrap items-center gap-4 text-xs text-neutral-600">
126
+ <span v-if="plugin.author" class="flex items-center gap-1">
127
+ <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
128
+ <path stroke-linecap="round" stroke-linejoin="round" d="M15.75 6a3.75 3.75 0 11-7.5 0 3.75 3.75 0 017.5 0zM4.501 20.118a7.5 7.5 0 0114.998 0A17.933 17.933 0 0112 21.75c-2.676 0-5.216-.584-7.499-1.632z" />
129
+ </svg>
130
+ {{ plugin.author }}
131
+ </span>
132
+ <span v-if="plugin.homepage" class="flex items-center gap-1">
133
+ <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
134
+ <path stroke-linecap="round" stroke-linejoin="round" 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.757m13.35-.622l1.757-1.757a4.5 4.5 0 00-6.364-6.364l-4.5 4.5a4.5 4.5 0 001.242 7.244" />
135
+ </svg>
136
+ <a :href="plugin.homepage" target="_blank" rel="noopener" class="hover:text-neutral-400">{{ plugin.homepage }}</a>
137
+ </span>
138
+ <span v-if="plugin.installed_at" class="flex items-center gap-1">
139
+ <svg class="h-3.5 w-3.5" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
140
+ <path stroke-linecap="round" stroke-linejoin="round" d="M6.75 3v2.25M17.25 3v2.25M3 18.75V7.5a2.25 2.25 0 012.25-2.25h13.5A2.25 2.25 0 0121 7.5v11.25m-18 0A2.25 2.25 0 005.25 21h13.5A2.25 2.25 0 0021 18.75m-18 0v-7.5A2.25 2.25 0 015.25 9h13.5A2.25 2.25 0 0121 11.25v7.5" />
141
+ </svg>
142
+ Installed {{ plugin.installed_at }}
143
+ </span>
144
+ </div>
145
+
146
+ <!-- Provided extensions summary -->
147
+ <div v-if="plugin.provides" class="mt-3 flex flex-wrap gap-2">
148
+ <span v-if="plugin.provides.menu_items"
149
+ class="rounded bg-white/[0.04] px-2 py-0.5 text-[10px] text-neutral-500">
150
+ {{ plugin.provides.menu_items }} menu item{{ plugin.provides.menu_items !== 1 ? 's' : '' }}
151
+ </span>
152
+ <span v-if="plugin.provides.widgets"
153
+ class="rounded bg-white/[0.04] px-2 py-0.5 text-[10px] text-neutral-500">
154
+ {{ plugin.provides.widgets }} widget{{ plugin.provides.widgets !== 1 ? 's' : '' }}
155
+ </span>
156
+ <span v-if="plugin.provides.page_components"
157
+ class="rounded bg-white/[0.04] px-2 py-0.5 text-[10px] text-neutral-500">
158
+ {{ plugin.provides.page_components }} page component{{ plugin.provides.page_components !== 1 ? 's' : '' }}
159
+ </span>
160
+ </div>
161
+ </div>
162
+
163
+ <!-- Actions -->
164
+ <div class="flex shrink-0 items-center gap-2">
165
+ <!-- Toggle active/inactive -->
166
+ <button @click="togglePlugin(plugin)"
167
+ :class="['relative inline-flex h-6 w-11 shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors',
168
+ plugin.active ? 'bg-emerald-500' : 'bg-neutral-700']"
169
+ :title="plugin.active ? 'Deactivate' : 'Activate'">
170
+ <span :class="['pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition-transform',
171
+ plugin.active ? 'translate-x-5' : 'translate-x-0']" />
172
+ </button>
173
+
174
+ <!-- Delete -->
175
+ <template v-if="confirmingDelete === plugin.id">
176
+ <button @click="deletePlugin(plugin)"
177
+ class="rounded-lg bg-rose-500/20 px-3 py-1.5 text-xs font-medium text-rose-400 transition-colors hover:bg-rose-500/30">
178
+ Confirm
179
+ </button>
180
+ <button @click="cancelDelete"
181
+ class="rounded-lg border border-white/10 px-3 py-1.5 text-xs font-medium text-neutral-400 transition-colors hover:bg-white/[0.04]">
182
+ Cancel
183
+ </button>
184
+ </template>
185
+ <button v-else @click="confirmDelete(plugin)"
186
+ class="rounded-lg border border-white/[0.06] p-1.5 text-neutral-600 transition-colors hover:border-rose-500/20 hover:bg-rose-500/5 hover:text-rose-400"
187
+ title="Delete plugin">
188
+ <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
189
+ <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
190
+ </svg>
191
+ </button>
192
+ </div>
193
+ </div>
194
+ </div>
195
+ </div>
196
+ </EscalatedLayout>
197
+ </template>
@@ -0,0 +1,129 @@
1
+ <script setup>
2
+ import EscalatedLayout from '../../components/EscalatedLayout.vue';
3
+ import { useForm, usePage, router } from '@inertiajs/vue3';
4
+ import { computed } from 'vue';
5
+
6
+ const props = defineProps({ plugins: Array });
7
+ const page = usePage();
8
+
9
+ const flash = computed(() => ({
10
+ success: page.props.flash?.success,
11
+ error: page.props.flash?.error,
12
+ }));
13
+
14
+ const uploadForm = useForm({
15
+ plugin: null,
16
+ });
17
+
18
+ function onFileChange(e) {
19
+ uploadForm.plugin = e.target.files[0];
20
+ }
21
+
22
+ function submitUpload() {
23
+ uploadForm.post(route('escalated.admin.plugins.upload'), {
24
+ forceFormData: true,
25
+ onSuccess: () => {
26
+ uploadForm.reset();
27
+ },
28
+ });
29
+ }
30
+
31
+ function activate(slug) {
32
+ router.post(route('escalated.admin.plugins.activate', slug));
33
+ }
34
+
35
+ function deactivate(slug) {
36
+ router.post(route('escalated.admin.plugins.deactivate', slug));
37
+ }
38
+
39
+ function deletePlugin(slug) {
40
+ if (confirm('Are you sure you want to delete this plugin? This cannot be undone.')) {
41
+ router.delete(route('escalated.admin.plugins.destroy', slug));
42
+ }
43
+ }
44
+ </script>
45
+
46
+ <template>
47
+ <EscalatedLayout title="Plugins">
48
+ <div class="mx-auto max-w-4xl space-y-6">
49
+ <!-- Flash messages -->
50
+ <div v-if="flash.success" class="rounded-lg border border-emerald-500/20 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-400">
51
+ {{ flash.success }}
52
+ </div>
53
+ <div v-if="flash.error" class="rounded-lg border border-red-500/20 bg-red-500/10 px-4 py-3 text-sm text-red-400">
54
+ {{ flash.error }}
55
+ </div>
56
+
57
+ <!-- Upload Plugin -->
58
+ <div class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-6">
59
+ <h3 class="mb-4 text-sm font-semibold text-white">Upload Plugin</h3>
60
+ <form @submit.prevent="submitUpload" class="flex items-end gap-4">
61
+ <div class="flex-1">
62
+ <label class="block text-sm font-medium text-neutral-200">Plugin ZIP File</label>
63
+ <input type="file" accept=".zip" @change="onFileChange"
64
+ class="mt-2 w-full rounded-lg border border-white/10 bg-neutral-950 px-3 py-2 text-sm text-neutral-200 file:mr-3 file:rounded file:border-0 file:bg-white/10 file:px-3 file:py-1 file:text-sm file:text-neutral-300 focus:border-white/20 focus:outline-none focus:ring-1 focus:ring-white/10" />
65
+ <p v-if="uploadForm.errors.plugin" class="mt-1 text-xs text-red-400">{{ uploadForm.errors.plugin }}</p>
66
+ </div>
67
+ <button type="submit" :disabled="uploadForm.processing || !uploadForm.plugin"
68
+ class="shrink-0 rounded-lg bg-gradient-to-r from-cyan-500 to-violet-500 px-5 py-2 text-sm font-medium text-white shadow-lg shadow-black/20 transition-all hover:from-cyan-400 hover:to-violet-400 disabled:opacity-50">
69
+ {{ uploadForm.processing ? 'Uploading...' : 'Upload' }}
70
+ </button>
71
+ </form>
72
+ </div>
73
+
74
+ <!-- Plugin List -->
75
+ <div class="rounded-xl border border-white/[0.06] bg-neutral-900/60 p-6">
76
+ <h3 class="mb-5 text-sm font-semibold text-white">Installed Plugins</h3>
77
+
78
+ <div v-if="!plugins || plugins.length === 0" class="py-8 text-center text-sm text-neutral-500">
79
+ No plugins installed yet.
80
+ </div>
81
+
82
+ <div v-else class="divide-y divide-white/[0.06]">
83
+ <div v-for="plugin in plugins" :key="plugin.slug" class="flex items-start justify-between gap-4 py-4 first:pt-0 last:pb-0">
84
+ <!-- Plugin info -->
85
+ <div class="min-w-0 flex-1">
86
+ <div class="flex items-center gap-2.5">
87
+ <span class="text-sm font-medium text-white">{{ plugin.name }}</span>
88
+ <span class="rounded bg-white/[0.06] px-1.5 py-0.5 text-[10px] font-medium text-neutral-500">
89
+ v{{ plugin.version }}
90
+ </span>
91
+ <span :class="[
92
+ 'rounded px-1.5 py-0.5 text-[10px] font-medium',
93
+ plugin.source === 'composer'
94
+ ? 'bg-violet-500/10 text-violet-400'
95
+ : 'bg-cyan-500/10 text-cyan-400'
96
+ ]">
97
+ {{ plugin.source }}
98
+ </span>
99
+ </div>
100
+ <p v-if="plugin.description" class="mt-1 text-xs text-neutral-500">{{ plugin.description }}</p>
101
+ <p class="mt-1 text-xs text-neutral-600">by {{ plugin.author }}</p>
102
+ </div>
103
+
104
+ <!-- Actions -->
105
+ <div class="flex shrink-0 items-center gap-2">
106
+ <!-- Active status toggle -->
107
+ <button v-if="plugin.is_active" @click="deactivate(plugin.slug)"
108
+ class="rounded-lg border border-emerald-500/20 bg-emerald-500/10 px-3 py-1.5 text-xs font-medium text-emerald-400 transition-colors hover:bg-emerald-500/20">
109
+ Active
110
+ </button>
111
+ <button v-else @click="activate(plugin.slug)"
112
+ class="rounded-lg border border-white/10 bg-white/[0.04] px-3 py-1.5 text-xs font-medium text-neutral-500 transition-colors hover:bg-white/[0.08] hover:text-neutral-300">
113
+ Inactive
114
+ </button>
115
+
116
+ <!-- Delete (local only) -->
117
+ <button v-if="plugin.source === 'local'" @click="deletePlugin(plugin.slug)"
118
+ class="rounded-lg border border-white/10 bg-white/[0.04] p-1.5 text-neutral-600 transition-colors hover:border-red-500/20 hover:bg-red-500/10 hover:text-red-400">
119
+ <svg class="h-4 w-4" fill="none" stroke="currentColor" stroke-width="1.5" viewBox="0 0 24 24">
120
+ <path stroke-linecap="round" stroke-linejoin="round" d="M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0" />
121
+ </svg>
122
+ </button>
123
+ </div>
124
+ </div>
125
+ </div>
126
+ </div>
127
+ </div>
128
+ </EscalatedLayout>
129
+ </template>
@@ -11,7 +11,9 @@ import FollowButton from '../../../components/FollowButton.vue';
11
11
  import PresenceIndicator from '../../../components/PresenceIndicator.vue';
12
12
  import PinnedNotes from '../../../components/PinnedNotes.vue';
13
13
  import KeyboardShortcutHelp from '../../../components/KeyboardShortcutHelp.vue';
14
+ import PluginSlot from '../../../components/PluginSlot.vue';
14
15
  import { useKeyboardShortcuts } from '../../../composables/useKeyboardShortcuts';
16
+ import { usePluginExtensions } from '../../../composables/usePluginExtensions';
15
17
  import { router, useForm, usePage } from '@inertiajs/vue3';
16
18
  import { ref } from 'vue';
17
19
 
@@ -56,6 +58,8 @@ function toggleFollow() {
56
58
  router.post(route('escalated.admin.tickets.follow', props.ticket.reference), {}, { preserveScroll: true });
57
59
  }
58
60
 
61
+ const { getPageComponents } = usePluginExtensions();
62
+
59
63
  // Keyboard shortcuts
60
64
  useKeyboardShortcuts({
61
65
  'r': () => { activeTab.value = 'reply'; replyComposerRef.value?.$el?.querySelector('textarea')?.focus(); },
@@ -69,6 +73,9 @@ useKeyboardShortcuts({
69
73
 
70
74
  <template>
71
75
  <EscalatedLayout :title="ticket.subject">
76
+ <!-- Plugin: ticket show header slot -->
77
+ <PluginSlot slot="ticket.show.header" :components="getPageComponents('ticket.show', 'header')" />
78
+
72
79
  <div class="mb-5 flex flex-wrap items-center gap-3">
73
80
  <span class="text-sm font-mono font-medium text-white">{{ ticket.reference }}</span>
74
81
  <StatusBadge :status="ticket.status" />
@@ -101,6 +108,8 @@ useKeyboardShortcuts({
101
108
  <option value="urgent">Urgent</option>
102
109
  <option value="critical">Critical</option>
103
110
  </select>
111
+ <!-- Plugin: ticket show actions slot -->
112
+ <PluginSlot slot="ticket.show.actions" :components="getPageComponents('ticket.show', 'actions')" />
104
113
  </div>
105
114
  </div>
106
115
  <div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
@@ -136,8 +145,10 @@ useKeyboardShortcuts({
136
145
  :ticket-reference="ticket.reference" route-prefix="escalated.admin" pinnable />
137
146
  </div>
138
147
  </div>
139
- <div>
148
+ <div class="space-y-6">
140
149
  <TicketSidebar :ticket="ticket" :tags="tags" :departments="departments" />
150
+ <!-- Plugin: ticket show sidebar slot -->
151
+ <PluginSlot slot="ticket.show.sidebar" :components="getPageComponents('ticket.show', 'sidebar')" />
141
152
  </div>
142
153
  </div>
143
154
  <KeyboardShortcutHelp v-model:show="showShortcutHelp" context="detail" />
@@ -1,10 +1,12 @@
1
1
  <script setup>
2
- import { computed } from 'vue';
2
+ import { computed, defineAsyncComponent } from 'vue';
3
3
  import { Link } from '@inertiajs/vue3';
4
4
  import EscalatedLayout from '../../components/EscalatedLayout.vue';
5
5
  import StatsCard from '../../components/StatsCard.vue';
6
6
  import StatusBadge from '../../components/StatusBadge.vue';
7
7
  import PriorityBadge from '../../components/PriorityBadge.vue';
8
+ import PluginSlot from '../../components/PluginSlot.vue';
9
+ import { usePluginExtensions } from '../../composables/usePluginExtensions';
8
10
 
9
11
  const props = defineProps({
10
12
  stats: Object,
@@ -43,10 +45,22 @@ function truncate(str, len = 50) {
43
45
  const hasSlaBreaching = computed(() => needsAttention.value?.sla_breaching?.length > 0);
44
46
  const hasUnassignedUrgent = computed(() => needsAttention.value?.unassigned_urgent?.length > 0);
45
47
  const needsAttention = computed(() => props.needsAttention);
48
+
49
+ const { dashboardWidgets, getPageComponents } = usePluginExtensions();
50
+
51
+ // Load a plugin widget component dynamically
52
+ const loadWidgetComponent = (plugin, component) => {
53
+ return defineAsyncComponent(() =>
54
+ import(`../../../../../plugins/escalated/${plugin}/resources/js/Components/${component}.vue`)
55
+ );
56
+ };
46
57
  </script>
47
58
 
48
59
  <template>
49
60
  <EscalatedLayout title="Agent Dashboard">
61
+ <!-- Plugin: dashboard header slot -->
62
+ <PluginSlot slot="dashboard.header" :components="getPageComponents('dashboard', 'header')" />
63
+
50
64
  <!-- Stats row -->
51
65
  <div class="mb-8 grid grid-cols-2 gap-4 md:grid-cols-5">
52
66
  <StatsCard label="Open Tickets" :value="stats.open" color="cyan" />
@@ -152,5 +166,21 @@ const needsAttention = computed(() => props.needsAttention);
152
166
  </div>
153
167
  </div>
154
168
  </div>
169
+
170
+ <!-- Plugin dashboard widgets -->
171
+ <div v-if="dashboardWidgets.length" class="mt-6 grid grid-cols-1 gap-4 md:grid-cols-2">
172
+ <div v-for="widget in dashboardWidgets" :key="widget.id"
173
+ :class="['rounded-xl border border-white/[0.06] bg-neutral-900/60 p-5',
174
+ widget.width === 'full' ? 'md:col-span-2' : '']">
175
+ <h3 v-if="widget.title" class="mb-3 text-sm font-semibold text-neutral-200">{{ widget.title }}</h3>
176
+ <component
177
+ :is="loadWidgetComponent(widget.plugin, widget.component)"
178
+ v-bind="widget.data || {}"
179
+ />
180
+ </div>
181
+ </div>
182
+
183
+ <!-- Plugin: dashboard footer slot -->
184
+ <PluginSlot slot="dashboard.footer" :components="getPageComponents('dashboard', 'footer')" />
155
185
  </EscalatedLayout>
156
186
  </template>
@@ -11,7 +11,9 @@ import FollowButton from '../../components/FollowButton.vue';
11
11
  import PresenceIndicator from '../../components/PresenceIndicator.vue';
12
12
  import PinnedNotes from '../../components/PinnedNotes.vue';
13
13
  import KeyboardShortcutHelp from '../../components/KeyboardShortcutHelp.vue';
14
+ import PluginSlot from '../../components/PluginSlot.vue';
14
15
  import { useKeyboardShortcuts } from '../../composables/useKeyboardShortcuts';
16
+ import { usePluginExtensions } from '../../composables/usePluginExtensions';
15
17
  import { router, useForm, usePage } from '@inertiajs/vue3';
16
18
  import { ref } from 'vue';
17
19
 
@@ -55,6 +57,8 @@ function toggleFollow() {
55
57
  router.post(route('escalated.agent.tickets.follow', props.ticket.reference), {}, { preserveScroll: true });
56
58
  }
57
59
 
60
+ const { getPageComponents } = usePluginExtensions();
61
+
58
62
  // Keyboard shortcuts
59
63
  useKeyboardShortcuts({
60
64
  'r': () => { activeTab.value = 'reply'; replyComposerRef.value?.$el?.querySelector('textarea')?.focus(); },
@@ -68,6 +72,9 @@ useKeyboardShortcuts({
68
72
 
69
73
  <template>
70
74
  <EscalatedLayout :title="ticket.subject">
75
+ <!-- Plugin: ticket show header slot -->
76
+ <PluginSlot slot="ticket.show.header" :components="getPageComponents('ticket.show', 'header')" />
77
+
71
78
  <div class="mb-5 flex flex-wrap items-center gap-3">
72
79
  <span class="text-sm font-mono font-medium text-white">{{ ticket.reference }}</span>
73
80
  <StatusBadge :status="ticket.status" />
@@ -100,6 +107,8 @@ useKeyboardShortcuts({
100
107
  <option value="urgent">Urgent</option>
101
108
  <option value="critical">Critical</option>
102
109
  </select>
110
+ <!-- Plugin: ticket show actions slot -->
111
+ <PluginSlot slot="ticket.show.actions" :components="getPageComponents('ticket.show', 'actions')" />
103
112
  </div>
104
113
  </div>
105
114
  <div class="grid grid-cols-1 gap-6 lg:grid-cols-3">
@@ -135,8 +144,10 @@ useKeyboardShortcuts({
135
144
  :ticket-reference="ticket.reference" route-prefix="escalated.agent" pinnable />
136
145
  </div>
137
146
  </div>
138
- <div>
147
+ <div class="space-y-6">
139
148
  <TicketSidebar :ticket="ticket" :tags="tags" :departments="departments" />
149
+ <!-- Plugin: ticket show sidebar slot -->
150
+ <PluginSlot slot="ticket.show.sidebar" :components="getPageComponents('ticket.show', 'sidebar')" />
140
151
  </div>
141
152
  </div>
142
153
  <KeyboardShortcutHelp v-model:show="showShortcutHelp" context="detail" />
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Sanitize HTML to prevent stored XSS.
3
+ *
4
+ * Uses the DOM parser to walk the tree and strip dangerous elements and
5
+ * attributes rather than regex, which avoids incomplete-sanitization pitfalls.
6
+ */
7
+
8
+ const DANGEROUS_TAGS = new Set([
9
+ 'script', 'style', 'iframe', 'object', 'embed', 'form', 'input',
10
+ 'textarea', 'button', 'select', 'option', 'link', 'meta', 'base',
11
+ 'applet', 'noscript', 'noframes',
12
+ ])
13
+
14
+ const URI_ATTRS = new Set(['href', 'src', 'action', 'formaction', 'xlink:href'])
15
+
16
+ export function sanitizeHtml(html) {
17
+ if (!html) return ''
18
+
19
+ const doc = new DOMParser().parseFromString(html, 'text/html')
20
+
21
+ // Remove dangerous elements
22
+ for (const tag of DANGEROUS_TAGS) {
23
+ const els = doc.body.getElementsByTagName(tag)
24
+ while (els.length) els[0].remove()
25
+ }
26
+
27
+ // Walk all remaining elements and strip dangerous attributes
28
+ const all = doc.body.querySelectorAll('*')
29
+ for (let i = 0; i < all.length; i++) {
30
+ const el = all[i]
31
+ const attrs = [...el.attributes]
32
+ for (let j = 0; j < attrs.length; j++) {
33
+ const name = attrs[j].name.toLowerCase()
34
+
35
+ // Remove event handlers (onclick, onerror, etc.)
36
+ if (name.startsWith('on')) {
37
+ el.removeAttribute(attrs[j].name)
38
+ continue
39
+ }
40
+
41
+ // Remove javascript: / vbscript: / dangerous data: URIs
42
+ if (URI_ATTRS.has(name)) {
43
+ const val = (attrs[j].value || '').replace(/[\s\u0000-\u001F]+/g, '').toLowerCase()
44
+ if (
45
+ val.startsWith('javascript:') ||
46
+ val.startsWith('vbscript:') ||
47
+ (val.startsWith('data:') && !val.startsWith('data:image/'))
48
+ ) {
49
+ el.removeAttribute(attrs[j].name)
50
+ }
51
+ }
52
+
53
+ // Remove style attributes containing expressions or javascript
54
+ if (name === 'style') {
55
+ const val = (attrs[j].value || '').toLowerCase()
56
+ if (val.includes('expression(') || val.includes('javascript:') || val.includes('url(')) {
57
+ el.removeAttribute(attrs[j].name)
58
+ }
59
+ }
60
+ }
61
+ }
62
+
63
+ return doc.body.innerHTML
64
+ }