From 7f58c6e819f04664396254f8babb6766f8f926e8 Mon Sep 17 00:00:00 2001 From: Alban Mouton Date: Wed, 30 Oct 2024 14:14:36 +0100 Subject: [PATCH] refactor: ui home page is ok --- api/config/custom-environment-variables.cjs | 6 +- api/config/default.cjs | 3 +- api/config/type/schema.json | 9 +- api/i18n/index.ts | 20 +- api/src/ui-config.ts | 3 +- package-lock.json | 62 ++++- package.json | 4 +- ui/.gitignore | 1 + ui/dts/auto-imports.d.ts | 26 -- ui/package.json | 5 +- ui/src/App.vue | 12 +- ui/src/assets/css/fonts.css | 225 ------------------ .../fonts/Nunito-300-cyrillic-ext1.woff2 | Bin 28868 -> 0 bytes .../assets/fonts/Nunito-300-cyrillic2.woff2 | Bin 20708 -> 0 bytes .../assets/fonts/Nunito-300-latin-ext4.woff2 | Bin 34608 -> 0 bytes ui/src/assets/fonts/Nunito-300-latin5.woff2 | Bin 39124 -> 0 bytes .../assets/fonts/Nunito-300-vietnamese3.woff2 | Bin 12960 -> 0 bytes .../fonts/Nunito-400-cyrillic-ext6.woff2 | Bin 28868 -> 0 bytes .../assets/fonts/Nunito-400-cyrillic7.woff2 | Bin 20708 -> 0 bytes .../assets/fonts/Nunito-400-latin-ext9.woff2 | Bin 34608 -> 0 bytes ui/src/assets/fonts/Nunito-400-latin10.woff2 | Bin 39124 -> 0 bytes .../assets/fonts/Nunito-400-vietnamese8.woff2 | Bin 12960 -> 0 bytes .../fonts/Nunito-500-cyrillic-ext11.woff2 | Bin 28868 -> 0 bytes .../assets/fonts/Nunito-500-cyrillic12.woff2 | Bin 20708 -> 0 bytes .../assets/fonts/Nunito-500-latin-ext14.woff2 | Bin 34608 -> 0 bytes ui/src/assets/fonts/Nunito-500-latin15.woff2 | Bin 39124 -> 0 bytes .../fonts/Nunito-500-vietnamese13.woff2 | Bin 12960 -> 0 bytes .../fonts/Nunito-700-cyrillic-ext16.woff2 | Bin 28868 -> 0 bytes .../assets/fonts/Nunito-700-cyrillic17.woff2 | Bin 20708 -> 0 bytes .../assets/fonts/Nunito-700-latin-ext19.woff2 | Bin 34608 -> 0 bytes ui/src/assets/fonts/Nunito-700-latin20.woff2 | Bin 39124 -> 0 bytes .../fonts/Nunito-700-vietnamese18.woff2 | Bin 12960 -> 0 bytes .../fonts/Nunito-900-cyrillic-ext21.woff2 | Bin 28868 -> 0 bytes .../assets/fonts/Nunito-900-cyrillic22.woff2 | Bin 20708 -> 0 bytes .../assets/fonts/Nunito-900-latin-ext24.woff2 | Bin 34608 -> 0 bytes ui/src/assets/fonts/Nunito-900-latin25.woff2 | Bin 39124 -> 0 bytes .../fonts/Nunito-900-vietnamese23.woff2 | Bin 12960 -> 0 bytes ui/src/components/layout/layout-app-bar.vue | 6 +- ui/src/context.ts | 2 +- ui/src/main.ts | 2 +- ui/src/store/index.ts | 1 - ui/vite.config.ts | 5 +- 42 files changed, 93 insertions(+), 299 deletions(-) delete mode 100644 ui/src/assets/css/fonts.css delete mode 100644 ui/src/assets/fonts/Nunito-300-cyrillic-ext1.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-300-cyrillic2.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-300-latin-ext4.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-300-latin5.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-300-vietnamese3.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-400-cyrillic-ext6.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-400-cyrillic7.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-400-latin-ext9.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-400-latin10.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-400-vietnamese8.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-500-cyrillic-ext11.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-500-cyrillic12.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-500-latin-ext14.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-500-latin15.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-500-vietnamese13.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-700-cyrillic-ext16.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-700-cyrillic17.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-700-latin-ext19.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-700-latin20.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-700-vietnamese18.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-900-cyrillic-ext21.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-900-cyrillic22.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-900-latin-ext24.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-900-latin25.woff2 delete mode 100644 ui/src/assets/fonts/Nunito-900-vietnamese23.woff2 diff --git a/api/config/custom-environment-variables.cjs b/api/config/custom-environment-variables.cjs index f9402c1d..980362d9 100644 --- a/api/config/custom-environment-variables.cjs +++ b/api/config/custom-environment-variables.cjs @@ -109,7 +109,11 @@ module.exports = { cssText: 'THEME_CSS_TEXT' }, i18n: { - defaultLocale: 'I18N_DEFAULT_LOCALE' + defaultLocale: 'I18N_DEFAULT_LOCALE', + locales: { + __name: 'I18N_LOCALES', + __format: 'json' + } }, mails: { transport: jsonEnv('MAILS_TRANSPORT'), diff --git a/api/config/default.cjs b/api/config/default.cjs index 64894947..6c73e243 100644 --- a/api/config/default.cjs +++ b/api/config/default.cjs @@ -143,7 +143,8 @@ module.exports = { cssText: '' }, i18n: { - defaultLocale: 'fr' + defaultLocale: 'fr', + locales: ['fr', 'en', 'es', 'pt', 'it', 'de'] }, mails: { from: 'no-reply@test.com', diff --git a/api/config/type/schema.json b/api/config/type/schema.json index daf6191f..35cf7e47 100644 --- a/api/config/type/schema.json +++ b/api/config/type/schema.json @@ -138,12 +138,19 @@ "i18n": { "type": "object", "required": [ - "defaultLocale" + "defaultLocale", + "locales" ], "properties": { "defaultLocale": { "type": "string", "default": "fr" + }, + "locales": { + "type": "array", + "items": { + "type": "string" + } } } }, diff --git a/api/i18n/index.ts b/api/i18n/index.ts index e64f4d64..8fe93684 100644 --- a/api/i18n/index.ts +++ b/api/i18n/index.ts @@ -21,21 +21,11 @@ const flatOpts = { delimiter: '_' } // cannot be changed at runtime for now, because it impacts the build export const defaultLocale = config.i18n.defaultLocale -// this the full list of available langs, the proposed list is overwritten in config.i18n.locales -export const locales = [ - { code: 'fr' }, - { code: 'en' }, - { code: 'de' }, - { code: 'it' }, - { code: 'es' }, - { code: 'pt' } -] - // Build a map of messages of this form // {fr: {msg1: 'libellé 1'}, en: {msg1: 'label 1'}} const _messages: any = {} -for (const l of locales) { - _messages[l.code] = (await import ('./' + l.code + '.js')).default +for (const l of config.i18n.locales) { + _messages[l] = (await import ('./' + l + '.js')).default } const flatMessages = flatten(_messages, flatOpts) as Record @@ -76,10 +66,10 @@ export const __ = (req: Request, key: string, params: Record = { export const __all = (key: string, params: Record = {}) => { const res: Record = {} - for (const locale of locales) { - const value = flatMessages[locale.code + '_' + key] + for (const locale of config.i18n.locales) { + const value = flatMessages[locale + '_' + key] if (value) { - res[locale.code] = microTemplate(value, params) + res[locale] = microTemplate(value, params) } } return res diff --git a/api/src/ui-config.ts b/api/src/ui-config.ts index de9c8397..d619e768 100644 --- a/api/src/ui-config.ts +++ b/api/src/ui-config.ts @@ -1,12 +1,13 @@ import config, { type ApiConfig } from './config.ts' import { publicMessages } from '../i18n/index.ts' -export type UiConfig = Pick & { publicMessages: any } +export type UiConfig = Pick & { publicMessages: any } export const uiConfig: UiConfig = { publicUrl: config.publicUrl, theme: config.theme, manageSites: config.manageSites, + i18n: config.i18n, publicMessages } export default uiConfig diff --git a/package-lock.json b/package-lock.json index ba89d174..9e2373c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -13,7 +13,7 @@ "api" ], "dependencies": { - "@data-fair/lib-types-builder": "^1.3.0" + "@data-fair/lib-types-builder": "^1.4.0" }, "devDependencies": { "@commitlint/config-conventional": "^19.2.2", @@ -785,9 +785,9 @@ } }, "node_modules/@data-fair/lib-types-builder": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/@data-fair/lib-types-builder/-/lib-types-builder-1.3.0.tgz", - "integrity": "sha512-/nNVV25JXJZcIttXNh46gKLfIvK8YyB5bVYKsTGVVrlWrSVU2WLIiDZqfrHujqE+F7i+ZhxeWz3AF/n18JqkYA==", + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/@data-fair/lib-types-builder/-/lib-types-builder-1.4.0.tgz", + "integrity": "sha512-FtL8+ymmOboGap+TmwLa7bC3CYXbsaPeWV6QD3ueIByTz0i8TJKRTkHiynbRUjM6IddvYwKhwvQDpsGahI+syA==", "license": "MIT", "dependencies": { "@bcherny/json-schema-ref-parser": "^10.0.5-fork", @@ -841,9 +841,9 @@ "license": "MIT" }, "node_modules/@data-fair/lib-vue": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/@data-fair/lib-vue/-/lib-vue-1.7.0.tgz", - "integrity": "sha512-QR8RGT9JydNL/XR8AdN1KI30f7wutQHscokOB8tTU4fP3WL6Da53xmlgHV3uFbO9GOVbTAAgHWkQ0Ngg6i2Gmw==", + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/@data-fair/lib-vue/-/lib-vue-1.8.0.tgz", + "integrity": "sha512-fyBNaJdfiL7HGwFTLYlVjRKpIL8Yvp1hoefeAL35ntNwK71BPX5x5YJDvRQ9Gyc/xk3hpO3mMnGwjaOCF6ddJQ==", "license": "MIT", "dependencies": { "@data-fair/lib-common-types": "^1.1.0", @@ -867,9 +867,9 @@ } }, "node_modules/@data-fair/lib-vuetify": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/@data-fair/lib-vuetify/-/lib-vuetify-1.2.0.tgz", - "integrity": "sha512-rj74mKzS9xuowVfxNps3kXI70THh4uwWCaHHfcKOLhl7wZADNGZhY3S/CIzGkIxrsa2UEd9Nna1CFwO/lCy0Sg==", + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/@data-fair/lib-vuetify/-/lib-vuetify-1.3.0.tgz", + "integrity": "sha512-+hRJqHv/kQIgiOHDYJAuBpmDF9HBoGT5R+twm/Kd/vTxm/zC9KHkpf6DRDucboO15Lb/RqDtdkUT9SgYh+8y/g==", "license": "MIT", "dependencies": { "@data-fair/lib-common-types": "^1.1.0", @@ -11220,6 +11220,43 @@ } } }, + "node_modules/unplugin-vue-components": { + "version": "0.27.4", + "resolved": "https://registry.npmjs.org/unplugin-vue-components/-/unplugin-vue-components-0.27.4.tgz", + "integrity": "sha512-1XVl5iXG7P1UrOMnaj2ogYa5YTq8aoh5jwDPQhemwO/OrXW+lPQKDXd1hMz15qxQPxgb/XXlbgo3HQ2rLEbmXQ==", + "license": "MIT", + "dependencies": { + "@antfu/utils": "^0.7.10", + "@rollup/pluginutils": "^5.1.0", + "chokidar": "^3.6.0", + "debug": "^4.3.6", + "fast-glob": "^3.3.2", + "local-pkg": "^0.5.0", + "magic-string": "^0.30.11", + "minimatch": "^9.0.5", + "mlly": "^1.7.1", + "unplugin": "^1.12.1" + }, + "engines": { + "node": ">=14" + }, + "funding": { + "url": "https://github.com/sponsors/antfu" + }, + "peerDependencies": { + "@babel/parser": "^7.15.8", + "@nuxt/kit": "^3.2.2", + "vue": "2 || 3" + }, + "peerDependenciesMeta": { + "@babel/parser": { + "optional": true + }, + "@nuxt/kit": { + "optional": true + } + } + }, "node_modules/unplugin-vue-router": { "version": "0.10.8", "resolved": "https://registry.npmjs.org/unplugin-vue-router/-/unplugin-vue-router-0.10.8.tgz", @@ -12067,8 +12104,8 @@ "ui": { "version": "0.0.0", "dependencies": { - "@data-fair/lib-vue": "^1.7.0", - "@data-fair/lib-vuetify": "^1.2.0", + "@data-fair/lib-vue": "^1.8.0", + "@data-fair/lib-vuetify": "^1.3.0", "@intlify/unplugin-vue-i18n": "^5.2.0", "@koumoul/v-iframe": "^2.4.4", "@mdi/js": "^7.4.47", @@ -12079,6 +12116,7 @@ "sass-embedded": "^1.79.4", "unplugin-auto-import": "^0.18.3", "unplugin-fonts": "^1.1.1", + "unplugin-vue-components": "^0.27.4", "unplugin-vue-router": "^0.10.8", "vite": "^5.4.1", "vite-plugin-vuetify": "^2.0.4", diff --git a/package.json b/package.json index a83629e7..ee87d6e2 100644 --- a/package.json +++ b/package.json @@ -66,9 +66,9 @@ "typescript": "^5.5.4" }, "dependencies": { - "@data-fair/lib-types-builder": "^1.3.0" + "@data-fair/lib-types-builder": "^1.4.0" }, "relativeDependencies": { - "@data-fair/lib-node": "../lib/packages/node" + "@data-fair/lib-vuetify": "../lib/packages/vuetify" } } diff --git a/ui/.gitignore b/ui/.gitignore index a547bf36..b6cdf575 100644 --- a/ui/.gitignore +++ b/ui/.gitignore @@ -11,6 +11,7 @@ node_modules dist dist-ssr *.local +*.tsbuildinfo # Editor directories and files .vscode/* diff --git a/ui/dts/auto-imports.d.ts b/ui/dts/auto-imports.d.ts index ee4cae7f..2145cff8 100644 --- a/ui/dts/auto-imports.d.ts +++ b/ui/dts/auto-imports.d.ts @@ -162,28 +162,14 @@ declare module 'vue' { readonly $sitePath: UnwrapRef readonly $uiConfig: UnwrapRef readonly EffectScope: UnwrapRef - readonly addDepartmentMenu: UnwrapRef - readonly addMemberMenu: UnwrapRef - readonly addOrganizationMenu: UnwrapRef - readonly addPartnerMenu: UnwrapRef - readonly authProvidersLoginLinks: UnwrapRef - readonly cancelDeletion: UnwrapRef - readonly changeHost: UnwrapRef readonly computed: UnwrapRef - readonly confirmMenu: UnwrapRef readonly createApp: UnwrapRef readonly customRef: UnwrapRef readonly defineAsyncComponent: UnwrapRef readonly defineComponent: UnwrapRef - readonly deleteDepartmentMenu: UnwrapRef - readonly deleteMemberMenu: UnwrapRef - readonly deletePartnerMenu: UnwrapRef readonly dfPersonalMenu: UnwrapRef readonly dfTutorialAlert: UnwrapRef readonly dfUserAvatar: UnwrapRef - readonly editDepartmentMenu: UnwrapRef - readonly editDepartmentsMenu: UnwrapRef - readonly editMemberMenu: UnwrapRef readonly effectScope: UnwrapRef readonly getActiveHead: UnwrapRef readonly getCurrentInstance: UnwrapRef @@ -195,7 +181,6 @@ declare module 'vue' { readonly isReactive: UnwrapRef readonly isReadonly: UnwrapRef readonly isRef: UnwrapRef - readonly loadAvatar: UnwrapRef readonly markRaw: UnwrapRef readonly mdiAlertCircle: UnwrapRef readonly mdiBell: UnwrapRef @@ -211,7 +196,6 @@ declare module 'vue' { readonly mdiSend: UnwrapRef readonly mdiWeb: UnwrapRef readonly nextTick: UnwrapRef - readonly notifyMenu: UnwrapRef readonly onActivated: UnwrapRef readonly onBeforeMount: UnwrapRef readonly onBeforeRouteLeave: UnwrapRef @@ -228,23 +212,14 @@ declare module 'vue' { readonly onUnmounted: UnwrapRef readonly onUpdated: UnwrapRef readonly onWatcherCleanup: UnwrapRef - readonly organizationDepartments: UnwrapRef - readonly organizationMembers: UnwrapRef - readonly organizationPartners: UnwrapRef - readonly organizationStorage: UnwrapRef - readonly partnerInvitation: UnwrapRef readonly provide: UnwrapRef readonly reactive: UnwrapRef readonly readonly: UnwrapRef readonly ref: UnwrapRef - readonly resendInvitation: UnwrapRef - readonly resendPartnerInvitation: UnwrapRef readonly resolveComponent: UnwrapRef readonly shallowReactive: UnwrapRef readonly shallowReadonly: UnwrapRef readonly shallowRef: UnwrapRef - readonly sitePatch: UnwrapRef - readonly sitePost: UnwrapRef readonly toRaw: UnwrapRef readonly toRef: UnwrapRef readonly toRefs: UnwrapRef @@ -280,7 +255,6 @@ declare module 'vue' { readonly useTemplateRef: UnwrapRef readonly useUiNotif: UnwrapRef readonly useWS: UnwrapRef - readonly vJsf: UnwrapRef readonly watch: UnwrapRef readonly watchEffect: UnwrapRef readonly watchPostEffect: UnwrapRef diff --git a/ui/package.json b/ui/package.json index e3bdac99..dc332189 100644 --- a/ui/package.json +++ b/ui/package.json @@ -12,8 +12,8 @@ "lint-fix": "eslint --fix ." }, "dependencies": { - "@data-fair/lib-vue": "^1.7.0", - "@data-fair/lib-vuetify": "^1.2.0", + "@data-fair/lib-vue": "^1.8.0", + "@data-fair/lib-vuetify": "^1.3.0", "@intlify/unplugin-vue-i18n": "^5.2.0", "@koumoul/v-iframe": "^2.4.4", "@mdi/js": "^7.4.47", @@ -24,6 +24,7 @@ "sass-embedded": "^1.79.4", "unplugin-auto-import": "^0.18.3", "unplugin-fonts": "^1.1.1", + "unplugin-vue-components": "^0.27.4", "unplugin-vue-router": "^0.10.8", "vite": "^5.4.1", "vite-plugin-vuetify": "^2.0.4", diff --git a/ui/src/App.vue b/ui/src/App.vue index 9069875b..16c73b40 100644 --- a/ui/src/App.vue +++ b/ui/src/App.vue @@ -1,7 +1,7 @@