@conduction/nextcloud-vue 0.1.0-beta.4 → 0.1.0-beta.6

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 (71) hide show
  1. package/dist/nextcloud-vue.cjs +67614 -0
  2. package/dist/nextcloud-vue.cjs.js +9559 -8983
  3. package/dist/nextcloud-vue.cjs.js.map +1 -1
  4. package/dist/nextcloud-vue.cjs.map +1 -0
  5. package/dist/nextcloud-vue.css +1231 -1231
  6. package/dist/nextcloud-vue.esm.js +9559 -8983
  7. package/dist/nextcloud-vue.esm.js.map +1 -1
  8. package/package.json +14 -5
  9. package/src/components/CnActionsBar/CnActionsBar.vue +235 -235
  10. package/src/components/CnAdvancedFormDialog/CnAdvancedFormDialog.vue +579 -579
  11. package/src/components/CnAdvancedFormDialog/CnDataTab.vue +217 -217
  12. package/src/components/CnAdvancedFormDialog/CnMetadataTab.vue +121 -121
  13. package/src/components/CnAdvancedFormDialog/CnPropertiesTab.vue +418 -418
  14. package/src/components/CnAdvancedFormDialog/CnPropertyValueCell.vue +247 -247
  15. package/src/components/CnCardGrid/CnCardGrid.vue +152 -152
  16. package/src/components/CnCellRenderer/CnCellRenderer.vue +132 -132
  17. package/src/components/CnChartWidget/CnChartWidget.vue +320 -320
  18. package/src/components/CnConfigurationCard/CnConfigurationCard.vue +77 -77
  19. package/src/components/CnCopyDialog/CnCopyDialog.vue +250 -250
  20. package/src/components/CnDashboardGrid/CnDashboardGrid.vue +225 -225
  21. package/src/components/CnDashboardPage/CnDashboardPage.vue +390 -390
  22. package/src/components/CnDataTable/CnDataTable.vue +349 -349
  23. package/src/components/CnDeleteDialog/CnDeleteDialog.vue +170 -170
  24. package/src/components/CnDetailCard/CnDetailCard.vue +214 -214
  25. package/src/components/CnDetailPage/CnDetailPage.vue +285 -281
  26. package/src/components/CnFacetSidebar/CnFacetSidebar.vue +231 -231
  27. package/src/components/CnFilterBar/CnFilterBar.vue +152 -152
  28. package/src/components/CnFormDialog/CnFormDialog.vue +302 -11
  29. package/src/components/CnIcon/CnIcon.vue +89 -89
  30. package/src/components/CnIndexPage/CnIndexPage.vue +884 -874
  31. package/src/components/CnIndexSidebar/CnIndexSidebar.vue +503 -503
  32. package/src/components/CnItemCard/CnItemCard.vue +132 -132
  33. package/src/components/CnKpiGrid/CnKpiGrid.vue +89 -89
  34. package/src/components/CnMassActionBar/CnMassActionBar.vue +160 -160
  35. package/src/components/CnMassCopyDialog/CnMassCopyDialog.vue +320 -320
  36. package/src/components/CnMassDeleteDialog/CnMassDeleteDialog.vue +238 -238
  37. package/src/components/CnMassExportDialog/CnMassExportDialog.vue +190 -190
  38. package/src/components/CnMassImportDialog/CnMassImportDialog.vue +491 -491
  39. package/src/components/CnNoteCard/CnNoteCard.vue +149 -149
  40. package/src/components/CnNotesCard/CnNotesCard.vue +413 -413
  41. package/src/components/CnObjectCard/CnObjectCard.vue +292 -292
  42. package/src/components/CnObjectCard/eslint-setup.md +235 -0
  43. package/src/components/CnObjectCard/package.json-or.json +132 -0
  44. package/src/components/CnObjectSidebar/CnObjectSidebar.vue +876 -876
  45. package/src/components/CnPageHeader/CnPageHeader.vue +57 -57
  46. package/src/components/CnPagination/CnPagination.vue +252 -252
  47. package/src/components/CnRegisterMapping/CnRegisterMapping.vue +792 -792
  48. package/src/components/CnRowActions/CnRowActions.vue +95 -73
  49. package/src/components/CnSchemaFormDialog/CnSchemaConfigurationTab.vue +226 -226
  50. package/src/components/CnSchemaFormDialog/CnSchemaFormDialog.vue +787 -787
  51. package/src/components/CnSchemaFormDialog/CnSchemaPropertiesTab.vue +305 -305
  52. package/src/components/CnSchemaFormDialog/CnSchemaPropertyActions.vue +1398 -1398
  53. package/src/components/CnSchemaFormDialog/CnSchemaSecurityTab.vue +236 -236
  54. package/src/components/CnSettingsCard/CnSettingsCard.vue +92 -92
  55. package/src/components/CnSettingsSection/CnSettingsSection.vue +266 -266
  56. package/src/components/CnStatsBlock/CnStatsBlock.vue +420 -420
  57. package/src/components/CnStatusBadge/CnStatusBadge.vue +77 -77
  58. package/src/components/CnTabbedFormDialog/CnTabbedFormDialog.vue +540 -540
  59. package/src/components/CnTasksCard/CnTasksCard.vue +373 -373
  60. package/src/components/CnTileWidget/CnTileWidget.vue +159 -159
  61. package/src/components/CnTimelineStages/CnTimelineStages.vue +292 -292
  62. package/src/components/CnUserActionMenu/CnUserActionMenu.vue +435 -435
  63. package/src/components/CnVersionInfoCard/CnVersionInfoCard.vue +312 -312
  64. package/src/components/CnWidgetRenderer/CnWidgetRenderer.vue +180 -180
  65. package/src/components/CnWidgetWrapper/CnWidgetWrapper.vue +211 -211
  66. package/src/index.js +1 -1
  67. package/src/types/notification.d.ts +13 -13
  68. package/src/types/organisation.d.ts +15 -15
  69. package/src/types/schema.d.ts +13 -13
  70. package/src/types/task.d.ts +6 -6
  71. package/src/utils/headers.js +5 -3
