mirror of
https://github.com/modrinth/code.git
synced 2026-08-28 10:34:53 +00:00
Feat: Many moderation checklist changes (#6730)
* Rule 1.x, 3.2 and 3.3x support * reorganize * Kinda Jank dynamic list stuff that should probably be implemented better but its 1:30 am * Checklist Stage Title * Make Stage Title Good * Rule 1.x, 3.2 and 3.3x support * reorganize * Kinda Jank dynamic list stuff that should probably be implemented better but its 1:30 am * Checklist Stage Title * Make Stage Title Good * oops i forgot 3.1 * Insufficient description improvement test * "i forgor" checklist tooltips tooltips (kinda jank but they work) update to latest * only use indexedDb for moderation storage, localStorage forces a bunch of cringe * store moderation stuff separately + compact checklist stuff * give stages actual titles + rename what was previously called titles to hints * Title & Slug, Summary Description, Links, License, Gallery, Versions and Reupload migrated to new system™️ * put stageoptions before nodes * do state and variablse in tooltips * checklist fully migrated to new system, not much new has been added (yet) * forgot to only do modpack permissions for modpacks * Idk why I wasn't just mutating the builder * actual node type hierarchy + action abstraction + improve message/text handling * dropdown + "functional" quick fixes * dropdown + "functional" quick fixes * Allow moderators to suggest correct environment. * remove vestigial function * Prioritization™️ * quickest fixes in the west * start of metadata stage + optimize checklist parsing + a couple of qol features * futureproof™️ environment metadata + just give me project context everywhere * tidy up after today's refactoring * tidy up after tidying up after today's refactoring * move loaders to metadata (from versions) * better required display + vueify + reorganize messages + tag quick fixes + todo * fix log spam + concat md * more bugs * nested state access * update description stage, add showcase clarity * Fix links stage mostly, and tweak metadata stage. * fix links lag + actions on stages * setup links bonus buttons * Change stage order * Update rules stage * Move conditional stages to the top where they belong. * fix some metadata stuff * fix stage selector * don't show non-english buttons on servers without english support. * prepr * stop linter from trying to break my markdown * fix: some issues * fix: lint * not sure why but link's links weren't links * fix quick fixes (again) (idk how they keep breaking) * make messages only actually count as messages if they actually have content * rename horror button to spoilers button * Update links name to match the links settings * re-review stage * unbreak stage selector * passing off version stage fixing. * actually fix the stage selector this time * fix showcase clarity msg * redirect when checklist updates slug fix initial stage not being first if first stage is only shown under certain conditions move to a consistent naming scheme * redirect when checklist updates slug fix initial stage not being first if first stage is only shown under certain conditions move to a consistent naming scheme * ok maybe lets use kebab * move custom description advice stage to first button. * temp priority on corrections applied * make metadata page go to non setting versions page * links stage bonus buttons, src required flag, show link value in msgs, fix msg groupings. * update re-review button * reupload stage navigates to project Description. * fix: link stage using page context too late * chore: run prepr * fix(ci): tell typo check to ignore moderation utils * fix: pr comment if storybook fails * make complex nodes less complex (for the most part) fix re-review stage shown condition new fancy message collection system all buttons that contribute to messages now have relevant tooltips don't store default values in checklist db * make complex nodes less complex (for the most part) fix re-review stage shown condition new fancy message collection system all buttons that contribute to messages now have relevant tooltips don't store default values in checklist db * maybe fixed markdown escaping? * tweak re-review wording. * Update license stage handling and info * add mixed option back for env info * fix: formatEnvironments fix: formatEnvironments * update metadata environment group shown * fix: status alert priority * fix: display suggested slug in slug/misused message * actually navigate when we change project slug * ok like redirect but like don't lose state when slug changes :smart: * make checklist reset button reset only current stage if there's modifications to it instead of full checklist * fix versions stage messages not working * fix donation links not being in a column * I think slug stuff is working? also like actually 100% garunteed markdown escaping works now * prepr * pseudo stages no longer interact with non-pseudo stages at all also query projects better I think? fix repetitive message spam in links stage * apply quick fixes before refreshing page * differentiate reset and return to start * remove random empty lines in some situations * better inaccurate slug message * slug correction input reset button resets to current slug again instead of auto * better keybind navigation * incorrect environment message tweak * use environment name(s) in checklist info * prepr --------- Signed-off-by: Prospector <6166773+Prospector@users.noreply.github.com> Co-authored-by: chyzman <chyzalt@gmail.com> Co-authored-by: Calum H. (IMB11) <contact@cal.engineer> Co-authored-by: Gravy Boat <gravy@thatgravyboat.tech> Co-authored-by: Michael H. <michael@iptables.sh> Co-authored-by: chyz <32403637+chyzman@users.noreply.github.com> Co-authored-by: Prospector <6166773+Prospector@users.noreply.github.com>
This commit is contained in:
co-authored by
chyzman
Calum H.
Gravy Boat
Michael H.
chyz
Prospector
parent
30e23e5cc2
commit
e2085c43c5
@@ -10,7 +10,7 @@ import type {
|
||||
|
||||
export interface ActionState {
|
||||
selected: boolean
|
||||
value?: Set<number> | number | string | unknown
|
||||
value?: Set<string | number> | number | string | unknown
|
||||
}
|
||||
|
||||
export interface MessagePart {
|
||||
@@ -20,10 +20,6 @@ export interface MessagePart {
|
||||
stageIndex: number
|
||||
}
|
||||
|
||||
export type SerializedActionState = {
|
||||
isSet?: boolean
|
||||
} & ActionState
|
||||
|
||||
export function getActionIdForStage(
|
||||
action: Action,
|
||||
stageIndex: number,
|
||||
@@ -50,34 +46,6 @@ export function getActionKey(
|
||||
return `${currentStage}-${index}-${getActionId(action, currentStage)}`
|
||||
}
|
||||
|
||||
export function serializeActionStates(states: Record<string, ActionState>): string {
|
||||
const serializable: Record<string, SerializedActionState> = {}
|
||||
for (const [key, state] of Object.entries(states)) {
|
||||
serializable[key] = {
|
||||
selected: state.selected,
|
||||
value: state.value instanceof Set ? Array.from(state.value) : state.value,
|
||||
isSet: state.value instanceof Set,
|
||||
}
|
||||
}
|
||||
return JSON.stringify(serializable)
|
||||
}
|
||||
|
||||
export function deserializeActionStates(data: string): Record<string, ActionState> {
|
||||
try {
|
||||
const parsed = JSON.parse(data)
|
||||
const states: Record<string, ActionState> = {}
|
||||
for (const [key, state] of Object.entries(parsed as Record<string, SerializedActionState>)) {
|
||||
states[key] = {
|
||||
selected: state.selected,
|
||||
value: state.isSet ? new Set(state.value as unknown[]) : state.value,
|
||||
}
|
||||
}
|
||||
return states
|
||||
} catch {
|
||||
return {}
|
||||
}
|
||||
}
|
||||
|
||||
export function initializeActionState(action: Action): ActionState {
|
||||
if (action.type === 'toggle') {
|
||||
return {
|
||||
@@ -91,7 +59,7 @@ export function initializeActionState(action: Action): ActionState {
|
||||
} else if (action.type === 'multi-select-chips') {
|
||||
return {
|
||||
selected: false,
|
||||
value: new Set<number>(),
|
||||
value: new Set<string | number>(),
|
||||
}
|
||||
} else {
|
||||
return {
|
||||
@@ -226,6 +194,65 @@ export function expandVariables(
|
||||
}, template)
|
||||
}
|
||||
|
||||
export const licensesNotRequiringSource: string[] = [
|
||||
'LicenseRef-All-Rights-Reserved',
|
||||
'Apache-2.0',
|
||||
'BSD-2-Clause',
|
||||
'BSD-3-Clause',
|
||||
'CC0-1.0',
|
||||
'CC-BY-4.0',
|
||||
'CC-BY-SA-4.0',
|
||||
'CC-BY-NC-4.0',
|
||||
'CC-BY-NC-SA-4.0',
|
||||
'CC-BY-ND-4.0',
|
||||
'CC-BY-NC-ND-4.0',
|
||||
'ISC',
|
||||
'MIT',
|
||||
'Zlib',
|
||||
]
|
||||
|
||||
export const licensesRequiringSource: string[] = [
|
||||
'GPL-2.0',
|
||||
'GPL-2.0+',
|
||||
'GPL-2.0-only',
|
||||
'GPL-2.0-or-later',
|
||||
'GPL-3.0',
|
||||
'GPL-3.0+',
|
||||
'GPL-3.0-only',
|
||||
'GPL-3.0-or-later',
|
||||
'LGPL-2.1',
|
||||
'LGPL-2.1+',
|
||||
'LGPL-2.1-only',
|
||||
'LGPL-2.1-or-later',
|
||||
'LGPL-3.0',
|
||||
'LGPL-3.0+',
|
||||
'LGPL-3.0-only',
|
||||
'LGPL-3.0-or-later',
|
||||
'AGPL-3.0',
|
||||
'AGPL-3.0+',
|
||||
'AGPL-3.0-only',
|
||||
'AGPL-3.0-or-later',
|
||||
'MPL-2.0',
|
||||
]
|
||||
|
||||
export function licenseDoesNotRequireSource(licenseId: string): boolean {
|
||||
return licensesNotRequiringSource.includes(licenseId)
|
||||
}
|
||||
export function licenseMayRequireSource(licenseId: string): boolean {
|
||||
return !licensesNotRequiringSource.includes(licenseId)
|
||||
}
|
||||
export function licenseRequiresSource(licenseId: string): boolean {
|
||||
return licensesRequiringSource.includes(licenseId)
|
||||
}
|
||||
|
||||
export function notSourceAsDistributed(projectTypes): boolean {
|
||||
return projectTypes.includes('mod') || projectTypes.includes('plugin')
|
||||
}
|
||||
|
||||
export function promptSourceRequired(licenseId: string, projectTypes): boolean {
|
||||
return licenseRequiresSource(licenseId) && notSourceAsDistributed(projectTypes)
|
||||
}
|
||||
|
||||
export function kebabToTitleCase(input: string): string {
|
||||
return input
|
||||
.split('-')
|
||||
@@ -256,6 +283,39 @@ export function formatProjectTypes(type: string, lower: boolean = false) {
|
||||
return value
|
||||
}
|
||||
|
||||
export function formatEnvironments(environment: string, lower: boolean = false) {
|
||||
let value = environment
|
||||
try {
|
||||
value = value
|
||||
.replaceAll('client_only_server_optional', 'Client and server: Optional on server')
|
||||
.replaceAll('client_and_server', 'Required on both')
|
||||
.replaceAll('client_only', 'Client-side only')
|
||||
.replaceAll('server_only_client_optional', 'Client optional')
|
||||
.replaceAll('dedicated_server_only', 'Dedicated server only')
|
||||
.replaceAll('server_only', 'Servers and Singleplayer')
|
||||
.replaceAll('singleplayer_only', 'Singleplayer only')
|
||||
.replaceAll(
|
||||
'client_or_server_prefers_both',
|
||||
'Optional on both, works best when installed on both sides',
|
||||
)
|
||||
.replaceAll(
|
||||
'client_or_server',
|
||||
'Optional on both, works the same if installed on either side',
|
||||
)
|
||||
// This shouldn't come up for this use but yk
|
||||
.replaceAll('unknown', 'Unknown')
|
||||
} catch {
|
||||
return 'No project environment'
|
||||
}
|
||||
|
||||
if (lower === true) value = value.toLowerCase()
|
||||
return value
|
||||
}
|
||||
|
||||
export function requiresEnvironmentInfo(projectTypes): boolean {
|
||||
return projectTypes.includes('mod') || projectTypes.includes('modpack')
|
||||
}
|
||||
|
||||
export function flattenStaticVariables(): Record<string, string> {
|
||||
const vars: Record<string, string> = {}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user