Skip to content

Commit 3dd5314

Browse files
committed
Add loading state to envs
1 parent d77823c commit 3dd5314

2 files changed

Lines changed: 18 additions & 11 deletions

File tree

apps/frontend/src/pages/[type]/[id]/settings/environment.vue

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
<template>
2-
<div v-if="showEnvironmentMigration" class="card experimental-styles-within">
2+
<LoadingIndicator v-if="!projectV3" class="py-6" />
3+
<div v-else-if="showEnvironmentMigration" class="card experimental-styles-within">
34
<h2 class="m-0 mb-2 block text-lg font-extrabold text-contrast">Project environment</h2>
45
<EnvironmentMigration />
56
</div>
@@ -25,10 +26,15 @@
2526

2627
<script setup lang="ts">
2728
import { SettingsIcon } from '@modrinth/assets'
28-
import { ButtonStyled, EnvironmentMigration, injectProjectPageContext } from '@modrinth/ui'
29+
import {
30+
ButtonStyled,
31+
EnvironmentMigration,
32+
injectProjectPageContext,
33+
LoadingIndicator,
34+
} from '@modrinth/ui'
2935
import { isStaff } from '@modrinth/utils'
3036
31-
const { currentMember, projectV2 } = injectProjectPageContext()
37+
const { currentMember, projectV2, projectV3 } = injectProjectPageContext()
3238
3339
const showEnvironmentMigration = computed(() => {
3440
return isStaff(currentMember.value?.user)

packages/ui/src/components/project/settings/environment/EnvironmentMigration.vue

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -21,14 +21,14 @@ const { handleError } = injectNotificationManager()
2121
const client = injectModrinthClient()
2222
2323
const supportsEnvironment = computed(() =>
24-
projectV3.value.project_types.some((type) => ['mod', 'modpack'].includes(type)),
24+
(projectV3.value?.project_types ?? []).some((type) => ['mod', 'modpack'].includes(type)),
2525
)
2626
2727
const needsToVerify = computed(
2828
() =>
29-
projectV3.value.side_types_migration_review_status === 'pending' &&
30-
(projectV3.value.environment?.length ?? 0) > 0 &&
31-
projectV3.value.environment?.[0] !== 'unknown' &&
29+
projectV3.value?.side_types_migration_review_status === 'pending' &&
30+
(projectV3.value?.environment?.length ?? 0) > 0 &&
31+
projectV3.value?.environment?.[0] !== 'unknown' &&
3232
supportsEnvironment.value,
3333
)
3434
@@ -38,13 +38,14 @@ const hasPermission = computed(() => {
3838
})
3939
4040
function getInitialEnv() {
41-
return projectV3.value.environment?.length === 1 ? projectV3.value.environment[0] : undefined
41+
const env = projectV3.value?.environment
42+
return env?.length === 1 ? env[0] : undefined
4243
}
4344
4445
const { saved, current, saving, reset, save } = useSavable(
4546
() => ({
4647
environment: getInitialEnv(),
47-
side_types_migration_review_status: projectV3.value.side_types_migration_review_status,
48+
side_types_migration_review_status: projectV3.value?.side_types_migration_review_status,
4849
}),
4950
async ({ environment }) => {
5051
try {
@@ -130,7 +131,7 @@ const messages = defineMessages({
130131
/>
131132
<Admonition
132133
v-else-if="
133-
!projectV3.environment ||
134+
!projectV3?.environment ||
134135
projectV3.environment.length === 0 ||
135136
(projectV3.environment.length === 1 && projectV3.environment[0] === 'unknown')
136137
"
@@ -140,7 +141,7 @@ const messages = defineMessages({
140141
class="mb-3"
141142
/>
142143
<Admonition
143-
v-else-if="projectV3.environment.length > 1"
144+
v-else-if="(projectV3?.environment?.length ?? 0) > 1"
144145
type="info"
145146
:header="formatMessage(messages.multipleEnvironmentsTitle)"
146147
:body="formatMessage(messages.multipleEnvironmentsDescription)"

0 commit comments

Comments
 (0)