feat: polish release v2 experience (#6800)
This commit is contained in:
1 parent
925b0fb801
commit
a4a903d7c3
295 files changed
+10627
-7115
No files matched your search
@@ -7,6 +7,7 @@ import dayjs from "dayjs";
|
||||
import localeData from "dayjs/plugin/localeData";
|
||||
|
||||
import { useSession } from "@homarr/auth/client";
|
||||
import type { ByteUnitSystem } from "@homarr/common";
|
||||
import type { ColorScheme } from "@homarr/definitions";
|
||||
import { visiblePreferenceDefinitions } from "@homarr/settings";
|
||||
import { localeConfigurations } from "@homarr/translation";
|
||||
@@ -75,11 +76,16 @@ const SELECT_KINDS = new Set(["select", "searchEngine", "board"]);
|
||||
export const useSettingsActions = (_: Record<string, unknown>, query: string): SettingsAction[] => {
|
||||
const t = useI18n("search.mode.command.group.preferences.option");
|
||||
const tUserField = useI18n("user.field");
|
||||
const tByteUnit = useI18n("user.field.byteUnitSystem.options");
|
||||
const tColorScheme = useI18n("common.colorScheme.options");
|
||||
const { data: session } = useSession();
|
||||
const isAuthenticated = Boolean(session?.user);
|
||||
const normalizedQuery = query.trim().toLowerCase();
|
||||
const preferences = useUserPreferences();
|
||||
const byteUnitLabels: Record<ByteUnitSystem, string> = {
|
||||
decimal: `${tByteUnit("decimal")} (KB, MB, GB)`,
|
||||
binary: `${tByteUnit("binary")} (KiB, MiB, GiB)`,
|
||||
};
|
||||
|
||||
const valueLabelResolvers: Record<string, () => string> = {
|
||||
colorScheme: () => tColorScheme(preferences.getPreference("colorScheme").value as ColorScheme),
|
||||
@@ -88,6 +94,7 @@ export const useSettingsActions = (_: Record<string, unknown>, query: string): S
|
||||
return localeConfigurations[val as keyof typeof localeConfigurations]?.name ?? String(val);
|
||||
},
|
||||
firstDayOfWeek: () => dayjs.weekdays(false)[preferences.getPreference("firstDayOfWeek").value as DayOfWeek] ?? "",
|
||||
byteUnitSystem: () => byteUnitLabels[preferences.getPreference("byteUnitSystem").value as ByteUnitSystem],
|
||||
};
|
||||
|
||||
return visiblePreferenceDefinitions(isAuthenticated)
|
||||
|
||||
@@ -9,6 +9,7 @@ import {
|
||||
IconHome,
|
||||
IconLanguage,
|
||||
IconLayoutBoard,
|
||||
IconRulerMeasure,
|
||||
IconSearch,
|
||||
IconSettings,
|
||||
IconWorldWww,
|
||||
@@ -41,6 +42,7 @@ export type UserFieldPreferenceKey =
|
||||
| "defaultSearchEngine"
|
||||
| "openSearchInNewTab"
|
||||
| "ddgBangs"
|
||||
| "byteUnitSystem"
|
||||
| "pingIconsEnabled"
|
||||
| "enableRightClickOnWidgets";
|
||||
|
||||
@@ -48,6 +50,7 @@ export const userFieldPreferenceLabels: Partial<Record<UserPreferenceKey, UserFi
|
||||
defaultSearchEngineId: "defaultSearchEngine",
|
||||
openSearchInNewTab: "openSearchInNewTab",
|
||||
ddgBangs: "ddgBangs",
|
||||
byteUnitSystem: "byteUnitSystem",
|
||||
pingIconsEnabled: "pingIconsEnabled",
|
||||
enableRightClickOnWidgets: "enableRightClickOnWidgets",
|
||||
} satisfies Partial<Record<UserPreferenceKey, UserFieldPreferenceKey>>;
|
||||
@@ -59,6 +62,7 @@ export const preferenceIcons: Record<UserPreferenceKey, TablerIcon> = {
|
||||
openSearchInNewTab: IconExternalLink,
|
||||
ddgBangs: IconWorldWww,
|
||||
firstDayOfWeek: IconCalendarWeek,
|
||||
byteUnitSystem: IconRulerMeasure,
|
||||
homeBoardId: IconHome,
|
||||
mobileHomeBoardId: IconLayoutBoard,
|
||||
pingIconsEnabled: IconActivity,
|
||||
@@ -136,6 +140,13 @@ export const preferenceChildrenOptionsByKey: Partial<Record<UserPreferenceKey, C
|
||||
value: day,
|
||||
})),
|
||||
),
|
||||
byteUnitSystem: createStaticChildren("byteUnitSystem", () => {
|
||||
const t = useI18n("user.field.byteUnitSystem.options");
|
||||
return [
|
||||
{ key: "decimal", label: `${t("decimal")} (KB, MB, GB)`, value: "decimal" },
|
||||
{ key: "binary", label: `${t("binary")} (KiB, MiB, GiB)`, value: "binary" },
|
||||
];
|
||||
}),
|
||||
homeBoardId: createAsyncSelectableChildren(
|
||||
"homeBoardId",
|
||||
() => clientApi.board.getAllBoards.useQuery(),
|
||||
|
||||
@@ -7,6 +7,7 @@ import type { DayOfWeek } from "@mantine/dates";
|
||||
|
||||
import { clientApi } from "@homarr/api/client";
|
||||
import { useSession } from "@homarr/auth/client";
|
||||
import type { ByteUnitSystem } from "@homarr/common";
|
||||
import type { ColorScheme } from "@homarr/definitions";
|
||||
import { showErrorNotification } from "@homarr/notifications";
|
||||
import type { SettingsContextProps } from "@homarr/settings/creator";
|
||||
@@ -92,6 +93,7 @@ export const useUserPreferences = () => {
|
||||
const searchMutation = clientApi.user.changeSearchPreferences.useMutation({ onSuccess: refresh });
|
||||
const homeBoardsMutation = clientApi.user.changeHomeBoards.useMutation({ onSuccess: refresh });
|
||||
const firstDayMutation = clientApi.user.changeFirstDayOfWeek.useMutation({ onSuccess: refresh });
|
||||
const byteUnitSystemMutation = clientApi.user.changeByteUnitSystem.useMutation({ onSuccess: refresh });
|
||||
const pingMutation = clientApi.user.changePingIconsEnabled.useMutation({ onSuccess: refresh });
|
||||
const rightClickMutation = clientApi.user.changeEnableRightClickOnWidgets.useMutation({ onSuccess: refresh });
|
||||
|
||||
@@ -116,6 +118,8 @@ export const useUserPreferences = () => {
|
||||
mobileHomeBoardId: pick("mobileHomeBoardId", key, value) as string | null,
|
||||
}),
|
||||
firstDayOfWeek: (uid, _key, value) => firstDayMutation.mutateAsync({ id: uid, firstDayOfWeek: value as DayOfWeek }),
|
||||
byteUnitSystem: (uid, _key, value) =>
|
||||
byteUnitSystemMutation.mutateAsync({ id: uid, byteUnitSystem: value as ByteUnitSystem }),
|
||||
pingIconsEnabled: (uid, _key, value) => pingMutation.mutateAsync({ id: uid, pingIconsEnabled: value as boolean }),
|
||||
enableRightClickOnWidgets: (uid, _key, value) =>
|
||||
rightClickMutation.mutateAsync({ id: uid, enableRightClickOnWidgets: value as boolean }),
|
||||
@@ -125,6 +129,7 @@ export const useUserPreferences = () => {
|
||||
searchPreferences: searchMutation.isPending,
|
||||
homeBoards: homeBoardsMutation.isPending,
|
||||
firstDayOfWeek: firstDayMutation.isPending,
|
||||
byteUnitSystem: byteUnitSystemMutation.isPending,
|
||||
pingIconsEnabled: pingMutation.isPending,
|
||||
enableRightClickOnWidgets: rightClickMutation.isPending,
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user