Skip to content

Commit e3998c0

Browse files
committed
fix: flag badges + auto open first issue in file tab
1 parent efe9eb1 commit e3998c0

File tree

2 files changed

+72
-8
lines changed

2 files changed

+72
-8
lines changed

apps/frontend/src/components/ui/moderation/ModerationTechRevCard.vue

Lines changed: 69 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,65 @@ import type { Labrinth } from '@modrinth/api-client'
33
import {
44
CheckIcon,
55
ChevronDownIcon,
6+
ClipboardCopyIcon,
67
CopyIcon,
78
DownloadIcon,
8-
MoreVerticalIcon,
9+
EllipsisVerticalIcon,
10+
LinkIcon,
911
ShieldCheckIcon,
1012
TriangleAlertIcon,
1113
} from '@modrinth/assets'
12-
import { Avatar, ButtonStyled, getProjectTypeIcon, injectModrinthClient } from '@modrinth/ui'
14+
import {
15+
Avatar,
16+
ButtonStyled,
17+
getProjectTypeIcon,
18+
injectModrinthClient,
19+
injectNotificationManager,
20+
OverflowMenu,
21+
type OverflowMenuOption,
22+
} from '@modrinth/ui'
1323
import { capitalizeString, formatProjectType, highlightCodeLines } from '@modrinth/utils'
1424
import { computed, ref } from 'vue'
1525
1626
const props = defineProps<{
1727
item: Labrinth.TechReview.Internal.ProjectReview
1828
}>()
1929
30+
const { addNotification } = injectNotificationManager()
31+
2032
const emit = defineEmits<{
2133
refetch: []
2234
}>()
2335
36+
const quickActions: OverflowMenuOption[] = [
37+
{
38+
id: 'copy-link',
39+
action: () => {
40+
const base = window.location.origin
41+
const reportUrl = `${base}/moderation/technical-review/${props.item.project.id}`
42+
navigator.clipboard.writeText(reportUrl).then(() => {
43+
addNotification({
44+
type: 'success',
45+
title: 'Technical Report link copied',
46+
text: 'The link to this report has been copied to your clipboard.',
47+
})
48+
})
49+
},
50+
},
51+
{
52+
id: 'copy-id',
53+
action: () => {
54+
navigator.clipboard.writeText(props.item.project.id).then(() => {
55+
addNotification({
56+
type: 'success',
57+
title: 'Technical Report ID copied',
58+
text: 'The ID of this report has been copied to your clipboard.',
59+
})
60+
})
61+
},
62+
},
63+
]
64+
2465
type Tab = 'Thread' | 'Files'
2566
const tabs: readonly Tab[] = ['Thread', 'Files']
2667
const currentTab = ref<Tab>('Thread')
@@ -77,6 +118,10 @@ function formatFileSize(bytes: number): string {
77118
78119
function viewFileFlags(file: Labrinth.TechReview.Internal.FileReview) {
79120
selectedFile.value = file
121+
// Automatically expand the first issue
122+
if (file.issues.length > 0) {
123+
expandedIssues.value.add(file.issues[0].issue_id)
124+
}
80125
}
81126
82127
function backToFileList() {
@@ -212,7 +257,19 @@ function getSeverityBreakdown(file: Labrinth.TechReview.Internal.FileReview) {
212257
</ButtonStyled>
213258

214259
<ButtonStyled circular>
215-
<button><MoreVerticalIcon /></button>
260+
<OverflowMenu :options="quickActions">
261+
<template #default>
262+
<EllipsisVerticalIcon class="size-4" />
263+
</template>
264+
<template #copy-id>
265+
<ClipboardCopyIcon />
266+
<span class="hidden sm:inline">Copy ID</span>
267+
</template>
268+
<template #copy-link>
269+
<LinkIcon />
270+
<span class="hidden sm:inline">Copy link</span>
271+
</template>
272+
</OverflowMenu>
216273
</ButtonStyled>
217274
</div>
218275
</div>
@@ -253,7 +310,9 @@ function getSeverityBreakdown(file: Labrinth.TechReview.Internal.FileReview) {
253310
<div v-if="currentTab === 'Thread'" class="p-4">
254311
<div v-if="true" class="flex min-h-[75px] items-center justify-center">
255312
<div class="text-center text-secondary">
256-
<p class="text-sm">No messages yet {{ ':(' }}</p>
313+
<p class="text-sm">
314+
Not yet implemented. See reports in prod for how thread will look (its the same)
315+
</p>
257316
</div>
258317
</div>
259318

@@ -277,6 +336,11 @@ function getSeverityBreakdown(file: Labrinth.TechReview.Internal.FileReview) {
277336
}}</span>
278337
</div>
279338
<div
339+
class="border-red/60 flex items-center gap-1 rounded-full border border-solid bg-highlight-red px-2.5 py-1 text-sm text-red"
340+
>
341+
{{ file.issues.length }} flags
342+
</div>
343+
<!-- <div
280344
v-for="severityItem in getSeverityBreakdown(file)"
281345
:key="severityItem.severity"
282346
class="rounded-full border border-solid px-2.5 py-1"
@@ -292,7 +356,7 @@ function getSeverityBreakdown(file: Labrinth.TechReview.Internal.FileReview) {
292356
>{{ severityItem.count }}
293357
{{ capitalizeString(severityItem.severity.toLowerCase()) }}</span
294358
>
295-
</div>
359+
</div> -->
296360
</div>
297361

298362
<div class="flex items-center gap-2">

apps/frontend/src/pages/moderation.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,9 +22,9 @@ import { defineMessages, useVIntl } from '@vintl/vintl'
2222
2323
import NavTabs from '@/components/ui/NavTabs.vue'
2424
25-
definePageMeta({
26-
middleware: 'auth',
27-
})
25+
// definePageMeta({
26+
// middleware: 'auth',
27+
// })
2828
2929
const { formatMessage } = useVIntl()
3030
const route = useRoute()

0 commit comments

Comments
 (0)