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
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 @@ -20,6 +20,7 @@ import { decodeStringContents } from './string-contents'
for (const [name, definition] of Object.entries({ bash, dos, powershell })) {
if (!hljs.getLanguage(name)) hljs.registerLanguage(name, definition)
}
const languagesExcludedFromAutoDetect = ['skript', 'mcfunction']
const languages = hljs
.listLanguages()
.map((value) => ({
Expand Down Expand Up @@ -138,7 +139,9 @@ async function onContextMenu(event: MouseEvent) {
function detectLanguage(text: string) {
const result = hljs.highlightAuto(
text,
languages.map(({ value }) => value),
languages
.map(({ value }) => value)
.filter((value) => !languagesExcludedFromAutoDetect.includes(value)),
)
if (
result.relevance < 3 ||
Expand Down
14 changes: 12 additions & 2 deletions apps/frontend/src/components/project-review/tech-review/index.vue
Original file line number Diff line number Diff line change
Expand Up @@ -92,10 +92,10 @@
<button
type="button"
class="mr-1 rounded-full bg-transparent p-0 transition-[filter] hover:brightness-125"
:aria-label="`Choose pending archive (${pendingReports.length} pending)`"
:aria-label="`Choose pending archive (${uniqueFileCount} pending)`"
>
<TagItem style="--_bg-color: var(--color-orange-bg); --_color: var(--color-orange)">
{{ pendingReports.length }} pending
{{ uniqueFileCount }} pending
</TagItem>
</button>
<template #popper>
Expand Down Expand Up @@ -551,6 +551,16 @@ provide(TECH_REVIEW_DECISIONS_KEY, decisions)
const archiveMenu = ref<InstanceType<typeof FloatingMenu>>()
const allArchivesMenu = ref<InstanceType<typeof FloatingMenu>>()
provideTechReviewMenus()
const uniqueFileCount = computed(
() =>
new Set(
pendingReports.value.map((report) =>
[...new Set(report.issues.flatMap((issue) => issue.details.map((detail) => detail.key)))]
.sort()
.join('|'),
),
).size,
)
const selectedFile = computed(
() =>
reports.value.find((file) => file.id === selectedFileId.value) ??
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
<script setup lang="ts">
import { moderationSettings } from '@modrinth/moderation'
import { computed, getCurrentInstance } from 'vue'

import { useModerationSettings } from '~/composables/moderation.ts'

const settings = useModerationSettings()
const TraceData = getCurrentInstance()!.type
const props = defineProps<{
value: unknown
Expand Down Expand Up @@ -75,7 +79,13 @@ const text = computed(() => {
v-for="[key, item] in booleanEntries"
:key="key"
class="min-w-0"
:class="item ? 'text-purple' : 'text-primary opacity-50'"
:class="item ? '' : 'text-primary opacity-50'"
:style="{
color: item
? settings.get(moderationSettings.General.TechReviewBooleanColor) ||
'var(--color-purple)'
: undefined,
}"
>
<dt class="max-w-40 truncate whitespace-nowrap font-medium" :title="`${key}: ${item}`">
{{ key }}
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 @@ -53,6 +53,10 @@ const messages = defineMessages({
id: 'moderation.settings.issue-toggles-section',
defaultMessage: 'Issue toggles',
},
techReview: {
id: 'moderation.settings.tech-review-section',
defaultMessage: 'Tech review',
},
controlLabel: {
id: 'moderation.settings.control-label',
defaultMessage: '{section}: {setting}',
Expand All @@ -71,6 +75,10 @@ const messages = defineMessages({
id: 'moderation.settings.theme-border',
defaultMessage: 'Theme orange (25% opacity)',
},
themeTechReviewBoolean: {
id: 'moderation.settings.theme-tech-review-boolean',
defaultMessage: 'Theme purple',
},
reset: {
id: 'moderation.settings.reset',
defaultMessage: 'Reset to default',
Expand Down Expand Up @@ -141,6 +149,11 @@ const groups = [
title: messages.issueToggles,
settings: [general.IssueToggleColor],
},
{
id: 'tech-review',
title: messages.techReview,
settings: [general.TechReviewBooleanColor],
},
]

const filteredGroups = computed(() => {
Expand Down Expand Up @@ -169,7 +182,9 @@ function defaultLabel(setting: (typeof groups)[number]['settings'][number]) {
return formatMessage(
setting.id === general.FloatingReviewPanelBorderColor.id
? messages.themeBorder
: messages.themeDefault,
: setting.id === general.TechReviewBooleanColor.id
? messages.themeTechReviewBoolean
: messages.themeDefault,
)
}
if (setting.type === 'toggle') return formatMessage(setting.default ? messages.on : messages.off)
Expand Down Expand Up @@ -256,7 +271,11 @@ const { style: floatingPanelStyle } = useFloatingReviewPanelAppearance()
:label="controlLabel(group.title, setting.title)"
:default-label="defaultLabel(setting)"
:reset-value="String(resetValue(setting))"
default-color="var(--color-orange)"
:default-color="
setting.id === general.TechReviewBooleanColor.id
? 'var(--color-purple)'
: 'var(--color-orange)'
"
:model-value="configuredSettings.get(setting)"
@update:model-value="(value) => configuredSettings.set(setting, value)"
/>
Expand Down
6 changes: 6 additions & 0 deletions apps/frontend/src/locales/en-US/index.json
Original file line number Diff line number Diff line change
Expand Up @@ -3311,12 +3311,18 @@
"moderation.settings.search": {
"message": "Search settings…"
},
"moderation.settings.tech-review-section": {
"message": "Tech review"
},
"moderation.settings.theme-border": {
"message": "Theme orange (25% opacity)"
},
"moderation.settings.theme-default": {
"message": "Theme orange"
},
"moderation.settings.theme-tech-review-boolean": {
"message": "Theme purple"
},
"modpack-scan-modal.batch.label": {
"message": "{amount} per batch"
},
Expand Down
12 changes: 10 additions & 2 deletions apps/frontend/src/providers/project-review/review-submission.ts
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,15 @@ 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 Expand Up @@ -406,7 +414,7 @@ export function createReviewSubmission(
threadId: current.thread_id,
body: draft.value,
images: [...uploadedImages.value],
privateMessage: false,
privateMessage: true,
}
: undefined,
})
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
7 changes: 7 additions & 0 deletions packages/moderation/src/data/settings.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,13 @@ const settings = {
step: 25,
unit: 'ms',
}),
TechReviewBooleanColor: setting.asColor({
type: 'color',
id: 'tech-review-boolean-color',
title: 'Trace Boolean Color',
description: 'Color for Boolean values in technical review traces',
default: '',
}),
TechReviewMode: setting.asToggle({
type: 'toggle',
id: 'tech-review-mode',
Expand Down
Loading