Self-hosted personal gallery application with online photo management and albums, supporting Live/Motion Photos, EXIF parsing, geolocation recognition, and an explore map.
TypeScript albumsexif-extractiongeocodinglive-photomotion-photophoto-galleryphoto-sharingwebgl-viewer
fix(wizard): stop rendering JSON settings as text inputs
Ahmet Ömer0381a5f693e6
diff --git a/apps/self-hosted/app/pages/onboarding/site.vue b/apps/self-hosted/app/pages/onboarding/site.vueindex 9f8fdb17..d766b611 100644--- a/apps/self-hosted/app/pages/onboarding/site.vue+++ b/apps/self-hosted/app/pages/onboarding/site.vue@@ -1,5 +1,6 @@<script setup lang="ts">import { z } from 'zod'+import type { FieldDescriptor } from '@chronoframe/gallery/shared/types/settings'import type { ProviderOption } from '~/components/Wizard/ProviderSelector.vue'import { useWizardStore } from '~/stores/wizard'@@ -21,6 +22,11 @@ const {isFieldVisible,} = useWizardForm('app')+function isTextEditable(field: FieldDescriptor) {+ const value = state.value[field.key]+ return field.type !== 'json' && (value === null || typeof value !== 'object')+}+const schema = z.object({title: z.string().min(1, $t('onboarding.site.invalidTitle')),slogan: z.string().optional(),@@ -79,7 +85,7 @@ function onSubmit() {/></WizardFormField><WizardFormField- v-else-if="isFieldVisible(field)"+ v-else-if="isFieldVisible(field) && isTextEditable(field)":label="$t(field.label || '')":name="field.key":required="field.ui.required"diff --git a/apps/self-hosted/server/api/wizard/schema.get.ts b/apps/self-hosted/server/api/wizard/schema.get.tsindex 0c369cd1..69651c24 100644--- a/apps/self-hosted/server/api/wizard/schema.get.ts+++ b/apps/self-hosted/server/api/wizard/schema.get.ts@@ -3,6 +3,7 @@ import { z } from 'zod'import { settingsManager } from '~~/server/services/settings/settingsManager'import { getHiddenSettingKeys } from '~~/server/services/settings/contants'import { getSettingUIConfig } from '~~/server/services/settings/ui-config'+import { isWizardRenderableField } from '~~/server/services/settings/wizard-fields'import type { FieldDescriptor } from '~~/shared/types/settings'export default defineWizardHandler(async (event) => {@@ -235,7 +236,10 @@ export default defineWizardHandler(async (event) => {const schema = await settingsManager.getSchema()const hiddenKeys = getHiddenSettingKeys(query.namespace)const namespaceSettings = schema.filter(- (s) => s.namespace === query.namespace && !hiddenKeys.has(s.key),+ (s) =>+ s.namespace === query.namespace &&+ !hiddenKeys.has(s.key) &&+ isWizardRenderableField(s),)const fields = namespaceSettings.map((setting) => {diff --git a/apps/self-hosted/server/services/settings/wizard-fields.ts b/apps/self-hosted/server/services/settings/wizard-fields.tsnew file mode 100644index 00000000..f901cd76--- /dev/null+++ b/apps/self-hosted/server/services/settings/wizard-fields.ts@@ -0,0 +1,15 @@+import type { SettingConfig } from '~~/shared/types/settings'++/**+ * The setup wizard only renders scalar settings. JSON settings (objects or+ * arrays, such as `socialLinks`) have no text representation and are edited+ * from the dashboard, which provides dedicated controls for them.+ */+export function isWizardRenderableField(+ field: Pick<SettingConfig, 'type' | 'value' | 'defaultValue'>,+): boolean {+ if (field.type === 'json') return false++ const value = field.value ?? field.defaultValue+ return value === null || typeof value !== 'object'+}diff --git a/tests/wizard-fields.test.ts b/tests/wizard-fields.test.tsnew file mode 100644index 00000000..78cd3f80--- /dev/null+++ b/tests/wizard-fields.test.ts@@ -0,0 +1,68 @@+import assert from 'node:assert/strict'+import test from 'node:test'+import { PUBLIC_GALLERY_DEFAULTS } from '@chronoframe/contracts/gallery-settings'+import { isWizardRenderableField } from '../apps/self-hosted/server/services/settings/wizard-fields.ts'++test('wizard excludes JSON settings such as socialLinks', () => {+ assert.equal(+ isWizardRenderableField({+ type: 'json',+ value: PUBLIC_GALLERY_DEFAULTS.app.socialLinks,+ defaultValue: PUBLIC_GALLERY_DEFAULTS.app.socialLinks,+ }),+ false,+ )+})++test('wizard excludes object and array values from text inputs', () => {+ assert.equal(+ isWizardRenderableField({+ type: 'string',+ value: { links: [] },+ defaultValue: '',+ }),+ false,+ )+ assert.equal(+ isWizardRenderableField({+ type: 'string',+ value: ['https://example.com'],+ defaultValue: '',+ }),+ false,+ )+})++test('wizard keeps scalar settings', () => {+ const fields = [+ { type: 'string', value: 'photos', defaultValue: '' },+ { type: 'number', value: 42, defaultValue: 0 },+ { type: 'boolean', value: true, defaultValue: false },+ { type: 'string', value: null, defaultValue: '' },+ ] as const++ for (const field of fields) {+ assert.equal(+ isWizardRenderableField(field),+ true,+ `expected ${String(field.value)} to be renderable`,+ )+ }+})++test('wizard falls back to the default value when value is missing', () => {+ assert.equal(+ isWizardRenderableField({+ type: 'string',+ defaultValue: 'photos',+ }),+ true,+ )+ assert.equal(+ isWizardRenderableField({+ type: 'json',+ defaultValue: PUBLIC_GALLERY_DEFAULTS.app.socialLinks,+ }),+ false,+ )+})