You've already forked AstralRinth
forked from didirus/AstralRinth
Coolbot/moderation updates for versions changes (#4942)
* update reports message to the correct support bubble color * update checklist to direct to new settings pages and use v3 env info * fix: project v2 + v3 in moderation checklist funcs * Split environment stage if project uses mixed environments. --------- Co-authored-by: Calum H. (IMB11) <contact@cal.engineer>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import type { Project } from '@modrinth/utils'
|
||||
import type { Labrinth } from '@modrinth/api-client'
|
||||
|
||||
import type {
|
||||
Action,
|
||||
@@ -210,11 +210,14 @@ export function getVisibleInputs(
|
||||
|
||||
export function expandVariables(
|
||||
template: string,
|
||||
project: Project,
|
||||
project: Labrinth.Projects.v2.Project,
|
||||
projectV3: Labrinth.Projects.v3.Project,
|
||||
variables?: Record<string, string>,
|
||||
): string {
|
||||
if (!variables) {
|
||||
variables = flattenProjectVariables(project)
|
||||
variables ??= {
|
||||
...flattenStaticVariables(),
|
||||
...flattenProjectVariables(project),
|
||||
...flattenProjectV3Variables(projectV3),
|
||||
}
|
||||
|
||||
return Object.entries(variables).reduce((result, [key, value]) => {
|
||||
@@ -234,7 +237,30 @@ export function arrayOrNone(arr: string[]): string {
|
||||
return arr.length > 0 ? arr.join(', ') : 'None'
|
||||
}
|
||||
|
||||
export function flattenProjectVariables(project: Project): Record<string, string> {
|
||||
export function flattenStaticVariables(): Record<string, string> {
|
||||
const vars: Record<string, string> = {}
|
||||
|
||||
vars[`RULES`] = `[Modrinth's Content Rules](https://modrinth.com/legal/rules)`
|
||||
vars[`TOS`] = `[Terms of Use](https://modrinth.com/legal/terms)`
|
||||
vars[`COPYRIGHT_POLICY`] = `[Copyright Policy](https://modrinth.com/legal/copyright)`
|
||||
vars[`SUPPORT`] =
|
||||
`please visit the [Modrinth Help Center](https://support.modrinth.com/) and click the blue bubble to contact support.`
|
||||
vars[`MODPACK_PERMISSIONS_GUIDE`] =
|
||||
`our guide to [Obtaining Modpack Permissions](https://support.modrinth.com/en/articles/8797527-obtaining-modpack-permissions)`
|
||||
vars[`MODPACKS_ON_MODRINTH`] =
|
||||
`[Modpacks on Modrinth](https://support.modrinth.com/en/articles/8802250-modpacks-on-modrinth)`
|
||||
vars[`ADVANCED_MARKDOWN`] =
|
||||
`[Markdown Formatting Guide](https://support.modrinth.com/en/articles/8801962-advanced-markdown-formatting)`
|
||||
vars[`LICENSING_GUIDE`] =
|
||||
`our guide to [Licensing your Mods](https://modrinth.com/news/article/licensing-guide)`
|
||||
vars[`NEW_ENVIRONMENTS_LINK`] = `https://modrinth.com/news/article/new-environments`
|
||||
|
||||
return vars
|
||||
}
|
||||
|
||||
export function flattenProjectVariables(
|
||||
project: Labrinth.Projects.v2.Project,
|
||||
): Record<string, string> {
|
||||
const vars: Record<string, string> = {}
|
||||
|
||||
vars['PROJECT_ID'] = project.id
|
||||
@@ -299,22 +325,6 @@ export function flattenProjectVariables(project: Project): Record<string, string
|
||||
vars[`PROJECT_GALLERY_${index}_FEATURED`] = image.featured.toString()
|
||||
})
|
||||
|
||||
// Static time saving stuff
|
||||
vars[`RULES`] = `[Modrinth's Content Rules](https://modrinth.com/legal/rules)`
|
||||
vars[`TOS`] = `[Terms of Use](https://modrinth.com/legal/terms)`
|
||||
vars[`COPYRIGHT_POLICY`] = `[Copyright Policy](https://modrinth.com/legal/copyright)`
|
||||
vars[`SUPPORT`] =
|
||||
`please visit the [Modrinth Help Center](https://support.modrinth.com/) and click the blue bubble to contact support.`
|
||||
vars[`MODPACK_PERMISSIONS_GUIDE`] =
|
||||
`our guide to [Obtaining Modpack Permissions](https://support.modrinth.com/en/articles/8797527-obtaining-modpack-permissions)`
|
||||
vars[`MODPACKS_ON_MODRINTH`] =
|
||||
`[Modpacks on Modrinth](https://support.modrinth.com/en/articles/8802250-modpacks-on-modrinth)`
|
||||
vars[`ADVANCED_MARKDOWN`] =
|
||||
`[Markdown Formatting Guide](https://support.modrinth.com/en/articles/8801962-advanced-markdown-formatting)`
|
||||
vars[`LICENSING_GUIDE`] =
|
||||
`our guide to [Licensing your Mods](https://modrinth.com/news/article/licensing-guide)`
|
||||
vars[`NEW_ENVIRONMENTS_LINK`] = `https://modrinth.com/news/article/new-environments`
|
||||
|
||||
// Navigation related variables
|
||||
vars[`PROJECT_PERMANENT_LINK`] = `https://modrinth.com/project/${project.id}`
|
||||
vars[`PROJECT_SETTINGS_LINK`] = `https://modrinth.com/project/${project.id}/settings`
|
||||
@@ -322,6 +332,7 @@ export function flattenProjectVariables(project: Project): Record<string, string
|
||||
vars[`PROJECT_TITLE_FLINK`] = `[Name](https://modrinth.com/project/${project.id}/settings)`
|
||||
vars[`PROJECT_SLUG_FLINK`] = `[URL](https://modrinth.com/project/${project.id}/settings)`
|
||||
vars[`PROJECT_SUMMARY_FLINK`] = `[Summary](https://modrinth.com/project/${project.id}/settings)`
|
||||
// Depreciated
|
||||
vars[`PROJECT_ENVIRONMENT_FLINK`] =
|
||||
`[Environment Information](https://modrinth.com/project/${project.id}/settings/environment)`
|
||||
vars[`PROJECT_TAGS_LINK`] = `https://modrinth.com/project/${project.id}/settings/tags`
|
||||
@@ -330,18 +341,40 @@ export function flattenProjectVariables(project: Project): Record<string, string
|
||||
`https://modrinth.com/project/${project.id}/settings/description`
|
||||
vars[`PROJECT_DESCRIPTION_FLINK`] =
|
||||
`[Description](https://modrinth.com/project/${project.id}/settings/description)`
|
||||
vars[`PROJECT_LICENSE_LINK`] = `https://modrinth.com/project/${project.id}/license`
|
||||
vars[`PROJECT_LICENSE_FLINK`] = `[License](https://modrinth.com/project/${project.id}/license)`
|
||||
vars[`PROJECT_LICENSE_LINK`] = `https://modrinth.com/project/${project.id}/settings/license`
|
||||
vars[`PROJECT_LICENSE_FLINK`] =
|
||||
`[License](https://modrinth.com/project/${project.id}/settings/license)`
|
||||
vars[`PROJECT_LINKS_LINK`] = `https://modrinth.com/project/${project.id}/settings/links`
|
||||
vars[`PROJECT_LINKS_FLINK`] =
|
||||
`[External Links](https://modrinth.com/project/${project.id}/settings/links)`
|
||||
vars[`PROJECT_GALLERY_LINK`] = `https://modrinth.com/project/${project.id}/gallery`
|
||||
vars[`PROJECT_GALLERY_FLINK`] = `[Gallery](https://modrinth.com/project/${project.id}/gallery)`
|
||||
vars[`PROJECT_GALLERY_FLINK`] =
|
||||
`[Gallery](https://modrinth.com/project/${project.id}/settings/gallery)`
|
||||
vars[`PROJECT_VERSIONS_LINK`] = `https://modrinth.com/project/${project.id}/versions`
|
||||
vars[`PROJECT_VERSIONS_FLINK`] = `[Versions](https://modrinth.com/project/${project.id}/versions)`
|
||||
vars[`PROJECT_VERSIONS_FLINK`] =
|
||||
`[Versions](https://modrinth.com/project/${project.id}/settings/versions)`
|
||||
vars[`PROJECT_MODERATION_LINK`] = `https://modrinth.com/project/${project.id}/moderation`
|
||||
vars[`PROJECT_MODERATION_FLINK`] =
|
||||
`[moderation tab](https://modrinth.com/project/${project.id}/moderation)`
|
||||
|
||||
return vars
|
||||
}
|
||||
|
||||
export function flattenProjectV3Variables(
|
||||
projectV3: Labrinth.Projects.v3.Project,
|
||||
): Record<string, string> {
|
||||
const vars: Record<string, string> = {}
|
||||
|
||||
const environment = projectV3.environment ?? []
|
||||
vars['PROJECT_V3_ENVIRONMENT_COUNT'] = environment.length.toString()
|
||||
vars['PROJECT_V3_ALL_ENVIRONMENTS'] = environment.join(', ')
|
||||
|
||||
environment.forEach((env, index) => {
|
||||
vars[`PROJECT_V3_ENVIRONMENT_${index}`] = env
|
||||
})
|
||||
|
||||
vars['PROJECT_V3_REVIEW_STATUS'] = projectV3.side_types_migration_review_status
|
||||
vars['PROJECT_V3_TYPES'] = projectV3.project_types.join(', ')
|
||||
|
||||
return vars
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user