Add loading state to envs
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
<template>
|
<template>
|
||||||
<div v-if="showEnvironmentMigration" class="card experimental-styles-within">
|
<LoadingIndicator v-if="!projectV3" class="py-6" />
|
||||||
|
<div v-else-if="showEnvironmentMigration" class="card experimental-styles-within">
|
||||||
<h2 class="m-0 mb-2 block text-lg font-extrabold text-contrast">Project environment</h2>
|
<h2 class="m-0 mb-2 block text-lg font-extrabold text-contrast">Project environment</h2>
|
||||||
<EnvironmentMigration />
|
<EnvironmentMigration />
|
||||||
</div>
|
</div>
|
||||||
@@ -25,10 +26,15 @@
|
|||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { SettingsIcon } from '@modrinth/assets'
|
import { SettingsIcon } from '@modrinth/assets'
|
||||||
import { ButtonStyled, EnvironmentMigration, injectProjectPageContext } from '@modrinth/ui'
|
import {
|
||||||
|
ButtonStyled,
|
||||||
|
EnvironmentMigration,
|
||||||
|
injectProjectPageContext,
|
||||||
|
LoadingIndicator,
|
||||||
|
} from '@modrinth/ui'
|
||||||
import { isStaff } from '@modrinth/utils'
|
import { isStaff } from '@modrinth/utils'
|
||||||
|
|
||||||
const { currentMember, projectV2 } = injectProjectPageContext()
|
const { currentMember, projectV2, projectV3 } = injectProjectPageContext()
|
||||||
|
|
||||||
const showEnvironmentMigration = computed(() => {
|
const showEnvironmentMigration = computed(() => {
|
||||||
return isStaff(currentMember.value?.user)
|
return isStaff(currentMember.value?.user)
|
||||||
|
|||||||
@@ -21,14 +21,14 @@ const { handleError } = injectNotificationManager()
|
|||||||
const client = injectModrinthClient()
|
const client = injectModrinthClient()
|
||||||
|
|
||||||
const supportsEnvironment = computed(() =>
|
const supportsEnvironment = computed(() =>
|
||||||
projectV3.value.project_types.some((type) => ['mod', 'modpack'].includes(type)),
|
(projectV3.value?.project_types ?? []).some((type) => ['mod', 'modpack'].includes(type)),
|
||||||
)
|
)
|
||||||
|
|
||||||
const needsToVerify = computed(
|
const needsToVerify = computed(
|
||||||
() =>
|
() =>
|
||||||
projectV3.value.side_types_migration_review_status === 'pending' &&
|
projectV3.value?.side_types_migration_review_status === 'pending' &&
|
||||||
(projectV3.value.environment?.length ?? 0) > 0 &&
|
(projectV3.value?.environment?.length ?? 0) > 0 &&
|
||||||
projectV3.value.environment?.[0] !== 'unknown' &&
|
projectV3.value?.environment?.[0] !== 'unknown' &&
|
||||||
supportsEnvironment.value,
|
supportsEnvironment.value,
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -38,13 +38,14 @@ const hasPermission = computed(() => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
function getInitialEnv() {
|
function getInitialEnv() {
|
||||||
return projectV3.value.environment?.length === 1 ? projectV3.value.environment[0] : undefined
|
const env = projectV3.value?.environment
|
||||||
|
return env?.length === 1 ? env[0] : undefined
|
||||||
}
|
}
|
||||||
|
|
||||||
const { saved, current, saving, reset, save } = useSavable(
|
const { saved, current, saving, reset, save } = useSavable(
|
||||||
() => ({
|
() => ({
|
||||||
environment: getInitialEnv(),
|
environment: getInitialEnv(),
|
||||||
side_types_migration_review_status: projectV3.value.side_types_migration_review_status,
|
side_types_migration_review_status: projectV3.value?.side_types_migration_review_status,
|
||||||
}),
|
}),
|
||||||
async ({ environment }) => {
|
async ({ environment }) => {
|
||||||
try {
|
try {
|
||||||
@@ -130,7 +131,7 @@ const messages = defineMessages({
|
|||||||
/>
|
/>
|
||||||
<Admonition
|
<Admonition
|
||||||
v-else-if="
|
v-else-if="
|
||||||
!projectV3.environment ||
|
!projectV3?.environment ||
|
||||||
projectV3.environment.length === 0 ||
|
projectV3.environment.length === 0 ||
|
||||||
(projectV3.environment.length === 1 && projectV3.environment[0] === 'unknown')
|
(projectV3.environment.length === 1 && projectV3.environment[0] === 'unknown')
|
||||||
"
|
"
|
||||||
@@ -140,7 +141,7 @@ const messages = defineMessages({
|
|||||||
class="mb-3"
|
class="mb-3"
|
||||||
/>
|
/>
|
||||||
<Admonition
|
<Admonition
|
||||||
v-else-if="projectV3.environment.length > 1"
|
v-else-if="(projectV3?.environment?.length ?? 0) > 1"
|
||||||
type="info"
|
type="info"
|
||||||
:header="formatMessage(messages.multipleEnvironmentsTitle)"
|
:header="formatMessage(messages.multipleEnvironmentsTitle)"
|
||||||
:body="formatMessage(messages.multipleEnvironmentsDescription)"
|
:body="formatMessage(messages.multipleEnvironmentsDescription)"
|
||||||
|
|||||||
Reference in New Issue
Block a user