mirror of
https://github.com/modrinth/code.git
synced 2026-08-25 09:04:55 +00:00
feat: tech review global trace database (#6648)
* global detail verdicts system * global traces frontend * split global routes into own mod * tweak migration to only do no-key check at app level * prepr
This commit is contained in:
@@ -45,7 +45,7 @@ import {
|
||||
type User,
|
||||
} from '@modrinth/utils'
|
||||
import dayjs from 'dayjs'
|
||||
import { computed, reactive, ref, watch } from 'vue'
|
||||
import { computed, nextTick, reactive, ref, watch } from 'vue'
|
||||
|
||||
import type { UnsafeFile } from '~/components/ui/moderation/MaliciousSummaryModal.vue'
|
||||
import ThreadView from '~/components/ui/thread/ThreadView.vue'
|
||||
@@ -89,6 +89,7 @@ const props = defineProps<{
|
||||
thread: Labrinth.TechReview.Internal.Thread
|
||||
reports: FlattenedFileReport[]
|
||||
}
|
||||
focusedDetailId?: string | null
|
||||
loadingIssues: Set<string>
|
||||
decompiledSources: Map<string, string>
|
||||
}>()
|
||||
@@ -192,7 +193,12 @@ watch(selectedFile, (newFile) => {
|
||||
|
||||
const client = injectModrinthClient()
|
||||
|
||||
async function updateIssueDetails(data: { detail_id: string; verdict: 'safe' | 'unsafe' }[]) {
|
||||
async function updateIssueDetails(
|
||||
data: {
|
||||
detail_id: string
|
||||
verdict: Labrinth.TechReview.Internal.DelphiReportIssueStatus
|
||||
}[],
|
||||
) {
|
||||
await client.request('/moderation/tech-review/issue-detail', {
|
||||
api: 'labrinth',
|
||||
version: 'internal',
|
||||
@@ -381,6 +387,49 @@ function viewFileFlags(file: FlattenedFileReport) {
|
||||
currentTab.value = 'File'
|
||||
}
|
||||
|
||||
function getDetailElementId(detailId: string) {
|
||||
return `tech-review-detail-${detailId}`
|
||||
}
|
||||
|
||||
function findFileForDetail(detailId: string): FlattenedFileReport | null {
|
||||
for (const report of props.item.reports) {
|
||||
for (const issue of report.issues) {
|
||||
if (issue.details.some((detail) => detail.id === detailId)) {
|
||||
return report
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return null
|
||||
}
|
||||
|
||||
async function focusDetail(detailId: string) {
|
||||
const file = findFileForDetail(detailId)
|
||||
if (!file) return
|
||||
|
||||
viewFileFlags(file)
|
||||
await nextTick()
|
||||
|
||||
const classItem = groupedByClass.value.find((group) =>
|
||||
group.flags.some((flag) => flag.detail.id === detailId),
|
||||
)
|
||||
|
||||
if (classItem) {
|
||||
expandClass(classItem)
|
||||
}
|
||||
|
||||
await nextTick()
|
||||
|
||||
if (!import.meta.client) return
|
||||
|
||||
window.requestAnimationFrame(() => {
|
||||
document.getElementById(getDetailElementId(detailId))?.scrollIntoView({
|
||||
behavior: 'smooth',
|
||||
block: 'center',
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
function backToFileList() {
|
||||
selectedFileId.value = null
|
||||
if (currentTab.value === 'File') {
|
||||
@@ -691,6 +740,16 @@ const groupedByJar = computed<JarGroup[]>(() => {
|
||||
})
|
||||
})
|
||||
|
||||
watch(
|
||||
() => props.focusedDetailId,
|
||||
(detailId) => {
|
||||
if (detailId) {
|
||||
focusDetail(detailId)
|
||||
}
|
||||
},
|
||||
{ immediate: true },
|
||||
)
|
||||
|
||||
// Auto-expand/load source for small files; keep larger files lazy.
|
||||
watch(
|
||||
[selectedFileId, groupedByClass],
|
||||
@@ -1384,8 +1443,12 @@ function copyId() {
|
||||
>
|
||||
<div
|
||||
v-for="flag in classItem.flags"
|
||||
:id="getDetailElementId(flag.detail.id)"
|
||||
:key="`${flag.issueId}-${flag.detail.id}`"
|
||||
class="flex flex-col gap-2 rounded-lg border-[1px] border-b border-solid border-surface-5 bg-surface-3 py-2 pl-4 last:border-b-0"
|
||||
:class="{
|
||||
'!border-brand bg-brand-highlight': props.focusedDetailId === flag.detail.id,
|
||||
}"
|
||||
>
|
||||
<div class="grid grid-cols-[1fr_auto] items-center">
|
||||
<div
|
||||
|
||||
Reference in New Issue
Block a user