-
+
{{
result?.flags.length === 0
? 'No flags found.'
@@ -62,36 +64,25 @@
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/rules/use-rules.ts b/apps/frontend/src/components/ui/moderation/project-flag/rules/use-rules.ts
new file mode 100644
index 00000000000..c923aa94867
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/rules/use-rules.ts
@@ -0,0 +1,91 @@
+import type { ProjectFlagRule, ProjectFlagRuleParams } from '@modrinth/api-client'
+import { injectModrinthClient } from '@modrinth/ui'
+import { useMutation, useQuery, useQueryClient } from '@tanstack/vue-query'
+import { computed, type Ref } from 'vue'
+
+export const RULES_PAGE_SIZE = 25
+const queryKey = ['moderation', 'project-flag', 'rules'] as const
+
+function rulesPageKey(pageOffset: number) {
+ return [...queryKey, { limit: RULES_PAGE_SIZE + 1, offset: pageOffset }] as const
+}
+
+export function useRules(offset: Ref, active: () => boolean, onDeleted: () => void) {
+ const client = injectModrinthClient()
+ const api = client.labrinth.project_flags_internal
+ const queryClient = useQueryClient()
+
+ const { data, isPending, isError, error, isFetching, refetch } = useQuery({
+ queryKey: computed(() => rulesPageKey(offset.value)),
+ queryFn: ({ queryKey: [, , , page] }) => api.list(page),
+ enabled: computed(() => active()),
+ })
+ const rules = computed(() => data.value?.slice(0, RULES_PAGE_SIZE) ?? [])
+ const hasNextPage = computed(() => (data.value?.length ?? 0) > RULES_PAGE_SIZE)
+
+ const {
+ mutate: deleteRule,
+ isPending: isDeleting,
+ error: deleteError,
+ reset: resetDelete,
+ } = useMutation({
+ mutationFn: (id: number) => api.delete(id),
+ onSuccess: async () => {
+ onDeleted()
+ await queryClient.invalidateQueries({ queryKey })
+ },
+ })
+
+ return {
+ data,
+ isPending,
+ isError,
+ error,
+ isFetching,
+ refetch,
+ rules,
+ hasNextPage,
+ deleteRule,
+ isDeleting,
+ deleteError,
+ resetDelete,
+ }
+}
+
+export function useSaveRule(
+ ruleId: () => number | undefined,
+ onSaved: (rule: ProjectFlagRule) => void,
+) {
+ const { labrinth } = injectModrinthClient()
+ const api = labrinth.project_flags_internal
+ const queryClient = useQueryClient()
+ const mutation = useMutation({
+ mutationFn: ({
+ id,
+ body,
+ }: {
+ id: number | undefined
+ body: { name: string; params: ProjectFlagRuleParams }
+ }) => (id === undefined ? api.create(body) : api.update(id, body)),
+ onSuccess: async (rule, { id }) => {
+ const created = id === undefined
+ await queryClient.cancelQueries({ queryKey })
+ if (created) {
+ queryClient.setQueryData(rulesPageKey(0), (previous = []) =>
+ [rule, ...previous.filter((entry) => entry.id !== rule.id)].slice(0, RULES_PAGE_SIZE + 1),
+ )
+ } else {
+ queryClient.setQueriesData({ queryKey }, (previous) =>
+ previous?.map((entry) => (entry.id === rule.id ? rule : entry)),
+ )
+ }
+ onSaved(rule)
+ await queryClient.invalidateQueries({ queryKey })
+ },
+ })
+ return {
+ ...mutation,
+ mutate: (body: { name: string; params: ProjectFlagRuleParams }) =>
+ mutation.mutate({ id: ruleId(), body }),
+ }
+}
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-actions.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-actions.vue
new file mode 100644
index 00000000000..7c6cd12d649
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-actions.vue
@@ -0,0 +1,201 @@
+
+
+
+
+
+
Applying flags from a run is not available yet.
+
+ Close
+
+
+ Apply run
+
+
+
+
+
+
+
+
+ Delete run {{ runToDelete.id }} ?
+
+
+ This permanently deletes the run, its results, and its inactive project flags. Active flags
+ are preserved and detached from the run. This cannot be undone.
+
+
+ Cancel
+
+
+
+ {{ isDeleting ? 'Deleting…' : 'Delete run' }}
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-format.ts b/apps/frontend/src/components/ui/moderation/project-flag/run-format.ts
new file mode 100644
index 00000000000..c63691ccdb3
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-format.ts
@@ -0,0 +1,48 @@
+import type { ProjectFlagRunResult } from '@modrinth/api-client'
+
+export function countUniqueFlagKeys(results: ProjectFlagRunResult[]) {
+ const keys = new Set()
+ for (const result of results) {
+ for (const rule of Object.values(result.rules)) {
+ for (const flag of rule.flags) keys.add(flag.key)
+ }
+ }
+ return keys.size
+}
+
+export function flagCountTooltip(count: number, uniqueCount: number, label = 'flagged') {
+ return {
+ text: `${count.toLocaleString('en-US')} ${label}\n${uniqueCount.toLocaleString('en-US')} unique flag${uniqueCount === 1 ? '' : 's'}`,
+ class: 'whitespace-pre-line',
+ }
+}
+
+export function formatDate(value: string, withTime = false) {
+ const date = new Date(value)
+ if (!withTime) return date.toLocaleDateString('en-US', { dateStyle: 'medium', timeZone: 'UTC' })
+
+ return (
+ date.toLocaleString('en-US', {
+ dateStyle: 'medium',
+ timeStyle: 'medium',
+ timeZone: 'UTC',
+ }) + ' UTC'
+ )
+}
+
+export function formatDuration(startedAt: string, completedAt: string, exact = false) {
+ const milliseconds = Math.max(0, Date.parse(completedAt) - Date.parse(startedAt))
+ const hours = Math.floor(milliseconds / 3_600_000)
+ const minutes = Math.floor(milliseconds / 60_000) % 60
+ const seconds = (milliseconds % 60_000) / 1_000
+
+ if (!exact) {
+ if (hours > 0) return `${hours} hr${minutes ? ` ${minutes} min` : ''}`
+ if (minutes > 0) return `${minutes} min`
+ return `${Math.floor(seconds)} sec`
+ }
+
+ return [hours ? `${hours} hr` : '', minutes ? `${minutes} min` : '', `${seconds} sec`]
+ .filter(Boolean)
+ .join(' ')
+}
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-history.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-history.vue
new file mode 100644
index 00000000000..abf6a271559
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-history.vue
@@ -0,0 +1,274 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{ isStarting ? 'Starting run…' : 'Start run' }}
+
+
+
+ Loading project flag runs…
+
+
+ Try again
+
+
+
+
+
+
+ {{ formatDate(run.started_at) }}
+
+
+
+
+
+
+
+ Scan errors:
+ {{ run.num_errors.toLocaleString('en-US') }}
+
+
+
+
+
+
+
+
+
+
Started by
+
+
+ {{ run.started_by.username }}
+
+
unknown user
+
+
+
+
+ {{
+ data.length ? 'No runs match your search and time period.' : 'No project flag runs yet.'
+ }}
+
+
+
+ Showing {{ offset + 1 }}–{{ offset + runs.length }} of {{ filteredRuns.length }}
+
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/flag-card.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-results/flag-card.vue
new file mode 100644
index 00000000000..a424090747b
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/flag-card.vue
@@ -0,0 +1,88 @@
+
+
+
+
+
+
+ {{ flag?.name || rule.name || (flag ? 'Flag' : 'Deleted rule') }}
+
+
+
+
+
+
+ {{ flag.reason }}
+
+
+
+ {{ flag.location.review_panel_key }}
+
+
+ Flag data
+ {{ JSON.stringify(flag, null, 2) }}
+
+
+
+
+
Scan error
+
{{ rule.error }}
+
+
+
+ {{ rule.flags.length > 1 ? 'Rule logs' : 'Logs' }}
+
+ {{
+ rule.log.join('\n')
+ }}
+
+
+ No flags
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/index.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-results/index.vue
new file mode 100644
index 00000000000..fd68fd5cafd
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/index.vue
@@ -0,0 +1,418 @@
+
+
+
+
+
+
+
+
+ {{
+ loadFilterOptions && fullResults.isFetching.value
+ ? 'Loading rule filters…'
+ : 'Load rule filters'
+ }}
+
+
+
+
+
+
+
+ Loading project results…
+
+
+ Try again
+
+
+ Loading project types…
+
+
+ Try again
+
+
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-card.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-card.vue
new file mode 100644
index 00000000000..c3a12fdbfa3
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-card.vue
@@ -0,0 +1,262 @@
+
+
+
+
+
+
+
+
+ {{ result.project.title }}
+
+
+
+
+
+ {{ formatProjectType(primaryProjectType, true) }}
+ ({{ project.project_types.length }})
+
+
+
+
+
+ {{ formatProjectType(type, true) }}
+
+
+
+
+
+
+
+
+
+
+ {{ statusLabel }}
+
+
+
+
+
+ {{ flagCount }} flags
+
+
+
+
+
+
+ Modview
+
+
+
+
+
+
+
+
+ {{ owner.name }}
+
+
+
+ {{ approvedCount }} approved projects
+
+
+
+ {{ externalCount }} external dependencies
+
+
+ {{ formatRelativeTime(projectDate) }}
+
+
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-detail.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-detail.vue
new file mode 100644
index 00000000000..1f894758590
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-detail.vue
@@ -0,0 +1,72 @@
+
+
+
+ Flags
+
+
+ Scan errors
+
+ {{ result.error }}
+
+
+
+
+ {{ section.label }} ({{ section.rules.length }})
+
+ No flags
+
+
+
+
+
+
+ Project flags appear here when a project is selected.
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-list.vue b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-list.vue
new file mode 100644
index 00000000000..359d1715b75
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/project-list.vue
@@ -0,0 +1,52 @@
+
+
+
+
+
+ {{ emptyMessage }}
+
+
+
+ Showing {{ offset + 1 }}–{{ offset + rows.length }} of {{ categoryTotal }}
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/run-results/use-result-projects.ts b/apps/frontend/src/components/ui/moderation/project-flag/run-results/use-result-projects.ts
new file mode 100644
index 00000000000..a59e60cfe50
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/run-results/use-result-projects.ts
@@ -0,0 +1,143 @@
+import type { Labrinth } from '@modrinth/api-client'
+import { injectModrinthClient } from '@modrinth/ui'
+import { useQuery } from '@tanstack/vue-query'
+import { computed } from 'vue'
+
+import { fetchSegmentedWith } from '~/utils/fetch-helpers'
+
+import { useFlagErrorNotification } from '../use-flag-error-notification'
+
+export function useResultProjects(categoryIds: () => string[], enabled: () => boolean) {
+ const client = injectModrinthClient()
+
+ const projectTypeIds = computed(() => [...categoryIds()].sort())
+ const {
+ data: filterProjects,
+ isPending: projectTypesPending,
+ error: projectTypeError,
+ refetch: refetchProjectTypes,
+ } = useQuery({
+ queryKey: computed(
+ () => ['moderation', 'project-flag', 'filter-projects', projectTypeIds.value] as const,
+ ),
+ queryFn: ({ queryKey: [, , , ids] }) =>
+ fetchSegmentedWith(ids, (batch) => client.labrinth.projects_v3.getMultiple(batch), 100),
+ enabled: computed(() => enabled() && projectTypeIds.value.length > 0),
+ staleTime: 60_000,
+ })
+ const loadingProjectTypes = computed(
+ () => enabled() && projectTypeIds.value.length > 0 && projectTypesPending.value,
+ )
+ const filterProjectsById = computed(
+ () => new Map(filterProjects.value?.map((project) => [project.id, project])),
+ )
+ return {
+ filterProjects,
+ filterProjectsById,
+ loadingProjectTypes,
+ projectTypeError,
+ refetchProjectTypes,
+ }
+}
+
+export function useResultProjectOwners(
+ visibleIds: () => string[],
+ filterByType: () => boolean,
+ filteredProject: (id: string) => Labrinth.Projects.v3.Project | undefined,
+) {
+ const client = injectModrinthClient()
+ const projectIds = computed(() => [...visibleIds()].sort())
+ const { data: projects, error: projectsError } = useQuery({
+ queryKey: computed(
+ () => ['moderation', 'project-flag', 'result-projects', projectIds.value] as const,
+ ),
+ queryFn: ({ queryKey: [, , , ids] }) => client.labrinth.projects_v3.getMultiple(ids),
+ enabled: computed(() => projectIds.value.length > 0 && !filterByType()),
+ })
+ const visibleProjects = computed(() =>
+ filterByType()
+ ? projectIds.value.flatMap((id) => {
+ const project = filteredProject(id)
+ return project ? [project] : []
+ })
+ : (projects.value ?? []),
+ )
+ const projectsById = computed(
+ () => new Map(visibleProjects.value.map((project) => [project.id, project])),
+ )
+ const teamIds = computed(() =>
+ [
+ ...new Set(
+ visibleProjects.value
+ .filter((project) => !project.organization)
+ .map((project) => project.team_id),
+ ),
+ ].sort(),
+ )
+ const organizationIds = computed(() =>
+ [
+ ...new Set(
+ visibleProjects.value.flatMap((project) =>
+ project.organization ? [project.organization] : [],
+ ),
+ ),
+ ].sort(),
+ )
+ const { data: teams, error: teamsError } = useQuery({
+ queryKey: computed(
+ () => ['moderation', 'project-flag', 'result-teams', teamIds.value] as const,
+ ),
+ queryFn: ({ queryKey: [, , , ids] }) => client.labrinth.teams_v3.getMultiple(ids),
+ enabled: computed(() => teamIds.value.length > 0),
+ })
+ const { data: organizations, error: organizationsError } = useQuery({
+ queryKey: computed(
+ () => ['moderation', 'project-flag', 'result-organizations', organizationIds.value] as const,
+ ),
+ queryFn: ({ queryKey: [, , , ids] }) => client.labrinth.organizations_v3.getMultiple(ids),
+ enabled: computed(() => organizationIds.value.length > 0),
+ })
+ useFlagErrorNotification(projectsError, 'Could not load project details')
+ useFlagErrorNotification(teamsError, 'Could not load project teams')
+ useFlagErrorNotification(organizationsError, 'Could not load project organizations')
+
+ const ownersByProject = computed(() => {
+ const usersByTeam = new Map(
+ teams.value
+ ?.flat()
+ .filter((member) => member.is_owner)
+ .map((member) => [member.team_id, member.user]),
+ )
+ const organizationsById = new Map(
+ organizations.value?.map((organization) => [organization.id, organization]),
+ )
+ const owners = new Map<
+ string,
+ { id: string; name: string; icon?: string | null; kind: 'user' | 'organization' }
+ >()
+ for (const project of visibleProjects.value) {
+ if (project.organization) {
+ const organization = organizationsById.get(project.organization)
+ if (organization)
+ owners.set(project.id, {
+ id: organization.id,
+ name: organization.name,
+ icon: organization.icon_url,
+ kind: 'organization',
+ })
+ } else {
+ const user = usersByTeam.get(project.team_id)
+ if (user)
+ owners.set(project.id, {
+ id: user.id,
+ name: user.username,
+ icon: user.avatar_url,
+ kind: 'user',
+ })
+ }
+ }
+ return owners
+ })
+
+ return { projectsById, ownersByProject }
+}
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/scan-badge.vue b/apps/frontend/src/components/ui/moderation/project-flag/scan-badge.vue
new file mode 100644
index 00000000000..160ac7d627b
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/scan-badge.vue
@@ -0,0 +1,54 @@
+
+
+
+
+
+ {{ progress === undefined ? 'Scanning…' : `${progress}% scanned` }}
+
+ {{ duration ?? 'Done' }}
+
+
+
+
diff --git a/apps/frontend/src/components/ui/moderation/project-flag/use-flag-error-notification.ts b/apps/frontend/src/components/ui/moderation/project-flag/use-flag-error-notification.ts
new file mode 100644
index 00000000000..c5528bf6f79
--- /dev/null
+++ b/apps/frontend/src/components/ui/moderation/project-flag/use-flag-error-notification.ts
@@ -0,0 +1,22 @@
+import { injectNotificationManager } from '@modrinth/ui'
+import { type WatchSource, watch } from 'vue'
+
+export function useFlagErrorNotification(
+ error: WatchSource,
+ title: string,
+) {
+ const { addNotification } = injectNotificationManager()
+ watch(
+ error,
+ (value) => {
+ if (import.meta.client && value) {
+ addNotification({
+ type: 'error',
+ title,
+ text: typeof value === 'string' ? value : value.message,
+ })
+ }
+ },
+ { immediate: true },
+ )
+}
diff --git a/apps/frontend/src/composables/queries/project-flag-run.ts b/apps/frontend/src/composables/queries/project-flag-run.ts
new file mode 100644
index 00000000000..b865ef8e282
--- /dev/null
+++ b/apps/frontend/src/composables/queries/project-flag-run.ts
@@ -0,0 +1,101 @@
+import type {
+ AbstractModrinthClient,
+ ProjectFlagRun,
+ ProjectFlagRunResult,
+} from '@modrinth/api-client'
+import { queryOptions } from '@tanstack/vue-query'
+
+const PAGE_LIMIT = 200
+const REFRESH_INTERVAL = 10_000
+const COMPLETED_RESULTS_CACHE_TIME = 3 * 60 * 60_000
+
+export const projectFlagRunHistoryKey = ['moderation', 'project-flag', 'runs', 'history'] as const
+export const projectFlagRunActivityKey = ['moderation', 'project-flag', 'runs', 'activity'] as const
+
+export function projectFlagRunActivityOptions(client: AbstractModrinthClient) {
+ return queryOptions({
+ queryKey: projectFlagRunActivityKey,
+ queryFn: () => client.labrinth.project_flags_internal.getRunActivity(),
+ refetchInterval: REFRESH_INTERVAL,
+ })
+}
+
+export function projectFlagRunHistoryOptions(client: AbstractModrinthClient) {
+ return queryOptions({
+ queryKey: projectFlagRunHistoryKey,
+ queryFn: async ({ signal }) => {
+ const runs = new Map()
+ for (let offset = 0; ; offset += PAGE_LIMIT) {
+ signal.throwIfAborted()
+ const page = await client.labrinth.project_flags_internal.listRuns({
+ limit: PAGE_LIMIT,
+ offset,
+ })
+ for (const run of page) runs.set(run.id, run)
+ if (page.length < PAGE_LIMIT) return [...runs.values()]
+ }
+ },
+ refetchInterval: (query) =>
+ query.state.data?.some((run) => run.status !== 'done') ? REFRESH_INTERVAL : false,
+ })
+}
+
+export function projectFlagResultCategory(result: ProjectFlagRunResult) {
+ const rules = Object.values(result.rules)
+ if (result.error !== null || rules.some((rule) => rule.error !== null)) return 'errors'
+ return rules.some((rule) => rule.flags.length > 0) ? 'flagged' : 'approvable'
+}
+
+export function projectFlagRunResultsPageOptions(
+ client: AbstractModrinthClient,
+ run: Pick,
+ limit: number,
+ offset: number,
+) {
+ const done = run.status === 'done'
+ return queryOptions({
+ queryKey: [
+ 'moderation',
+ 'project-flag',
+ 'runs',
+ run.id,
+ 'results-page',
+ done,
+ limit,
+ offset,
+ ] as const,
+ queryFn: () => client.labrinth.project_flags_internal.getRunResults(run.id, { limit, offset }),
+ staleTime: done ? COMPLETED_RESULTS_CACHE_TIME : REFRESH_INTERVAL,
+ gcTime: done ? COMPLETED_RESULTS_CACHE_TIME : undefined,
+ refetchInterval: done ? false : REFRESH_INTERVAL,
+ })
+}
+
+export function projectFlagRunResultsOptions(
+ client: AbstractModrinthClient,
+ run: Pick,
+) {
+ const done = run.status === 'done'
+ return queryOptions({
+ queryKey: ['moderation', 'project-flag', 'runs', run.id, 'results', done] as const,
+ queryFn: async ({ signal }) => {
+ const results = new Map()
+ let total = 0
+ let offset = 0
+ do {
+ signal.throwIfAborted()
+ const page = await client.labrinth.project_flags_internal.getRunResults(run.id, {
+ limit: PAGE_LIMIT,
+ offset,
+ })
+ if (offset === 0) total = page.total
+ for (const result of page.results) results.set(result.project.id, result)
+ offset += PAGE_LIMIT
+ } while (offset < total)
+ return [...results.values()]
+ },
+ staleTime: done ? COMPLETED_RESULTS_CACHE_TIME : REFRESH_INTERVAL,
+ gcTime: done ? COMPLETED_RESULTS_CACHE_TIME : undefined,
+ refetchInterval: done ? false : REFRESH_INTERVAL,
+ })
+}
diff --git a/apps/frontend/src/pages/moderation/project-flag.vue b/apps/frontend/src/pages/moderation/project-flag.vue
deleted file mode 100644
index 96996887388..00000000000
--- a/apps/frontend/src/pages/moderation/project-flag.vue
+++ /dev/null
@@ -1,413 +0,0 @@
-
-
-
-
-
-
- Create rule
-
-
-
-
- {{ runsView.numScanning }}
- {{ runsView.numScanning === 1 ? 'project' : 'projects' }} scanning…
- ·
-
- {{ runsView.numConsumers }} {{ runsView.numConsumers === 1 ? 'consumer' : 'consumers' }}
-
-
-
-
-
- {{ runsView?.isStarting ? 'Starting run…' : 'Start run' }}
-
-
-
-
-
-
-
-
-
-
-
-
- Loading project flag rules…
-
-
-
Could not load project flag rules: {{ errorMessage(error) }}
-
Try again
-
-
-
-
- {{ offset === 0 ? 'No project flag rules' : 'No rules on this page' }}
-
-
- {{
- offset === 0
- ? 'Create a rule to get started.'
- : 'Go to the previous page to see more rules.'
- }}
-
-
-
-
-
-
{{ rule.name }}
-
- Created {{ formatDate(rule.created_at) }} · Updated {{ formatDate(rule.updated_at) }}
-
-
-
-
-
- Edit
-
-
-
- Delete
-
-
-
- {{ rule.params.expression }}
-
-
Delete “{{ rule.name }}”? This cannot be undone.
-
- Existing flags will be preserved without a link to this rule.
-
-
- Could not delete the rule: {{ errorMessage(deleteError) }}
-
-
- Cancel
-
-
- {{ isDeleting ? 'Deleting…' : 'Delete rule' }}
-
-
-
-
-
-
-
- Showing {{ offset + 1 }}–{{ offset + rules.length }}
- No rules on this page
-
-
-
- Previous
-
-
- Next
-
-
-
-
-
-
-
-
diff --git a/apps/frontend/src/pages/moderation/project-flag/index.vue b/apps/frontend/src/pages/moderation/project-flag/index.vue
new file mode 100644
index 00000000000..0a656a8e7eb
--- /dev/null
+++ b/apps/frontend/src/pages/moderation/project-flag/index.vue
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/pages/moderation/project-flag/runs/[run].vue b/apps/frontend/src/pages/moderation/project-flag/runs/[run].vue
new file mode 100644
index 00000000000..348d82bbeb8
--- /dev/null
+++ b/apps/frontend/src/pages/moderation/project-flag/runs/[run].vue
@@ -0,0 +1,198 @@
+
+
+
+
+ All runs
+
+
+
+ Loading project flag run…
+
+
+ Try again
+
+
Project flag run not found.
+
+
+
+
+
+
+
+
+
+
+
diff --git a/apps/frontend/src/providers/project-review/review-flags.ts b/apps/frontend/src/providers/project-review/review-flags.ts
new file mode 100644
index 00000000000..32c11b55802
--- /dev/null
+++ b/apps/frontend/src/providers/project-review/review-flags.ts
@@ -0,0 +1,29 @@
+import { createContext, injectModrinthClient } from '@modrinth/ui'
+import { useQuery } from '@tanstack/vue-query'
+import { computed, type Ref } from 'vue'
+
+export const [injectReviewFlags, provideReviewFlags] =
+ createContext>('ProjectReviewFlags')
+
+export function createReviewFlags(projectId: Ref) {
+ const { labrinth } = injectModrinthClient()
+ const { data, isPending, isError } = useQuery({
+ queryKey: computed(() => ['project', 'flags', projectId.value]),
+ queryFn: () => labrinth.project_flags_internal.getProjectFlags(projectId.value!),
+ enabled: computed(() => !!projectId.value),
+ })
+ const flags = computed(() =>
+ [...(data.value ?? [])].sort(
+ (a, b) =>
+ Number(!!a.location) - Number(!!b.location) ||
+ (a.name || a.key).localeCompare(b.name || b.key, 'en'),
+ ),
+ )
+ return {
+ flags,
+ isPending,
+ isError,
+ forPanel: (key: string) =>
+ flags.value.filter((flag) => flag.location?.review_panel_key === key),
+ }
+}
diff --git a/packages/api-client/src/modules/labrinth/project-flags/internal.ts b/packages/api-client/src/modules/labrinth/project-flags/internal.ts
index 7f1a9bff5c7..695cc3128d5 100644
--- a/packages/api-client/src/modules/labrinth/project-flags/internal.ts
+++ b/packages/api-client/src/modules/labrinth/project-flags/internal.ts
@@ -5,6 +5,7 @@ import type {
ListProjectFlagRulesParams,
ListProjectFlagRunResultsParams,
ListProjectFlagRunsParams,
+ ProjectFlag,
ProjectFlagEvaluation,
ProjectFlagRule,
ProjectFlagRuleSchemaResponse,
@@ -18,6 +19,13 @@ export class LabrinthProjectFlagsInternalModule extends AbstractModule {
return 'labrinth_project_flags_internal'
}
+ public async getProjectFlags(id: string): Promise {
+ return this.client.request(
+ `/moderation/project-flag/project/${encodeURIComponent(id)}`,
+ { api: 'labrinth', version: 'internal', method: 'GET' },
+ )
+ }
+
public async getRuleSchema(): Promise {
return this.client.request(
'/moderation/project-flag/rules/schema',
diff --git a/packages/api-client/src/modules/labrinth/project-flags/types.ts b/packages/api-client/src/modules/labrinth/project-flags/types.ts
index 60aab7f3174..002bd591534 100644
--- a/packages/api-client/src/modules/labrinth/project-flags/types.ts
+++ b/packages/api-client/src/modules/labrinth/project-flags/types.ts
@@ -40,7 +40,12 @@ export interface ProjectFlagEvaluation {
export interface ProjectFlag {
key: string
retain_if_inactive: boolean
- [field: string]: ProjectFlagValue
+ name?: string
+ reason?: string
+ location?: {
+ review_panel_key: string
+ }
+ [field: string]: ProjectFlagValue | undefined
}
export interface ProjectFlagRunActivity {
diff --git a/packages/ui/src/components/project/ProjectCombobox.vue b/packages/ui/src/components/project/ProjectCombobox.vue
index 623a8a85bd0..4b26301a394 100644
--- a/packages/ui/src/components/project/ProjectCombobox.vue
+++ b/packages/ui/src/components/project/ProjectCombobox.vue
@@ -14,7 +14,11 @@
:select-search-text-on-focus="selectSearchTextOnFocus"
show-icon-in-selected
@search-input="(query) => handleSearch(query)"
- />
+ >
+
+
+
+