@frigear-nu/inbox 0.0.0-stage → 0.0.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.
- package/README.md +39 -2
- package/dist/module.d.mts +452 -0
- package/dist/module.json +9 -0
- package/dist/module.mjs +242 -0
- package/dist/runtime/access.d.ts +1 -0
- package/dist/runtime/access.js +62 -0
- package/dist/runtime/app/components/InboxChannelSlideover.d.vue.ts +12 -0
- package/dist/runtime/app/components/InboxChannelSlideover.vue +171 -0
- package/dist/runtime/app/components/InboxChannelSlideover.vue.d.ts +12 -0
- package/dist/runtime/app/components/InboxComposer.d.vue.ts +12 -0
- package/dist/runtime/app/components/InboxComposer.vue +71 -0
- package/dist/runtime/app/components/InboxComposer.vue.d.ts +12 -0
- package/dist/runtime/app/components/InboxConversation.d.vue.ts +8 -0
- package/dist/runtime/app/components/InboxConversation.vue +82 -0
- package/dist/runtime/app/components/InboxConversation.vue.d.ts +8 -0
- package/dist/runtime/app/components/InboxHideSlideover.d.vue.ts +12 -0
- package/dist/runtime/app/components/InboxHideSlideover.vue +54 -0
- package/dist/runtime/app/components/InboxHideSlideover.vue.d.ts +12 -0
- package/dist/runtime/app/components/InboxMailboxSlideover.d.vue.ts +11 -0
- package/dist/runtime/app/components/InboxMailboxSlideover.vue +125 -0
- package/dist/runtime/app/components/InboxMailboxSlideover.vue.d.ts +11 -0
- package/dist/runtime/app/composables/index.d.ts +6 -0
- package/dist/runtime/app/composables/index.js +5 -0
- package/dist/runtime/app/composables/useInboxChannelActions.d.ts +15 -0
- package/dist/runtime/app/composables/useInboxChannelActions.js +45 -0
- package/dist/runtime/app/composables/useInboxLinks.d.ts +11 -0
- package/dist/runtime/app/composables/useInboxLinks.js +17 -0
- package/dist/runtime/app/composables/useInboxMailboxActions.d.ts +14 -0
- package/dist/runtime/app/composables/useInboxMailboxActions.js +47 -0
- package/dist/runtime/app/composables/useInboxThreadActions.d.ts +29 -0
- package/dist/runtime/app/composables/useInboxThreadActions.js +76 -0
- package/dist/runtime/app/composables/useInboxTranslate.d.ts +3 -0
- package/dist/runtime/app/composables/useInboxTranslate.js +7 -0
- package/dist/runtime/app/dashboard/InboxMine.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/InboxMine.vue +25 -0
- package/dist/runtime/app/dashboard/InboxMine.vue.d.ts +3 -0
- package/dist/runtime/app/dashboard/InboxUnassigned.d.vue.ts +3 -0
- package/dist/runtime/app/dashboard/InboxUnassigned.vue +25 -0
- package/dist/runtime/app/dashboard/InboxUnassigned.vue.d.ts +3 -0
- package/dist/runtime/app/pages/admin-settings.d.vue.ts +3 -0
- package/dist/runtime/app/pages/admin-settings.vue +161 -0
- package/dist/runtime/app/pages/admin-settings.vue.d.ts +3 -0
- package/dist/runtime/app/pages/admin-thread.d.vue.ts +3 -0
- package/dist/runtime/app/pages/admin-thread.vue +234 -0
- package/dist/runtime/app/pages/admin-thread.vue.d.ts +3 -0
- package/dist/runtime/app/pages/admin.d.vue.ts +3 -0
- package/dist/runtime/app/pages/admin.vue +211 -0
- package/dist/runtime/app/pages/admin.vue.d.ts +3 -0
- package/dist/runtime/channels/email.d.ts +2 -0
- package/dist/runtime/channels/email.js +8 -0
- package/dist/runtime/channels/form.d.ts +2 -0
- package/dist/runtime/channels/form.js +9 -0
- package/dist/runtime/channels/instagram.d.ts +2 -0
- package/dist/runtime/channels/instagram.js +5 -0
- package/dist/runtime/channels/messenger.d.ts +2 -0
- package/dist/runtime/channels/messenger.js +5 -0
- package/dist/runtime/channels/whatsapp.d.ts +2 -0
- package/dist/runtime/channels/whatsapp.js +5 -0
- package/dist/runtime/i18n/lang/da.json +247 -0
- package/dist/runtime/i18n/lang/en.json +247 -0
- package/dist/runtime/menus.d.ts +2 -0
- package/dist/runtime/menus.js +19 -0
- package/dist/runtime/server/db/schema.postgresql.d.ts +1216 -0
- package/dist/runtime/server/db/schema.postgresql.js +154 -0
- package/dist/runtime/server/db/schema.sqlite.d.ts +1294 -0
- package/dist/runtime/server/db/schema.sqlite.js +154 -0
- package/dist/runtime/server/plugins/forms.d.ts +2 -0
- package/dist/runtime/server/plugins/forms.js +55 -0
- package/dist/runtime/server/plugins/links.d.ts +2 -0
- package/dist/runtime/server/plugins/links.js +18 -0
- package/dist/runtime/server/plugins/notify.d.ts +2 -0
- package/dist/runtime/server/plugins/notify.js +24 -0
- package/dist/runtime/server/plugins/seed.d.ts +2 -0
- package/dist/runtime/server/plugins/seed.js +7 -0
- package/dist/runtime/server/plugins/teams.d.ts +2 -0
- package/dist/runtime/server/plugins/teams.js +3 -0
- package/dist/runtime/server/policies.d.ts +2 -0
- package/dist/runtime/server/policies.js +15 -0
- package/dist/runtime/server/routes/admin/audit.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/audit.get.js +43 -0
- package/dist/runtime/server/routes/admin/channel.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/channel.delete.js +13 -0
- package/dist/runtime/server/routes/admin/channel.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/channel.patch.js +24 -0
- package/dist/runtime/server/routes/admin/channels.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/channels.get.js +10 -0
- package/dist/runtime/server/routes/admin/channels.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/channels.post.js +21 -0
- package/dist/runtime/server/routes/admin/contact-erase.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/contact-erase.post.js +20 -0
- package/dist/runtime/server/routes/admin/contact-export.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/contact-export.get.js +41 -0
- package/dist/runtime/server/routes/admin/mailbox.delete.d.ts +2 -0
- package/dist/runtime/server/routes/admin/mailbox.delete.js +14 -0
- package/dist/runtime/server/routes/admin/mailbox.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/mailbox.get.js +9 -0
- package/dist/runtime/server/routes/admin/mailbox.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/mailbox.patch.js +17 -0
- package/dist/runtime/server/routes/admin/mailboxes.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/mailboxes.get.js +5 -0
- package/dist/runtime/server/routes/admin/mailboxes.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/mailboxes.post.js +22 -0
- package/dist/runtime/server/routes/admin/summary.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/summary.get.js +19 -0
- package/dist/runtime/server/routes/admin/thread-assignees.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread-assignees.get.js +11 -0
- package/dist/runtime/server/routes/admin/thread-hide.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread-hide.post.js +23 -0
- package/dist/runtime/server/routes/admin/thread-messages.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread-messages.post.js +10 -0
- package/dist/runtime/server/routes/admin/thread-notes.post.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread-notes.post.js +10 -0
- package/dist/runtime/server/routes/admin/thread.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread.get.js +27 -0
- package/dist/runtime/server/routes/admin/thread.patch.d.ts +2 -0
- package/dist/runtime/server/routes/admin/thread.patch.js +23 -0
- package/dist/runtime/server/routes/admin/threads.get.d.ts +2 -0
- package/dist/runtime/server/routes/admin/threads.get.js +49 -0
- package/dist/runtime/server/routes/webhooks/channel.post.d.ts +2 -0
- package/dist/runtime/server/routes/webhooks/channel.post.js +11 -0
- package/dist/runtime/server/routes/webhooks/email.post.d.ts +2 -0
- package/dist/runtime/server/routes/webhooks/email.post.js +38 -0
- package/dist/runtime/server/routes/webhooks/meta.get.d.ts +2 -0
- package/dist/runtime/server/routes/webhooks/meta.get.js +19 -0
- package/dist/runtime/server/routes/webhooks/meta.post.d.ts +2 -0
- package/dist/runtime/server/routes/webhooks/meta.post.js +29 -0
- package/dist/runtime/server/search-index.d.ts +2 -0
- package/dist/runtime/server/search-index.js +7 -0
- package/dist/runtime/server/tasks/retention.d.ts +2 -0
- package/dist/runtime/server/tasks/retention.js +12 -0
- package/dist/runtime/server/utils/inbox-audit.d.ts +17 -0
- package/dist/runtime/server/utils/inbox-audit.js +35 -0
- package/dist/runtime/server/utils/inbox-channels.d.ts +42 -0
- package/dist/runtime/server/utils/inbox-channels.js +73 -0
- package/dist/runtime/server/utils/inbox-config.d.ts +12 -0
- package/dist/runtime/server/utils/inbox-config.js +8 -0
- package/dist/runtime/server/utils/inbox-dto.d.ts +19 -0
- package/dist/runtime/server/utils/inbox-dto.js +92 -0
- package/dist/runtime/server/utils/inbox-ingest.d.ts +43 -0
- package/dist/runtime/server/utils/inbox-ingest.js +136 -0
- package/dist/runtime/server/utils/inbox-integrations.d.ts +7 -0
- package/dist/runtime/server/utils/inbox-integrations.js +13 -0
- package/dist/runtime/server/utils/inbox-mailboxes.d.ts +14 -0
- package/dist/runtime/server/utils/inbox-mailboxes.js +27 -0
- package/dist/runtime/server/utils/inbox-registry.d.ts +7 -0
- package/dist/runtime/server/utils/inbox-registry.js +10 -0
- package/dist/runtime/server/utils/inbox-retention.d.ts +57 -0
- package/dist/runtime/server/utils/inbox-retention.js +167 -0
- package/dist/runtime/server/utils/inbox-schemas.d.ts +123 -0
- package/dist/runtime/server/utils/inbox-schemas.js +78 -0
- package/dist/runtime/server/utils/inbox-search.d.ts +8 -0
- package/dist/runtime/server/utils/inbox-search.js +2 -0
- package/dist/runtime/server/utils/inbox-seed.d.ts +9 -0
- package/dist/runtime/server/utils/inbox-seed.js +35 -0
- package/dist/runtime/server/utils/inbox-send.d.ts +25 -0
- package/dist/runtime/server/utils/inbox-send.js +84 -0
- package/dist/runtime/server/utils/inbox-tombstones.d.ts +25 -0
- package/dist/runtime/server/utils/inbox-tombstones.js +47 -0
- package/dist/runtime/server/utils/inbox-webhooks.d.ts +8 -0
- package/dist/runtime/server/utils/inbox-webhooks.js +10 -0
- package/dist/runtime/server/utils/inbox.d.ts +79 -0
- package/dist/runtime/server/utils/inbox.js +134 -0
- package/dist/runtime/utils/api.d.ts +40 -0
- package/dist/runtime/utils/api.js +43 -0
- package/dist/runtime/utils/index.d.ts +44 -0
- package/dist/runtime/utils/index.js +27 -0
- package/dist/runtime/utils/payloads.d.ts +99 -0
- package/dist/runtime/utils/payloads.js +173 -0
- package/dist/runtime/utils/registry.d.ts +17 -0
- package/dist/runtime/utils/registry.js +29 -0
- package/dist/runtime/utils/signature.d.ts +14 -0
- package/dist/runtime/utils/signature.js +16 -0
- package/dist/types.d.mts +7 -0
- package/package.json +118 -3
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { inboxApi } from "../../utils/api";
|
|
3
|
+
import { computed, useInboxLinks, useLazyFetch, useModuleT } from "#imports";
|
|
4
|
+
defineOptions({ name: "InboxDashboardUnassigned" });
|
|
5
|
+
const t = useModuleT("inbox.dashboard");
|
|
6
|
+
const links = useInboxLinks();
|
|
7
|
+
const { data, status } = useLazyFetch(inboxApi.admin.summary, {
|
|
8
|
+
key: "inbox:summary",
|
|
9
|
+
server: false,
|
|
10
|
+
onResponseError: () => {
|
|
11
|
+
}
|
|
12
|
+
});
|
|
13
|
+
const visible = computed(() => status.value === "success" && (data.value?.mailboxes ?? 0) > 0);
|
|
14
|
+
</script>
|
|
15
|
+
|
|
16
|
+
<template>
|
|
17
|
+
<StatCard
|
|
18
|
+
v-if="visible"
|
|
19
|
+
:label="t('unassigned', 'Unassigned messages')"
|
|
20
|
+
icon="i-lucide-inbox"
|
|
21
|
+
:value="data?.unassigned ?? 0"
|
|
22
|
+
:hint="t('unassignedHint', 'Open threads nobody has picked up')"
|
|
23
|
+
:to="links.admin({ assignee: 'none' })"
|
|
24
|
+
/>
|
|
25
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { channels } from "#inbox/registry";
|
|
3
|
+
import { inboxApi } from "../../utils/api";
|
|
4
|
+
import { computed, errorMessage, h, resolveComponent, tableUi, useFetch, useInboxChannelActions, useInboxLinks, useInboxMailboxActions, useInboxTranslate, useModuleT } from "#imports";
|
|
5
|
+
defineOptions({ name: "InboxAdminSettingsPage" });
|
|
6
|
+
const t = useModuleT("inbox");
|
|
7
|
+
const tr = useInboxTranslate();
|
|
8
|
+
const links = useInboxLinks();
|
|
9
|
+
const mailboxActions = useInboxMailboxActions();
|
|
10
|
+
const channelActions = useInboxChannelActions();
|
|
11
|
+
const { data: mailboxes, status: mailboxStatus, error: mailboxError, refresh: refreshMailboxes } = await useFetch(inboxApi.admin.mailboxes, { key: "inbox:mailboxes", default: () => [] });
|
|
12
|
+
const { data: accounts, status: accountStatus, error: accountError, refresh: refreshAccounts } = await useFetch(inboxApi.admin.channels, { default: () => [] });
|
|
13
|
+
const channelsForbidden = computed(() => accountError.value?.statusCode === 401 || accountError.value?.statusCode === 403);
|
|
14
|
+
async function refreshAll() {
|
|
15
|
+
await Promise.all([refreshMailboxes(), refreshAccounts()]);
|
|
16
|
+
}
|
|
17
|
+
async function addMailbox() {
|
|
18
|
+
if (await mailboxActions.create()) await refreshAll();
|
|
19
|
+
}
|
|
20
|
+
async function addChannel() {
|
|
21
|
+
if (await channelActions.create(mailboxes.value ?? [])) await refreshAccounts();
|
|
22
|
+
}
|
|
23
|
+
const mailboxName = (id) => tr(mailboxes.value?.find((mailbox) => mailbox.id === id)?.name) || id;
|
|
24
|
+
const readers = (mailbox) => {
|
|
25
|
+
const parts = [];
|
|
26
|
+
if (mailbox.ownerType === "team") parts.push(t("settings.teamLeads", "Team leads"));
|
|
27
|
+
const roles = mailbox.grants.flatMap((grant) => grant.kind === "role" && typeof grant.role === "string" ? [grant.role] : []);
|
|
28
|
+
if (roles.length) parts.push(roles.join(", "));
|
|
29
|
+
const others = mailbox.grants.filter((grant) => grant.kind !== "role").length;
|
|
30
|
+
if (others) parts.push(t("settings.moreGrants", "{count} more", { count: others }));
|
|
31
|
+
return parts.join(" \xB7 ") || t("settings.staffOnly", "Staff only");
|
|
32
|
+
};
|
|
33
|
+
const TableIdentity = resolveComponent("TableIdentity");
|
|
34
|
+
const RowMenu = resolveComponent("RowMenu");
|
|
35
|
+
const StatusBadge = resolveComponent("StatusBadge");
|
|
36
|
+
const UIcon = resolveComponent("UIcon");
|
|
37
|
+
const mailboxColumns = computed(() => [
|
|
38
|
+
{ id: "name", header: t("settings.name", "Name"), cell: ({ row }) => h(TableIdentity, { title: tr(row.original.name), description: row.original.key }) },
|
|
39
|
+
{ id: "owner", header: t("settings.owner", "Owner"), cell: ({ row }) => h("span", { class: "text-muted" }, row.original.ownerType === "team" ? `${t("settings.ownerTeam", "A team")} ${row.original.ownerId ?? ""}` : t("settings.ownerPlatform", "Platform")) },
|
|
40
|
+
{ id: "readers", header: t("settings.readers", "Who reads it"), cell: ({ row }) => h("span", { class: "text-muted" }, readers(row.original)) },
|
|
41
|
+
{ id: "retention", header: t("settings.retentionShort", "Keeps closed threads"), cell: ({ row }) => h("span", { class: "tabular-nums text-muted" }, row.original.retentionDays ? t("settings.days", "{count} days", { count: row.original.retentionDays }) : t("settings.defaultRetention", "Default")) },
|
|
42
|
+
{
|
|
43
|
+
id: "actions",
|
|
44
|
+
meta: { class: { th: "w-0", td: "w-0" } },
|
|
45
|
+
cell: ({ row }) => h(RowMenu, { items: mailboxActions.menu(row.original, { onChanged: refreshAll }), subject: tr(row.original.name) })
|
|
46
|
+
}
|
|
47
|
+
]);
|
|
48
|
+
const accountColumns = computed(() => [
|
|
49
|
+
{
|
|
50
|
+
id: "channel",
|
|
51
|
+
header: t("channels.channel", "Channel"),
|
|
52
|
+
cell: ({ row }) => h("span", { class: "inline-flex items-center gap-2" }, [
|
|
53
|
+
h(UIcon, { name: channels[row.original.channel]?.icon ?? "i-lucide-plug", class: "size-4 shrink-0 text-muted" }),
|
|
54
|
+
h(TableIdentity, { title: row.original.address, description: tr(channels[row.original.channel]?.label) || row.original.channel })
|
|
55
|
+
])
|
|
56
|
+
},
|
|
57
|
+
{ id: "mailbox", header: t("channels.mailbox", "Mailbox"), cell: ({ row }) => h("span", { class: "text-muted" }, mailboxName(row.original.mailboxId)) },
|
|
58
|
+
{
|
|
59
|
+
id: "secret",
|
|
60
|
+
header: t("channels.secret", "Token"),
|
|
61
|
+
cell: ({ row }) => row.original.secretRef ? h(StatusBadge, { status: row.original.secretConfigured ? "set" : "missing", label: row.original.secretConfigured ? row.original.secretRef : t("channels.secretMissing", "{name} missing", { name: row.original.secretRef }), colors: { set: "success", missing: "error" } }) : h("span", { class: "text-muted" }, "\u2014")
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: "enabled",
|
|
65
|
+
header: t("channels.state", "State"),
|
|
66
|
+
cell: ({ row }) => h(StatusBadge, { status: row.original.enabled ? "on" : "off", label: row.original.enabled ? t("channels.on", "On") : t("channels.off", "Off"), colors: { on: "success", off: "neutral" } })
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
id: "actions",
|
|
70
|
+
meta: { class: { th: "w-0", td: "w-0" } },
|
|
71
|
+
cell: ({ row }) => h(RowMenu, { items: channelActions.menu(row.original, mailboxes.value ?? [], { onChanged: refreshAccounts }), subject: row.original.address })
|
|
72
|
+
}
|
|
73
|
+
]);
|
|
74
|
+
</script>
|
|
75
|
+
|
|
76
|
+
<template>
|
|
77
|
+
<div class="flex flex-col gap-4">
|
|
78
|
+
<PageHeading
|
|
79
|
+
:title="t('settings.title', 'Inbox settings')"
|
|
80
|
+
:description="t('settings.description', 'Mailboxes, who reads them, and the channels that deliver into them.')"
|
|
81
|
+
:breadcrumb="[{ label: t('list.title', 'Inbox'), to: links.admin() }, { label: t('settings.title', 'Inbox settings') }]"
|
|
82
|
+
/>
|
|
83
|
+
|
|
84
|
+
<TableCard
|
|
85
|
+
:title="t('settings.mailboxes', 'Mailboxes')"
|
|
86
|
+
:loading="mailboxStatus === 'pending' && !mailboxes?.length"
|
|
87
|
+
>
|
|
88
|
+
<template #actions>
|
|
89
|
+
<UButton
|
|
90
|
+
icon="i-lucide-plus"
|
|
91
|
+
size="sm"
|
|
92
|
+
:label="t('settings.addMailbox', 'Add mailbox')"
|
|
93
|
+
@click="addMailbox"
|
|
94
|
+
/>
|
|
95
|
+
</template>
|
|
96
|
+
<UEmpty
|
|
97
|
+
v-if="mailboxError"
|
|
98
|
+
variant="naked"
|
|
99
|
+
icon="i-lucide-circle-alert"
|
|
100
|
+
:title="t('settings.mailboxesFailed', 'The mailboxes could not be loaded')"
|
|
101
|
+
:description="errorMessage(mailboxError, '')"
|
|
102
|
+
/>
|
|
103
|
+
<UTable
|
|
104
|
+
v-else
|
|
105
|
+
:data="mailboxes ?? []"
|
|
106
|
+
:columns="mailboxColumns"
|
|
107
|
+
:ui="tableUi()"
|
|
108
|
+
>
|
|
109
|
+
<template #empty>
|
|
110
|
+
<UEmpty
|
|
111
|
+
variant="naked"
|
|
112
|
+
icon="i-lucide-inbox"
|
|
113
|
+
:title="t('settings.noMailboxes', 'No mailboxes yet')"
|
|
114
|
+
:description="t('settings.noMailboxesDescription', 'Add a shared mailbox, such as Support, then connect channels to it.')"
|
|
115
|
+
:actions="[{ label: t('settings.addMailbox', 'Add mailbox'), icon: 'i-lucide-plus', onClick: addMailbox }]"
|
|
116
|
+
/>
|
|
117
|
+
</template>
|
|
118
|
+
</UTable>
|
|
119
|
+
</TableCard>
|
|
120
|
+
|
|
121
|
+
<TableCard
|
|
122
|
+
:title="t('settings.channels', 'Channels')"
|
|
123
|
+
:description="t('settings.channelsDescription', 'Each connects an address on a channel to a mailbox. Tokens stay in the server config.')"
|
|
124
|
+
:loading="accountStatus === 'pending' && !accounts?.length"
|
|
125
|
+
>
|
|
126
|
+
<template #actions>
|
|
127
|
+
<UButton
|
|
128
|
+
v-if="!accountError"
|
|
129
|
+
icon="i-lucide-plus"
|
|
130
|
+
size="sm"
|
|
131
|
+
:disabled="!mailboxes?.length"
|
|
132
|
+
:label="t('settings.addChannel', 'Connect channel')"
|
|
133
|
+
@click="addChannel"
|
|
134
|
+
/>
|
|
135
|
+
</template>
|
|
136
|
+
<UEmpty
|
|
137
|
+
v-if="accountError"
|
|
138
|
+
variant="naked"
|
|
139
|
+
:icon="channelsForbidden ? 'i-lucide-lock' : 'i-lucide-circle-alert'"
|
|
140
|
+
:title="channelsForbidden ? t('settings.channelsForbidden', 'Only admins signed in with a session manage channels') : t('settings.channelsFailed', 'The channels could not be loaded')"
|
|
141
|
+
:description="channelsForbidden ? void 0 : errorMessage(accountError, '')"
|
|
142
|
+
/>
|
|
143
|
+
<UTable
|
|
144
|
+
v-else
|
|
145
|
+
:data="accounts ?? []"
|
|
146
|
+
:columns="accountColumns"
|
|
147
|
+
:ui="tableUi()"
|
|
148
|
+
>
|
|
149
|
+
<template #empty>
|
|
150
|
+
<UEmpty
|
|
151
|
+
variant="naked"
|
|
152
|
+
icon="i-lucide-plug"
|
|
153
|
+
:title="t('settings.noChannels', 'No channels connected')"
|
|
154
|
+
:description="t('settings.noChannelsDescription', 'Connect the contact form, an email address, a WhatsApp number or a Meta page.')"
|
|
155
|
+
:actions="mailboxes?.length ? [{ label: t('settings.addChannel', 'Connect channel'), icon: 'i-lucide-plus', onClick: addChannel }] : []"
|
|
156
|
+
/>
|
|
157
|
+
</template>
|
|
158
|
+
</UTable>
|
|
159
|
+
</TableCard>
|
|
160
|
+
</div>
|
|
161
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,234 @@
|
|
|
1
|
+
<script setup>
|
|
2
|
+
import { channels } from "#inbox/registry";
|
|
3
|
+
import { inboxApi } from "../../utils/api";
|
|
4
|
+
import { INBOX_AUDIT_LABELS, INBOX_STATUS_LABELS } from "../../utils";
|
|
5
|
+
import { computed, errorMessage, h, navigateTo, tableUi, useFetch, useFormat, useInboxLinks, useInboxThreadActions, useInboxTranslate, useModuleT, useRoute } from "#imports";
|
|
6
|
+
defineOptions({ name: "InboxAdminThreadPage" });
|
|
7
|
+
const t = useModuleT("inbox");
|
|
8
|
+
const tr = useInboxTranslate();
|
|
9
|
+
const format = useFormat();
|
|
10
|
+
const route = useRoute();
|
|
11
|
+
const links = useInboxLinks();
|
|
12
|
+
const actions = useInboxThreadActions();
|
|
13
|
+
const id = computed(() => String(route.params.id));
|
|
14
|
+
const { data, error, refresh } = await useFetch(() => inboxApi.admin.thread(id.value));
|
|
15
|
+
const thread = computed(() => data.value?.thread);
|
|
16
|
+
const notFound = computed(() => error.value?.statusCode === 404);
|
|
17
|
+
const forbidden = computed(() => error.value?.statusCode === 401 || error.value?.statusCode === 403);
|
|
18
|
+
const can = computed(() => data.value?.can);
|
|
19
|
+
const { data: audit, status: auditStatus, refresh: refreshAudit } = await useFetch(inboxApi.admin.audit, {
|
|
20
|
+
query: computed(() => ({ threadId: id.value, pageSize: 20 })),
|
|
21
|
+
immediate: !!can.value?.audit,
|
|
22
|
+
default: () => ({ items: [], total: 0, page: 1, pageSize: 20 })
|
|
23
|
+
});
|
|
24
|
+
async function refreshAll() {
|
|
25
|
+
await refresh();
|
|
26
|
+
if (can.value?.audit) await refreshAudit();
|
|
27
|
+
}
|
|
28
|
+
const statusColors = { open: "info", pending: "warning", closed: "neutral" };
|
|
29
|
+
const statusItems = computed(() => ["open", "pending", "closed"].map((value) => ({ label: t(`status.${value}`, INBOX_STATUS_LABELS[value] ?? value), value })));
|
|
30
|
+
async function changeStatus(value) {
|
|
31
|
+
if (thread.value && value !== thread.value.status && await actions.setStatus(thread.value, value)) await refreshAll();
|
|
32
|
+
}
|
|
33
|
+
const { data: assignees, status: assigneesStatus, execute: loadAssignees } = await useFetch(() => inboxApi.admin.assignees(id.value), {
|
|
34
|
+
immediate: false,
|
|
35
|
+
default: () => []
|
|
36
|
+
});
|
|
37
|
+
const userLabel = (person) => person.name ?? `#${person.id}`;
|
|
38
|
+
const assigneeItems = computed(() => {
|
|
39
|
+
const people = [...assignees.value ?? []];
|
|
40
|
+
const current = data.value?.assignee;
|
|
41
|
+
if (current && !people.some((person) => person.id === current.id)) people.unshift(current);
|
|
42
|
+
return [
|
|
43
|
+
{ label: t("list.nobody", "Unassigned"), value: "none" },
|
|
44
|
+
...people.map((person) => ({ label: userLabel(person), value: String(person.id) }))
|
|
45
|
+
];
|
|
46
|
+
});
|
|
47
|
+
async function onAssigneeOpen(open) {
|
|
48
|
+
if (open && assigneesStatus.value === "idle") await loadAssignees();
|
|
49
|
+
}
|
|
50
|
+
async function changeAssignee(value) {
|
|
51
|
+
if (!thread.value) return;
|
|
52
|
+
const assigneeId = value === "none" ? null : Number(value);
|
|
53
|
+
if (assigneeId !== thread.value.assigneeId && await actions.assign(thread.value, assigneeId)) await refreshAll();
|
|
54
|
+
}
|
|
55
|
+
const contactName = computed(() => data.value?.contact?.name ?? null);
|
|
56
|
+
const facts = computed(() => data.value ? [
|
|
57
|
+
{ key: "mailbox", label: t("thread.mailbox", "Mailbox"), value: tr(data.value.mailbox.name) },
|
|
58
|
+
{ key: "channel", label: t("list.channel", "Channel"), value: tr(channels[data.value.thread.channel]?.label) || data.value.thread.channel },
|
|
59
|
+
{ key: "assignee", label: t("list.assignee", "Assignee"), value: data.value.assignee ? data.value.assignee.name ?? `#${data.value.assignee.id}` : t("list.nobody", "Unassigned") },
|
|
60
|
+
{ key: "hidden", label: t("thread.visibleTo", "Seen by"), value: data.value.thread.hiddenBelow ? t("hide.role", "{role} and up", { role: data.value.thread.hiddenBelow }) : t("hide.everyone", "Everyone with access to the mailbox") },
|
|
61
|
+
{ key: "started", label: t("thread.started", "Started"), value: format.dateTime(data.value.thread.createdAt) }
|
|
62
|
+
] : []);
|
|
63
|
+
const contactFacts = computed(() => {
|
|
64
|
+
const contact = data.value?.contact;
|
|
65
|
+
if (!contact) return [];
|
|
66
|
+
return [
|
|
67
|
+
{ key: "name", label: t("contact.name", "Name"), value: contact.name ?? "\u2014" },
|
|
68
|
+
...can.value?.pii ? [
|
|
69
|
+
{ key: "email", label: t("contact.email", "Email"), value: contact.email ?? "\u2014" },
|
|
70
|
+
{ key: "phone", label: t("contact.phone", "Phone"), value: contact.phone ?? "\u2014" },
|
|
71
|
+
{ key: "externalId", label: t("contact.externalId", "Channel id"), value: contact.externalId ?? "\u2014" }
|
|
72
|
+
] : []
|
|
73
|
+
];
|
|
74
|
+
});
|
|
75
|
+
const auditColumns = computed(() => [
|
|
76
|
+
{ id: "action", header: t("audit.action", "What"), cell: ({ row }) => {
|
|
77
|
+
const label = t(`audit.actions.${row.original.action}`, INBOX_AUDIT_LABELS[row.original.action] ?? row.original.action);
|
|
78
|
+
const detail = row.original.action === "linked" && typeof row.original.data?.label === "string" ? row.original.data.label : null;
|
|
79
|
+
return detail ? `${label}: ${detail}` : label;
|
|
80
|
+
} },
|
|
81
|
+
{ id: "actor", header: t("audit.actor", "Who"), cell: ({ row }) => row.original.actor?.name ?? (row.original.actorId ? `#${row.original.actorId}` : t("audit.system", "System")) },
|
|
82
|
+
{ accessorKey: "createdAt", header: t("audit.when", "When"), cell: ({ row }) => h("span", { class: "tabular-nums text-muted" }, format.dateTime(row.original.createdAt)) }
|
|
83
|
+
]);
|
|
84
|
+
</script>
|
|
85
|
+
|
|
86
|
+
<template>
|
|
87
|
+
<div class="flex flex-col gap-4">
|
|
88
|
+
<template v-if="data && thread">
|
|
89
|
+
<PageHeading
|
|
90
|
+
:title="thread.subject || t('thread.noSubject', '(no subject)')"
|
|
91
|
+
:breadcrumb="[{ label: t('list.title', 'Inbox'), to: links.admin() }, { label: thread.subject || t('thread.noSubject', '(no subject)') }]"
|
|
92
|
+
>
|
|
93
|
+
<template #badge>
|
|
94
|
+
<StatusBadge
|
|
95
|
+
:status="thread.status"
|
|
96
|
+
:label="t(`status.${thread.status}`, INBOX_STATUS_LABELS[thread.status] ?? thread.status)"
|
|
97
|
+
:colors="statusColors"
|
|
98
|
+
/>
|
|
99
|
+
</template>
|
|
100
|
+
<template #actions>
|
|
101
|
+
<USelect
|
|
102
|
+
v-if="can?.reply"
|
|
103
|
+
:model-value="thread.status"
|
|
104
|
+
:items="statusItems"
|
|
105
|
+
:aria-label="t('list.status', 'Status')"
|
|
106
|
+
class="w-36"
|
|
107
|
+
@update:model-value="(value) => changeStatus(value)"
|
|
108
|
+
/>
|
|
109
|
+
<USelectMenu
|
|
110
|
+
v-if="can?.assign"
|
|
111
|
+
:model-value="thread.assigneeId === null ? 'none' : String(thread.assigneeId)"
|
|
112
|
+
:items="assigneeItems"
|
|
113
|
+
value-key="value"
|
|
114
|
+
icon="i-lucide-user-check"
|
|
115
|
+
:loading="assigneesStatus === 'pending'"
|
|
116
|
+
:search-input="{ placeholder: t('thread.assigneeSearch', 'Search people') }"
|
|
117
|
+
:aria-label="t('thread.assignTo', 'Assign thread')"
|
|
118
|
+
class="w-52"
|
|
119
|
+
data-assignee-picker
|
|
120
|
+
@update:open="onAssigneeOpen"
|
|
121
|
+
@update:model-value="(value) => changeAssignee(value)"
|
|
122
|
+
>
|
|
123
|
+
<template #empty>
|
|
124
|
+
{{ t("thread.assigneesEmpty", "Nobody else can read this thread") }}
|
|
125
|
+
</template>
|
|
126
|
+
</USelectMenu>
|
|
127
|
+
<RowMenu
|
|
128
|
+
variant="outline"
|
|
129
|
+
:subject="thread.subject ?? ''"
|
|
130
|
+
:items="actions.menu(thread, { open: false, onChanged: refreshAll, can: { reply: false, assign: can?.assign, hide: can?.hide }, hideRoles: data.hideRoles })"
|
|
131
|
+
/>
|
|
132
|
+
</template>
|
|
133
|
+
</PageHeading>
|
|
134
|
+
|
|
135
|
+
<div class="grid gap-4 lg:grid-cols-3">
|
|
136
|
+
<div class="flex flex-col gap-4 lg:col-span-2">
|
|
137
|
+
<SectionCard
|
|
138
|
+
:title="t('thread.conversation', 'Conversation')"
|
|
139
|
+
icon="i-lucide-messages-square"
|
|
140
|
+
>
|
|
141
|
+
<InboxConversation
|
|
142
|
+
:messages="data.messages"
|
|
143
|
+
:contact-name="contactName"
|
|
144
|
+
/>
|
|
145
|
+
</SectionCard>
|
|
146
|
+
<SectionCard
|
|
147
|
+
v-if="can?.reply"
|
|
148
|
+
:title="t('composer.title', 'Answer')"
|
|
149
|
+
icon="i-lucide-reply"
|
|
150
|
+
>
|
|
151
|
+
<InboxComposer
|
|
152
|
+
:thread="thread"
|
|
153
|
+
:disabled="!!data.contact?.erasedAt"
|
|
154
|
+
@sent="refreshAll"
|
|
155
|
+
/>
|
|
156
|
+
</SectionCard>
|
|
157
|
+
</div>
|
|
158
|
+
|
|
159
|
+
<div class="flex flex-col gap-4">
|
|
160
|
+
<SectionCard
|
|
161
|
+
:title="t('thread.details', 'Details')"
|
|
162
|
+
icon="i-lucide-info"
|
|
163
|
+
>
|
|
164
|
+
<DescriptionList :items="facts" />
|
|
165
|
+
</SectionCard>
|
|
166
|
+
<SectionCard
|
|
167
|
+
v-if="data.contact"
|
|
168
|
+
:title="t('contact.title', 'Contact')"
|
|
169
|
+
icon="i-lucide-user"
|
|
170
|
+
:description="can?.pii ? void 0 : t('contact.piiHidden', 'Contact details are only shown to people allowed to see them.')"
|
|
171
|
+
>
|
|
172
|
+
<DescriptionList :items="contactFacts" />
|
|
173
|
+
<p
|
|
174
|
+
v-if="data.contact.erasedAt"
|
|
175
|
+
class="mt-3 text-sm text-muted"
|
|
176
|
+
>
|
|
177
|
+
{{ t("contact.erasedOn", "Erased {date}", { date: format.dateTime(data.contact.erasedAt) }) }}
|
|
178
|
+
</p>
|
|
179
|
+
<div
|
|
180
|
+
v-else-if="can?.pii"
|
|
181
|
+
class="mt-3 flex flex-wrap gap-2"
|
|
182
|
+
>
|
|
183
|
+
<UButton
|
|
184
|
+
color="neutral"
|
|
185
|
+
variant="outline"
|
|
186
|
+
size="sm"
|
|
187
|
+
icon="i-lucide-download"
|
|
188
|
+
:label="t('contact.export', 'Export contact data')"
|
|
189
|
+
@click="actions.exportContact(data.contact)"
|
|
190
|
+
/>
|
|
191
|
+
<UButton
|
|
192
|
+
v-if="can?.erase"
|
|
193
|
+
color="error"
|
|
194
|
+
variant="outline"
|
|
195
|
+
size="sm"
|
|
196
|
+
icon="i-lucide-trash-2"
|
|
197
|
+
:label="t('contact.erase', 'Erase contact')"
|
|
198
|
+
@click="async () => {
|
|
199
|
+
if (data?.contact && await actions.eraseContact(data.contact)) await refreshAll();
|
|
200
|
+
}"
|
|
201
|
+
/>
|
|
202
|
+
</div>
|
|
203
|
+
<!-- Other modules' actions on the thread's person (crew's "Add to crew"): the `inbox.thread.actions` widget area (`extendWidgets` in a module). -->
|
|
204
|
+
<WidgetArea
|
|
205
|
+
v-if="!data.contact.erasedAt"
|
|
206
|
+
name="inbox.thread.actions"
|
|
207
|
+
:context="{ threadId: thread.id, contact: data.contact, onChanged: refreshAll }"
|
|
208
|
+
grid-class="mt-3 flex flex-wrap gap-2"
|
|
209
|
+
/>
|
|
210
|
+
</SectionCard>
|
|
211
|
+
<TableCard
|
|
212
|
+
v-if="can?.audit"
|
|
213
|
+
:title="t('audit.title', 'Activity')"
|
|
214
|
+
:loading="auditStatus === 'pending' && !audit?.items.length"
|
|
215
|
+
>
|
|
216
|
+
<UTable
|
|
217
|
+
:data="audit?.items ?? []"
|
|
218
|
+
:columns="auditColumns"
|
|
219
|
+
:ui="tableUi()"
|
|
220
|
+
/>
|
|
221
|
+
</TableCard>
|
|
222
|
+
</div>
|
|
223
|
+
</div>
|
|
224
|
+
</template>
|
|
225
|
+
|
|
226
|
+
<UEmpty
|
|
227
|
+
v-else-if="error"
|
|
228
|
+
:icon="notFound ? 'i-lucide-search-x' : forbidden ? 'i-lucide-lock' : 'i-lucide-circle-alert'"
|
|
229
|
+
:title="notFound ? t('thread.notFound', 'This thread does not exist') : forbidden ? t('list.forbidden', 'You do not have access to the inbox') : t('thread.loadFailed', 'The thread could not be loaded')"
|
|
230
|
+
:description="notFound || forbidden ? void 0 : errorMessage(error, '')"
|
|
231
|
+
:actions="[{ label: t('thread.backToInbox', 'Back to the inbox'), icon: 'i-lucide-arrow-left', color: 'neutral', variant: 'outline', onClick: () => navigateTo(links.admin() ?? '/') }]"
|
|
232
|
+
/>
|
|
233
|
+
</div>
|
|
234
|
+
</template>
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
declare const __VLS_export: import("vue").DefineComponent<{}, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<{}> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, true, {}, any>;
|
|
2
|
+
declare const _default: typeof __VLS_export;
|
|
3
|
+
export default _default;
|