Skip to content

Commit e877167

Browse files
authored
feat: global trace database frontend + improvements to tech review status sync (#6671)
* wip * ui edits * better logic for syncing tech review state in a single centralized place * never automatically finish a tech review report * fix css * fix clippy * prepr
1 parent 623b51e commit e877167

29 files changed

Lines changed: 1370 additions & 397 deletions

File tree

‎apps/frontend/src/components/ui/moderation/GlobalDetailTracesList.vue‎

Lines changed: 48 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,18 @@
5555
{{ formatTraceCount(trace.local_trace_count) }}
5656
</p>
5757
</div>
58-
<Badge :type="trace.verdict" />
58+
<div class="flex shrink-0 flex-wrap items-center gap-2">
59+
<Badge :type="trace.verdict" />
60+
<ButtonStyled color="red">
61+
<button
62+
:disabled="removingTraceKeys.has(trace.detail_key)"
63+
@click="removeGlobalTrace(trace)"
64+
>
65+
<TrashIcon aria-hidden="true" />
66+
Remove
67+
</button>
68+
</ButtonStyled>
69+
</div>
5970
</div>
6071

6172
<div v-if="getPreviewLocalTraces(trace).length > 0" class="flex flex-col gap-2">
@@ -97,19 +108,21 @@
97108

98109
<script setup lang="ts">
99110
import type { Labrinth } from '@modrinth/api-client'
100-
import { HashIcon, ListIcon, SearchIcon } from '@modrinth/assets'
111+
import { HashIcon, ListIcon, SearchIcon, TrashIcon } from '@modrinth/assets'
101112
import {
102113
Badge,
103114
ButtonStyled,
104115
EmptyState,
105116
injectModrinthClient,
117+
injectNotificationManager,
106118
Pagination,
107119
StyledInput,
108120
} from '@modrinth/ui'
109121
110122
import GlobalDetailLocalTraceCard from '~/components/ui/moderation/GlobalDetailLocalTraceCard.vue'
111123
112124
const client = injectModrinthClient()
125+
const { addNotification } = injectNotificationManager()
113126
const query = ref('')
114127
const activeQuery = ref<string | null>(null)
115128
const isLoading = ref(false)
@@ -119,6 +132,7 @@ const itemsPerPage = 20
119132
const localTracePreviewLimit = 10
120133
const total = ref(0)
121134
const traces = ref<Labrinth.TechReview.Internal.GlobalIssueDetail[]>([])
135+
const removingTraceKeys = reactive<Set<string>>(new Set())
122136
123137
const pageCount = computed(() => Math.max(Math.ceil(total.value / itemsPerPage), 1))
124138
const pageStart = computed(() =>
@@ -176,5 +190,37 @@ async function switchPage(page: number) {
176190
await loadTraces()
177191
}
178192
193+
async function removeGlobalTrace(trace: Labrinth.TechReview.Internal.GlobalIssueDetail) {
194+
if (removingTraceKeys.has(trace.detail_key)) return
195+
196+
removingTraceKeys.add(trace.detail_key)
197+
try {
198+
await client.labrinth.tech_review_internal.updateGlobalIssueDetails([
199+
{ detail_key: trace.detail_key, verdict: 'pending' },
200+
])
201+
202+
addNotification({
203+
type: 'success',
204+
title: 'Global trace removed',
205+
text: 'The global verdict for this trace key has been removed.',
206+
})
207+
208+
if (traces.value.length === 1 && currentPage.value > 1) {
209+
currentPage.value--
210+
}
211+
212+
await loadTraces()
213+
} catch (error) {
214+
console.error('Failed to remove global trace', error)
215+
addNotification({
216+
type: 'error',
217+
title: 'Failed to remove global trace',
218+
text: 'An error occurred while removing the global trace verdict.',
219+
})
220+
} finally {
221+
removingTraceKeys.delete(trace.detail_key)
222+
}
223+
}
224+
179225
onMounted(loadTraces)
180226
</script>

0 commit comments

Comments
 (0)