Fix Mantine v9 CI failures for typecheck, lint, and e2e.
Align form generics with v9 TransformedValues typing, merge element-size refs for gridstack, and tighten selectors and lint fixes from the migration.
This commit is contained in:
10 files changed
+64
-37
No files matched your search
@@ -9,7 +9,7 @@ import { z } from "zod/v4";
|
|||||||
|
|
||||||
import { signIn } from "@homarr/auth/client";
|
import { signIn } from "@homarr/auth/client";
|
||||||
import { revalidatePathActionAsync } from "@homarr/common/client";
|
import { revalidatePathActionAsync } from "@homarr/common/client";
|
||||||
import type { useForm } from "@homarr/form";
|
import type { UseFormReturnType } from "@homarr/form";
|
||||||
import { useZodForm } from "@homarr/form";
|
import { useZodForm } from "@homarr/form";
|
||||||
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
|
import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";
|
||||||
import { useScopedI18n } from "@homarr/translation/client";
|
import { useScopedI18n } from "@homarr/translation/client";
|
||||||
@@ -162,7 +162,7 @@ export const LoginForm = ({ providers, oidcClientName, isOidcAutoLoginEnabled, c
|
|||||||
|
|
||||||
interface SubmitButtonProps {
|
interface SubmitButtonProps {
|
||||||
isPending: boolean;
|
isPending: boolean;
|
||||||
form: ReturnType<typeof useForm<FormType, (values: FormType) => FormType>>;
|
form: UseFormReturnType<FormType>;
|
||||||
provider: "credentials" | "ldap";
|
provider: "credentials" | "ldap";
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+1
-1
@@ -12,7 +12,7 @@ interface FormType {
|
|||||||
interface SecretKindsSegmentedControlProps<TFormType extends FormType> {
|
interface SecretKindsSegmentedControlProps<TFormType extends FormType> {
|
||||||
defaultKinds?: IntegrationSecretKind[];
|
defaultKinds?: IntegrationSecretKind[];
|
||||||
secretKinds: IntegrationSecretKind[][];
|
secretKinds: IntegrationSecretKind[][];
|
||||||
form: UseFormReturnType<TFormType, (values: TFormType) => TFormType>;
|
form: UseFormReturnType<TFormType, TFormType>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const SecretKindsSegmentedControl = <TFormType extends FormType>({
|
export const SecretKindsSegmentedControl = <TFormType extends FormType>({
|
||||||
|
|||||||
@@ -15,7 +15,7 @@ export const SwitchSetting = <TFormValue extends Record<string, boolean>>({
|
|||||||
disabled,
|
disabled,
|
||||||
}: {
|
}: {
|
||||||
form: Modify<
|
form: Modify<
|
||||||
UseFormReturnType<TFormValue, () => TFormValue>,
|
UseFormReturnType<TFormValue, TFormValue>,
|
||||||
{
|
{
|
||||||
setFieldValue: (key: keyof TFormValue, value: (previous: boolean) => boolean) => void;
|
setFieldValue: (key: keyof TFormValue, value: (previous: boolean) => boolean) => void;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,12 +2,14 @@
|
|||||||
|
|
||||||
import { Select } from "@mantine/core";
|
import { Select } from "@mantine/core";
|
||||||
|
|
||||||
import type { LogLevel } from "@homarr/core/infrastructure/logs/constants";
|
|
||||||
import { logLevelConfiguration, logLevels } from "@homarr/core/infrastructure/logs/constants";
|
import { logLevelConfiguration, logLevels } from "@homarr/core/infrastructure/logs/constants";
|
||||||
|
import type { LogLevel } from "@homarr/core/infrastructure/logs/constants";
|
||||||
import { useI18n } from "@homarr/translation/client";
|
import { useI18n } from "@homarr/translation/client";
|
||||||
|
|
||||||
import { useLogContext } from "./log-context";
|
import { useLogContext } from "./log-context";
|
||||||
|
|
||||||
|
const levelByValue = Object.fromEntries(logLevels.map((logLevel) => [logLevel, logLevel])) as Record<string, LogLevel>;
|
||||||
|
|
||||||
export const LogLevelSelection = () => {
|
export const LogLevelSelection = () => {
|
||||||
const { level, setLevel } = useLogContext();
|
const { level, setLevel } = useLogContext();
|
||||||
const t = useI18n();
|
const t = useI18n();
|
||||||
@@ -19,7 +21,12 @@ export const LogLevelSelection = () => {
|
|||||||
label: `${logLevelConfiguration[level].prefix} ${t(`log.level.option.${level}`)}`,
|
label: `${logLevelConfiguration[level].prefix} ${t(`log.level.option.${level}`)}`,
|
||||||
}))}
|
}))}
|
||||||
value={level}
|
value={level}
|
||||||
onChange={(value) => setLevel(value as LogLevel)}
|
onChange={(value) => {
|
||||||
|
const nextLevel = value && levelByValue[value];
|
||||||
|
if (nextLevel) {
|
||||||
|
setLevel(nextLevel);
|
||||||
|
}
|
||||||
|
}}
|
||||||
checkIconPosition="right"
|
checkIconPosition="right"
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
|
|||||||
+1
-1
@@ -62,7 +62,7 @@ export const FirstDayOfWeek = ({ user }: FirstDayOfWeekProps) => {
|
|||||||
return (
|
return (
|
||||||
<form onSubmit={form.onSubmit(handleSubmit)}>
|
<form onSubmit={form.onSubmit(handleSubmit)}>
|
||||||
<Stack gap="md">
|
<Stack gap="md">
|
||||||
<Radio.Group {...inputProps} value={value} onChange={(value) => onChange(parseInt(value))}>
|
<Radio.Group {...inputProps} value={value} onChange={(nextValue: string) => onChange(parseInt(nextValue, 10))}>
|
||||||
<Group mt="xs">
|
<Group mt="xs">
|
||||||
<Radio value="1" label={weekDays[1]} />
|
<Radio value="1" label={weekDays[1]} />
|
||||||
<Radio value="6" label={weekDays[6]} />
|
<Radio value="6" label={weekDays[6]} />
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import type { RefObject } from "react";
|
import type { Ref, RefObject } from "react";
|
||||||
import { createRef, useCallback, useEffect, useRef } from "react";
|
import { createRef, useCallback, useEffect, useRef } from "react";
|
||||||
import { useElementSize } from "@mantine/hooks";
|
import { useElementSize, useMergedRef } from "@mantine/hooks";
|
||||||
|
|
||||||
import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
|
import { useCurrentLayout, useRequiredBoard } from "@homarr/boards/context";
|
||||||
import { useEditMode } from "@homarr/boards/edit-mode";
|
import { useEditMode } from "@homarr/boards/edit-mode";
|
||||||
@@ -13,7 +13,7 @@ import { useSectionActions } from "../section-actions";
|
|||||||
import { initializeGridstack } from "./init-gridstack";
|
import { initializeGridstack } from "./init-gridstack";
|
||||||
|
|
||||||
export interface UseGridstackRefs {
|
export interface UseGridstackRefs {
|
||||||
wrapper: RefObject<HTMLDivElement | null>;
|
wrapper: Ref<HTMLDivElement | null>;
|
||||||
items: RefObject<Record<string, RefObject<GridItemHTMLElement | null>>>;
|
items: RefObject<Record<string, RefObject<GridItemHTMLElement | null>>>;
|
||||||
gridstack: RefObject<GridStack | null>;
|
gridstack: RefObject<GridStack | null>;
|
||||||
}
|
}
|
||||||
@@ -59,8 +59,9 @@ export const useGridstack = (section: Omit<Section, "items">, itemIds: string[])
|
|||||||
const { moveAndResizeItem, moveItemToSection } = useItemActions();
|
const { moveAndResizeItem, moveItemToSection } = useItemActions();
|
||||||
const { moveAndResizeInnerSection, moveInnerSectionToSection } = useSectionActions();
|
const { moveAndResizeInnerSection, moveInnerSectionToSection } = useSectionActions();
|
||||||
|
|
||||||
// define reference for wrapper - is used to calculate the width of the wrapper
|
const wrapperElementRef = useRef<HTMLDivElement | null>(null);
|
||||||
const { ref: wrapperRef, width, height } = useElementSize<HTMLDivElement>();
|
const { ref: measureWrapperRef, width, height } = useElementSize<HTMLDivElement>();
|
||||||
|
const wrapperRef = useMergedRef(measureWrapperRef, wrapperElementRef);
|
||||||
// references to the diffrent items contained in the gridstack
|
// references to the diffrent items contained in the gridstack
|
||||||
const itemRefs = useRef<Record<string, RefObject<GridItemHTMLElement | null>>>({});
|
const itemRefs = useRef<Record<string, RefObject<GridItemHTMLElement | null>>>({});
|
||||||
// reference of the gridstack object for modifications after initialization
|
// reference of the gridstack object for modifications after initialization
|
||||||
@@ -193,7 +194,7 @@ export const useGridstack = (section: Omit<Section, "items">, itemIds: string[])
|
|||||||
itemIds,
|
itemIds,
|
||||||
refs: {
|
refs: {
|
||||||
items: itemRefs,
|
items: itemRefs,
|
||||||
wrapper: wrapperRef,
|
wrapper: wrapperElementRef,
|
||||||
gridstack: gridRef,
|
gridstack: gridRef,
|
||||||
},
|
},
|
||||||
sectionColumnCount: columnCount,
|
sectionColumnCount: columnCount,
|
||||||
@@ -276,7 +277,7 @@ export const useGridstack = (section: Omit<Section, "items">, itemIds: string[])
|
|||||||
useCssVariableConfiguration({
|
useCssVariableConfiguration({
|
||||||
columnCount,
|
columnCount,
|
||||||
gridRef,
|
gridRef,
|
||||||
wrapperRef,
|
wrapperRef: wrapperElementRef,
|
||||||
width,
|
width,
|
||||||
height,
|
height,
|
||||||
isDynamic: section.kind === "dynamic",
|
isDynamic: section.kind === "dynamic",
|
||||||
@@ -293,7 +294,7 @@ export const useGridstack = (section: Omit<Section, "items">, itemIds: string[])
|
|||||||
|
|
||||||
interface UseCssVariableConfiguration {
|
interface UseCssVariableConfiguration {
|
||||||
gridRef: UseGridstackRefs["gridstack"];
|
gridRef: UseGridstackRefs["gridstack"];
|
||||||
wrapperRef: UseGridstackRefs["wrapper"];
|
wrapperRef: RefObject<HTMLDivElement | null>;
|
||||||
width: number;
|
width: number;
|
||||||
height: number;
|
height: number;
|
||||||
columnCount: number;
|
columnCount: number;
|
||||||
|
|||||||
+1
-1
@@ -45,7 +45,7 @@ describe("LLDAP authorization", () => {
|
|||||||
// Act
|
// Act
|
||||||
await page.goto(`http://${homarrContainer.getHost()}:${homarrContainer.getMappedPort(7575)}/auth/login`);
|
await page.goto(`http://${homarrContainer.getHost()}:${homarrContainer.getMappedPort(7575)}/auth/login`);
|
||||||
await page.getByLabel("Username").fill(defaultCredentials.username);
|
await page.getByLabel("Username").fill(defaultCredentials.username);
|
||||||
await page.getByLabel("Password").fill(defaultCredentials.password);
|
await page.locator("#password").fill(defaultCredentials.password);
|
||||||
await page.locator("css=button[type='submit']").click();
|
await page.locator("css=button[type='submit']").click();
|
||||||
|
|
||||||
// Assert
|
// Assert
|
||||||
|
|||||||
@@ -25,9 +25,22 @@ export const WidgetDynamicSelectInput = ({ property, kind, options }: CommonWidg
|
|||||||
const [search, setSearch] = useState("");
|
const [search, setSearch] = useState("");
|
||||||
const [debouncedSearch] = useDebouncedValue(search, 300);
|
const [debouncedSearch] = useDebouncedValue(search, 300);
|
||||||
const { isPending, options: selectOptions } = options.useOptions(debouncedSearch, form.values.integrationIds);
|
const { isPending, options: selectOptions } = options.useOptions(debouncedSearch, form.values.integrationIds);
|
||||||
const value = inputProps.value as DynamicSelectOption | null;
|
const currentOption = inputProps.value as DynamicSelectOption | null;
|
||||||
const onChange = inputProps.onChange as (value: DynamicSelectOption | null) => void;
|
const onChange = inputProps.onChange as (value: DynamicSelectOption | null) => void;
|
||||||
|
|
||||||
|
const getLabelForValue = (selectedValue: string) => {
|
||||||
|
const matched = selectOptions.find((option) =>
|
||||||
|
typeof option === "string" ? option === selectedValue : option.value === selectedValue,
|
||||||
|
);
|
||||||
|
if (!matched) {
|
||||||
|
return selectedValue;
|
||||||
|
}
|
||||||
|
if (typeof matched === "string") {
|
||||||
|
return matched;
|
||||||
|
}
|
||||||
|
return translateIfNecessary(t, matched.label) ?? selectedValue;
|
||||||
|
};
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Select
|
<Select
|
||||||
label={tWidget("label")}
|
label={tWidget("label")}
|
||||||
@@ -41,14 +54,15 @@ export const WidgetDynamicSelectInput = ({ property, kind, options }: CommonWidg
|
|||||||
},
|
},
|
||||||
)
|
)
|
||||||
.concat(
|
.concat(
|
||||||
typeof value === "object" &&
|
currentOption !== null &&
|
||||||
value !== null &&
|
|
||||||
!selectOptions.some((option) =>
|
!selectOptions.some((option) =>
|
||||||
typeof option === "string" ? option === value.value : option.value === value.value,
|
typeof option === "string"
|
||||||
|
? option === currentOption.value
|
||||||
|
: option.value === currentOption.value,
|
||||||
)
|
)
|
||||||
? {
|
? {
|
||||||
value: value.value,
|
value: currentOption.value,
|
||||||
label: value.label,
|
label: currentOption.label,
|
||||||
}
|
}
|
||||||
: [],
|
: [],
|
||||||
)}
|
)}
|
||||||
@@ -74,19 +88,17 @@ export const WidgetDynamicSelectInput = ({ property, kind, options }: CommonWidg
|
|||||||
description={options.withDescription ? tWidget("description") : undefined}
|
description={options.withDescription ? tWidget("description") : undefined}
|
||||||
searchable
|
searchable
|
||||||
{...inputProps}
|
{...inputProps}
|
||||||
value={value?.value ?? null}
|
value={currentOption === null ? null : currentOption.value}
|
||||||
onChange={(value) =>
|
onChange={(selectedValue: string | null) => {
|
||||||
onChange(
|
if (selectedValue === null) {
|
||||||
value
|
onChange(null);
|
||||||
? {
|
return;
|
||||||
value,
|
}
|
||||||
label:
|
onChange({
|
||||||
selectOptions.filter((option) => typeof option === "object").find((option) => option.value === value)
|
value: selectedValue,
|
||||||
?.label ?? value,
|
label: getLabelForValue(selectedValue),
|
||||||
}
|
});
|
||||||
: null,
|
}}
|
||||||
)
|
|
||||||
}
|
|
||||||
/>
|
/>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -53,7 +53,7 @@ export const WidgetSelectInput = ({ property, kind, options }: CommonWidgetInput
|
|||||||
)}
|
)}
|
||||||
leftSection={CurrentIcon && <CurrentIcon size={16} stroke={1.5} />}
|
leftSection={CurrentIcon && <CurrentIcon size={16} stroke={1.5} />}
|
||||||
renderOption={({ option, checked }) => {
|
renderOption={({ option, checked }) => {
|
||||||
const Icon = getIconFor(options.options, option.value);
|
const Icon = getIconFor(options.options, String(option.value));
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Group flex="1" gap="xs">
|
<Group flex="1" gap="xs">
|
||||||
|
|||||||
@@ -17,6 +17,8 @@ import { WorkersPanel } from "./panels/workers.panel";
|
|||||||
|
|
||||||
type View = (typeof views)[number];
|
type View = (typeof views)[number];
|
||||||
|
|
||||||
|
const viewBySegmentValue = Object.fromEntries(views.map((view) => [view, view])) as Record<string, View>;
|
||||||
|
|
||||||
const viewIcons = {
|
const viewIcons = {
|
||||||
workers: IconCpu2,
|
workers: IconCpu2,
|
||||||
queue: IconClipboardList,
|
queue: IconClipboardList,
|
||||||
@@ -83,7 +85,12 @@ export default function MediaTranscodingWidget({
|
|||||||
};
|
};
|
||||||
})}
|
})}
|
||||||
value={view}
|
value={view}
|
||||||
onChange={(value) => setView(value as View)}
|
onChange={(value) => {
|
||||||
|
const nextView = viewBySegmentValue[value];
|
||||||
|
if (nextView) {
|
||||||
|
setView(nextView);
|
||||||
|
}
|
||||||
|
}}
|
||||||
size="xs"
|
size="xs"
|
||||||
/>
|
/>
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user