@@ -1,435 +1,435 @@
1
- <!--
2
- CnUserActionMenu — Popover menu triggered by clicking a user name.
3
-
4
- Shows avatar, display name, and contextual actions (message, chat, email, meeting)
5
- based on which Nextcloud apps are installed (Talk, Mail, Calendar).
6
- -->
7
- <template>
8
- <span class="cn-user-action-menu">
9
- <span
10
- ref="trigger"
11
- class="cn-user-action-menu__trigger"
12
- :class="{ 'cn-user-action-menu__trigger--interactive': interactive }"
13
- role="button"
14
- :tabindex="interactive ? 0 : -1"
15
- :aria-haspopup="interactive ? 'menu' : undefined"
16
- @click="interactive && openMenu()"
17
- @keydown.enter.prevent="interactive && openMenu()"
18
- @keydown.space.prevent="interactive && openMenu()">
19
- <slot>{{ displayName }}</slot>
20
- </span>
21
-
22
- <NcPopover
23
- v-if="interactive"
24
- :shown.sync="isOpen"
25
- :trigger="triggerElements"
26
- placement="bottom-start"
27
- @after-hide="onClose">
28
- <div
29
- class="cn-user-action-menu__popover"
30
- role="menu"
31
- :aria-label="'Actions for ' + displayName"
32
- @keydown.escape.prevent="closeMenu">
33
- <!-- User info header -->
34
- <div class="cn-user-action-menu__header">
35
- <NcAvatar
36
- :user="userId"
37
- :display-name="displayName"
38
- :size="36"
39
- :show-user-status="false" />
40
- <div class="cn-user-action-menu__user-info">
41
- <span class="cn-user-action-menu__display-name">{{ displayName }}</span>
42
- <span v-if="userEmail" class="cn-user-action-menu__email">{{ userEmail }}</span>
43
- </div>
44
- </div>
45
-
46
- <!-- Action buttons -->
47
- <div class="cn-user-action-menu__actions">
48
- <NcActionButton
49
- v-if="hasTalk"
50
- role="menuitem"
51
- @click="sendMessage">
52
- <template #icon>
53
- <MessageTextOutline :size="20" />
54
- </template>
55
- {{ sendMessageLabel }}
56
- </NcActionButton>
57
-
58
- <NcActionButton
59
- v-if="hasTalk"
60
- role="menuitem"
61
- @click="startChat">
62
- <template #icon>
63
- <ChatOutline :size="20" />
64
- </template>
65
- {{ startChatLabel }}
66
- </NcActionButton>
67
-
68
- <NcActionButton
69
- v-if="showEmailAction"
70
- role="menuitem"
71
- @click="sendEmail">
72
- <template #icon>
73
- <EmailOutline :size="20" />
74
- </template>
75
- {{ sendEmailLabel }}
76
- </NcActionButton>
77
-
78
- <NcActionButton
79
- v-if="hasCalendar"
80
- role="menuitem"
81
- @click="planMeeting">
82
- <template #icon>
83
- <CalendarOutline :size="20" />
84
- </template>
85
- {{ planMeetingLabel }}
86
- </NcActionButton>
87
-
88
- <div
89
- v-if="!hasTalk && !showEmailAction && !hasCalendar"
90
- class="cn-user-action-menu__no-actions">
91
- {{ noActionsLabel }}
92
- </div>
93
- </div>
94
- </div>
95
- </NcPopover>
96
- </span>
97
- </template>
98
-
99
- <script>
100
- import { NcPopover, NcActionButton, NcAvatar } from '@nextcloud/vue'
101
-
102
- import MessageTextOutline from 'vue-material-design-icons/MessageTextOutline.vue'
103
- import ChatOutline from 'vue-material-design-icons/ChatOutline.vue'
104
- import EmailOutline from 'vue-material-design-icons/EmailOutline.vue'
105
- import CalendarOutline from 'vue-material-design-icons/CalendarOutline.vue'
106
-
107
- import { buildHeaders } from '../../utils/index.js'
108
-
109
- // Module-level capabilities cache (shared across all instances, fetched once per session)
110
- let _capabilitiesCache = null
111
- let _capabilitiesPromise = null
112
-
113
- /**
114
- * CnUserActionMenu — Popover with user communication actions.
115
- *
116
- * Shows contextual actions based on installed Nextcloud apps (Talk, Mail, Calendar).
117
- * Uses @nextcloud/capabilities when available, falls back to OCS API.
118
- *
119
- * @example Usage in notes/tasks cards
120
- * <CnUserActionMenu
121
- * :user-id="note.actorId || note.author"
122
- * :display-name="note.actorDisplayName || note.author || 'Unknown'" />
123
- */
124
- export default {
125
- name: 'CnUserActionMenu',
126
-
127
- components: {
128
- NcPopover,
129
- NcActionButton,
130
- NcAvatar,
131
- MessageTextOutline,
132
- ChatOutline,
133
- EmailOutline,
134
- CalendarOutline,
135
- },
136
-
137
- props: {
138
- /** The Nextcloud user ID */
139
- userId: {
140
- type: String,
141
- required: true,
142
- },
143
- /** The user's display name */
144
- displayName: {
145
- type: String,
146
- default: 'Unknown',
147
- },
148
- /** Whether the menu is interactive (false for current user or system accounts) */
149
- interactive: {
150
- type: Boolean,
151
- default: true,
152
- },
153
-
154
- // --- Pre-translated labels ---
155
- sendMessageLabel: { type: String, default: 'Send message' },
156
- startChatLabel: { type: String, default: 'Start chat' },
157
- sendEmailLabel: { type: String, default: 'Send email' },
158
- planMeetingLabel: { type: String, default: 'Plan meeting' },
159
- noActionsLabel: { type: String, default: 'No communication apps available' },
160
- },
161
-
162
- emits: ['action'],
163
-
164
- data() {
165
- return {
166
- isOpen: false,
167
- hasTalk: false,
168
- hasMail: false,
169
- hasCalendar: false,
170
- userEmail: '',
171
- emailResolved: false,
172
- triggerElements: [],
173
- }
174
- },
175
-
176
- computed: {
177
- showEmailAction() {
178
- return !!this.userEmail
179
- },
180
- },
181
-
182
- mounted() {
183
- this.triggerElements = [this.$refs.trigger]
184
- this.detectCapabilities()
185
- },
186
-
187
- methods: {
188
- openMenu() {
189
- if (!this.interactive) return
190
- this.isOpen = true
191
- // Resolve email on first open if not yet done
192
- if (!this.emailResolved) {
193
- this.resolveUserEmail()
194
- }
195
- },
196
-
197
- closeMenu() {
198
- this.isOpen = false
199
- },
200
-
201
- onClose() {
202
- this.isOpen = false
203
- // Return focus to trigger
204
- if (this.$refs.trigger) {
205
- this.$refs.trigger.focus()
206
- }
207
- },
208
-
209
- async detectCapabilities() {
210
- if (_capabilitiesCache) {
211
- this.applyCapabilities(_capabilitiesCache)
212
- return
213
- }
214
-
215
- // Try @nextcloud/capabilities first (synchronous, from initial state)
216
- try {
217
- // eslint-disable-next-line n/no-missing-import
218
- const { getCapabilities } = await import('@nextcloud/capabilities')
219
- const caps = getCapabilities()
220
- if (caps) {
221
- _capabilitiesCache = caps
222
- this.applyCapabilities(caps)
223
- return
224
- }
225
- } catch {
226
- // Package not available, fall back to API
227
- }
228
-
229
- // Fallback: fetch from OCS API (once per session)
230
- if (!_capabilitiesPromise) {
231
- _capabilitiesPromise = this.fetchCapabilities()
232
- }
233
- const caps = await _capabilitiesPromise
234
- if (caps) {
235
- _capabilitiesCache = caps
236
- this.applyCapabilities(caps)
237
- }
238
- },
239
-
240
- async fetchCapabilities() {
241
- try {
242
- const response = await fetch('/ocs/v2.php/cloud/capabilities?format=json', {
243
- headers: buildHeaders(),
244
- })
245
- if (response.ok) {
246
- const data = await response.json()
247
- return data?.ocs?.data?.capabilities || {}
248
- }
249
- } catch (err) {
250
- console.error('CnUserActionMenu: Failed to fetch capabilities', err)
251
- }
252
- return {}
253
- },
254
-
255
- applyCapabilities(caps) {
256
- this.hasTalk = !!caps?.spreed
257
- this.hasCalendar = !!caps?.dav
258
- this.hasMail = !!caps?.mail
259
- },
260
-
261
- async resolveUserEmail() {
262
- this.emailResolved = true
263
- try {
264
- const response = await fetch(
265
- `/ocs/v2.php/cloud/users/${encodeURIComponent(this.userId)}?format=json`,
266
- {
267
- headers: {
268
- ...buildHeaders(),
269
- 'OCS-APIREQUEST': 'true',
270
- },
271
- },
272
- )
273
- if (response.ok) {
274
- const data = await response.json()
275
- this.userEmail = data?.ocs?.data?.email || ''
276
- }
277
- } catch (err) {
278
- console.error('CnUserActionMenu: Failed to resolve user email', err)
279
- this.userEmail = ''
280
- }
281
- },
282
-
283
- async sendMessage() {
284
- try {
285
- const response = await fetch('/ocs/v2.php/apps/spreed/api/v4/room', {
286
- method: 'POST',
287
- headers: {
288
- ...buildHeaders(),
289
- 'OCS-APIREQUEST': 'true',
290
- 'Content-Type': 'application/json',
291
- },
292
- body: JSON.stringify({ roomType: 1, invite: this.userId }),
293
- })
294
- if (response.ok) {
295
- const data = await response.json()
296
- const token = data?.ocs?.data?.token
297
- if (token) {
298
- window.location.href = `/apps/spreed/#/call/${token}`
299
- }
300
- } else {
301
- this.showActionError('Failed to create conversation')
302
- }
303
- } catch (err) {
304
- console.error('CnUserActionMenu: Failed to send message', err)
305
- this.showActionError('Failed to create conversation')
306
- }
307
- this.$emit('action', { type: 'message', userId: this.userId })
308
- },
309
-
310
- async startChat() {
311
- try {
312
- const response = await fetch('/ocs/v2.php/apps/spreed/api/v4/room', {
313
- method: 'POST',
314
- headers: {
315
- ...buildHeaders(),
316
- 'OCS-APIREQUEST': 'true',
317
- 'Content-Type': 'application/json',
318
- },
319
- body: JSON.stringify({ roomType: 1, invite: this.userId }),
320
- })
321
- if (response.ok) {
322
- const data = await response.json()
323
- const token = data?.ocs?.data?.token
324
- if (token) {
325
- window.open(`/apps/spreed/#/call/${token}`, '_blank')
326
- }
327
- } else {
328
- this.showActionError('Failed to create conversation')
329
- }
330
- } catch (err) {
331
- console.error('CnUserActionMenu: Failed to start chat', err)
332
- this.showActionError('Failed to create conversation')
333
- }
334
- this.$emit('action', { type: 'chat', userId: this.userId })
335
- },
336
-
337
- sendEmail() {
338
- if (!this.userEmail) return
339
- if (this.hasMail) {
340
- window.location.href = `/apps/mail/compose?to=${encodeURIComponent(this.userEmail)}`
341
- } else {
342
- window.location.href = `mailto:${this.userEmail}`
343
- }
344
- this.closeMenu()
345
- this.$emit('action', { type: 'email', userId: this.userId })
346
- },
347
-
348
- planMeeting() {
349
- window.location.href = `/apps/calendar/new?attendees=${encodeURIComponent(this.userId)}&title=Meeting`
350
- this.closeMenu()
351
- this.$emit('action', { type: 'meeting', userId: this.userId })
352
- },
353
-
354
- showActionError(message) {
355
- try {
356
- // eslint-disable-next-line n/no-missing-import
357
- import('@nextcloud/dialogs').then(({ showError }) => {
358
- showError(message)
359
- })
360
- } catch {
361
- console.error(message)
362
- }
363
- },
364
- },
365
- }
366
- </script>
367
-
368
- <style scoped>
369
- .cn-user-action-menu {
370
- display: inline;
371
- }
372
-
373
- .cn-user-action-menu__trigger--interactive {
374
- cursor: pointer;
375
- color: var(--color-primary-element);
376
- font-weight: 600;
377
- }
378
-
379
- .cn-user-action-menu__trigger--interactive:hover {
380
- text-decoration: underline;
381
- }
382
-
383
- .cn-user-action-menu__trigger--interactive:focus-visible {
384
- outline: 2px solid var(--color-primary-element);
385
- outline-offset: 2px;
386
- border-radius: var(--border-radius);
387
- }
388
-
389
- .cn-user-action-menu__popover {
390
- min-width: 220px;
391
- padding: 8px 0;
392
- }
393
-
394
- .cn-user-action-menu__header {
395
- display: flex;
396
- align-items: center;
397
- gap: 10px;
398
- padding: 8px 12px 12px;
399
- border-bottom: 1px solid var(--color-border);
400
- margin-bottom: 4px;
401
- }
402
-
403
- .cn-user-action-menu__user-info {
404
- display: flex;
405
- flex-direction: column;
406
- min-width: 0;
407
- }
408
-
409
- .cn-user-action-menu__display-name {
410
- font-weight: 600;
411
- font-size: 14px;
412
- white-space: nowrap;
413
- overflow: hidden;
414
- text-overflow: ellipsis;
415
- }
416
-
417
- .cn-user-action-menu__email {
418
- font-size: 12px;
419
- color: var(--color-text-maxcontrast);
420
- white-space: nowrap;
421
- overflow: hidden;
422
- text-overflow: ellipsis;
423
- }
424
-
425
- .cn-user-action-menu__actions {
426
- padding: 4px 0;
427
- }
428
-
429
- .cn-user-action-menu__no-actions {
430
- padding: 12px 16px;
431
- text-align: center;
432
- color: var(--color-text-maxcontrast);
433
- font-size: 13px;
434
- }
435
- </style>
1
+ <!--
2
+ CnUserActionMenu — Popover menu triggered by clicking a user name.
3
+
4
+ Shows avatar, display name, and contextual actions (message, chat, email, meeting)
5
+ based on which Nextcloud apps are installed (Talk, Mail, Calendar).
6
+ -->
7
+ <template>
8
+ <span class="cn-user-action-menu">
9
+ <span
10
+ ref="trigger"
11
+ class="cn-user-action-menu__trigger"
12
+ :class="{ 'cn-user-action-menu__trigger--interactive': interactive }"
13
+ role="button"
14
+ :tabindex="interactive ? 0 : -1"
15
+ :aria-haspopup="interactive ? 'menu' : undefined"
16
+ @click="interactive && openMenu()"
17
+ @keydown.enter.prevent="interactive && openMenu()"
18
+ @keydown.space.prevent="interactive && openMenu()">
19
+ <slot>{{ displayName }}</slot>
20
+ </span>
21
+
22
+ <NcPopover
23
+ v-if="interactive"
24
+ :shown.sync="isOpen"
25
+ :trigger="triggerElements"
26
+ placement="bottom-start"
27
+ @after-hide="onClose">
28
+ <div
29
+ class="cn-user-action-menu__popover"
30
+ role="menu"
31
+ :aria-label="'Actions for ' + displayName"
32
+ @keydown.escape.prevent="closeMenu">
33
+ <!-- User info header -->
34
+ <div class="cn-user-action-menu__header">
35
+ <NcAvatar
36
+ :user="userId"
37
+ :display-name="displayName"
38
+ :size="36"
39
+ :show-user-status="false" />
40
+ <div class="cn-user-action-menu__user-info">
41
+ <span class="cn-user-action-menu__display-name">{{ displayName }}</span>
42
+ <span v-if="userEmail" class="cn-user-action-menu__email">{{ userEmail }}</span>
43
+ </div>
44
+ </div>
45
+
46
+ <!-- Action buttons -->
47
+ <div class="cn-user-action-menu__actions">
48
+ <NcActionButton
49
+ v-if="hasTalk"
50
+ role="menuitem"
51
+ @click="sendMessage">
52
+ <template #icon>
53
+ <MessageTextOutline :size="20" />
54
+ </template>
55
+ {{ sendMessageLabel }}
56
+ </NcActionButton>
57
+
58
+ <NcActionButton
59
+ v-if="hasTalk"
60
+ role="menuitem"
61
+ @click="startChat">
62
+ <template #icon>
63
+ <ChatOutline :size="20" />
64
+ </template>
65
+ {{ startChatLabel }}
66
+ </NcActionButton>
67
+
68
+ <NcActionButton
69
+ v-if="showEmailAction"
70
+ role="menuitem"
71
+ @click="sendEmail">
72
+ <template #icon>
73
+ <EmailOutline :size="20" />
74
+ </template>
75
+ {{ sendEmailLabel }}
76
+ </NcActionButton>
77
+
78
+ <NcActionButton
79
+ v-if="hasCalendar"
80
+ role="menuitem"
81
+ @click="planMeeting">
82
+ <template #icon>
83
+ <CalendarOutline :size="20" />
84
+ </template>
85
+ {{ planMeetingLabel }}
86
+ </NcActionButton>
87
+
88
+ <div
89
+ v-if="!hasTalk && !showEmailAction && !hasCalendar"
90
+ class="cn-user-action-menu__no-actions">
91
+ {{ noActionsLabel }}
92
+ </div>
93
+ </div>
94
+ </div>
95
+ </NcPopover>
96
+ </span>
97
+ </template>
98
+
99
+ <script>
100
+ import { NcPopover, NcActionButton, NcAvatar } from '@nextcloud/vue'
101
+
102
+ import MessageTextOutline from 'vue-material-design-icons/MessageTextOutline.vue'
103
+ import ChatOutline from 'vue-material-design-icons/ChatOutline.vue'
104
+ import EmailOutline from 'vue-material-design-icons/EmailOutline.vue'
105
+ import CalendarOutline from 'vue-material-design-icons/CalendarOutline.vue'
106
+
107
+ import { buildHeaders } from '../../utils/index.js'
108
+
109
+ // Module-level capabilities cache (shared across all instances, fetched once per session)
110
+ let _capabilitiesCache = null
111
+ let _capabilitiesPromise = null
112
+
113
+ /**
114
+ * CnUserActionMenu — Popover with user communication actions.
115
+ *
116
+ * Shows contextual actions based on installed Nextcloud apps (Talk, Mail, Calendar).
117
+ * Uses @nextcloud/capabilities when available, falls back to OCS API.
118
+ *
119
+ * @example Usage in notes/tasks cards
120
+ * <CnUserActionMenu
121
+ * :user-id="note.actorId || note.author"
122
+ * :display-name="note.actorDisplayName || note.author || 'Unknown'" />
123
+ */
124
+ export default {
125
+ name: 'CnUserActionMenu',
126
+
127
+ components: {
128
+ NcPopover,
129
+ NcActionButton,
130
+ NcAvatar,
131
+ MessageTextOutline,
132
+ ChatOutline,
133
+ EmailOutline,
134
+ CalendarOutline,
135
+ },
136
+
137
+ props: {
138
+ /** The Nextcloud user ID */
139
+ userId: {
140
+ type: String,
141
+ required: true,
142
+ },
143
+ /** The user's display name */
144
+ displayName: {
145
+ type: String,
146
+ default: 'Unknown',
147
+ },
148
+ /** Whether the menu is interactive (false for current user or system accounts) */
149
+ interactive: {
150
+ type: Boolean,
151
+ default: true,
152
+ },
153
+
154
+ // --- Pre-translated labels ---
155
+ sendMessageLabel: { type: String, default: 'Send message' },
156
+ startChatLabel: { type: String, default: 'Start chat' },
157
+ sendEmailLabel: { type: String, default: 'Send email' },
158
+ planMeetingLabel: { type: String, default: 'Plan meeting' },
159
+ noActionsLabel: { type: String, default: 'No communication apps available' },
160
+ },
161
+
162
+ emits: ['action'],
163
+
164
+ data() {
165
+ return {
166
+ isOpen: false,
167
+ hasTalk: false,
168
+ hasMail: false,
169
+ hasCalendar: false,
170
+ userEmail: '',
171
+ emailResolved: false,
172
+ triggerElements: [],
173
+ }
174
+ },
175
+
176
+ computed: {
177
+ showEmailAction() {
178
+ return !!this.userEmail
179
+ },
180
+ },
181
+
182
+ mounted() {
183
+ this.triggerElements = [this.$refs.trigger]
184
+ this.detectCapabilities()
185
+ },
186
+
187
+ methods: {
188
+ openMenu() {
189
+ if (!this.interactive) return
190
+ this.isOpen = true
191
+ // Resolve email on first open if not yet done
192
+ if (!this.emailResolved) {
193
+ this.resolveUserEmail()
194
+ }
195
+ },
196
+
197
+ closeMenu() {
198
+ this.isOpen = false
199
+ },
200
+
201
+ onClose() {
202
+ this.isOpen = false
203
+ // Return focus to trigger
204
+ if (this.$refs.trigger) {
205
+ this.$refs.trigger.focus()
206
+ }
207
+ },
208
+
209
+ async detectCapabilities() {
210
+ if (_capabilitiesCache) {
211
+ this.applyCapabilities(_capabilitiesCache)
212
+ return
213
+ }
214
+
215
+ // Try @nextcloud/capabilities first (synchronous, from initial state)
216
+ try {
217
+ // eslint-disable-next-line n/no-missing-import
218
+ const { getCapabilities } = await import('@nextcloud/capabilities')
219
+ const caps = getCapabilities()
220
+ if (caps) {
221
+ _capabilitiesCache = caps
222
+ this.applyCapabilities(caps)
223
+ return
224
+ }
225
+ } catch {
226
+ // Package not available, fall back to API
227
+ }
228
+
229
+ // Fallback: fetch from OCS API (once per session)
230
+ if (!_capabilitiesPromise) {
231
+ _capabilitiesPromise = this.fetchCapabilities()
232
+ }
233
+ const caps = await _capabilitiesPromise
234
+ if (caps) {
235
+ _capabilitiesCache = caps
236
+ this.applyCapabilities(caps)
237
+ }
238
+ },
239
+
240
+ async fetchCapabilities() {
241
+ try {
242
+ const response = await fetch('/ocs/v2.php/cloud/capabilities?format=json', {
243
+ headers: buildHeaders(),
244
+ })
245
+ if (response.ok) {
246
+ const data = await response.json()
247
+ return data?.ocs?.data?.capabilities || {}
248
+ }
249
+ } catch (err) {
250
+ console.error('CnUserActionMenu: Failed to fetch capabilities', err)
251
+ }
252
+ return {}
253
+ },
254
+
255
+ applyCapabilities(caps) {
256
+ this.hasTalk = !!caps?.spreed
257
+ this.hasCalendar = !!caps?.dav
258
+ this.hasMail = !!caps?.mail
259
+ },
260
+
261
+ async resolveUserEmail() {
262
+ this.emailResolved = true
263
+ try {
264
+ const response = await fetch(
265
+ `/ocs/v2.php/cloud/users/${encodeURIComponent(this.userId)}?format=json`,
266
+ {
267
+ headers: {
268
+ ...buildHeaders(),
269
+ 'OCS-APIREQUEST': 'true',
270
+ },
271
+ },
272
+ )
273
+ if (response.ok) {
274
+ const data = await response.json()
275
+ this.userEmail = data?.ocs?.data?.email || ''
276
+ }
277
+ } catch (err) {
278
+ console.error('CnUserActionMenu: Failed to resolve user email', err)
279
+ this.userEmail = ''
280
+ }
281
+ },
282
+
283
+ async sendMessage() {
284
+ try {
285
+ const response = await fetch('/ocs/v2.php/apps/spreed/api/v4/room', {
286
+ method: 'POST',
287
+ headers: {
288
+ ...buildHeaders(),
289
+ 'OCS-APIREQUEST': 'true',
290
+ 'Content-Type': 'application/json',
291
+ },
292
+ body: JSON.stringify({ roomType: 1, invite: this.userId }),
293
+ })
294
+ if (response.ok) {
295
+ const data = await response.json()
296
+ const token = data?.ocs?.data?.token
297
+ if (token) {
298
+ window.location.href = `/apps/spreed/#/call/${token}`
299
+ }
300
+ } else {
301
+ this.showActionError('Failed to create conversation')
302
+ }
303
+ } catch (err) {
304
+ console.error('CnUserActionMenu: Failed to send message', err)
305
+ this.showActionError('Failed to create conversation')
306
+ }
307
+ this.$emit('action', { type: 'message', userId: this.userId })
308
+ },
309
+
310
+ async startChat() {
311
+ try {
312
+ const response = await fetch('/ocs/v2.php/apps/spreed/api/v4/room', {
313
+ method: 'POST',
314
+ headers: {
315
+ ...buildHeaders(),
316
+ 'OCS-APIREQUEST': 'true',
317
+ 'Content-Type': 'application/json',
318
+ },
319
+ body: JSON.stringify({ roomType: 1, invite: this.userId }),
320
+ })
321
+ if (response.ok) {
322
+ const data = await response.json()
323
+ const token = data?.ocs?.data?.token
324
+ if (token) {
325
+ window.open(`/apps/spreed/#/call/${token}`, '_blank')
326
+ }
327
+ } else {
328
+ this.showActionError('Failed to create conversation')
329
+ }
330
+ } catch (err) {
331
+ console.error('CnUserActionMenu: Failed to start chat', err)
332
+ this.showActionError('Failed to create conversation')
333
+ }
334
+ this.$emit('action', { type: 'chat', userId: this.userId })
335
+ },
336
+
337
+ sendEmail() {
338
+ if (!this.userEmail) return
339
+ if (this.hasMail) {
340
+ window.location.href = `/apps/mail/compose?to=${encodeURIComponent(this.userEmail)}`
341
+ } else {
342
+ window.location.href = `mailto:${this.userEmail}`
343
+ }
344
+ this.closeMenu()
345
+ this.$emit('action', { type: 'email', userId: this.userId })
346
+ },
347
+
348
+ planMeeting() {
349
+ window.location.href = `/apps/calendar/new?attendees=${encodeURIComponent(this.userId)}&title=Meeting`
350
+ this.closeMenu()
351
+ this.$emit('action', { type: 'meeting', userId: this.userId })
352
+ },
353
+
354
+ showActionError(message) {
355
+ try {
356
+ // eslint-disable-next-line n/no-missing-import
357
+ import('@nextcloud/dialogs').then(({ showError }) => {
358
+ showError(message)
359
+ })
360
+ } catch {
361
+ console.error(message)
362
+ }
363
+ },
364
+ },
365
+ }
366
+ </script>
367
+
368
+ <style scoped>
369
+ .cn-user-action-menu {
370
+ display: inline;
371
+ }
372
+
373
+ .cn-user-action-menu__trigger--interactive {
374
+ cursor: pointer;
375
+ color: var(--color-primary-element);
376
+ font-weight: 600;
377
+ }
378
+
379
+ .cn-user-action-menu__trigger--interactive:hover {
380
+ text-decoration: underline;
381
+ }
382
+
383
+ .cn-user-action-menu__trigger--interactive:focus-visible {
384
+ outline: 2px solid var(--color-primary-element);
385
+ outline-offset: 2px;
386
+ border-radius: var(--border-radius);
387
+ }
388
+
389
+ .cn-user-action-menu__popover {
390
+ min-width: 220px;
391
+ padding: 8px 0;
392
+ }
393
+
394
+ .cn-user-action-menu__header {
395
+ display: flex;
396
+ align-items: center;
397
+ gap: 10px;
398
+ padding: 8px 12px 12px;
399
+ border-bottom: 1px solid var(--color-border);
400
+ margin-bottom: 4px;
401
+ }
402
+
403
+ .cn-user-action-menu__user-info {
404
+ display: flex;
405
+ flex-direction: column;
406
+ min-width: 0;
407
+ }
408
+
409
+ .cn-user-action-menu__display-name {
410
+ font-weight: 600;
411
+ font-size: 14px;
412
+ white-space: nowrap;
413
+ overflow: hidden;
414
+ text-overflow: ellipsis;
415
+ }
416
+
417
+ .cn-user-action-menu__email {
418
+ font-size: 12px;
419
+ color: var(--color-text-maxcontrast);
420
+ white-space: nowrap;
421
+ overflow: hidden;
422
+ text-overflow: ellipsis;
423
+ }
424
+
425
+ .cn-user-action-menu__actions {
426
+ padding: 4px 0;
427
+ }
428
+
429
+ .cn-user-action-menu__no-actions {
430
+ padding: 12px 16px;
431
+ text-align: center;
432
+ color: var(--color-text-maxcontrast);
433
+ font-size: 13px;
434
+ }
435
+ </style>