Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions apps/frontend/src/components/project-review/queue-bar.vue
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,19 @@
</template>
</div>
</div>

<div class="flex items-center gap-1">
<template v-if="settings.get(moderationSettings.General.ShowProjectReviewTimer)">
<span class="text-xs font-medium">
<span>
Reviewing for
</span>
<span class="tabular-nums" :class="getClassForWarning(secondsSinceLastUpdate, settings.get(moderationSettings.General.ProjectReviewTimerWarning))">
{{ secondsSinceLastUpdate < 0 ? '-' : '' }}{{ (Math.abs(secondsSinceLastUpdate) / 60).toFixed(0).padStart(2, '0') }}:{{ (Math.abs(secondsSinceLastUpdate) % 60).toFixed(0).padStart(2, '0') }}
</span>
</span>
<span class="mx-1.5 h-5 w-px bg-divider" aria-hidden="true" />
</template>
<Tooltip :delay="750">
<template #popper>
<div class="flex items-center gap-2">
Expand Down Expand Up @@ -231,6 +243,7 @@ import KbdChip from './kdb-chip.vue'
import { injectProjectReviewContext } from './layout/context'
import QueueProjectList from './queue-project-list.vue'
import { useReviewShortcut } from './shortcuts'
import {useNow} from "@vueuse/core";

const config = useRuntimeConfig()
const { hostname } = useRequestURL()
Expand Down Expand Up @@ -333,6 +346,17 @@ const queueColumns = computed(() => {
},
]
})
const now = useNow({ interval: 1000 })
const secondsSinceLastUpdate = computed(() =>
Math.ceil((now.value.getTime() - queue.currentQueue.lastUpdated.getTime()) / 1000)
)

function getClassForWarning(seconds: number, cutoff: number) {
if (cutoff <= 0) return 'text-primary'
if (seconds > cutoff) return 'text-red'
if (seconds > cutoff / 2) return 'text-orange'
return 'text-primary'
}

function runPanelAction(action: () => void, hide: () => void) {
action()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ async function openSearch() {
const pane = sourcePane.value
const selection = pane?.ownerDocument.getSelection()
if (selection && pane?.contains(selection.anchorNode) && pane.contains(selection.focusNode)) {
const text = selection.toString()
if (text && !text.includes('\n')) findQuery.value = text
const text = selection.rangeCount ? selection.getRangeAt(0).cloneRange().toString() : null;
if (text && !text.includes('\n')) findQuery.value = text.trim()
}
matchMode.value = 'search'
await nextTick()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,13 @@ function fileActions(file: VersionFile): ButtonMenuOption[] {
},
},
},
{
id: 'copy-file-id',
label: 'Copy file ID',
icon: ClipboardCopyIcon,
disabled: !file.id,
action: () => navigator.clipboard.writeText(file.id),
}
]
for (const algorithm of ['sha1', 'sha512'] as const) {
const hash = file.hashes[algorithm]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,14 @@ const groups = [
general.PrivateMessageHighlight,
],
},
{
id: 'queue-bar',
title: 'Queue Bar',
settings: [
general.ShowProjectReviewTimer,
general.ProjectReviewTimerWarning,
]
},
{
id: 'shortcuts',
title: 'Editors and shortcut hints',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,13 @@ export function createReviewSubmission(
await client.labrinth.threads_v3.editIssueFacet(facet.id, facet.data)
}
assertPass()
await client.labrinth.tech_review_internal.submitProject(id, { verdict: 'safe' })
client.labrinth.tech_review_internal.submitProject(id, { verdict: 'safe' }).catch(error => {
addNotification({
title: 'An error occurred',
text: error instanceof Error ? error.message : String(error),
type: 'error',
})
})
if (reply) {
await sendThreadReply(reply, client, () => {
assertCurrent(id)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -292,6 +292,7 @@ export class LabrinthTechReviewInternalModule extends AbstractModule {
version: 'internal',
method: 'POST',
body: data,
timeout: 30_000,
})
}

Expand Down
18 changes: 18 additions & 0 deletions packages/moderation/src/data/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@ const settings = {
description: 'Allow queue navigation to include projects that are no longer awaiting review.',
default: false,
}),
ShowProjectReviewTimer: setting.asToggle({
type: 'toggle',
id: 'show-project-review-timer',
title: 'Show project review timer',
description: 'Show a timer in the project review queue bar indicating how long you have been reviewing the current project.',
default: false,
}),
ProjectReviewTimerWarning: setting.asNumber({
type: 'number',
id: 'project-review-timer-warning',
title: 'Project review timer warning',
description: 'Maximum time in seconds to show the project review timer before it turns red. Set to 0 to disable the warning. At >=75% of the time it will turn orange.',
default: 0,
min: 0,
max: 3600,
step: 60,
unit: 's',
}),
},
} as const

Expand Down
Loading