A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.
feat(users): rework general settings (#4915)
Thomas2991777b0a0a
diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-home-board.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-home-board.tsxdeleted file mode 100644index bdad9cfea..000000000--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-home-board.tsx+++ /dev/null@@ -1,85 +0,0 @@-"use client";--import { Button, Group, Stack } from "@mantine/core";-import type { z } from "zod/v4";--import type { RouterOutputs } from "@homarr/api";-import { clientApi } from "@homarr/api/client";-import { revalidatePathActionAsync } from "@homarr/common/client";-import { useZodForm } from "@homarr/form";-import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";-import { useI18n } from "@homarr/translation/client";-import { userChangeHomeBoardsSchema } from "@homarr/validation/user";--import type { Board } from "~/app/[locale]/boards/_types";-import { BoardSelect } from "~/components/board/board-select";--interface ChangeHomeBoardFormProps {- user: RouterOutputs["user"]["getById"];- boardsData: Pick<Board, "id" | "name" | "logoImageUrl">[];-}--export const ChangeHomeBoardForm = ({ user, boardsData }: ChangeHomeBoardFormProps) => {- const t = useI18n();- const { mutate, isPending } = clientApi.user.changeHomeBoards.useMutation({- async onSettled() {- await revalidatePathActionAsync(`/manage/users/${user.id}`);- },- onSuccess(_, variables) {- form.setInitialValues({- homeBoardId: variables.homeBoardId,- mobileHomeBoardId: variables.mobileHomeBoardId,- });- showSuccessNotification({- message: t("user.action.changeHomeBoard.notification.success.message"),- });- },- onError() {- showErrorNotification({- message: t("user.action.changeHomeBoard.notification.error.message"),- });- },- });- const form = useZodForm(userChangeHomeBoardsSchema, {- initialValues: {- homeBoardId: user.homeBoardId,- mobileHomeBoardId: user.mobileHomeBoardId,- },- });-- const handleSubmit = (values: FormType) => {- mutate({- userId: user.id,- ...values,- });- };-- return (- <form onSubmit={form.onSubmit(handleSubmit)}>- <Stack gap="md">- <BoardSelect- label={t("management.page.user.setting.general.item.board.type.general")}- clearable- boards={boardsData}- w="100%"- {...form.getInputProps("homeBoardId")}- />- <BoardSelect- label={t("management.page.user.setting.general.item.board.type.mobile")}- clearable- boards={boardsData}- w="100%"- {...form.getInputProps("mobileHomeBoardId")}- />-- <Group justify="end">- <Button type="submit" loading={isPending}>- {t("common.action.save")}- </Button>- </Group>- </Stack>- </form>- );-};--type FormType = z.infer<typeof userChangeHomeBoardsSchema>;diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-search-preferences.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-search-preferences.tsxdeleted file mode 100644index afae60dc1..000000000--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_change-search-preferences.tsx+++ /dev/null@@ -1,84 +0,0 @@-"use client";--import { Button, Group, Select, Stack, Switch } from "@mantine/core";-import type { z } from "zod/v4";--import type { RouterOutputs } from "@homarr/api";-import { clientApi } from "@homarr/api/client";-import { revalidatePathActionAsync } from "@homarr/common/client";-import { useZodForm } from "@homarr/form";-import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";-import { useI18n } from "@homarr/translation/client";-import { userChangeSearchPreferencesSchema } from "@homarr/validation/user";--interface ChangeSearchPreferencesFormProps {- user: RouterOutputs["user"]["getById"];- searchEnginesData: { value: string; label: string }[];-}--export const ChangeSearchPreferencesForm = ({ user, searchEnginesData }: ChangeSearchPreferencesFormProps) => {- const t = useI18n();- const { mutate, isPending } = clientApi.user.changeSearchPreferences.useMutation({- async onSettled() {- await revalidatePathActionAsync(`/manage/users/${user.id}`);- },- onSuccess(_, variables) {- form.setInitialValues({- defaultSearchEngineId: variables.defaultSearchEngineId,- openInNewTab: variables.openInNewTab,- ddgBangsEnabled: variables.ddgBangsEnabled,- });- showSuccessNotification({- message: t("user.action.changeSearchPreferences.notification.success.message"),- });- },- onError() {- showErrorNotification({- message: t("user.action.changeSearchPreferences.notification.error.message"),- });- },- });- const form = useZodForm(userChangeSearchPreferencesSchema, {- initialValues: {- defaultSearchEngineId: user.defaultSearchEngineId,- openInNewTab: user.openSearchInNewTab,- ddgBangsEnabled: user.ddgBangs,- },- });-- const handleSubmit = (values: FormType) => {- mutate({- userId: user.id,- ...values,- });- };-- return (- <form onSubmit={form.onSubmit(handleSubmit)}>- <Stack gap="md">- <Select- label={t("user.field.defaultSearchEngine.label")}- w="100%"- data={searchEnginesData}- {...form.getInputProps("defaultSearchEngineId")}- />- <Switch- label={t("user.field.openSearchInNewTab.label")}- {...form.getInputProps("openInNewTab", { type: "checkbox" })}- />- <Switch- label={t("user.field.ddgBangs.label")}- {...form.getInputProps("ddgBangsEnabled", { type: "checkbox" })}- />-- <Group justify="end">- <Button type="submit" loading={isPending}>- {t("common.action.save")}- </Button>- </Group>- </Stack>- </form>- );-};--type FormType = z.infer<typeof userChangeSearchPreferencesSchema>;diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_first-day-of-week.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_first-day-of-week.tsxdeleted file mode 100644index 2bf43a3bc..000000000--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_first-day-of-week.tsx+++ /dev/null@@ -1,83 +0,0 @@-"use client";--import { Button, Group, Radio, Stack } from "@mantine/core";-import type { DayOfWeek } from "@mantine/dates";-import dayjs from "dayjs";-import localeData from "dayjs/plugin/localeData";-import type { z } from "zod/v4";--import type { RouterOutputs } from "@homarr/api";-import { clientApi } from "@homarr/api/client";-import { revalidatePathActionAsync } from "@homarr/common/client";-import { useZodForm } from "@homarr/form";-import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";-import { useI18n } from "@homarr/translation/client";-import { userFirstDayOfWeekSchema } from "@homarr/validation/user";--dayjs.extend(localeData);--interface FirstDayOfWeekProps {- user: RouterOutputs["user"]["getById"];-}--const weekDays = dayjs.weekdays(false);--export const FirstDayOfWeek = ({ user }: FirstDayOfWeekProps) => {- const t = useI18n();- const { mutate, isPending } = clientApi.user.changeFirstDayOfWeek.useMutation({- async onSettled() {- await revalidatePathActionAsync(`/manage/users/${user.id}`);- },- onSuccess(_, variables) {- form.setInitialValues({- firstDayOfWeek: variables.firstDayOfWeek as DayOfWeek,- });- showSuccessNotification({- message: t("user.action.changeFirstDayOfWeek.notification.success.message"),- });- },- onError() {- showErrorNotification({- message: t("user.action.changeFirstDayOfWeek.notification.error.message"),- });- },- });- const form = useZodForm(userFirstDayOfWeekSchema, {- initialValues: {- firstDayOfWeek: user.firstDayOfWeek as DayOfWeek,- },- });-- const handleSubmit = (values: FormType) => {- mutate({- id: user.id,- ...values,- });- };-- const inputProps = form.getInputProps("firstDayOfWeek");- const onChange = inputProps.onChange as (value: number) => void;- const value = (inputProps.value as number).toString();-- return (- <form onSubmit={form.onSubmit(handleSubmit)}>- <Stack gap="md">- <Radio.Group {...inputProps} value={value} onChange={(nextValue: string) => onChange(parseInt(nextValue, 10))}>- <Group mt="xs">- <Radio value="1" label={weekDays[1]} />- <Radio value="6" label={weekDays[6]} />- <Radio value="0" label={weekDays[0]} />- </Group>- </Radio.Group>-- <Group justify="end">- <Button type="submit" loading={isPending}>- {t("common.action.save")}- </Button>- </Group>- </Stack>- </form>- );-};--type FormType = z.infer<typeof userFirstDayOfWeekSchema>;diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_general-settings-form.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_general-settings-form.tsxnew file mode 100644index 000000000..46eaecd73--- /dev/null+++ b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_general-settings-form.tsx@@ -0,0 +1,332 @@+"use client";++import { useEffect, useMemo, useRef } from "react";+import {+ Button,+ Card,+ Divider,+ Group,+ Radio,+ Select,+ SimpleGrid,+ Stack,+ Switch,+ Text,+ TextInput,+ Title,+} from "@mantine/core";+import type { DayOfWeek } from "@mantine/dates";+import dayjs from "dayjs";+import localeData from "dayjs/plugin/localeData";+import { z } from "zod/v4";++import type { RouterOutputs } from "@homarr/api";+import { clientApi } from "@homarr/api/client";+import { revalidatePathActionAsync } from "@homarr/common/client";+import { env } from "@homarr/common/env";+import { useZodForm } from "@homarr/form";+import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";+import { useI18n, useScopedI18n } from "@homarr/translation/client";+import {+ userChangeHomeBoardsSchema,+ userChangeSearchPreferencesSchema,+ userEditProfileSchema,+ userFirstDayOfWeekSchema,+ userPingIconsEnabledSchema,+} from "@homarr/validation/user";++import type { Board } from "~/app/[locale]/boards/_types";+import { BoardSelect } from "~/components/board/board-select";+import { CurrentLanguageCombobox } from "~/components/language/current-language-combobox";++dayjs.extend(localeData);++const userGeneralSettingsSchema = z.object({+ name: userEditProfileSchema.shape.name,+ email: userEditProfileSchema.shape.email,+ homeBoardId: userChangeHomeBoardsSchema.shape.homeBoardId,+ mobileHomeBoardId: userChangeHomeBoardsSchema.shape.mobileHomeBoardId,+ defaultSearchEngineId: userChangeSearchPreferencesSchema.shape.defaultSearchEngineId,+ openInNewTab: userChangeSearchPreferencesSchema.shape.openInNewTab,+ ddgBangsEnabled: userChangeSearchPreferencesSchema.shape.ddgBangsEnabled,+ firstDayOfWeek: userFirstDayOfWeekSchema.shape.firstDayOfWeek,+ pingIconsEnabled: userPingIconsEnabledSchema.shape.pingIconsEnabled,+});++type FormValues = z.infer<typeof userGeneralSettingsSchema>;++const FIRST_DAY_OPTIONS: { value: DayOfWeek; labelKey: number }[] = [+ { value: 1, labelKey: 1 },+ { value: 6, labelKey: 6 },+ { value: 0, labelKey: 0 },+];++interface UserGeneralSettingsFormProps {+ user: RouterOutputs["user"]["getById"];+ boardsData: Pick<Board, "id" | "name" | "logoImageUrl">[];+ searchEnginesData: { value: string; label: string }[];+ showLanguageSelector?: boolean;+}++const buildInitialValues = (user: RouterOutputs["user"]["getById"]): FormValues => ({+ name: user.name ?? "",+ email: user.email ?? "",+ homeBoardId: user.homeBoardId,+ mobileHomeBoardId: user.mobileHomeBoardId,+ defaultSearchEngineId: user.defaultSearchEngineId,+ openInNewTab: user.openSearchInNewTab,+ ddgBangsEnabled: user.ddgBangs,+ firstDayOfWeek: user.firstDayOfWeek as DayOfWeek,+ pingIconsEnabled: user.pingIconsEnabled,+});++export const UserGeneralSettingsForm = ({+ user,+ boardsData,+ searchEnginesData,+ showLanguageSelector = false,+}: UserGeneralSettingsFormProps) => {+ const t = useI18n();+ const tGeneral = useScopedI18n("management.page.user.setting.general");+ const isCredentialsUser = user.provider === "credentials";++ const editProfileMutation = clientApi.user.editProfile.useMutation();+ const changeHomeBoardsMutation = clientApi.user.changeHomeBoards.useMutation();+ const changeSearchPreferencesMutation = clientApi.user.changeSearchPreferences.useMutation();+ const changeFirstDayOfWeekMutation = clientApi.user.changeFirstDayOfWeek.useMutation();+ const changePingIconsEnabledMutation = clientApi.user.changePingIconsEnabled.useMutation();++ const initialValues = buildInitialValues(user);+ const initialValuesRef = useRef(initialValues);++ const form = useZodForm(userGeneralSettingsSchema, {+ initialValues,+ });++ const isDirtyRef = useRef(false);+ isDirtyRef.current = form.isDirty();++ const weekDays = useMemo(() => dayjs.weekdays(false), []);++ const mutations = [+ editProfileMutation,+ changeHomeBoardsMutation,+ changeSearchPreferencesMutation,+ changeFirstDayOfWeekMutation,+ changePingIconsEnabledMutation,+ ];+ const isPending = mutations.some((m) => m.isPending);++ useEffect(() => {+ const handler = (e: BeforeUnloadEvent) => {+ if (env.NODE_ENV === "development") return;+ if (isDirtyRef.current) e.preventDefault();+ };+ window.addEventListener("beforeunload", handler);+ return () => window.removeEventListener("beforeunload", handler);+ }, []);++ const handleSubmitAsync = async (values: FormValues) => {+ const parsed = userGeneralSettingsSchema.safeParse(values);+ if (!parsed.success) return;++ const defaults = initialValuesRef.current;+ const changed = <K extends keyof FormValues>(...fields: K[]) =>+ fields.some((f) => (f === "email" ? (values[f] || null) !== (defaults[f] || null) : values[f] !== defaults[f]));++ const saveActions: { when: boolean; action: () => Promise<unknown> }[] = [+ {+ when: isCredentialsUser && changed("name", "email"),+ action: () =>+ editProfileMutation.mutateAsync({ id: user.id, name: parsed.data.name, email: parsed.data.email ?? "" }),+ },+ {+ when: changed("homeBoardId", "mobileHomeBoardId"),+ action: () =>+ changeHomeBoardsMutation.mutateAsync({+ userId: user.id,+ homeBoardId: parsed.data.homeBoardId,+ mobileHomeBoardId: parsed.data.mobileHomeBoardId,+ }),+ },+ {+ when: changed("defaultSearchEngineId", "openInNewTab", "ddgBangsEnabled"),+ action: () =>+ changeSearchPreferencesMutation.mutateAsync({+ userId: user.id,+ defaultSearchEngineId: parsed.data.defaultSearchEngineId,+ openInNewTab: parsed.data.openInNewTab,+ ddgBangsEnabled: parsed.data.ddgBangsEnabled,+ }),+ },+ {+ when: changed("firstDayOfWeek"),+ action: () =>+ changeFirstDayOfWeekMutation.mutateAsync({ id: user.id, firstDayOfWeek: parsed.data.firstDayOfWeek }),+ },+ {+ when: changed("pingIconsEnabled"),+ action: () =>+ changePingIconsEnabledMutation.mutateAsync({ id: user.id, pingIconsEnabled: parsed.data.pingIconsEnabled }),+ },+ ];++ const promises = saveActions.filter((s) => s.when).map((s) => s.action());+ if (promises.length === 0) return;++ try {+ await Promise.all(promises);+ const newValues = { ...parsed.data, email: parsed.data.email ?? "" };+ initialValuesRef.current = newValues;+ form.setInitialValues(newValues);+ form.resetDirty();+ await revalidatePathActionAsync(`/manage/users/${user.id}`);+ showSuccessNotification({+ title: t("common.notification.update.success"),+ message: t("common.notification.update.success"),+ });+ } catch {+ showErrorNotification({+ title: t("common.notification.update.error"),+ message: t("common.notification.update.error"),+ });+ }+ };++ const handleDiscard = () => {+ form.setValues(initialValuesRef.current);+ form.resetDirty();+ };++ const firstDayOfWeekInputProps = form.getInputProps("firstDayOfWeek");+ const firstDayOfWeekOnChange = firstDayOfWeekInputProps.onChange as (value: number) => void;+ const firstDayOfWeekValue = (firstDayOfWeekInputProps.value as number).toString();++ return (+ <form onSubmit={form.onSubmit(handleSubmitAsync)}>+ <Stack gap="lg">+ <SimpleGrid cols={{ base: 1, md: 2 }} spacing="lg" verticalSpacing="lg">+ <Card withBorder bg="transparent">+ <Stack gap="md">+ <Stack gap={2}>+ <Title order={3}>{t("user.name")}</Title>+ {!isCredentialsUser && (+ <Text c="dimmed" size="sm">+ {t("management.page.user.fieldsDisabledExternalProvider")}+ </Text>+ )}+ </Stack>+ <Divider />+ <TextInput+ disabled={!isCredentialsUser}+ label={t("user.field.username.label")}+ withAsterisk+ {...form.getInputProps("name")}+ />+ <TextInput+ disabled={!isCredentialsUser}+ label={t("user.field.email.label")}+ {...form.getInputProps("email")}+ />+ </Stack>+ </Card>++ <Card withBorder bg="transparent">+ <Stack gap="md">+ <Stack gap={2}>+ <Title order={3}>{tGeneral("item.board.title")}</Title>+ </Stack>+ <Divider />+ <BoardSelect+ label={tGeneral("item.board.type.general")}+ clearable+ boards={boardsData}+ w="100%"+ withinPortal+ {...form.getInputProps("homeBoardId")}+ />+ <BoardSelect+ label={tGeneral("item.board.type.mobile")}+ clearable+ boards={boardsData}+ w="100%"+ withinPortal+ {...form.getInputProps("mobileHomeBoardId")}+ />+ </Stack>+ </Card>++ <Card withBorder bg="transparent">+ <Stack gap="md">+ <Stack gap={2}>+ <Title order={3}>{tGeneral("item.search")}</Title>+ </Stack>+ <Divider />+ <Select+ label={t("user.field.defaultSearchEngine.label")}+ w="100%"+ data={searchEnginesData}+ comboboxProps={{ withinPortal: true }}+ {...form.getInputProps("defaultSearchEngineId")}+ />+ <Switch+ label={t("user.field.openSearchInNewTab.label")}+ {...form.getInputProps("openInNewTab", { type: "checkbox" })}+ />+ <Switch+ label={t("user.field.ddgBangs.label")}+ {...form.getInputProps("ddgBangsEnabled", { type: "checkbox" })}+ />+ </Stack>+ </Card>++ <Card withBorder bg="transparent">+ <Stack gap="md">+ <Stack gap={2}>+ <Title order={3}>{tGeneral("item.language")}</Title>+ </Stack>+ <Divider />+ {showLanguageSelector && <CurrentLanguageCombobox withinPortal />}+ <Title order={4}>{tGeneral("item.firstDayOfWeek")}</Title>+ <Radio.Group+ {...firstDayOfWeekInputProps}+ value={firstDayOfWeekValue}+ onChange={(nextValue: string) => firstDayOfWeekOnChange(parseInt(nextValue, 10))}+ >+ <Group mt="xs" wrap="wrap">+ {FIRST_DAY_OPTIONS.map(({ value: dayValue, labelKey }) => (+ <Radio key={dayValue} value={dayValue.toString()} label={weekDays[labelKey]} />+ ))}+ </Group>+ </Radio.Group>+ <Divider my="xs" />+ <Title order={4}>{tGeneral("item.accessibility")}</Title>+ <Switch+ label={t("user.field.pingIconsEnabled.label")}+ {...form.getInputProps("pingIconsEnabled", { type: "checkbox" })}+ />+ </Stack>+ </Card>+ </SimpleGrid>++ <div style={{ position: "sticky", bottom: 20 }}>+ {form.isDirty() && (+ <Card withBorder>+ <Group justify="space-between" wrap="wrap">+ <Text fw={500}>{t("common.unsavedChanges")}</Text>+ <Group>+ <Button disabled={isPending} variant="default" onClick={handleDiscard}>+ {t("common.action.discard")}+ </Button>+ <Button loading={isPending} type="submit" disabled={!form.isValid()}>+ {t("common.action.saveChanges")}+ </Button>+ </Group>+ </Group>+ </Card>+ )}+ </div>+ </Stack>+ </form>+ );+};diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_ping-icons-enabled.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_ping-icons-enabled.tsxdeleted file mode 100644index d218ac39a..000000000--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_ping-icons-enabled.tsx+++ /dev/null@@ -1,69 +0,0 @@-"use client";--import { Button, Group, Stack, Switch } from "@mantine/core";-import type { z } from "zod/v4";--import type { RouterOutputs } from "@homarr/api";-import { clientApi } from "@homarr/api/client";-import { revalidatePathActionAsync } from "@homarr/common/client";-import { useZodForm } from "@homarr/form";-import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";-import { useI18n } from "@homarr/translation/client";-import { userPingIconsEnabledSchema } from "@homarr/validation/user";--interface PingIconsEnabledProps {- user: RouterOutputs["user"]["getById"];-}--export const PingIconsEnabled = ({ user }: PingIconsEnabledProps) => {- const t = useI18n();- const { mutate, isPending } = clientApi.user.changePingIconsEnabled.useMutation({- async onSettled() {- await revalidatePathActionAsync(`/manage/users/${user.id}`);- },- onSuccess(_, variables) {- form.setInitialValues({- pingIconsEnabled: variables.pingIconsEnabled,- });- showSuccessNotification({- message: t("user.action.changePingIconsEnabled.notification.success.message"),- });- },- onError() {- showErrorNotification({- message: t("user.action.changePingIconsEnabled.notification.error.message"),- });- },- });- const form = useZodForm(userPingIconsEnabledSchema, {- initialValues: {- pingIconsEnabled: user.pingIconsEnabled,- },- });-- const handleSubmit = (values: FormType) => {- mutate({- id: user.id,- ...values,- });- };-- return (- <form onSubmit={form.onSubmit(handleSubmit)}>- <Stack gap="md">- <Switch- {...form.getInputProps("pingIconsEnabled", { type: "checkbox" })}- label={t("user.field.pingIconsEnabled.label")}- />-- <Group justify="end">- <Button type="submit" loading={isPending}>- {t("common.action.save")}- </Button>- </Group>- </Stack>- </form>- );-};--type FormType = z.infer<typeof userPingIconsEnabledSchema>;diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-avatar-form.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-avatar-form.tsxindex 2137add34..809345a0f 100644--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-avatar-form.tsx+++ b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-avatar-form.tsx@@ -2,7 +2,7 @@import { useCallback } from "react";import { Box, Button, FileButton, Menu, UnstyledButton } from "@mantine/core";-import { useDisclosure } from "@mantine/hooks";+import { useDisclosure, useMediaQuery } from "@mantine/hooks";import { IconPencil, IconPhotoEdit, IconPhotoX } from "@tabler/icons-react";import type { RouterOutputs } from "@homarr/api";@@ -25,6 +25,7 @@ export const UserProfileAvatarForm = ({ user }: UserProfileAvatarForm) => {},});const [opened, { toggle }] = useDisclosure(false);+ const isMobile = useMediaQuery("(max-width: 48em)");const { openConfirmModal } = useConfirmModal();const t = useI18n();const tManageAvatar = useScopedI18n("user.action.manageAvatar");@@ -94,11 +95,11 @@ export const UserProfileAvatarForm = ({ user }: UserProfileAvatarForm) => {}, [mutate, user.id, openConfirmModal, tManageAvatar]);return (- <Box pos="relative">- <Menu opened={opened} keepMounted onChange={toggle} position="bottom-start">+ <Box pos="relative" display="flex" style={{ justifyContent: isMobile ? "center" : undefined }}>+ <Menu opened={opened} keepMounted onChange={toggle} position="bottom-start" withArrow withinPortal><Menu.Target><UnstyledButton onClick={toggle}>- <UserAvatar user={user} size={200} />+ <UserAvatar user={user} size={isMobile ? 120 : 200} /><Buttoncomponent="div"pos="absolute"diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-form.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-form.tsxdeleted file mode 100644index 2db358cae..000000000--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/_components/_profile-form.tsx+++ /dev/null@@ -1,94 +0,0 @@-"use client";--import { useCallback } from "react";-import { Button, Group, Stack, TextInput } from "@mantine/core";--import type { RouterInputs, RouterOutputs } from "@homarr/api";-import { clientApi } from "@homarr/api/client";-import { revalidatePathActionAsync } from "@homarr/common/client";-import { useZodForm } from "@homarr/form";-import { showErrorNotification, showSuccessNotification } from "@homarr/notifications";-import { useI18n } from "@homarr/translation/client";-import { userEditProfileSchema } from "@homarr/validation/user";--interface UserProfileFormProps {- user: RouterOutputs["user"]["getById"];-}--export const UserProfileForm = ({ user }: UserProfileFormProps) => {- const t = useI18n();- const { mutate, isPending } = clientApi.user.editProfile.useMutation({- async onSettled() {- await revalidatePathActionAsync("/manage/users");- },- onSuccess(_, variables) {- // Reset form initial values to reset dirty state- form.setInitialValues({- name: variables.name,- email: variables.email ?? "",- });- showSuccessNotification({- title: t("common.notification.update.success"),- message: t("user.action.editProfile.notification.success.message"),- });- },- onError(error) {- const message =- error.data?.code === "CONFLICT"- ? t("user.error.usernameTaken")- : t("user.action.editProfile.notification.error.message");- showErrorNotification({- title: t("common.notification.update.error"),- message,- });- },- });- const form = useZodForm(userEditProfileSchema.omit({ id: true }), {- initialValues: {- name: user.name ?? "",- email: user.email ?? "",- },- });-- // Only credentials users can edit their profile- const isProviderCredentials = user.provider === "credentials";-- const handleSubmit = useCallback(- (values: FormType) => {- if (!isProviderCredentials) return;- mutate({- ...values,- id: user.id,- });- },- [isProviderCredentials, mutate, user.id],- );-- return (- <form onSubmit={form.onSubmit(handleSubmit)}>- <Stack>- <TextInput- disabled={!isProviderCredentials}- label={t("user.field.username.label")}- withAsterisk- {...form.getInputProps("name")}- />- <TextInput- disabled={!isProviderCredentials}- label={t("user.field.email.label")}- {...form.getInputProps("email")}- />-- {isProviderCredentials && (- <Group justify="end">- <Button type="submit" disabled={!form.isDirty()} loading={isPending}>- {t("common.action.saveChanges")}- </Button>- </Group>- )}- </Stack>- </form>- );-};--type FormType = Omit<RouterInputs["user"]["editProfile"], "id">;diff --git a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/page.tsx b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/page.tsxindex ee960b0f5..cf68c20e2 100644--- a/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/page.tsx+++ b/apps/nextjs/src/app/[locale]/manage/users/[userId]/general/page.tsx@@ -6,18 +6,13 @@ import { api } from "@homarr/api/server";import { auth } from "@homarr/auth/next";import { getI18n, getScopedI18n } from "@homarr/translation/server";-import { CurrentLanguageCombobox } from "~/components/language/current-language-combobox";import { DangerZoneItem, DangerZoneRoot } from "~/components/manage/danger-zone";import { catchTrpcNotFound } from "~/errors/trpc-catch-error";import { createMetaTitle } from "~/metadata";import { canAccessUserEditPage } from "../access";-import { ChangeHomeBoardForm } from "./_components/_change-home-board";-import { ChangeSearchPreferencesForm } from "./_components/_change-search-preferences";import { DeleteUserButton } from "./_components/_delete-user-button";-import { FirstDayOfWeek } from "./_components/_first-day-of-week";-import { PingIconsEnabled } from "./_components/_ping-icons-enabled";+import { UserGeneralSettingsForm } from "./_components/_general-settings-form";import { UserProfileAvatarForm } from "./_components/_profile-avatar-form";-import { UserProfileForm } from "./_components/_profile-form";interface Props {params: Promise<{@@ -63,7 +58,7 @@ export default async function EditUserPage(props: Props) {const boards = await api.board.getAllBoards();const searchEngines = await api.searchEngine.getSelectable();-+ const isSelf = session?.user.id === user.id;const isCredentialsUser = user.provider === "credentials";return (@@ -73,51 +68,25 @@ export default async function EditUserPage(props: Props) {{t("management.page.user.fieldsDisabledExternalProvider")}</Alert>)}-<Title>{tGeneral("title")}</Title>- <Group gap="xl">- <Box flex={1}>- <UserProfileForm user={user} />+ <Group gap="xl" align="flex-start" wrap="wrap">+ <Box flex={1} miw={{ base: "100%", md: 540 }}>+ <UserGeneralSettingsForm+ user={user}+ boardsData={boards.map((board) => ({+ id: board.id,+ name: board.name,+ logoImageUrl: board.logoImageUrl,+ }))}+ searchEnginesData={searchEngines}+ showLanguageSelector={isSelf}+ /></Box>- <Box w={{ base: "100%", lg: 200 }}>+ <Box w={{ base: "100%", lg: 260 }}><UserProfileAvatarForm user={user} /></Box></Group>- {session?.user.id === user.id && (- <Stack mb="lg">- <Title order={2}>{tGeneral("item.language")}</Title>- <CurrentLanguageCombobox />- </Stack>- )}-- <Stack mb="lg">- <Title order={2}>{tGeneral("item.board.title")}</Title>- <ChangeHomeBoardForm- user={user}- boardsData={boards.map((board) => ({- id: board.id,- name: board.name,- logoImageUrl: board.logoImageUrl,- }))}- />- </Stack>-- <Stack mb="lg">- <Title order={2}>{tGeneral("item.search")}</Title>- <ChangeSearchPreferencesForm user={user} searchEnginesData={searchEngines} />- </Stack>-- <Stack mb="lg">- <Title order={2}>{tGeneral("item.firstDayOfWeek")}</Title>- <FirstDayOfWeek user={user} />- </Stack>-- <Stack mb="lg">- <Title order={2}>{tGeneral("item.accessibility")}</Title>- <PingIconsEnabled user={user} />- </Stack>-<DangerZoneRoot><DangerZoneItemlabel={t("user.action.delete.label")}diff --git a/apps/nextjs/src/components/language/current-language-combobox.tsx b/apps/nextjs/src/components/language/current-language-combobox.tsxindex e27f34c39..54d9a0f98 100644--- a/apps/nextjs/src/components/language/current-language-combobox.tsx+++ b/apps/nextjs/src/components/language/current-language-combobox.tsx@@ -6,11 +6,20 @@ import { LanguageCombobox } from "./language-combobox";interface CurrentLanguageComboboxProps {width?: string;+ withinPortal?: boolean;}-export const CurrentLanguageCombobox = ({ width }: CurrentLanguageComboboxProps) => {+export const CurrentLanguageCombobox = ({ width, withinPortal }: CurrentLanguageComboboxProps) => {const currentLocale = useCurrentLocale();const { changeLocale, isPending } = useChangeLocale();- return <LanguageCombobox value={currentLocale} onChange={changeLocale} isPending={isPending} width={width} />;+ return (+ <LanguageCombobox+ value={currentLocale}+ onChange={changeLocale}+ isPending={isPending}+ width={width}+ withinPortal={withinPortal}+ />+ );};diff --git a/apps/nextjs/src/components/language/language-combobox.tsx b/apps/nextjs/src/components/language/language-combobox.tsxindex 6f4b39b33..f6eaaac69 100644--- a/apps/nextjs/src/components/language/language-combobox.tsx+++ b/apps/nextjs/src/components/language/language-combobox.tsx@@ -16,9 +16,17 @@ interface LanguageComboboxProps {onChange: (value: SupportedLanguage) => void;isPending?: boolean;width?: string;+ withinPortal?: boolean;}-export const LanguageCombobox = ({ label, value, onChange, isPending, width }: LanguageComboboxProps) => {+export const LanguageCombobox = ({+ label,+ value,+ onChange,+ isPending,+ width,+ withinPortal = false,+}: LanguageComboboxProps) => {const combobox = useCombobox({onDropdownClose: () => combobox.resetSelectedOption(),});@@ -39,7 +47,7 @@ export const LanguageCombobox = ({ label, value, onChange, isPending, width }: L}, [combobox]);return (- <Combobox store={combobox} onOptionSubmit={handleOnOptionSubmit}>+ <Combobox store={combobox} withinPortal={withinPortal} onOptionSubmit={handleOnOptionSubmit}><Combobox.Target><InputBasecomponent="button"diff --git a/packages/ui/src/components/select-with-custom-items.tsx b/packages/ui/src/components/select-with-custom-items.tsxindex b1fe554e4..d4a9545ab 100644--- a/packages/ui/src/components/select-with-custom-items.tsx+++ b/packages/ui/src/components/select-with-custom-items.tsx@@ -20,6 +20,7 @@ export interface SelectWithCustomItemsProps<TSelectItem extends BaseSelectItem>onBlur?: (event: React.FocusEvent<HTMLButtonElement>) => void;onFocus?: (event: React.FocusEvent<HTMLButtonElement>) => void;w?: string;+ withinPortal?: boolean;}type Props<TSelectItem extends BaseSelectItem> = SelectWithCustomItemsProps<TSelectItem> & {@@ -35,6 +36,7 @@ export const SelectWithCustomItems = <TSelectItem extends BaseSelectItem>({SelectOption,w,clearable,+ withinPortal = false,...props}: Props<TSelectItem>) => {const combobox = useCombobox({@@ -71,7 +73,7 @@ export const SelectWithCustomItems = <TSelectItem extends BaseSelectItem>({const _clearable = clearable && Boolean(_value);return (- <Combobox store={combobox} withinPortal={false} onOptionSubmit={onOptionSubmit}>+ <Combobox store={combobox} withinPortal={withinPortal} onOptionSubmit={onOptionSubmit}><Combobox.Target><InputBase{...props}diff --git a/pnpm-lock.yaml b/pnpm-lock.yamlindex 044d2d5a7..b26cef0eb 100644--- a/pnpm-lock.yaml+++ b/pnpm-lock.yaml@@ -4871,6 +4871,13 @@ packages:'@tabler/[email protected]':resolution: {integrity: sha512-Wn0AOZG9sg0L+bjfMqq4eNhC6pQjIrk94LvvWYNYkY8KH8wC3YILRzQlrnVJc4FUeMxH/AK97QsYCX35H3LndA==}+ '@tanstack/[email protected]':+ resolution: {integrity: sha512-RPfGuk2bDZgcu9bAJodvO2lnZeHuz4/71HjZ0bGb/SPg8+lyTA+RLSKQvo7fSmPSi8/vcH3aKQ8EM9ywf1olaw==}+ engines: {node: '>=18'}++ '@tanstack/[email protected]':+ resolution: {integrity: sha512-nvogpyE98fhb0NDw1Bf2YaCH+L7ZIUgEpqO9TkHucDn6zg3ni521boUpv0i8HKIrmmFwDYjWZoCnrgY4HYWTkw==}+'@tanstack/[email protected]':resolution: {integrity: sha512-Wo1iKt2b9OT7d+YGhvEPD3DXvPv2etTusIMhMUoG7fbhmxcXCtIjJDEygy91Y2JFlwGyjqiBPRozme7UD8hoqg==}engines: {node: '>=12'}@@ -4899,6 +4906,12 @@ packages:peerDependencies:react: ^18 || ^19+ '@tanstack/[email protected]':+ resolution: {integrity: sha512-1vG9beLIuB7q69skxK9r5xiLN3ztzIPfSQSs0GfeqWGO2tGIyInZx0x1COhpx97RKaONSoAb8C3dxacWksm1ow==}+ peerDependencies:+ react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0+ react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0+'@tanstack/[email protected]':resolution: {integrity: sha512-WEHopKw3znbUZ61s9i0+i9g8drmDo6asTWbrQh8Us63DAk/M0FkmIqERew6P71HI75ksZ2Pxyuf4vvKh9rAkiA==}engines: {node: '>=12'}@@ -4912,6 +4925,12 @@ packages:react: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0react-dom: ^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0+ '@tanstack/[email protected]':+ resolution: {integrity: sha512-xa6pTan1bcaqYDS9BDpSiS63qa6EoDkPN9RsRaxHuDdVDNntzq3xNwR5YKTU/V3SkSyC9T4YVOPh2zRQN0nhIQ==}++ '@tanstack/[email protected]':+ resolution: {integrity: sha512-Om+BO0YfMZe//X2z0uLF2j+75nQga6TpTJgLJQBiq85aOyZNIhkCgleNcud2KQg4k4v9Y9l+Uhru3qWMPGTOzQ==}+'@tanstack/[email protected]':resolution: {integrity: sha512-P9dF7XbibHph2PFRz8gfBKEXEY/HJPOhym8CHmjF8y3q5mWpKx9xtZapXQUWCgkqvsK0R46Azuz+VaxD4Xl+Tg==}engines: {node: '>=12'}@@ -12161,6 +12180,14 @@ snapshots:'@tabler/[email protected]': {}+ '@tanstack/[email protected]': {}++ '@tanstack/[email protected]':+ dependencies:+ '@tanstack/devtools-event-client': 0.4.0+ '@tanstack/pacer-lite': 0.1.1+ '@tanstack/store': 0.7.7+'@tanstack/[email protected]':dependencies:remove-accents: 0.5.0@@ -12198,6 +12225,10 @@ snapshots:react: 19.2.6react-dom: 19.2.6([email protected])+ '@tanstack/[email protected]': {}++ '@tanstack/[email protected]': {}+'@tanstack/[email protected]': {}'@tanstack/[email protected]': {}