impr(config): validation on layoutFluid and polyglot (@fehmer) (#6844)

This commit is contained in:
Christian Fehmer 2025-08-07 14:48:48 +02:00 committed by GitHub
parent cd99d5af16
commit ced5dc1920
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 6 additions and 5 deletions

View file

@ -1089,8 +1089,9 @@ describe("Config", () => {
expect(Config.setQuoteLength([-4 as any, 5 as any])).toBe(false);
});
it("setCustomLayoutfluid", () => {
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(true);
expect(Config.setCustomLayoutfluid(["qwerty", "qwertz"])).toBe(true);
expect(Config.setCustomLayoutfluid(["qwerty"])).toBe(false);
expect(Config.setCustomLayoutfluid([])).toBe(false);
expect(Config.setCustomLayoutfluid("qwerty#qwertz" as any)).toBe(false);
expect(Config.setCustomLayoutfluid("invalid" as any)).toBe(false);

View file

@ -607,7 +607,7 @@ async function fillSettingsPage(): Promise<void> {
customLayoutFluidSelect = new SlimSelect({
select:
".pageSettings .section[data-config-name='customLayoutfluid'] select",
settings: { keepOrder: true, minSelected: 1 },
settings: { keepOrder: true, minSelected: 2 },
events: {
afterChange: (newVal): void => {
const customLayoutfluid = newVal.map(
@ -625,7 +625,7 @@ async function fillSettingsPage(): Promise<void> {
customPolyglotSelect = new SlimSelect({
select: ".pageSettings .section[data-config-name='customPolyglot'] select",
settings: { minSelected: 1 },
settings: { minSelected: 2 },
data: getLanguageDropdownData((language) =>
Config.customPolyglot.includes(language)
),

View file

@ -211,11 +211,11 @@ export type CustomBackgroundFilter = z.infer<
export const CustomLayoutFluidSchema = z
.array(Layouts.LayoutNameSchema)
.min(1)
.min(2)
.max(15);
export type CustomLayoutFluid = z.infer<typeof CustomLayoutFluidSchema>;
export const CustomPolyglotSchema = z.array(LanguageSchema).min(1);
export const CustomPolyglotSchema = z.array(LanguageSchema).min(2);
export type CustomPolyglot = z.infer<typeof CustomPolyglotSchema>;
export const MonkeyPowerLevelSchema = z.enum(["off", "1", "2", "3", "4"]);