feat: moderation settings (#6895)

* feat: moderation settings

* chore: move moderation specific feature flag to settings

* feat: force open collapsed regions if opened in new tab

* chore: remove unused field

* chore: run prepr
This commit is contained in:
ThatGravyBoat
2026-07-28 19:38:56 +00:00
committed by GitHub
parent 82348fe40a
commit fe69e04785
25 changed files with 698 additions and 416 deletions
+46 -5
View File
@@ -1,77 +1,118 @@
import type { KeybindListener } from '../types/keybinds'
import type { Labrinth } from '@modrinth/api-client'
const copyProjectLink = async (
project: Labrinth.Projects.v2.Project,
permalink: boolean,
relative: boolean,
page: boolean,
) => {
let url = ``
if (relative) {
url += `${globalThis.location.origin}`
} else {
url += `https://modrinth.com`
}
if (permalink) {
url += `/project/${project.id}`
} else {
url += `/${project.project_type}/${project.slug}`
}
if (page) {
url += `/${globalThis.location.pathname.split('/').slice(3).join('/')}`
}
await navigator.clipboard.writeText(url)
}
const keybinds: { [id: string]: KeybindListener } = {
'next-stage': {
keybind: 'ArrowRight',
description: 'Go to next stage',
scope: 'checklist',
enabled: (ctx) => !ctx.state.isDone,
action: (ctx) => ctx.actions.tryGoNext(),
},
'previous-stage': {
keybind: 'ArrowLeft',
description: 'Go to previous stage',
scope: 'checklist',
enabled: (ctx) => !ctx.state.isDone,
action: (ctx) => ctx.actions.tryGoBack(),
},
'generate-message': {
keybind: 'Ctrl+Shift+E',
description: 'Generate moderation message',
scope: 'checklist',
action: (ctx) => ctx.actions.tryGenerateMessage(),
},
'toggle-collapse': {
keybind: 'Shift+C',
description: 'Toggle collapse/expand',
scope: 'checklist',
action: (ctx) => ctx.actions.tryToggleCollapse(),
},
'reset-progress': {
keybind: 'Ctrl+Shift+R',
description: 'Reset moderation progress',
scope: 'checklist',
action: (ctx) => ctx.actions.tryResetProgress(),
},
'skip-project': {
keybind: 'Ctrl+Shift+S',
description: 'Skip to next project',
scope: 'checklist',
enabled: (ctx) => ctx.state.futureProjectCount > 0 && !ctx.state.isDone,
action: (ctx) => ctx.actions.trySkipProject(),
},
'copy-permalink': {
keybind: 'Ctrl+Alt+C',
description: 'Copy permalink',
action: (ctx) => ctx.actions.tryCopyLink(true, false, false),
scope: 'project',
action: async (ctx) => copyProjectLink(ctx.project, true, false, false),
},
'copy-relative-permalink': {
keybind: 'Ctrl+Alt+R',
description: 'Copy relative permalink',
action: (ctx) => ctx.actions.tryCopyLink(true, true, false),
scope: 'project',
action: async (ctx) => copyProjectLink(ctx.project, true, true, false),
},
'copy-page-permalink': {
keybind: 'Shift+Ctrl+Alt+C',
description: 'Copy permalink with page',
action: (ctx) => ctx.actions.tryCopyLink(true, false, true),
scope: 'project',
action: async (ctx) => copyProjectLink(ctx.project, true, false, true),
},
'copy-page-relative-permalink': {
keybind: 'Shift+Ctrl+Alt+R',
description: 'Copy relative permalink with page',
action: (ctx) => ctx.actions.tryCopyLink(true, true, true),
scope: 'project',
action: async (ctx) => copyProjectLink(ctx.project, true, true, true),
},
'copy-id': {
keybind: 'Ctrl+Alt+D',
description: 'Copy Project ID',
action: (ctx) => ctx.actions.tryCopyId(),
scope: 'project',
action: async (ctx) => await navigator.clipboard.writeText(ctx.project.id),
},
'approve-project': {
keybind: 'Shift+Alt+A',
description: 'Approve project',
scope: 'checklist',
action: (ctx) => ctx.actions.tryApprove(),
},
'withhold-project': {
keybind: 'Shift+Alt+W',
description: 'Withhold project',
scope: 'checklist',
action: (ctx) => ctx.actions.tryWithhold(),
},
'reject-project': {
keybind: 'Shift+Alt+R',
description: 'Reject project',
scope: 'checklist',
action: (ctx) => ctx.actions.tryReject(),
},
}
+33
View File
@@ -0,0 +1,33 @@
import type { EnumSettingDefinition, ToggleSettingDefinition } from '../types/settings.ts'
const settings = {
General: {
ChecklistPosition: {
type: 'enum',
id: 'checklist-position',
title: 'Checklist Position',
description: 'Where the checklist should be displayed on the page',
entries: [
{ value: 'left', label: 'Left' },
{ value: 'right', label: 'Right' },
],
default: 'right',
} as EnumSettingDefinition,
ProjectKeybinds: {
type: 'toggle',
id: 'project-keybinds',
title: 'Enable Project Keybinds',
description: 'Weather certain keybinds should work without the checklist visible.',
default: false,
} as ToggleSettingDefinition,
PrivateMessageHighlight: {
type: 'toggle',
id: 'private-message-highlight',
title: 'Highlight Private Messages',
description: 'Whether private messages should be highlighted in the chat.',
default: true,
} as ToggleSettingDefinition,
},
} as const
export default settings