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(social-links): polish settings form feedback and layout
Ahmet Ömer435de0e6c354
diff --git a/packages/console/app/composables/useSettingsForm.ts b/packages/console/app/composables/useSettingsForm.tsindex e7dce94c..7176d94d 100644--- a/packages/console/app/composables/useSettingsForm.ts+++ b/packages/console/app/composables/useSettingsForm.ts@@ -5,6 +5,7 @@ import type {SettingsFieldsResponse,} from '@chronoframe/gallery/shared/types/settings'import {+ MAX_SOCIAL_LINKS,isSocialLinkErrorCode,SocialLinkError,} from '@chronoframe/contracts/social-links'@@ -124,7 +125,9 @@ export function useSettingsForm(namespace: string) {if (isSocialLinkErrorCode(socialFailure.code)) {throw new SocialLinkError(socialFailure.code,- t(`settings.app.socialLinks.${socialFailure.code}`),+ t(`settings.app.socialLinks.${socialFailure.code}`, {+ max: MAX_SOCIAL_LINKS,+ }),)}throw new Error(t('settings.form.saveFailed'))diff --git a/packages/console/app/pages/dashboard/settings/general.vue b/packages/console/app/pages/dashboard/settings/general.vueindex 769382da..e6aac9b0 100644--- a/packages/console/app/pages/dashboard/settings/general.vue+++ b/packages/console/app/pages/dashboard/settings/general.vue@@ -88,6 +88,14 @@ const resetSocialLinks = () => {}const socialSubmitError = ref('')+watch(+ socialDraft,+ () => {+ socialSubmitError.value = ''+ },+ { deep: true },+)+const handleSocialLinksSubmit = async () => {socialSubmitError.value = ''const draftAtSubmission = [...socialDraft.value]@@ -102,9 +110,15 @@ const handleSocialLinksSubmit = async () => {savedSocialLinks.value,)} catch (error) {+ if (+ socialDraft.value.some(+ (value, index) => value !== draftAtSubmission[index],+ )+ )+ returnsocialSubmitError.value =error instanceof SocialLinkError- ? t(`settings.app.socialLinks.${error.code}`)+ ? t(`settings.app.socialLinks.${error.code}`, { max: MAX_SOCIAL_LINKS }): t('settings.form.saveFailed')}}@@ -337,7 +351,11 @@ const handleAppearanceSettingsSubmit = async () => {{{ $t('settings.app.socialLinks.title') }}</h3><p class="mt-1 text-sm text-neutral-600 dark:text-neutral-400">- {{ $t('settings.app.socialLinks.description') }}+ {{+ $t('settings.app.socialLinks.description', {+ max: MAX_SOCIAL_LINKS,+ })+ }}</p></header>@@ -359,43 +377,30 @@ const handleAppearanceSettingsSubmit = async () => {<divv-for="(_, index) in socialDraft":key="index"- class="flex items-start gap-3"+ class="grid grid-cols-[20px_minmax(0,1fr)_auto] items-center gap-x-3">+ <label+ :for="`social-link-${index}`"+ class="col-start-2 col-span-2 row-start-1 mb-1 block text-sm font-medium text-neutral-900 dark:text-neutral-100"+ >+ {{ $t('settings.app.socialLinks.slot', { number: index + 1 }) }}+ </label><Icon:name="resolveSocialPlatform(socialDraft[index] || '').icon"- class="mt-2.5 shrink-0 text-xl text-neutral-500 dark:text-neutral-400"+ class="col-start-1 row-start-2 self-center text-xl text-neutral-500 dark:text-neutral-400"aria-hidden="true"/>- <div class="min-w-0 flex-1">- <label- :for="`social-link-${index}`"- class="mb-1 block text-sm font-medium text-neutral-900 dark:text-neutral-100"- >- {{- $t('settings.app.socialLinks.slot', { number: index + 1 })- }}- </label>- <UInput- :id="`social-link-${index}`"- v-model="socialDraft[index]"- type="url"- class="w-full"- :placeholder="$t('settings.app.socialLinks.placeholder')"- :aria-invalid="Boolean(socialErrors[index])"- :aria-describedby="- socialErrors[index]- ? `social-link-error-${index}`- : undefined- "- />- <p- v-if="socialErrors[index]"- :id="`social-link-error-${index}`"- class="mt-1 text-sm text-error-600 dark:text-error-400"- >- {{ socialErrors[index] }}- </p>- </div>+ <UInput+ :id="`social-link-${index}`"+ v-model="socialDraft[index]"+ type="url"+ class="col-start-2 row-start-2 w-full min-w-0"+ :placeholder="$t('settings.app.socialLinks.placeholder')"+ :aria-invalid="Boolean(socialErrors[index])"+ :aria-describedby="+ socialErrors[index] ? `social-link-error-${index}` : undefined+ "+ /><UButtonv-if="socialDraft[index]"type="button"@@ -405,9 +410,16 @@ const handleAppearanceSettingsSubmit = async () => {:aria-label="$t('settings.app.socialLinks.clear', { number: index + 1 })"- class="mt-6"+ class="col-start-3 row-start-2 self-center"@click="socialDraft[index] = ''"/>+ <p+ v-if="socialErrors[index]"+ :id="`social-link-error-${index}`"+ class="col-start-2 col-span-2 row-start-3 mt-1 text-sm text-error-600 dark:text-error-400"+ >+ {{ socialErrors[index] }}+ </p></div><p@@ -418,25 +430,33 @@ const handleAppearanceSettingsSubmit = async () => {{{ socialSubmitError }}</p><div- class="flex items-center justify-end gap-2 border-t border-neutral-200 pt-4 dark:border-neutral-800"+ class="border-t border-neutral-200 pt-4 dark:border-neutral-800">- <UButton- type="button"- color="neutral"- variant="outline"- :disabled="!isSocialDirty || loading"- @click="resetSocialLinks"+ <div+ v-if="isSocialDirty"+ class="mb-3 rounded-md border border-warning-200 bg-warning-50 px-3 py-2 text-sm text-warning-800 dark:border-warning-900/60 dark:bg-warning-950/30 dark:text-warning-200">- {{ $t('common.actions.reset') }}- </UButton>- <UButton- type="submit"- icon="tabler:device-floppy"- :loading="loading"- :disabled="!isSocialDirty || socialErrors.some(Boolean)"- >- {{ $t('common.actions.saveSettings') }}- </UButton>+ {{ $t('common.unsavedChanges') }}+ </div>+ <div class="flex items-center justify-end gap-2">+ <UButton+ type="button"+ color="neutral"+ variant="outline"+ :disabled="!isSocialDirty || loading"+ @click="resetSocialLinks"+ >+ {{ $t('common.actions.reset') }}+ </UButton>+ <UButton+ type="submit"+ icon="tabler:device-floppy"+ :loading="loading"+ :disabled="!isSocialDirty || socialErrors.some(Boolean)"+ >+ {{ $t('common.actions.saveSettings') }}+ </UButton>+ </div></div></form></section>diff --git a/packages/contracts/src/social-links.ts b/packages/contracts/src/social-links.tsindex f5e63ec4..4feab83b 100644--- a/packages/contracts/src/social-links.ts+++ b/packages/contracts/src/social-links.ts@@ -103,7 +103,10 @@ export function parseSocialLinks(value: unknown): string[] {const links = (value as { links: unknown[] }).linksif (links.length > MAX_SOCIAL_LINKS)- throw new SocialLinkError('limit', 'Use at most four social links')+ throw new SocialLinkError(+ 'limit',+ `Use at most ${MAX_SOCIAL_LINKS} social links`,+ )const seen = new Set<string>()return links.map((link) => {diff --git a/packages/gallery/i18n/locales/en.json b/packages/gallery/i18n/locales/en.jsonindex 1e8e2fc7..4528c3e4 100644--- a/packages/gallery/i18n/locales/en.json+++ b/packages/gallery/i18n/locales/en.json@@ -1220,13 +1220,13 @@"app": {"socialLinks": {"title": "Social accounts",- "description": "Add up to four HTTPS links to show in the home page header.",+ "description": "Add up to {max} HTTPS links to show in the home page header.","slot": "Social link {number}","placeholder": "https://example.com/your-profile","clear": "Clear social link {number}","visit": "Visit {platform}","shape": "Invalid social links data",- "limit": "Add no more than four links",+ "limit": "Add no more than {max} links","invalid": "Enter a valid HTTPS URL","duplicate": "This link is already listed"},diff --git a/packages/gallery/i18n/locales/ja.json b/packages/gallery/i18n/locales/ja.jsonindex f3d32cad..8285a8da 100644--- a/packages/gallery/i18n/locales/ja.json+++ b/packages/gallery/i18n/locales/ja.json@@ -1142,13 +1142,13 @@"app": {"socialLinks": {"title": "ソーシャルアカウント",- "description": "ホームページのヘッダーに表示する HTTPS リンクを最大4件追加できます。",+ "description": "ホームページのヘッダーに表示する HTTPS リンクを最大{max}件追加できます。","slot": "ソーシャルリンク {number}","placeholder": "https://example.com/your-profile","clear": "ソーシャルリンク {number} を消去","visit": "{platform} を開く","shape": "ソーシャルリンクのデータが無効です",- "limit": "リンクは最大4件までです",+ "limit": "リンクは最大{max}件までです","invalid": "有効な HTTPS URL を入力してください","duplicate": "このリンクは既に追加されています"},diff --git a/packages/gallery/i18n/locales/ru.json b/packages/gallery/i18n/locales/ru.jsonindex c738330d..f29e9c03 100644--- a/packages/gallery/i18n/locales/ru.json+++ b/packages/gallery/i18n/locales/ru.json@@ -1220,13 +1220,13 @@"app": {"socialLinks": {"title": "Социальные сети",- "description": "Добавьте до четырёх ссылок HTTPS для отображения в шапке главной страницы.",+ "description": "Добавьте до {max} ссылок HTTPS для отображения в шапке главной страницы.","slot": "Ссылка {number}","placeholder": "https://example.com/your-profile","clear": "Очистить ссылку {number}","visit": "Открыть {platform}","shape": "Неверные данные социальных ссылок",- "limit": "Можно добавить не более четырёх ссылок",+ "limit": "Можно добавить не более {max} ссылок","invalid": "Введите корректный URL-адрес HTTPS","duplicate": "Эта ссылка уже добавлена"},diff --git a/packages/gallery/i18n/locales/zh-Hans.json b/packages/gallery/i18n/locales/zh-Hans.jsonindex e459cc64..7b5489f3 100644--- a/packages/gallery/i18n/locales/zh-Hans.json+++ b/packages/gallery/i18n/locales/zh-Hans.json@@ -1220,13 +1220,13 @@"app": {"socialLinks": {"title": "社交账号",- "description": "最多添加四个 HTTPS 链接,显示在首页页眉。",+ "description": "最多添加 {max} 个 HTTPS 链接,显示在首页页眉。","slot": "社交链接 {number}","placeholder": "https://example.com/your-profile","clear": "清除社交链接 {number}","visit": "访问 {platform}","shape": "社交链接数据无效",- "limit": "最多添加四个链接",+ "limit": "最多添加 {max} 个链接","invalid": "请输入有效的 HTTPS URL","duplicate": "此链接已添加"},diff --git a/packages/gallery/i18n/locales/zh-Hant-HK.json b/packages/gallery/i18n/locales/zh-Hant-HK.jsonindex 75910f34..c31614bc 100644--- a/packages/gallery/i18n/locales/zh-Hant-HK.json+++ b/packages/gallery/i18n/locales/zh-Hant-HK.json@@ -1142,13 +1142,13 @@"app": {"socialLinks": {"title": "社交帳戶",- "description": "最多加入四個 HTTPS 連結,顯示於首頁頁首。",+ "description": "最多加入 {max} 個 HTTPS 連結,顯示於首頁頁首。","slot": "社交連結 {number}","placeholder": "https://example.com/your-profile","clear": "清除社交連結 {number}","visit": "瀏覽 {platform}","shape": "社交連結資料無效",- "limit": "最多只能加入四個連結",+ "limit": "最多只能加入 {max} 個連結","invalid": "請輸入有效的 HTTPS URL","duplicate": "此連結已加入"},diff --git a/packages/gallery/i18n/locales/zh-Hant-TW.json b/packages/gallery/i18n/locales/zh-Hant-TW.jsonindex 348a5dad..b3a2e463 100644--- a/packages/gallery/i18n/locales/zh-Hant-TW.json+++ b/packages/gallery/i18n/locales/zh-Hant-TW.json@@ -1142,13 +1142,13 @@"app": {"socialLinks": {"title": "社群帳號",- "description": "最多新增四個 HTTPS 連結,顯示在首頁頁首。",+ "description": "最多新增 {max} 個 HTTPS 連結,顯示在首頁頁首。","slot": "社群連結 {number}","placeholder": "https://example.com/your-profile","clear": "清除社群連結 {number}","visit": "前往 {platform}","shape": "社群連結資料無效",- "limit": "最多只能新增四個連結",+ "limit": "最多只能新增 {max} 個連結","invalid": "請輸入有效的 HTTPS URL","duplicate": "此連結已新增"},diff --git a/tests/settings-batch-errors.test.ts b/tests/settings-batch-errors.test.tsindex da8642b4..74c3199f 100644--- a/tests/settings-batch-errors.test.ts+++ b/tests/settings-batch-errors.test.ts@@ -1,7 +1,10 @@import assert from 'node:assert/strict'import test from 'node:test'import { reactive, readonly, ref } from 'vue'-import { SocialLinkError } from '@chronoframe/contracts/social-links'+import {+ MAX_SOCIAL_LINKS,+ SocialLinkError,+} from '@chronoframe/contracts/social-links'import {applySettingsBatch,toSettingsBatchError,@@ -13,12 +16,15 @@ test('batch errors preserve social validation codes without coding unrelated faitoSettingsBatchError('app','socialLinks',- new SocialLinkError('limit', 'Use at most four social links'),+ new SocialLinkError(+ 'limit',+ `Use at most ${MAX_SOCIAL_LINKS} social links`,+ ),),{namespace: 'app',key: 'socialLinks',- error: 'Use at most four social links',+ error: `Use at most ${MAX_SOCIAL_LINKS} social links`,code: 'limit',},)@@ -77,15 +83,15 @@ test('social validation errors from batch save use localized inline and toast me{namespace: 'app',key: 'socialLinks',- error: 'Use at most four social links',+ error: `Use at most ${MAX_SOCIAL_LINKS} social links`,code: errorCode,},],},useI18n: () => ({- t: (key: string) =>+ t: (key: string, values?: { max?: number }) =>key === 'settings.app.socialLinks.limit'- ? 'Add no more than four links'+ ? `Add no more than ${values?.max} links`: key === 'settings.form.saveFailed'? 'Could not save settings': key,@@ -106,9 +112,12 @@ test('social validation errors from batch save use localized inline and toast me(error: unknown) =>error instanceof SocialLinkError &&error.code === 'limit' &&- error.message === 'Add no more than four links',+ error.message === `Add no more than ${MAX_SOCIAL_LINKS} links`,+ )+ assert.equal(+ toasts.at(-1)?.description,+ `Add no more than ${MAX_SOCIAL_LINKS} links`,)- assert.equal(toasts.at(-1)?.description, 'Add no more than four links')errorCode = 'new-server-code'await assert.rejects(form.submit({ socialLinks: { links: [] } }), {diff --git a/tests/social-links.test.ts b/tests/social-links.test.tsindex afaba198..e0283711 100644--- a/tests/social-links.test.ts+++ b/tests/social-links.test.ts@@ -1,6 +1,7 @@import assert from 'node:assert/strict'import test from 'node:test'import {+ MAX_SOCIAL_LINKS,parseSocialLinks,parseSocialLink,resolveSocialPlatform,@@ -8,7 +9,7 @@ import {} from '@chronoframe/contracts/social-links'import { validateSettingWrite } from '@chronoframe/core'-test('accepts an ordered list of at most four HTTPS profile links', () => {+test('accepts an ordered list up to the configured HTTPS profile link limit', () => {const links = ['https://instagram.com/example','https://github.com/example',@@ -17,9 +18,12 @@ test('accepts an ordered list of at most four HTTPS profile links', () => {]assert.deepEqual(parseSocialLinks({ links }), links)assert.deepEqual(parseSocialLinks({ links: [] }), [])+ assert.equal(links.length, MAX_SOCIAL_LINKS)assert.throws(() => parseSocialLinks({ links: [...links, 'https://x.com/example'] }),- /four/i,+ {+ message: `Use at most ${MAX_SOCIAL_LINKS} social links`,+ },)})