9 Commits

Author SHA1 Message Date
jakob.scheid 235cf04b09 Merge pull request 'Fix top-level await in main.js' (#119) from chore/Old-browser-incompatibility into main
Deploy on dev / Deploy on dev (push) Successful in 42s
Reviewed-on: #119
Reviewed-by: Jakob Scheid
2026-06-19 14:59:28 +02:00
johannes.vos 8a0d4ac949 fix(main): use async IIFE instead of top-level await 2026-06-19 14:55:51 +02:00
johannes.vos 5740b354f9 fix(main): remove top-level await and fix bootstrap flow 2026-06-19 14:49:22 +02:00
jakob.scheid eea417013d Merge pull request 'Allow only sections as first-level settings' (#117) from feature/restrict-first-level-settings into main
Deploy on dev / Deploy on dev (push) Successful in 39s
Reviewed-on: #117
Reviewed-by: Jakob Gregory
2026-06-05 12:29:51 +02:00
jakob.scheid 192f3c37a9 feat(settings): add test cases to test that only sections are allowed as first-level settings 2026-06-05 11:37:17 +02:00
jakob.scheid b729b85ad0 feat(settings): allow only sections as first-level settings 2026-06-05 11:35:41 +02:00
jakob.scheid a9f805e1fd Merge pull request 'Fix font scaling on Not Found page by removing vw units' (#115) from feature/fix-not-found-font-scaling into main
Deploy on dev / Deploy on dev (push) Successful in 39s
Reviewed-on: #115
Reviewed-by: Jakob Scheid
2026-06-04 18:54:44 +02:00
johannes.vos af418197a4 style(not-found): replace 2vw font size with stable 1.75rem dimension 2026-06-04 18:41:15 +02:00
jakob.scheid 8a718b4bab Merge pull request 'Add settings validator unit test' (#113) from testing/settings-validator into main
Deploy on dev / Deploy on dev (push) Successful in 42s
Reviewed-on: #113
Reviewed-by: Jakob Gregory
2026-06-04 17:48:08 +02:00
5 changed files with 93 additions and 21 deletions
@@ -53,10 +53,6 @@ limitations under the License.
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry * @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
*/ */
/**
* @typedef {Object} SettingsConfig
* @property {SettingConfigEntry[]} contents
*/
/** /**
* @typedef {{ type: 'bool', name: string, i18n: string, description?: string, default: boolean }} BoolSettingConfig * @typedef {{ type: 'bool', name: string, i18n: string, description?: string, default: boolean }} BoolSettingConfig
* @typedef {{ type: 'number', name: string, i18n: string, description?: string, default: number }} NumberSettingConfig * @typedef {{ type: 'number', name: string, i18n: string, description?: string, default: number }} NumberSettingConfig
@@ -64,5 +60,6 @@ limitations under the License.
* @typedef {{ type: 'selection', name: string, i18n: string, description?: string, default: string | string[], allowMultiple?: boolean, options: SelectionOption[] }} SelectionSettingConfig * @typedef {{ type: 'selection', name: string, i18n: string, description?: string, default: string | string[], allowMultiple?: boolean, options: SelectionOption[] }} SelectionSettingConfig
* @typedef {{ type: 'section', name: string, i18n?: string, description?: string, content: SettingConfigEntry[] }} SectionSettingConfig * @typedef {{ type: 'section', name: string, i18n?: string, description?: string, content: SettingConfigEntry[] }} SectionSettingConfig
* @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry * @typedef {BoolSettingConfig | NumberSettingConfig | StringSettingConfig | SelectionSettingConfig | SectionSettingConfig} SettingConfigEntry
* @typedef {{ contents: SettingConfigEntry[] }} SettingsConfig * @typedef {{ contents: SettingConfigEntry[] }} FirstLevelSettingConfigEntry
* @typedef {{ contents: FirstLevelSettingConfigEntry[] }} SettingsConfig
*/ */
@@ -33,7 +33,6 @@ describe('validateSettingsConfig', () => {
{ raw: { { raw: {
contents: [ contents: [
{ {
type: 'section',
name: 'general', name: 'general',
i18n: 'settings.settings.general', i18n: 'settings.settings.general',
content: [ content: [
@@ -49,7 +48,6 @@ describe('validateSettingsConfig', () => {
{ raw: { { raw: {
contents: [ contents: [
{ {
type: 'section',
name: 'general', name: 'general',
i18n: 'settings.settings.general', i18n: 'settings.settings.general',
content: [ content: [
@@ -61,7 +59,6 @@ describe('validateSettingsConfig', () => {
] ]
}, },
{ {
type: 'section',
name: 'copyOfGeneral', name: 'copyOfGeneral',
i18n: 'settings.settings.copyOfGeneral', i18n: 'settings.settings.copyOfGeneral',
content: [ content: [
@@ -77,7 +74,6 @@ describe('validateSettingsConfig', () => {
{ raw: { { raw: {
contents: [ contents: [
{ {
type: 'section',
name: 'general', name: 'general',
i18n: 'settings.settings.general', i18n: 'settings.settings.general',
content: [ content: [
@@ -89,7 +85,6 @@ describe('validateSettingsConfig', () => {
] ]
}, },
{ {
type: 'section',
name: 'copyOfGeneral', name: 'copyOfGeneral',
i18n: 'settings.settings.copyOfGeneral', i18n: 'settings.settings.copyOfGeneral',
content: [ content: [
@@ -102,7 +97,6 @@ describe('validateSettingsConfig', () => {
] ]
}, },
{ {
type: 'section',
name: 'aSection', name: 'aSection',
i18n: 'settings.settings.aSection', i18n: 'settings.settings.aSection',
content: [ content: [
@@ -141,7 +135,6 @@ describe('validateSettingsConfig', () => {
{ raw: { { raw: {
contents: [ contents: [
{ {
type: 'section',
name: 'general', name: 'general',
i18n: 'settings.settings.general', i18n: 'settings.settings.general',
content: [ content: [
@@ -153,7 +146,6 @@ describe('validateSettingsConfig', () => {
] ]
}, },
{ {
type: 'section',
name: 'copyOfGeneral', name: 'copyOfGeneral',
i18n: 'settings.settings.copyOfGeneral', i18n: 'settings.settings.copyOfGeneral',
content: [ content: [
@@ -166,7 +158,6 @@ describe('validateSettingsConfig', () => {
] ]
}, },
{ {
type: 'section',
name: 'aSection', name: 'aSection',
i18n: 'settings.settings.aSection', i18n: 'settings.settings.aSection',
content: [ content: [
@@ -203,6 +194,74 @@ describe('validateSettingsConfig', () => {
}, },
] ]
}, expected: true }, }, expected: true },
{ raw: {
contents: [
{
type: 'bool',
name: 'aStandaloneBooleanSetting',
i18n: 'settings.settings.aStandaloneBooleanSetting',
default: true
},
{
name: 'general',
i18n: 'settings.settings.general',
content: [
{
type: 'bool',
name: 'Enable feature 42',
i18n: 'settings.settings.general.enableFeature42'
}
]
},
{
name: 'copyOfGeneral',
i18n: 'settings.settings.copyOfGeneral',
content: [
{
type: 'bool',
name: 'Enable feature 42',
default: false,
i18n: 'settings.settings.general.enableFeature42'
}
]
},
{
name: 'aSection',
i18n: 'settings.settings.aSection',
content: [
{
type: 'bool',
name: 'Enable feature 43',
i18n: 'settings.settings.aSection.enableFeature43'
},
{
type: 'selection',
name: 'language',
i18n: 'settings.settings.aSection.language.label',
default: 'en',
allowMultiple: false,
options: [
{ name: 'en', i18n: 'settings.settings.aSection.language.options.en' },
{ name: 'de', i18n: 'settings.settings.aSection.language.options.de' },
]
},
{
type: 'section',
name: 'section2',
i18n: 'settings.settings.aSection.section2.label',
content: [
{
type: 'string',
name: 'string',
i18n: 'settings.settings.aSection.sections.string',
default: 'str'
}
]
},
]
},
]
}, expected: false },
{ raw: { { raw: {
contents: [ contents: [
{ {
@@ -83,6 +83,19 @@ export const validateEntry = function validateEntry (entry, path) {
} }
} }
export const validateFirstLevelSection = function validateFirstLevelSection (section, path) {
assertString(section.name);
assertString(section.i18n);
if (!Array.isArray(section.content)) {
throw new Error(`[settings] "${path}.content" must be an array`);
};
section.content.forEach((entry, i) =>
validateEntry(entry, `${path}.content[${i}]`)
);
};
/** /**
* Validates a raw settings config object. * Validates a raw settings config object.
* @param {unknown} raw * @param {unknown} raw
@@ -97,7 +110,7 @@ export function validateSettingsConfig(raw) {
throw new Error('[settings] "contents" must be an array'); throw new Error('[settings] "contents" must be an array');
} }
raw.contents.forEach((entry, i) => raw.contents.forEach((entry, i) =>
validateEntry(entry, `contents[${i}]`) validateFirstLevelSection(entry, `contents[${i}]`)
); );
return { valid: true, config: raw }; return { valid: true, config: raw };
} catch (e) { } catch (e) {
+8 -5
View File
@@ -16,15 +16,18 @@ limitations under the License.
import { createApp } from 'vue' import { createApp } from 'vue'
import App from './App.vue' import App from './App.vue'
import { i18n, loadLanguage } from './i18n'; import { i18n, loadLanguage } from './i18n'
import getCurrentLanguage from './utils/currentLanguage'; import getCurrentLanguage from './utils/currentLanguage'
import router from './router' import router from './router'
import './styles/common.css' import './styles/common.css'
import './styles/variables/colors.css' import './styles/variables/colors.css'
await loadLanguage(getCurrentLanguage()); (async () => {
await loadLanguage(getCurrentLanguage())
createApp(App) createApp(App)
.use(router) .use(router)
.use(i18n) .use(i18n)
.mount('#app') .mount('#app')
})()
+1 -1
View File
@@ -43,7 +43,7 @@ const { t } = useI18n();
.error-message{ .error-message{
margin: 0; margin: 0;
font-weight: 600; font-weight: 600;
font-size: 2vw; font-size: 1.75rem;
} }
#link { #link {
align-items: center; align-items: center;