memi-board 0.56.2 → 0.58.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 +55 -9
- package/dist/{ar-CQhBdHu3.js → ar-GNguZBN4.js} +45 -4
- package/dist/ar-GNguZBN4.js.map +1 -0
- package/dist/{commentImages-DsW2yCqu.js → commentImages-CRK_2uVi.js} +195 -70
- package/dist/commentImages-CRK_2uVi.js.map +1 -0
- package/dist/composables/useMemiBoardModeration.d.ts +2 -0
- package/dist/composables/useMemiBoardPosts.d.ts +1 -1
- package/dist/composables/useMemiBoardReports.d.ts +102 -3
- package/dist/composables/useMemiBoardUserDirectory.d.ts +20 -0
- package/dist/composables/useMemiBoardUserProfile.d.ts +1 -1
- package/dist/composables/useMemiBoardUsers.d.ts +1 -1
- package/dist/{de-B4GZqxQj.js → de-CS0iRLqe.js} +45 -4
- package/dist/de-CS0iRLqe.js.map +1 -0
- package/dist/{en-BDkfivhc.js → en-DeExi-DR.js} +129 -4
- package/dist/en-DeExi-DR.js.map +1 -0
- package/dist/{es-DzFDaLwo.js → es-dlEFrox-.js} +45 -4
- package/dist/es-dlEFrox-.js.map +1 -0
- package/dist/{fr-Zf5mcs8m.js → fr-B9sjKJF4.js} +45 -4
- package/dist/fr-B9sjKJF4.js.map +1 -0
- package/dist/{id-CaWN8212.js → id-Ca7skouh.js} +45 -4
- package/dist/id-Ca7skouh.js.map +1 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +1089 -829
- package/dist/index.js.map +1 -1
- package/dist/{ja-xDttH9CE.js → ja-ByVLGIDd.js} +45 -4
- package/dist/ja-ByVLGIDd.js.map +1 -0
- package/dist/module.mjs +4 -0
- package/dist/module.mjs.map +1 -1
- package/dist/{pt-WIfxYYWQ.js → pt-COQL_Q7A.js} +45 -4
- package/dist/pt-COQL_Q7A.js.map +1 -0
- package/dist/runtime/components/AccountDeletion.vue +64 -0
- package/dist/runtime/components/AuthorMenu.vue +4 -4
- package/dist/runtime/components/CommentFeed.vue +17 -13
- package/dist/runtime/components/CommentForm.vue +58 -56
- package/dist/runtime/components/CommentImageField.vue +18 -13
- package/dist/runtime/components/CommentItem.vue +95 -60
- package/dist/runtime/components/CommentList.vue +10 -1
- package/dist/runtime/components/CommentThread.vue +16 -2
- package/dist/runtime/components/CustomFieldEditor.vue +10 -8
- package/dist/runtime/components/Detail.vue +18 -10
- package/dist/runtime/components/Editor.vue +1 -5
- package/dist/runtime/components/ImageLightbox.vue +126 -58
- package/dist/runtime/components/LikeButton.vue +14 -11
- package/dist/runtime/components/ListViewSwitch.vue +10 -10
- package/dist/runtime/components/Profile.vue +14 -2
- package/dist/runtime/components/ProfileEditModal.vue +20 -3
- package/dist/runtime/components/ReportButton.vue +22 -13
- package/dist/runtime/components/ReportList.vue +77 -93
- package/dist/runtime/components/UserListControls.vue +29 -0
- package/dist/runtime/components/UserListPagination.vue +17 -0
- package/dist/runtime/components/UserManagementEmail.vue +21 -0
- package/dist/runtime/components/UserRoleGuide.vue +38 -0
- package/dist/runtime/components/Users.vue +21 -59
- package/dist/runtime/components/UsersSettings.vue +119 -0
- package/dist/storage.js +1 -1
- package/dist/types.d.ts +5 -0
- package/dist/utils/postSlug.d.ts +12 -0
- package/dist/utils/profileNameModeration.d.ts +8 -0
- package/dist/utils/userDirectoryPage.d.ts +19 -0
- package/dist/{zh-CI6Sd8PD.js → zh-DBjX9qAS.js} +45 -4
- package/dist/zh-DBjX9qAS.js.map +1 -0
- package/docs/account-deletion.md +60 -0
- package/docs/firebase-setup.md +77 -0
- package/docs/firestore.rules.example +78 -4
- package/docs/host-integration.md +85 -11
- package/docs/storage.rules.example +7 -2
- package/package.json +3 -2
- package/scripts/backfill-post-slugs.mjs +38 -0
- package/dist/ar-CQhBdHu3.js.map +0 -1
- package/dist/commentImages-DsW2yCqu.js.map +0 -1
- package/dist/de-B4GZqxQj.js.map +0 -1
- package/dist/en-BDkfivhc.js.map +0 -1
- package/dist/es-DzFDaLwo.js.map +0 -1
- package/dist/fr-Zf5mcs8m.js.map +0 -1
- package/dist/id-CaWN8212.js.map +0 -1
- package/dist/ja-xDttH9CE.js.map +0 -1
- package/dist/pt-WIfxYYWQ.js.map +0 -1
- package/dist/zh-CI6Sd8PD.js.map +0 -1
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import MemiBoardSurface from './BoardSurface.vue'
|
|
3
|
-
import { ref, resolveComponent } from 'vue'
|
|
3
|
+
import { computed, ref, resolveComponent, watch } from 'vue'
|
|
4
4
|
import {
|
|
5
|
+
imeSafeSubmitClick,
|
|
6
|
+
imeSafeSubmitPointerDown,
|
|
7
|
+
REPORT_REVIEW_NOTE_MAX_LENGTH,
|
|
5
8
|
reportReasonLabel,
|
|
6
9
|
useMemiBoardAuth,
|
|
7
10
|
useMemiBoardI18n,
|
|
@@ -13,116 +16,97 @@ const props = defineProps<{
|
|
|
13
16
|
boardId?: string
|
|
14
17
|
getPostLink?: (report: BoardReportModel) => string | undefined
|
|
15
18
|
}>()
|
|
16
|
-
|
|
17
19
|
const NuxtLink = resolveComponent('NuxtLink')
|
|
18
20
|
const { t, locale, formatRelativeDate } = useMemiBoardI18n()
|
|
19
21
|
const { canManageContent } = useMemiBoardAuth()
|
|
22
|
+
const selectedStatus = ref<'open' | 'processed'>('open')
|
|
20
23
|
const { reports, pending, loadingMore, hasMore, loadError, loadMore, dismissReport, actionReport } = useMemiBoardReportQueue({
|
|
21
|
-
boardId: () => props.boardId || '',
|
|
24
|
+
boardId: () => props.boardId || '', status: selectedStatus,
|
|
22
25
|
})
|
|
23
26
|
const now = ref(Date.now())
|
|
24
27
|
const actingId = ref<string | null>(null)
|
|
28
|
+
const selectedReport = ref<BoardReportModel | null>(null)
|
|
29
|
+
const selectedAction = ref<'dismiss' | 'action'>('dismiss')
|
|
30
|
+
const reviewNote = ref('')
|
|
31
|
+
const actionError = ref('')
|
|
32
|
+
const modalOpen = ref(false)
|
|
33
|
+
const modalTitle = computed(() => t(selectedAction.value === 'dismiss' ? 'reportList.dismissTitle' : 'reportList.resolveTitle'))
|
|
25
34
|
|
|
26
|
-
function postLink(report: BoardReportModel) {
|
|
27
|
-
|
|
35
|
+
function postLink(report: BoardReportModel) { return props.getPostLink?.(report) }
|
|
36
|
+
function openReview(report: BoardReportModel, action: 'dismiss' | 'action') {
|
|
37
|
+
selectedReport.value = report
|
|
38
|
+
selectedAction.value = action
|
|
39
|
+
reviewNote.value = ''
|
|
40
|
+
actionError.value = ''
|
|
41
|
+
modalOpen.value = true
|
|
28
42
|
}
|
|
29
|
-
|
|
30
|
-
async function handle(
|
|
31
|
-
|
|
43
|
+
watch(() => props.boardId, () => { if (!actingId.value) modalOpen.value = false })
|
|
44
|
+
async function handle() {
|
|
45
|
+
const report = selectedReport.value
|
|
46
|
+
if (!report?.id || actingId.value) return
|
|
47
|
+
if (!reviewNote.value.trim()) { actionError.value = t('reports.reviewNoteRequired'); return }
|
|
32
48
|
actingId.value = report.id
|
|
49
|
+
actionError.value = ''
|
|
33
50
|
try {
|
|
34
|
-
if (
|
|
35
|
-
else await actionReport(report)
|
|
51
|
+
if (selectedAction.value === 'dismiss') await dismissReport(report, reviewNote.value)
|
|
52
|
+
else await actionReport(report, reviewNote.value)
|
|
53
|
+
modalOpen.value = false
|
|
36
54
|
}
|
|
37
|
-
|
|
38
|
-
|
|
55
|
+
catch (cause) {
|
|
56
|
+
actionError.value = cause instanceof Error ? cause.message : t('reportList.actionFailed')
|
|
39
57
|
}
|
|
58
|
+
finally { actingId.value = null }
|
|
40
59
|
}
|
|
41
60
|
</script>
|
|
42
61
|
|
|
43
62
|
<template>
|
|
44
63
|
<MemiBoardSurface>
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
v-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
{{ t('reportList.staffOnly') }}
|
|
51
|
-
</p>
|
|
52
|
-
<template v-else-if="pending">
|
|
53
|
-
<USkeleton v-for="i in 4" :key="i" class="h-16 w-full" />
|
|
54
|
-
</template>
|
|
55
|
-
<p
|
|
56
|
-
v-else-if="loadError"
|
|
57
|
-
class="py-8 text-center text-sm text-error"
|
|
58
|
-
>
|
|
59
|
-
{{ t('reportList.loadFailed', { error: String(loadError) }) }}
|
|
60
|
-
</p>
|
|
61
|
-
<p
|
|
62
|
-
v-else-if="!reports.length"
|
|
63
|
-
class="py-8 text-center text-sm text-muted"
|
|
64
|
-
>
|
|
65
|
-
{{ t('reportList.empty') }}
|
|
66
|
-
</p>
|
|
67
|
-
<ul
|
|
68
|
-
v-else
|
|
69
|
-
class="flex flex-col divide-y divide-default overflow-hidden rounded-lg border border-default"
|
|
70
|
-
>
|
|
71
|
-
<li
|
|
72
|
-
v-for="report in reports"
|
|
73
|
-
:key="report.id"
|
|
74
|
-
class="flex flex-col gap-2 px-3 py-3 sm:flex-row sm:items-start sm:justify-between"
|
|
75
|
-
>
|
|
76
|
-
<div class="min-w-0 flex-1">
|
|
77
|
-
<component
|
|
78
|
-
:is="postLink(report) ? NuxtLink : 'p'"
|
|
79
|
-
:to="postLink(report)"
|
|
80
|
-
class="truncate text-sm font-medium text-highlighted"
|
|
81
|
-
:class="postLink(report) ? 'hover:underline' : ''"
|
|
82
|
-
>
|
|
83
|
-
{{ report.postTitle || t('reportList.untitled') }}
|
|
84
|
-
</component>
|
|
85
|
-
<p class="mt-0.5 text-xs text-muted">
|
|
86
|
-
{{ reportReasonLabel(report.reason, locale.value) }}
|
|
87
|
-
<span v-if="report.authorName"> · {{ t('reportList.author', { name: report.authorName }) }}</span>
|
|
88
|
-
· {{ formatRelativeDate(report.createdAt, now) }}
|
|
89
|
-
</p>
|
|
90
|
-
<p
|
|
91
|
-
v-if="report.detail"
|
|
92
|
-
class="mt-1 line-clamp-3 text-sm text-toned"
|
|
93
|
-
>
|
|
94
|
-
{{ report.detail }}
|
|
95
|
-
</p>
|
|
96
|
-
</div>
|
|
97
|
-
<div class="flex shrink-0 items-center gap-1">
|
|
98
|
-
<UButton
|
|
99
|
-
size="xs"
|
|
100
|
-
color="neutral"
|
|
101
|
-
variant="soft"
|
|
102
|
-
:label="t('reportList.dismiss')"
|
|
103
|
-
:loading="actingId === report.id"
|
|
104
|
-
@click="handle(report, 'dismiss')"
|
|
105
|
-
/>
|
|
106
|
-
<UButton
|
|
107
|
-
size="xs"
|
|
108
|
-
color="warning"
|
|
109
|
-
variant="soft"
|
|
110
|
-
:label="t('reportList.confirm')"
|
|
111
|
-
:loading="actingId === report.id"
|
|
112
|
-
@click="handle(report, 'action')"
|
|
113
|
-
/>
|
|
64
|
+
<div class="flex flex-col gap-3">
|
|
65
|
+
<p v-if="!canManageContent" class="py-8 text-center text-sm text-muted">{{ t('reportList.staffOnly') }}</p>
|
|
66
|
+
<template v-else>
|
|
67
|
+
<div class="flex flex-wrap gap-2" role="group" :aria-label="t('reportList.filterLabel')">
|
|
68
|
+
<UButton v-for="status in (['open', 'processed'] as const)" :key="status" :variant="selectedStatus === status ? 'solid' : 'outline'" :aria-pressed="selectedStatus === status" :label="t(`reportList.tabs.${status}`)" @click="selectedStatus = status" />
|
|
114
69
|
</div>
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
70
|
+
<p class="text-xs text-muted">{{ t('reportList.orderHint') }}</p>
|
|
71
|
+
<template v-if="pending"><USkeleton v-for="i in 4" :key="i" class="h-16 w-full" /></template>
|
|
72
|
+
<p v-else-if="loadError" role="alert" class="py-8 text-center text-sm text-error">{{ t('reportList.loadFailed', { error: String(loadError) }) }}</p>
|
|
73
|
+
<p v-else-if="!reports.length" class="py-8 text-center text-sm text-muted">{{ t(selectedStatus === 'open' ? 'reportList.empty' : 'reportList.historyEmpty') }}</p>
|
|
74
|
+
<ul v-else class="flex flex-col divide-y divide-default overflow-hidden rounded-lg border border-default">
|
|
75
|
+
<li v-for="report in reports" :key="report.id" class="flex flex-col gap-3 px-3 py-3 sm:flex-row sm:items-start sm:justify-between">
|
|
76
|
+
<div class="min-w-0 flex-1 space-y-2">
|
|
77
|
+
<component :is="postLink(report) ? NuxtLink : 'p'" :to="postLink(report)" class="block break-words text-sm font-medium text-highlighted" :class="postLink(report) ? 'hover:underline' : ''">{{ report.postTitle || t('reportList.untitled') }}</component>
|
|
78
|
+
<p class="text-xs text-muted">{{ reportReasonLabel(report.reason, locale) }}<span v-if="report.authorName"> · {{ t('reportList.author', { name: report.authorName }) }}</span> · {{ formatRelativeDate(report.createdAt, now) }}</p>
|
|
79
|
+
<p v-if="report.detail" class="whitespace-pre-wrap break-words text-sm text-toned">{{ report.detail }}</p>
|
|
80
|
+
<template v-if="report.status !== 'open'">
|
|
81
|
+
<UBadge :color="report.status === 'dismissed' ? 'neutral' : 'success'" variant="subtle" :label="t(`reportButton.status.${report.status}`)" />
|
|
82
|
+
<p class="text-xs text-muted">{{ t('reportList.reviewer') }}: <span :title="report.reviewedBy">{{ report.reviewedByName || report.reviewedBy || t('reportList.unknownReviewer') }}</span><span v-if="report.reviewedAt"> · {{ formatRelativeDate(report.reviewedAt, now) }}</span></p>
|
|
83
|
+
<p class="whitespace-pre-wrap break-words text-sm text-toned">{{ t('reportList.reviewNote') }}: {{ report.reviewNote || t('reportButton.noNote') }}</p>
|
|
84
|
+
</template>
|
|
85
|
+
</div>
|
|
86
|
+
<div v-if="report.status === 'open'" class="flex shrink-0 flex-wrap items-center gap-2">
|
|
87
|
+
<UButton size="sm" color="neutral" variant="soft" :label="t('reportList.dismiss')" :disabled="!!actingId" @click="openReview(report, 'dismiss')" />
|
|
88
|
+
<UButton size="sm" color="warning" variant="soft" :label="t('reportList.confirm')" :disabled="!!actingId" @click="openReview(report, 'action')" />
|
|
89
|
+
</div>
|
|
90
|
+
</li>
|
|
91
|
+
</ul>
|
|
92
|
+
<UButton v-if="!pending && !loadError && hasMore" color="neutral" variant="outline" :label="t('common.action.more')" block :loading="loadingMore" @click="loadMore" />
|
|
93
|
+
</template>
|
|
94
|
+
</div>
|
|
95
|
+
<UModal v-model:open="modalOpen" :title="modalTitle" :dismissible="!actingId" :close="actingId ? false : undefined">
|
|
96
|
+
<template #body>
|
|
97
|
+
<form class="space-y-4" @submit.prevent="handle">
|
|
98
|
+
<p class="break-words text-sm font-medium text-highlighted">{{ selectedReport?.postTitle || t('reportList.untitled') }}</p>
|
|
99
|
+
<p class="text-sm text-muted">{{ t('reportList.actionHint') }}</p>
|
|
100
|
+
<UFormField :label="t('reportList.reviewNote')" :description="t('reportList.publicNote')" required>
|
|
101
|
+
<UTextarea v-model="reviewNote" required :maxlength="REPORT_REVIEW_NOTE_MAX_LENGTH" :rows="3" :disabled="!!actingId" class="w-full" />
|
|
102
|
+
</UFormField>
|
|
103
|
+
<p v-if="actionError" role="alert" class="text-sm text-error">{{ actionError }}</p>
|
|
104
|
+
<div class="flex flex-wrap justify-end gap-2">
|
|
105
|
+
<UButton type="button" color="neutral" variant="outline" :disabled="!!actingId" :label="t('common.action.cancel')" @click="modalOpen = false" />
|
|
106
|
+
<UButton type="submit" :loading="!!actingId" :label="modalTitle" @pointerdown="imeSafeSubmitPointerDown" @click="imeSafeSubmitClick" />
|
|
107
|
+
</div>
|
|
108
|
+
</form>
|
|
109
|
+
</template>
|
|
110
|
+
</UModal>
|
|
127
111
|
</MemiBoardSurface>
|
|
128
112
|
</template>
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { useMemiBoardI18n } from 'memi-board/runtime'
|
|
4
|
+
import type { UserDirectorySort, UserDirectoryDirection } from 'memi-board/runtime'
|
|
5
|
+
|
|
6
|
+
const sort = defineModel<UserDirectorySort>('sort', { required: true })
|
|
7
|
+
const direction = defineModel<UserDirectoryDirection>('direction', { required: true })
|
|
8
|
+
const pageSize = defineModel<number>('pageSize', { required: true })
|
|
9
|
+
defineProps<{ disabled?: boolean }>()
|
|
10
|
+
const { t, formatNumber } = useMemiBoardI18n()
|
|
11
|
+
const sortItems = computed(() => [
|
|
12
|
+
{ label: t('users.sort.name'), value: 'name' },
|
|
13
|
+
{ label: t('users.sort.role'), value: 'role' },
|
|
14
|
+
])
|
|
15
|
+
const directionItems = computed(() => [
|
|
16
|
+
{ label: t('users.sort.asc'), value: 'asc' },
|
|
17
|
+
{ label: t('users.sort.desc'), value: 'desc' },
|
|
18
|
+
])
|
|
19
|
+
const sizeItems = computed(() => [10, 25, 50].map(value => ({ label: t('users.pagination.perPage', { count: formatNumber(value) }), value })))
|
|
20
|
+
</script>
|
|
21
|
+
|
|
22
|
+
<template>
|
|
23
|
+
<div class="flex flex-wrap items-center gap-2">
|
|
24
|
+
<UIcon name="i-lucide-arrow-up-down" class="size-4 shrink-0 text-muted" />
|
|
25
|
+
<USelect v-model="sort" :items="sortItems" :aria-label="t('users.sort.label')" :disabled="disabled" class="min-w-28" />
|
|
26
|
+
<USelect v-model="direction" :items="directionItems" :aria-label="t('users.sort.direction')" :disabled="disabled" class="min-w-28" />
|
|
27
|
+
<USelect v-model="pageSize" :items="sizeItems" :aria-label="t('users.pagination.pageSize')" :disabled="disabled" class="min-w-32 sm:ml-auto" />
|
|
28
|
+
</div>
|
|
29
|
+
</template>
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { useMemiBoardI18n } from 'memi-board/runtime'
|
|
3
|
+
|
|
4
|
+
defineProps<{ page: number; count: number; hasNext: boolean; pending: boolean }>()
|
|
5
|
+
defineEmits<{ previous: []; next: [] }>()
|
|
6
|
+
const { t, formatNumber } = useMemiBoardI18n()
|
|
7
|
+
</script>
|
|
8
|
+
|
|
9
|
+
<template>
|
|
10
|
+
<nav class="flex flex-wrap items-center justify-between gap-3" :aria-label="t('users.pagination.label')">
|
|
11
|
+
<p aria-live="polite" class="text-sm text-muted">{{ t('users.pagination.status', { page: formatNumber(page), count: formatNumber(count) }) }}</p>
|
|
12
|
+
<div class="flex items-center gap-2">
|
|
13
|
+
<UButton icon="i-lucide-chevron-left" color="neutral" variant="outline" :label="t('common.action.prev')" :disabled="pending || page <= 1" @click="$emit('previous')" />
|
|
14
|
+
<UButton trailing-icon="i-lucide-chevron-right" color="neutral" variant="outline" :label="t('common.action.next')" :disabled="pending || !hasNext" @click="$emit('next')" />
|
|
15
|
+
</div>
|
|
16
|
+
</nav>
|
|
17
|
+
</template>
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { computed } from 'vue'
|
|
3
|
+
import { doc } from 'firebase/firestore'
|
|
4
|
+
import { useDocument, useFirestore } from 'vuefire'
|
|
5
|
+
import { useBoardPathConfig, useMemiBoardI18n } from 'memi-board/runtime'
|
|
6
|
+
import type { BoardUserPrivateModel } from 'memi-board/runtime'
|
|
7
|
+
|
|
8
|
+
const props = defineProps<{ uid: string; authorized: boolean }>()
|
|
9
|
+
const db = useFirestore()
|
|
10
|
+
const { t } = useMemiBoardI18n()
|
|
11
|
+
const privateRef = computed(() => props.authorized && props.uid
|
|
12
|
+
? doc(db, useBoardPathConfig().usersCollection, props.uid, 'private', 'info')
|
|
13
|
+
: null)
|
|
14
|
+
const { data: info, pending, error } = useDocument<BoardUserPrivateModel>(privateRef)
|
|
15
|
+
</script>
|
|
16
|
+
|
|
17
|
+
<template>
|
|
18
|
+
<p class="truncate text-sm text-muted">
|
|
19
|
+
{{ pending ? t('common.label.loading') : error ? t('users.emailLoadFailed') : info?.email || t('users.noEmail') }}
|
|
20
|
+
</p>
|
|
21
|
+
</template>
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import { BOARD_USER_ROLES, useMemiBoardI18n } from 'memi-board/runtime'
|
|
3
|
+
|
|
4
|
+
const { t } = useMemiBoardI18n()
|
|
5
|
+
const appearance = {
|
|
6
|
+
owner: { icon: 'i-lucide-crown', color: 'text-amber-500 dark:text-amber-400', badge: 'border-amber-500/30 bg-amber-500/10' },
|
|
7
|
+
admin: { icon: 'i-lucide-shield-check', color: 'text-teal-600 dark:text-teal-400', badge: 'border-teal-500/30 bg-teal-500/10' },
|
|
8
|
+
manager: { icon: 'i-lucide-user-cog', color: 'text-blue-500 dark:text-blue-400', badge: 'border-blue-500/30 bg-blue-500/10' },
|
|
9
|
+
staff: { icon: 'i-lucide-user-check', color: 'text-green-600 dark:text-green-400', badge: 'border-green-500/30 bg-green-500/10' },
|
|
10
|
+
user: { icon: 'i-lucide-user-round', color: 'text-muted', badge: 'border-default bg-elevated' },
|
|
11
|
+
}
|
|
12
|
+
</script>
|
|
13
|
+
|
|
14
|
+
<template>
|
|
15
|
+
<details class="group overflow-hidden rounded-xl border border-default bg-muted/30">
|
|
16
|
+
<summary class="flex cursor-pointer list-none items-center gap-3 px-4 py-4 select-none focus-visible:outline-2 focus-visible:outline-offset-[-2px] focus-visible:outline-primary sm:px-5 [&::-webkit-details-marker]:hidden">
|
|
17
|
+
<UIcon name="i-lucide-info" class="size-5 shrink-0 text-teal-500" />
|
|
18
|
+
<span class="flex-1 font-semibold text-highlighted">{{ t('boardUsers.guide.title') }}</span>
|
|
19
|
+
<UIcon name="i-lucide-chevron-down" class="size-5 shrink-0 text-muted transition-transform group-open:rotate-180" />
|
|
20
|
+
</summary>
|
|
21
|
+
<div class="grid gap-3 border-t border-default p-4 sm:grid-cols-2 sm:p-5 xl:grid-cols-5">
|
|
22
|
+
<article v-for="item in BOARD_USER_ROLES" :key="item.value" class="rounded-lg border border-default bg-default p-4">
|
|
23
|
+
<div class="mb-4 flex items-center gap-2.5" :class="appearance[item.value].color">
|
|
24
|
+
<UIcon :name="appearance[item.value].icon" class="size-6 shrink-0" />
|
|
25
|
+
<h3 class="rounded-md border px-2 py-1 text-sm font-medium" :class="appearance[item.value].badge">
|
|
26
|
+
{{ t(`common.role.${item.value}`) }}
|
|
27
|
+
</h3>
|
|
28
|
+
</div>
|
|
29
|
+
<ul class="space-y-2.5 pl-4 text-sm leading-6 text-muted list-disc marker:text-dimmed">
|
|
30
|
+
<li v-for="point in ['permissions', 'roles', 'restriction']" :key="point">
|
|
31
|
+
{{ t(`boardUsers.guide.${item.value}.${point}`) }}
|
|
32
|
+
</li>
|
|
33
|
+
</ul>
|
|
34
|
+
</article>
|
|
35
|
+
</div>
|
|
36
|
+
<p class="border-t border-default px-4 py-4 text-sm leading-6 text-muted sm:px-5">{{ t('boardUsers.guide.assignmentNote') }}</p>
|
|
37
|
+
</details>
|
|
38
|
+
</template>
|
|
@@ -1,73 +1,35 @@
|
|
|
1
1
|
<script setup lang="ts">
|
|
2
2
|
import MemiBoardSurface from './BoardSurface.vue'
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
3
|
+
import UserListControls from './UserListControls.vue'
|
|
4
|
+
import UserListPagination from './UserListPagination.vue'
|
|
5
|
+
import { useMemiBoardI18n, useMemiBoardUserDirectory } from 'memi-board/runtime'
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
const {
|
|
9
|
-
const
|
|
10
|
-
const { users, usersPending, updateUserRole } = useMemiBoardUsers({ enabled: canManage })
|
|
11
|
-
const { t, formatNumber } = useMemiBoardI18n()
|
|
12
|
-
const roleItems = computed(() => BOARD_USER_ROLES.map(item => ({
|
|
13
|
-
...item,
|
|
14
|
-
label: t(`common.role.${item.value}`),
|
|
15
|
-
description: t(`boardUsers.roleDescription.${item.value}`),
|
|
16
|
-
})))
|
|
17
|
-
const assignableRoles = computed(() => roleItems.value.filter(item => isOwner.value ? item.value !== 'owner' : !['owner', 'admin'].includes(item.value)))
|
|
18
|
-
const savingUid = ref<string | null>(null)
|
|
19
|
-
const savedUid = ref<string | null>(null)
|
|
20
|
-
const error = ref('')
|
|
21
|
-
|
|
22
|
-
async function changeRole(uid: string, role: BoardUserRole) {
|
|
23
|
-
if (!canManage.value) return
|
|
24
|
-
savingUid.value = uid
|
|
25
|
-
savedUid.value = null
|
|
26
|
-
error.value = ''
|
|
27
|
-
try {
|
|
28
|
-
await updateUserRole(uid, role)
|
|
29
|
-
savedUid.value = uid
|
|
30
|
-
}
|
|
31
|
-
catch (cause) {
|
|
32
|
-
error.value = cause instanceof Error ? cause.message : t('users.changeRoleFailed')
|
|
33
|
-
}
|
|
34
|
-
finally {
|
|
35
|
-
savingUid.value = null
|
|
36
|
-
}
|
|
37
|
-
}
|
|
7
|
+
defineProps<{ authorProfileTo?: (uid: string) => string }>()
|
|
8
|
+
const { users, usersPending, loadError, sort, direction, pageSize, page, hasNext, previousPage, nextPage, refresh } = useMemiBoardUserDirectory()
|
|
9
|
+
const { t } = useMemiBoardI18n()
|
|
38
10
|
</script>
|
|
39
11
|
|
|
40
12
|
<template>
|
|
41
13
|
<MemiBoardSurface>
|
|
42
|
-
|
|
43
|
-
<div class="
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
<div v-if="rolePending || usersPending" class="py-12 text-center text-sm text-muted">{{ t('users.loading') }}</div>
|
|
48
|
-
<UAlert v-else-if="!canManage" color="error" variant="subtle" icon="i-lucide-shield-alert" :title="t('users.noPermission.title')" :description="t('users.noPermission.description')" />
|
|
14
|
+
<UserListControls v-model:sort="sort" v-model:direction="direction" v-model:page-size="pageSize" />
|
|
15
|
+
<div v-if="usersPending" class="py-12 text-center text-sm text-muted">{{ t('users.loading') }}</div>
|
|
16
|
+
<UAlert v-else-if="loadError" color="error" variant="subtle" :description="t('users.loadFailed')">
|
|
17
|
+
<template #actions><UButton color="neutral" variant="outline" :label="t('common.action.retry')" @click="refresh()" /></template>
|
|
18
|
+
</UAlert>
|
|
49
19
|
<div v-else-if="users.length === 0" class="py-12 text-center text-sm text-muted">{{ t('users.empty') }}</div>
|
|
50
20
|
<div v-else class="divide-y divide-default rounded-lg border border-default">
|
|
51
|
-
<div v-for="boardUser in users" :key="boardUser.id" class="
|
|
52
|
-
<
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
</
|
|
57
|
-
<p class="truncate
|
|
58
|
-
<p v-if="boardUser.
|
|
21
|
+
<div v-for="boardUser in users" :key="boardUser.id" class="flex items-center gap-3 p-4">
|
|
22
|
+
<UAvatar :src="boardUser.photoURL || undefined" :alt="boardUser.displayName || t('users.noName')" />
|
|
23
|
+
<div class="min-w-0 flex-1">
|
|
24
|
+
<ULink v-if="authorProfileTo" :to="authorProfileTo(boardUser.id)" class="block truncate font-medium text-highlighted">
|
|
25
|
+
{{ boardUser.displayName || t('users.noName') }}
|
|
26
|
+
</ULink>
|
|
27
|
+
<p v-else class="truncate font-medium text-highlighted">{{ boardUser.displayName || t('users.noName') }}</p>
|
|
28
|
+
<p v-if="boardUser.bio" class="truncate text-sm text-muted">{{ boardUser.bio }}</p>
|
|
59
29
|
</div>
|
|
60
|
-
<
|
|
61
|
-
:model-value="boardUser.role || 'user'"
|
|
62
|
-
:items="boardUser.role === 'owner' || (!isOwner && boardUser.role === 'admin') ? roleItems : assignableRoles"
|
|
63
|
-
value-key="value"
|
|
64
|
-
label-key="label"
|
|
65
|
-
:loading="savingUid === boardUser.id"
|
|
66
|
-
:disabled="savingUid === boardUser.id || boardUser.id === user?.uid || boardUser.role === 'owner' || (!isOwner && boardUser.role === 'admin')"
|
|
67
|
-
@update:model-value="changeRole(boardUser.id, $event as BoardUserRole)"
|
|
68
|
-
/>
|
|
30
|
+
<UBadge color="neutral" variant="subtle" :label="t(`common.role.${boardUser.role || 'user'}`)" />
|
|
69
31
|
</div>
|
|
70
32
|
</div>
|
|
71
|
-
|
|
33
|
+
<UserListPagination :page="page" :count="users.length" :has-next="hasNext" :pending="usersPending" @previous="previousPage" @next="nextPage" />
|
|
72
34
|
</MemiBoardSurface>
|
|
73
35
|
</template>
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
<script setup lang="ts">
|
|
2
|
+
import MemiBoardSurface from './BoardSurface.vue'
|
|
3
|
+
import UserManagementEmail from './UserManagementEmail.vue'
|
|
4
|
+
import UserRoleGuide from './UserRoleGuide.vue'
|
|
5
|
+
import UserListControls from './UserListControls.vue'
|
|
6
|
+
import UserListPagination from './UserListPagination.vue'
|
|
7
|
+
import { computed, ref, watch } from 'vue'
|
|
8
|
+
import { BOARD_USER_ROLES, useMemiBoardAuth, useMemiBoardI18n, useMemiBoardUserDirectory } from 'memi-board/runtime'
|
|
9
|
+
import type { BoardUserModel, BoardUserRole } from 'memi-board/runtime'
|
|
10
|
+
|
|
11
|
+
const props = withDefaults(defineProps<{ authorized?: boolean }>(), { authorized: false })
|
|
12
|
+
const { isAdmin, isOwner, user, rolePending } = useMemiBoardAuth()
|
|
13
|
+
const canManage = computed(() => isAdmin.value || props.authorized)
|
|
14
|
+
const { users, usersPending, updateUserRole, loadError, sort, direction, pageSize, page, hasNext, previousPage, nextPage, refresh } = useMemiBoardUserDirectory({ enabled: canManage })
|
|
15
|
+
const { t, formatNumber } = useMemiBoardI18n()
|
|
16
|
+
const roleItems = computed(() => BOARD_USER_ROLES.map(item => ({
|
|
17
|
+
...item,
|
|
18
|
+
label: t(`common.role.${item.value}`),
|
|
19
|
+
description: t(`boardUsers.roleDescription.${item.value}`),
|
|
20
|
+
})))
|
|
21
|
+
const assignableRoles = computed(() => roleItems.value.filter(item => isOwner.value ? item.value !== 'owner' : !['owner', 'admin'].includes(item.value)))
|
|
22
|
+
const savingUid = ref<string | null>(null)
|
|
23
|
+
const savedUid = ref<string | null>(null)
|
|
24
|
+
const error = ref('')
|
|
25
|
+
const confirmOpen = ref(false)
|
|
26
|
+
const pendingChange = ref<{ uid: string; name: string; from: BoardUserRole; to: BoardUserRole } | null>(null)
|
|
27
|
+
const confirmDescription = computed(() => pendingChange.value ? t('users.confirmRole.description', {
|
|
28
|
+
name: pendingChange.value.name,
|
|
29
|
+
from: t(`common.role.${pendingChange.value.from}`),
|
|
30
|
+
to: t(`common.role.${pendingChange.value.to}`),
|
|
31
|
+
}) : '')
|
|
32
|
+
|
|
33
|
+
watch(confirmOpen, open => {
|
|
34
|
+
if (!open) {
|
|
35
|
+
pendingChange.value = null
|
|
36
|
+
error.value = ''
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
|
|
40
|
+
function requestRoleChange(target: BoardUserModel, role: BoardUserRole) {
|
|
41
|
+
if (!canManage.value || savingUid.value || target.id === user.value?.uid || target.role === 'owner'
|
|
42
|
+
|| (!isOwner.value && target.role === 'admin') || (target.role || 'user') === role
|
|
43
|
+
|| !assignableRoles.value.some(item => item.value === role)) return
|
|
44
|
+
pendingChange.value = { uid: target.id, name: target.displayName || t('users.noName'), from: target.role || 'user', to: role }
|
|
45
|
+
error.value = ''
|
|
46
|
+
confirmOpen.value = true
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
async function confirmRoleChange() {
|
|
50
|
+
const change = pendingChange.value
|
|
51
|
+
if (!confirmOpen.value || !change || !canManage.value || savingUid.value
|
|
52
|
+
|| change.uid === user.value?.uid || (!isOwner.value && change.from === 'admin')
|
|
53
|
+
|| !assignableRoles.value.some(item => item.value === change.to)) return
|
|
54
|
+
const { uid, to: role } = change
|
|
55
|
+
savingUid.value = uid
|
|
56
|
+
savedUid.value = null
|
|
57
|
+
error.value = ''
|
|
58
|
+
try {
|
|
59
|
+
await updateUserRole(uid, role)
|
|
60
|
+
savedUid.value = uid
|
|
61
|
+
confirmOpen.value = false
|
|
62
|
+
}
|
|
63
|
+
catch (cause) {
|
|
64
|
+
error.value = cause instanceof Error ? cause.message : t('users.changeRoleFailed')
|
|
65
|
+
}
|
|
66
|
+
finally {
|
|
67
|
+
savingUid.value = null
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
</script>
|
|
71
|
+
|
|
72
|
+
<template>
|
|
73
|
+
<MemiBoardSurface>
|
|
74
|
+
<div class="flex flex-col gap-6">
|
|
75
|
+
<UserRoleGuide />
|
|
76
|
+
<UserListControls v-if="canManage" v-model:sort="sort" v-model:direction="direction" v-model:page-size="pageSize" :disabled="!!savingUid" />
|
|
77
|
+
<div v-if="rolePending || usersPending" class="py-12 text-center text-sm text-muted">{{ t('users.loading') }}</div>
|
|
78
|
+
<UAlert v-else-if="!canManage" color="error" variant="subtle" icon="i-lucide-shield-alert" :title="t('users.noPermission.title')" :description="t('users.noPermission.description')" />
|
|
79
|
+
<UAlert v-else-if="loadError" color="error" variant="subtle" :description="t('users.loadFailed')">
|
|
80
|
+
<template #actions><UButton color="neutral" variant="outline" :label="t('common.action.retry')" @click="refresh()" /></template>
|
|
81
|
+
</UAlert>
|
|
82
|
+
<div v-else-if="users.length === 0" class="py-12 text-center text-sm text-muted">{{ t('users.empty') }}</div>
|
|
83
|
+
<div v-else class="divide-y divide-default rounded-lg border border-default">
|
|
84
|
+
<div v-for="boardUser in users" :key="boardUser.id" class="grid gap-4 p-4 md:grid-cols-[minmax(0,1fr)_12rem] md:items-center">
|
|
85
|
+
<div class="min-w-0">
|
|
86
|
+
<div class="flex items-center gap-2">
|
|
87
|
+
<p class="truncate font-medium text-highlighted">{{ boardUser.displayName || t('users.noName') }}</p>
|
|
88
|
+
<UBadge v-if="savedUid === boardUser.id" color="success" variant="subtle" :label="t('common.action.saved')" />
|
|
89
|
+
</div>
|
|
90
|
+
<UserManagementEmail :uid="boardUser.id" :authorized="canManage" />
|
|
91
|
+
<p v-if="boardUser.moderationBlockCount" class="mt-1 text-xs text-warning">{{ t('users.moderationWarnings', { count: formatNumber(boardUser.moderationBlockCount) }) }}</p>
|
|
92
|
+
</div>
|
|
93
|
+
<USelect
|
|
94
|
+
:model-value="boardUser.role || 'user'"
|
|
95
|
+
:items="boardUser.role === 'owner' || (!isOwner && boardUser.role === 'admin') ? roleItems : assignableRoles"
|
|
96
|
+
value-key="value"
|
|
97
|
+
label-key="label"
|
|
98
|
+
:loading="savingUid === boardUser.id"
|
|
99
|
+
:disabled="!!savingUid || boardUser.id === user?.uid || boardUser.role === 'owner' || (!isOwner && boardUser.role === 'admin')"
|
|
100
|
+
@update:model-value="requestRoleChange(boardUser, $event as BoardUserRole)"
|
|
101
|
+
/>
|
|
102
|
+
</div>
|
|
103
|
+
</div>
|
|
104
|
+
<UserListPagination v-if="canManage" :page="page" :count="users.length" :has-next="hasNext" :pending="usersPending || !!savingUid" @previous="previousPage" @next="nextPage" />
|
|
105
|
+
</div>
|
|
106
|
+
<UModal v-model:open="confirmOpen" :title="t('users.confirmRole.title')" :description="confirmDescription" :dismissible="!savingUid" :close="!savingUid">
|
|
107
|
+
<template #body>
|
|
108
|
+
<UserManagementEmail v-if="pendingChange" :uid="pendingChange.uid" :authorized="canManage" />
|
|
109
|
+
<UAlert v-if="error" class="mt-3" color="error" variant="subtle" icon="i-lucide-circle-alert" :description="error" />
|
|
110
|
+
</template>
|
|
111
|
+
<template #footer>
|
|
112
|
+
<div class="flex w-full justify-end gap-2">
|
|
113
|
+
<UButton color="neutral" variant="outline" :label="t('common.action.cancel')" :disabled="!!savingUid" @click="confirmOpen = false" />
|
|
114
|
+
<UButton :label="t('users.confirmRole.confirm')" :loading="!!savingUid" :disabled="!canManage" @click="confirmRoleChange" />
|
|
115
|
+
</div>
|
|
116
|
+
</template>
|
|
117
|
+
</UModal>
|
|
118
|
+
</MemiBoardSurface>
|
|
119
|
+
</template>
|
package/dist/storage.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { G as e, T as t, a as n, c as r, h as i, n as a } from "./commentImages-
|
|
1
|
+
import { G as e, T as t, a as n, c as r, h as i, n as a } from "./commentImages-CRK_2uVi.js";
|
|
2
2
|
import { useFirebaseApp as o } from "vuefire";
|
|
3
3
|
import { getAuth as s } from "firebase/auth";
|
|
4
4
|
import { deleteObject as c, getDownloadURL as l, getStorage as u, ref as d, uploadBytes as f, uploadBytesResumable as p } from "firebase/storage";
|
package/dist/types.d.ts
CHANGED
|
@@ -175,6 +175,8 @@ export type BoardUserRole = 'owner' | 'admin' | 'manager' | 'staff' | 'user';
|
|
|
175
175
|
/** memiBoardUsers/{uid} — 이메일만 빼고 전부 공개 프로필 정보다(누구나 읽을 수 있음). */
|
|
176
176
|
export interface BoardUserModel {
|
|
177
177
|
id: string;
|
|
178
|
+
/** 서버 탈퇴 처리 중 또는 개인정보 없는 탈퇴 표식. 클라이언트는 수정할 수 없다. */
|
|
179
|
+
deletionPending?: boolean;
|
|
178
180
|
role: BoardUserRole;
|
|
179
181
|
displayName?: string | null;
|
|
180
182
|
photoURL?: string | null;
|
|
@@ -335,6 +337,9 @@ export interface BoardReportModel {
|
|
|
335
337
|
authorName?: string | null;
|
|
336
338
|
reviewedAt?: Timestamp;
|
|
337
339
|
reviewedBy?: string;
|
|
340
|
+
reviewedByName?: string | null;
|
|
341
|
+
/** 신고자에게도 공개되는 처리 사유. */
|
|
342
|
+
reviewNote?: string;
|
|
338
343
|
}
|
|
339
344
|
export type BoardLikeTarget = 'post' | 'comment';
|
|
340
345
|
/** memiBoardLikes/{targetId}_{uid} — 글·댓글 좋아요. 문서ID의 targetId 는 postId 또는 commentId. */
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Firestore, Transaction } from 'firebase/firestore';
|
|
2
|
+
import { BoardPathConfig } from './boardPaths';
|
|
3
|
+
/** Keep room for numeric suffixes within Firestore's 1,500-byte document ID limit. */
|
|
4
|
+
export declare function postSlugBase(slug: string): string;
|
|
5
|
+
export declare function postSlugRef(db: Firestore, cfg: BoardPathConfig, boardId: string, slug: string): import('firebase/firestore').DocumentReference<import('firebase/firestore').DocumentData, import('firebase/firestore').DocumentData>;
|
|
6
|
+
export declare function postSlugMigrationRef(db: Firestore, cfg: BoardPathConfig): import('firebase/firestore').DocumentReference<import('firebase/firestore').DocumentData, import('firebase/firestore').DocumentData>;
|
|
7
|
+
/** Advisory only: the final reservation must be committed with the new post. */
|
|
8
|
+
export declare function availablePostSlug(db: Firestore, cfg: BoardPathConfig, boardId: string, base: string): Promise<string>;
|
|
9
|
+
/** The callback atomically claims a candidate, or returns false when already occupied. */
|
|
10
|
+
export declare function choosePostSlug(base: string, claim: (slug: string) => Promise<boolean>): Promise<string>;
|
|
11
|
+
/** Reservation, metadata and body either all commit, or none do. Retries cannot overwrite a post. */
|
|
12
|
+
export declare function createPostWithSlug(db: Firestore, cfg: BoardPathConfig, boardId: string, postId: string, base: string, write: (transaction: Transaction, slug: string) => void): Promise<string>;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/** Usernames are untrusted data, never instructions for the reviewer. */
|
|
2
|
+
export declare function buildProfileNameModerationPrompt(language: string): string;
|
|
3
|
+
/** A missing, contradictory, or malformed verdict is never an approval. */
|
|
4
|
+
export declare function parseProfileNameModerationJson(raw: string): {
|
|
5
|
+
flagged: boolean;
|
|
6
|
+
category: 'none' | 'abuse' | 'spam' | 'adult' | 'violence' | 'other';
|
|
7
|
+
reason: string;
|
|
8
|
+
} | null;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export type UserDirectorySort = 'name' | 'role';
|
|
2
|
+
export type UserDirectoryDirection = 'asc' | 'desc';
|
|
3
|
+
export interface UserDirectoryCursor<T> {
|
|
4
|
+
document: T;
|
|
5
|
+
roleIndex: number;
|
|
6
|
+
}
|
|
7
|
+
export declare const USER_DIRECTORY_ROLES: readonly ["owner", "admin", "manager", "staff", "user"];
|
|
8
|
+
/** Fetch one bounded page, including a lookahead across role boundaries. */
|
|
9
|
+
export declare function readUserDirectoryPage<T>(options: {
|
|
10
|
+
sort: UserDirectorySort;
|
|
11
|
+
direction: UserDirectoryDirection;
|
|
12
|
+
pageSize: number;
|
|
13
|
+
cursor: UserDirectoryCursor<T> | null;
|
|
14
|
+
readBatch: (role: typeof USER_DIRECTORY_ROLES[number] | null, after: T | null, count: number) => Promise<T[]>;
|
|
15
|
+
}): Promise<{
|
|
16
|
+
documents: T[];
|
|
17
|
+
cursor: UserDirectoryCursor<T> | null;
|
|
18
|
+
hasNext: boolean;
|
|
19
|
+
}>;
|