Skip to content

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: group bookmarks and streamline app creation (#7080)

Thomas0679b9062994
diff --git a/packages/forms-collection/src/new-app/_form.tsx b/packages/forms-collection/src/new-app/_form.tsx
index f103d8cd6..c0e30c139 100644
--- a/packages/forms-collection/src/new-app/_form.tsx
+++ b/packages/forms-collection/src/new-app/_form.tsx
@@ -1,7 +1,7 @@
"use client";
import type { ChangeEventHandler } from "react";
-import { useEffect, useImperativeHandle, useRef } from "react";
+import { useCallback, useEffect, useImperativeHandle, useRef } from "react";
import { Button, Checkbox, Collapse, Group, Stack, Textarea, TextInput } from "@mantine/core";
import { useDisclosure } from "@mantine/hooks";
import type { z } from "zod/v4";
@@ -82,16 +82,20 @@ export const AppForm = ({
}, [initialValuesKey]);
const shouldCreateAnother = useRef(false);
- const handleSubmit = (values: FormType) => {
- const redirect = !shouldCreateAnother.current;
- const afterSuccess = shouldCreateAnother.current
- ? () => {
- form.reset();
- shouldCreateAnother.current = false;
- }
- : undefined;
- originalHandleSubmit(values, redirect, afterSuccess);
- };
+ const handleSubmit = useCallback(
+ async (values: FormType) => {
+ const redirect = !shouldCreateAnother.current;
+ const afterSuccess = shouldCreateAnother.current
+ ? () => {
+ form.reset();
+ shouldCreateAnother.current = false;
+ }
+ : undefined;
+ shouldCreateAnother.current = false;
+ await originalHandleSubmit(values, redirect, afterSuccess);
+ },
+ [form, originalHandleSubmit],
+ );
useImperativeHandle(
formRef,
@@ -102,7 +106,7 @@ export const AppForm = ({
async (values) => {
try {
await Promise.resolve(handleSubmit(values));
- form.initialize(values);
+ form.resetDirty(values);
resolve(true);
} catch {
resolve(false);
@@ -128,62 +132,83 @@ export const AppForm = ({
};
const formFields = (
- <Stack>
- <TextInput {...form.getInputProps("name")} withAsterisk label={tCommon("field.name")} />
- <IconPicker
- {...form.getInputProps("iconUrl")}
- suggestedSearch={initialValues === undefined ? form.values.name : undefined}
- />
- <Textarea
- {...form.getInputProps("description")}
- label={tApp("field.description.label")}
- autosize
- minRows={2}
- resize="vertical"
- />
- <TextInput {...form.getInputProps("href")} label={invariantTechnicalLabels.url} />
-
- <Checkbox
- checked={opened}
- onChange={handleClickDifferentUrlPing}
- label={tApp("field.useDifferentUrlForPing.checkbox.label")}
- description={tApp("field.useDifferentUrlForPing.checkbox.description")}
- mt="md"
- />
-
- <Collapse expanded={opened}>
- <TextInput {...form.getInputProps("pingUrl")} />
- </Collapse>
-
- {!hideButtons && (
- <Group justify="end">
- {showBackToOverview && (
- <Button variant="default" component={Link} href="/manage/apps">
- {tCommon("action.backToOverview")}
- </Button>
- )}
- {buttonLabels.submitAndCreateAnother && (
+ <fieldset disabled={isPending} style={{ border: 0, padding: 0, margin: 0, minWidth: 0 }}>
+ <Stack>
+ <TextInput {...form.getInputProps("name")} withAsterisk label={tCommon("field.name")} />
+ <IconPicker
+ {...form.getInputProps("iconUrl")}
+ suggestedSearch={initialValues === undefined ? form.values.name : undefined}
+ />
+ <Textarea
+ {...form.getInputProps("description")}
+ label={tApp("field.description.label")}
+ autosize
+ minRows={2}
+ resize="vertical"
+ />
+ <TextInput {...form.getInputProps("href")} label={invariantTechnicalLabels.url} />
+
+ <Checkbox
+ checked={opened}
+ onChange={handleClickDifferentUrlPing}
+ label={tApp("field.useDifferentUrlForPing.checkbox.label")}
+ description={tApp("field.useDifferentUrlForPing.checkbox.description")}
+ mt="md"
+ />
+
+ <Collapse expanded={opened}>
+ <TextInput {...form.getInputProps("pingUrl")} />
+ </Collapse>
+
+ {!hideButtons && (
+ <Group justify="end">
+ {showBackToOverview && (
+ <Button variant="default" component={Link} href="/manage/apps">
+ {tCommon("action.backToOverview")}
+ </Button>
+ )}
+ {buttonLabels.submitAndCreateAnother && (
+ <Button
+ type="submit"
+ onClick={() => {
+ shouldCreateAnother.current = true;
+ }}
+ loading={isPending}
+ >
+ {buttonLabels.submitAndCreateAnother}
+ </Button>
+ )}
<Button
type="submit"
+ loading={isPending}
onClick={() => {
- shouldCreateAnother.current = true;
+ shouldCreateAnother.current = false;
}}
- loading={isPending}
>
- {buttonLabels.submitAndCreateAnother}
+ {buttonLabels.submit}
</Button>
- )}
- <Button type="submit" loading={isPending}>
- {buttonLabels.submit}
- </Button>
- </Group>
- )}
- </Stack>
+ </Group>
+ )}
+ </Stack>
+ </fieldset>
);
if (hideButtons) {
return formFields;
}
- return <form onSubmit={form.onSubmit(handleSubmit)}>{formFields}</form>;
+ return (
+ <form
+ onSubmit={form.onSubmit(
+ (values) => {
+ void handleSubmit(values).catch(() => {});
+ },
+ () => {
+ shouldCreateAnother.current = false;
+ },
+ )}
+ >
+ {formFields}
+ </form>
+ );
};
diff --git a/packages/modals-collection/src/apps/app-select-modal.tsx b/packages/modals-collection/src/apps/app-select-modal.tsx
index 29b811243..0c43c0a78 100644
--- a/packages/modals-collection/src/apps/app-select-modal.tsx
+++ b/packages/modals-collection/src/apps/app-select-modal.tsx
@@ -12,15 +12,17 @@ import {
Text,
ThemeIcon,
} from "@mantine/core";
-import { IconBulb, IconPlus, IconSearch } from "@tabler/icons-react";
+import { IconArrowLeft, IconPlus, IconSearch } from "@tabler/icons-react";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
-import { createModal, modalSizeSelect, useModalAction } from "@homarr/modals";
+import { createModal, modalSizeSelect } from "@homarr/modals";
import { useI18n } from "@homarr/translation/client";
-import { FloatingTip, selectGridCols, SelectableCard } from "@homarr/ui";
+import { selectGridCols, SelectableCard } from "@homarr/ui";
-import { QuickAddAppModal } from "./quick-add-app/quick-add-app-modal";
+import { AppForm } from "@homarr/forms-collection";
+import { useSession } from "@homarr/auth/client";
+import { showErrorNotification } from "@homarr/notifications";
type SelectableApp = RouterOutputs["app"]["selectable"][number];
@@ -34,10 +36,19 @@ export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, inner
const [search, setSearch] = useState("");
const [selectedAppIds, setSelectedAppIds] = useState<Set<string>>(new Set());
const [createdApps, setCreatedApps] = useState<SelectableApp[]>([]);
- const [multiSelectActive, setMultiSelectActive] = useState(false);
+ const [creating, setCreating] = useState(false);
const t = useI18n();
const { data: apps = [], isPending } = clientApi.app.selectable.useQuery();
- const { openModal: openQuickAddAppModal } = useModalAction(QuickAddAppModal);
+ const { data: session } = useSession();
+ const utils = clientApi.useUtils();
+ const canCreate = innerProps.withCreate && Boolean(session?.user.permissions.includes("app-create"));
+ const { mutateAsync: createApp, isPending: isCreating } = clientApi.app.create.useMutation({
+ onError: () =>
+ showErrorNotification({
+ title: t("common.notification.create.error"),
+ message: t("app.page.create.notification.error.message"),
+ }),
+ });
const multiSelectAvailable = Boolean(innerProps.onSelectMany);
const selectableApps = useMemo(
@@ -48,7 +59,10 @@ export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, inner
const filteredApps = useMemo(
() =>
selectableApps
- .filter((app) => app.name.toLowerCase().includes(search.toLowerCase()))
+ .filter((app) => {
+ const query = search.trim().toLowerCase();
+ return app.name.toLowerCase().includes(query) || Boolean(app.href?.toLowerCase().includes(query));
+ })
.sort((appA, appB) => appA.name.localeCompare(appB.name)),
[search, selectableApps],
);
@@ -58,39 +72,17 @@ export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, inner
[selectableApps, selectedAppIds],
);
- const handleSelect = (app: SelectableApp, event?: React.MouseEvent) => {
- const isModifierPressed = multiSelectAvailable && Boolean(event?.shiftKey || event?.ctrlKey || event?.metaKey);
-
- if (!multiSelectActive && !isModifierPressed) {
- if (innerProps.onSelect) innerProps.onSelect(app);
- else innerProps.onSelectMany?.([app]);
+ const handleSelect = (app: SelectableApp) => {
+ if (!multiSelectAvailable) {
+ innerProps.onSelect?.(app);
actions.closeModal();
return;
}
-
- if (multiSelectAvailable) {
- setMultiSelectActive(true);
- setSelectedAppIds((current) => {
- const next = new Set(current);
- if (next.has(app.id)) next.delete(app.id);
- else next.add(app.id);
- return next;
- });
- }
- };
-
- const handleAddNewApp = () => {
- openQuickAddAppModal({
- onClose(app) {
- if (multiSelectActive) {
- setCreatedApps((current) => [...current, app]);
- setSelectedAppIds((current) => new Set(current).add(app.id));
- return;
- }
- if (innerProps.onSelect) innerProps.onSelect(app);
- else innerProps.onSelectMany?.([app]);
- actions.closeModal();
- },
+ setSelectedAppIds((current) => {
+ const next = new Set(current);
+ if (next.has(app.id)) next.delete(app.id);
+ else next.add(app.id);
+ return next;
});
};
@@ -101,78 +93,104 @@ export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, inner
return (
<Stack gap="md">
- <FloatingTip
- opened={multiSelectAvailable}
- showDelay={2_000}
- dismissAfter={3_000}
- transitionDuration={200}
- closable={false}
- alertProps={{ color: "primaryColor", icon: <IconBulb size={18} />, variant: "light" }}
- >
- {t("tips.multiSelectApps")}
- </FloatingTip>
-
- {/* Top Search Input */}
- <Stack gap={6}>
- <Input
- value={search}
- onChange={(event) => setSearch(event.currentTarget.value)}
- leftSection={<IconSearch size={16} />}
- placeholder={`${t("app.action.select.search")}...`}
- aria-label={t("app.action.select.search")}
- data-autofocus
- onKeyDown={(event) => {
- if (event.key === "Enter" && filteredApps.length === 1 && filteredApps[0]) {
- handleSelect(filteredApps[0]);
- }
- }}
- />
- </Stack>
-
- {/* Scrollable Container with App Cards */}
- <ScrollArea.Autosize mah="70vh" offsetScrollbars>
- <Stack gap="md" pt="xs" pr="xs" px={4}>
- <SimpleGrid cols={selectGridCols} spacing="sm">
- {innerProps.withCreate && (
- <SelectableCard
- onClick={handleAddNewApp}
- style={{ borderStyle: "dashed" }}
- icon={
- <ThemeIcon variant="light" color="primaryColor" size={34} radius="md">
- <IconPlus size={20} />
- </ThemeIcon>
- }
- title={t("app.action.create.title")}
- description={t("app.action.create.description")}
- footerLeft={
- <Text size="xs" c="dimmed">
- {t("app.action.select.customApplication")}
- </Text>
- }
- />
- )}
-
- {filteredApps.map((app) => (
- <AppCard
- key={app.id}
- app={app}
- isSelected={selectedAppIds.has(app.id)}
- multiSelectActive={multiSelectActive}
- onSelect={handleSelect}
- />
- ))}
- </SimpleGrid>
-
- {filteredApps.length === 0 && !isPending && (
- <Center p="xl">
- <Text c="dimmed">{t("app.action.select.noResults")}</Text>
- </Center>
- )}
+ {creating ? (
+ <Stack>
+ <Button
+ variant="subtle"
+ leftSection={<IconArrowLeft size={16} />}
+ onClick={() => setCreating(false)}
+ disabled={isCreating}
+ style={{ alignSelf: "flex-start" }}
+ >
+ {t("app.action.select.backToApps")}
+ </Button>
+ <AppForm
+ showBackToOverview={false}
+ buttonLabels={{
+ submit: t("app.action.select.createAndAdd"),
+ submitAndCreateAnother: multiSelectAvailable ? t("app.action.select.createAnother") : undefined,
+ }}
+ isPending={isCreating}
+ handleSubmit={async (values, finish, afterSuccess) => {
+ const app = await createApp(values);
+ setCreatedApps((current) => [...current, app]);
+ setSelectedAppIds((current) => new Set(current).add(app.id));
+ void utils.app.invalidate();
+ if (!finish) {
+ afterSuccess?.();
+ return;
+ }
+ if (multiSelectAvailable) innerProps.onSelectMany?.([...selectedApps, app]);
+ else innerProps.onSelect?.(app);
+ actions.closeModal();
+ }}
+ />
</Stack>
- </ScrollArea.Autosize>
+ ) : (
+ <>
+ {/* Top Search Input */}
+ <Stack gap={6}>
+ <Input
+ value={search}
+ onChange={(event) => setSearch(event.currentTarget.value)}
+ leftSection={<IconSearch size={16} />}
+ placeholder={`${t("app.action.select.search")}...`}
+ aria-label={t("app.action.select.search")}
+ data-autofocus
+ onKeyDown={(event) => {
+ if (event.key === "Enter" && filteredApps.length === 1 && filteredApps[0]) {
+ handleSelect(filteredApps[0]);
+ }
+ }}
+ />
+ </Stack>
+
+ {/* Scrollable Container with App Cards */}
+ <ScrollArea.Autosize mah="70vh" offsetScrollbars>
+ <Stack gap="md" pt="xs" pr="xs" px={4}>
+ <SimpleGrid cols={selectGridCols} spacing="sm">
+ {canCreate && (
+ <SelectableCard
+ onClick={() => setCreating(true)}
+ style={{ borderStyle: "dashed" }}
+ icon={
+ <ThemeIcon variant="light" color="primaryColor" size={34} radius="md">
+ <IconPlus size={20} />
+ </ThemeIcon>
+ }
+ title={t("app.action.create.title")}
+ description={t("app.action.create.description")}
+ footerLeft={
+ <Text size="xs" c="dimmed">
+ {t("app.action.select.customApplication")}
+ </Text>
+ }
+ />
+ )}
+
+ {filteredApps.map((app) => (
+ <AppCard
+ key={app.id}
+ app={app}
+ isSelected={selectedAppIds.has(app.id)}
+ multiSelectActive={multiSelectAvailable}
+ onSelect={handleSelect}
+ />
+ ))}
+ </SimpleGrid>
+
+ {filteredApps.length === 0 && !isPending && (
+ <Center p="xl">
+ <Text c="dimmed">{t("app.action.select.noResults")}</Text>
+ </Center>
+ )}
+ </Stack>
+ </ScrollArea.Autosize>
+ </>
+ )}
{/* Multi-Select Action Footer */}
- {multiSelectActive && (
+ {multiSelectAvailable && (
<Paper withBorder p="xs" radius="md" bg="light-dark(var(--mantine-color-gray-0), var(--mantine-color-dark-8))">
<Group justify="space-between" align="center">
<Text size="sm" fw={600}>
@@ -182,12 +200,17 @@ export const AppSelectModal = createModal<AppSelectModalProps>(({ actions, inner
<Button
variant="default"
size="xs"
- disabled={selectedApps.length === 0}
+ disabled={selectedApps.length === 0 || isCreating}
onClick={() => setSelectedAppIds(new Set())}
>
{t("common.action.discard")}
</Button>
- <Button color="primaryColor" size="xs" disabled={selectedApps.length === 0} onClick={handleMultiSubmit}>
+ <Button
+ color="primaryColor"
+ size="xs"
+ disabled={selectedApps.length === 0 || creating}
+ onClick={handleMultiSubmit}
+ >
{t("common.action.add")} ({selectedApps.length})
</Button>
</Group>
diff --git a/packages/modals-collection/src/apps/quick-add-app/quick-add-app-modal.tsx b/packages/modals-collection/src/apps/quick-add-app/quick-add-app-modal.tsx
index f21ea3f4b..35128d2c9 100644
--- a/packages/modals-collection/src/apps/quick-add-app/quick-add-app-modal.tsx
+++ b/packages/modals-collection/src/apps/quick-add-app/quick-add-app-modal.tsx
@@ -15,7 +15,6 @@ interface QuickAddAppModalProps {
export const QuickAddAppModal = createModal<QuickAddAppModalProps>(({ actions, innerProps }) => {
const tScoped = useI18n("app.page.create.notification");
const tCommon = useI18n("common");
- const tBoard = useI18n("board");
const utils = clientApi.useUtils();
const { mutate, isPending } = clientApi.app.create.useMutation({
@@ -45,7 +44,7 @@ export const QuickAddAppModal = createModal<QuickAddAppModalProps>(({ actions, i
return (
<AppForm
buttonLabels={{
- submit: tBoard("action.quickCreateApp.modal.createAndUse"),
+ submit: tCommon("action.create"),
submitAndCreateAnother: undefined,
}}
showBackToOverview={false}
@@ -55,7 +54,7 @@ export const QuickAddAppModal = createModal<QuickAddAppModalProps>(({ actions, i
);
}).withOptions({
defaultTitle(t) {
- return t("board.action.quickCreateApp.modal.title");
+ return t("app.action.create.title");
},
size: modalSizeForm,
});
diff --git a/packages/translation/src/lang/en-gb.json b/packages/translation/src/lang/en-gb.json
index 4cf7eae9f..8b69d426a 100644
--- a/packages/translation/src/lang/en-gb.json
+++ b/packages/translation/src/lang/en-gb.json
@@ -749,7 +749,10 @@
"selectMultiple": "Select several",
"cancelMultiple": "Exit multiple selection",
"customApplication": "Custom application",
- "application": "Application"
+ "application": "Application",
+ "backToApps": "Back to apps",
+ "createAndAdd": "Create and add",
+ "createAnother": "Create and continue"
},
"create": {
"title": "Create new app",
@@ -2346,7 +2349,16 @@
}
}
},
- "empty": "Add a URL or app in the widget settings"
+ "empty": "Add a URL or app in the widget settings",
+ "groups": {
+ "label": "Categories",
+ "placeholder": "New category",
+ "add": "Add category",
+ "remove": "Remove {name} category",
+ "rename": "Category name for {name}",
+ "assign": "Category for {name}",
+ "ungrouped": "Ungrouped"
+ }
},
"archiveTeamWarrior": {
"name": "ArchiveTeam Warrior",
@@ -3688,7 +3700,8 @@
"app": {
"noData": "No app found",
"description": "Click <here></here> to create a new app",
- "quickCreate": "Create app on the fly"
+ "quickCreate": "Create app on the fly",
+ "create": "Create app"
},
"error": {
"noIntegration": "No integration selected",
diff --git a/packages/translation/src/lang/en.json b/packages/translation/src/lang/en.json
index 2a09a8bc2..038fcc982 100644
--- a/packages/translation/src/lang/en.json
+++ b/packages/translation/src/lang/en.json
@@ -749,7 +749,10 @@
"selectMultiple": "Select multiple",
"cancelMultiple": "Exit multi-select",
"customApplication": "Custom application",
- "application": "Application"
+ "application": "Application",
+ "backToApps": "Back to apps",
+ "createAndAdd": "Create and add",
+ "createAnother": "Create and continue"
},
"create": {
"title": "Create new app",
@@ -2346,7 +2349,16 @@
}
}
},
- "empty": "Add a URL or App in the widget settings"
+ "empty": "Add a URL or App in the widget settings",
+ "groups": {
+ "label": "Categories",
+ "placeholder": "New category",
+ "add": "Add category",
+ "remove": "Remove {name} category",
+ "rename": "Category name for {name}",
+ "assign": "Category for {name}",
+ "ungrouped": "Ungrouped"
+ }
},
"archiveTeamWarrior": {
"name": "ArchiveTeam Warrior",
@@ -3695,7 +3707,8 @@
"app": {
"noData": "No app found",
"description": "Click <here></here> to create a new app",
- "quickCreate": "Create app on the fly"
+ "quickCreate": "Create app on the fly",
+ "create": "Create app"
},
"error": {
"noIntegration": "No integration selected",
diff --git a/packages/widgets/src/_inputs/widget-app-input.tsx b/packages/widgets/src/_inputs/widget-app-input.tsx
index 481a6126f..57ec82eb9 100644
--- a/packages/widgets/src/_inputs/widget-app-input.tsx
+++ b/packages/widgets/src/_inputs/widget-app-input.tsx
@@ -3,7 +3,7 @@
import { memo, useMemo } from "react";
import type { SelectProps } from "@mantine/core";
import { Anchor, Button, Group, Loader, Select, SimpleGrid, Text } from "@mantine/core";
-import { IconCheck, IconRocket } from "@tabler/icons-react";
+import { IconCheck, IconPlus } from "@tabler/icons-react";
import type { RouterOutputs } from "@homarr/api";
import { clientApi } from "@homarr/api/client";
@@ -68,7 +68,7 @@ export const WidgetAppInput = ({ property, kind }: CommonWidgetInputProps<"app">
{canCreateApps && (
<Button
mt={3}
- rightSection={<IconRocket size="1.5rem" />}
+ leftSection={<IconPlus size={18} />}
variant="default"
onClick={() =>
openModal({
@@ -80,7 +80,7 @@ export const WidgetAppInput = ({ property, kind }: CommonWidgetInputProps<"app">
})
}
>
- {tApp("quickCreate")}
+ {tApp("create")}
</Button>
)}
</SimpleGrid>
diff --git a/packages/widgets/src/bookmarks/add-button.tsx b/packages/widgets/src/bookmarks/add-button.tsx
index cb85d1095..1254a7c28 100644
--- a/packages/widgets/src/bookmarks/add-button.tsx
+++ b/packages/widgets/src/bookmarks/add-button.tsx
@@ -22,6 +22,7 @@ import { useI18n } from "@homarr/translation/client";
import type { SortableItemListInput } from "../options";
import { createDirectBookmark, getBookmarkFaviconUrl, splitBookmarkUrls } from "./bookmark-item";
import type { BookmarkItem } from "./bookmark-item";
+import { BookmarkGroupsEditor } from "./groups";
type SelectableApp = RouterOutputs["app"]["selectable"][number];
export type BookmarkSelectionItem = SelectableApp | BookmarkItem;
@@ -110,89 +111,92 @@ export const BookmarkAddButton: SortableItemListInput<BookmarkSelectionItem, str
));
return (
- <Combobox
- store={combobox}
- onOptionSubmit={handleOptionSubmit}
- position="bottom-start"
- middlewares={{ flip: true, shift: true }}
- styles={{
- dropdown: { overflow: "hidden" },
- option: { borderRadius: "var(--mantine-radius-sm)" },
- }}
- >
- <Combobox.DropdownTarget>
- <PillsInput
- label={t("label")}
- description={t("description")}
- error={error ? tCommon("error") : undefined}
- onClick={() => combobox.openDropdown()}
- leftSection={
- <ThemeIcon variant="light" size="sm" radius="xl">
- <IconLink size={14} />
- </ThemeIcon>
- }
- rightSection={isPending ? <Loader size="xs" /> : undefined}
- styles={{ input: { minHeight: 44 } }}
- >
- <Combobox.EventsTarget>
- <PillsInput.Field
- value={search}
- placeholder={t("placeholder")}
- onFocus={() => combobox.openDropdown()}
- onBlur={() => combobox.closeDropdown()}
- onChange={(event) => {
- setSearch(event.currentTarget.value);
- combobox.openDropdown();
- combobox.updateSelectedOptionIndex();
- }}
- onPaste={(event) => {
- const pastedValue = event.clipboardData.getData("text");
- if (splitBookmarkUrls(pastedValue).length < 2) return;
- event.preventDefault();
- addUrls(pastedValue);
- }}
- onKeyDown={(event) => {
- if (event.key !== "Enter") return;
- if (!pendingUrl) return;
- event.preventDefault();
- addUrls(search);
- }}
- />
- </Combobox.EventsTarget>
- </PillsInput>
- </Combobox.DropdownTarget>
-
- <Combobox.Dropdown>
- <ScrollArea.Autosize mah={280}>
- <Combobox.Options>
- {pendingUrl && !selectedValues.has(pendingUrl.id) ? (
- <Combobox.Option value={createOptionValue}>
- <Group gap="sm" wrap="nowrap">
- <Avatar src={getBookmarkFaviconUrl(pendingUrl.href)} size={28} radius="sm" color="gray">
- <IconLink size={16} />
- </Avatar>
- <Stack gap={0} miw={0} flex={1}>
- <Text size="sm" fw={600} truncate>
- {t("addUrl")}
- </Text>
- <Text size="xs" c="dimmed" truncate>
- {pendingUrl.href}
- </Text>
- </Stack>
- <IconCheck size={16} aria-hidden />
- </Group>
- </Combobox.Option>
- ) : null}
- {options}
- {!pendingUrl && options.length === 0 ? <Combobox.Empty>{tSelect("notFound")}</Combobox.Empty> : null}
- </Combobox.Options>
- </ScrollArea.Autosize>
- <Combobox.Footer>
- <Text size="xs" c="dimmed">
- {t("hint")}
- </Text>
- </Combobox.Footer>
- </Combobox.Dropdown>
- </Combobox>
+ <Stack gap="sm">
+ <Combobox
+ store={combobox}
+ onOptionSubmit={handleOptionSubmit}
+ position="bottom-start"
+ middlewares={{ flip: true, shift: true }}
+ styles={{
+ dropdown: { overflow: "hidden" },
+ option: { borderRadius: "var(--mantine-radius-sm)" },
+ }}
+ >
+ <Combobox.DropdownTarget>
+ <PillsInput
+ label={t("label")}
+ description={t("description")}
+ error={error ? tCommon("error") : undefined}
+ onClick={() => combobox.openDropdown()}
+ leftSection={
+ <ThemeIcon variant="light" size="sm" radius="xl">
+ <IconLink size={14} />
+ </ThemeIcon>
+ }
+ rightSection={isPending ? <Loader size="xs" /> : undefined}
+ styles={{ input: { minHeight: 44 } }}
+ >
+ <Combobox.EventsTarget>
+ <PillsInput.Field
+ value={search}
+ placeholder={t("placeholder")}
+ onFocus={() => combobox.openDropdown()}
+ onBlur={() => combobox.closeDropdown()}
+ onChange={(event) => {
+ setSearch(event.currentTarget.value);
+ combobox.openDropdown();
+ combobox.updateSelectedOptionIndex();
+ }}
+ onPaste={(event) => {
+ const pastedValue = event.clipboardData.getData("text");
+ if (splitBookmarkUrls(pastedValue).length < 2) return;
+ event.preventDefault();
+ addUrls(pastedValue);
+ }}
+ onKeyDown={(event) => {
+ if (event.key !== "Enter") return;
+ if (!pendingUrl) return;
+ event.preventDefault();
+ addUrls(search);
+ }}
+ />
+ </Combobox.EventsTarget>
+ </PillsInput>
+ </Combobox.DropdownTarget>
+
+ <Combobox.Dropdown>
+ <ScrollArea.Autosize mah={280}>
+ <Combobox.Options>
+ {pendingUrl && !selectedValues.has(pendingUrl.id) ? (
+ <Combobox.Option value={createOptionValue}>
+ <Group gap="sm" wrap="nowrap">
+ <Avatar src={getBookmarkFaviconUrl(pendingUrl.href)} size={28} radius="sm" color="gray">
+ <IconLink size={16} />
+ </Avatar>
+ <Stack gap={0} miw={0} flex={1}>
+ <Text size="sm" fw={600} truncate>
+ {t("addUrl")}
+ </Text>
+ <Text size="xs" c="dimmed" truncate>
+ {pendingUrl.href}
+ </Text>
+ </Stack>
+ <IconCheck size={16} aria-hidden />
+ </Group>
+ </Combobox.Option>
+ ) : null}
+ {options}
+ {!pendingUrl && options.length === 0 ? <Combobox.Empty>{tSelect("notFound")}</Combobox.Empty> : null}
+ </Combobox.Options>
+ </ScrollArea.Autosize>
+ <Combobox.Footer>
+ <Text size="xs" c="dimmed">
+ {t("hint")}
+ </Text>
+ </Combobox.Footer>
+ </Combobox.Dropdown>
+ </Combobox>
+ <BookmarkGroupsEditor />
+ </Stack>
);
};
diff --git a/packages/widgets/src/bookmarks/bookmarks-widget.tsx b/packages/widgets/src/bookmarks/bookmarks-widget.tsx
index 9c8ec73a4..03f6cdaa6 100644
--- a/packages/widgets/src/bookmarks/bookmarks-widget.tsx
+++ b/packages/widgets/src/bookmarks/bookmarks-widget.tsx
@@ -3,12 +3,14 @@
import type { CSSProperties } from "react";
import { useMemo, useState } from "react";
import {
+ Accordion,
Avatar,
Box,
Card,
Center,
Grid,
Group,
+ rem,
ScrollArea,
SimpleGrid,
Stack,
@@ -16,7 +18,7 @@ import {
ThemeIcon,
Tooltip,
} from "@mantine/core";
-import { useReducedMotion } from "@mantine/hooks";
+import { useLocalStorage, useReducedMotion } from "@mantine/hooks";
import { IconArrowUpRight, IconBookmark, IconLink } from "@tabler/icons-react";
import { clientApi } from "@homarr/api/client";
@@ -33,6 +35,7 @@ import { createDirectBookmark, getBookmarkFaviconUrl, getDirectBookmarkUrl } fro
import type { BookmarkItem } from "./bookmark-item";
import { getBookmarkCardDisplay, getBookmarkDisplayPlan } from "./layout";
import type { BookmarkOrientation } from "./layout";
+import { getBookmarkGroups } from "./groups-data";
type BookmarkVariant = WidgetComponentProps<"bookmarks">["options"]["variant"];
@@ -67,6 +70,19 @@ export default function BookmarksWidget({
return [item];
});
const data = [...configuredItems, ...legacyItems];
+ const groups = getBookmarkGroups(options.groups);
+ const groupedIds = new Set<string>();
+ const sections = groups.flatMap((group) => {
+ const items = data.filter((item) => group.itemIds.includes(item.id) && !groupedIds.has(item.id));
+ for (const item of items) groupedIds.add(item.id);
+ if (items.length === 0) return [];
+ return [{ ...group, items }];
+ });
+ const ungroupedItems = data.filter((item) => !groupedIds.has(item.id));
+ const [collapsedGroups, setCollapsedGroups] = useLocalStorage<string[]>({
+ key: `homarr-bookmarks-collapsed-${itemId ?? "preview"}`,
+ defaultValue: [],
+ });
let responsiveWidth = width;
let responsiveHeight = height;
@@ -130,23 +146,49 @@ export default function BookmarksWidget({
plan,
});
- const cards = data.map((bookmark) => (
- <BookmarkCard
- key={bookmark.id}
- bookmark={bookmark}
- advanced={advanced}
- orientation={cardDisplay.orientation}
- showHostname={cardDisplay.showHostname}
- showIcon={cardDisplay.showIcon}
- showTitle={cardDisplay.showTitle}
- openNewTab={options.openNewTab}
- variant={options.variant}
- withBorder={options.withBorder}
- radius={board.itemRadius}
- height={plan.itemHeight}
- width={plan.horizontalScroll ? plan.itemWidth : undefined}
- />
- ));
+ const renderCards = (items: BookmarkItem[]) =>
+ items.map((bookmark) => (
+ <BookmarkCard
+ key={bookmark.id}
+ bookmark={bookmark}
+ advanced={advanced}
+ orientation={cardDisplay.orientation}
+ showHostname={cardDisplay.showHostname}
+ showIcon={cardDisplay.showIcon}
+ showTitle={cardDisplay.showTitle}
+ openNewTab={options.openNewTab}
+ variant={options.variant}
+ withBorder={options.withBorder}
+ radius={board.itemRadius}
+ height={plan.itemHeight}
+ width={plan.horizontalScroll ? plan.itemWidth : undefined}
+ />
+ ));
+
+ const renderItems = (items: BookmarkItem[]) => {
+ const cards = renderCards(items);
+ if (plan.horizontalScroll)
+ return (
+ <Group gap={plan.itemGap} wrap="nowrap" align="center" h="100%">
+ {cards}
+ </Group>
+ );
+ if (options.grow)
+ return (
+ <Grid grow columns={plan.columns} gap={plan.itemGap}>
+ {cards.map((card) => (
+ <Grid.Col key={card.key} span={1}>
+ {card}
+ </Grid.Col>
+ ))}
+ </Grid>
+ );
+ return (
+ <SimpleGrid cols={plan.columns} spacing={plan.itemGap} verticalSpacing={plan.itemGap}>
+ {cards}
+ </SimpleGrid>
+ );
+ };
if (appIds.length > 0 && isInitialWidgetQueryPending(appsQuery)) return <WidgetQueryLoadingState />;
@@ -185,27 +227,61 @@ export default function BookmarksWidget({
</Center>
) : (
<ScrollArea
- scrollbars={plan.horizontalScroll ? "x" : "y"}
+ scrollbars={sections.length > 0 ? "xy" : plan.horizontalScroll ? "x" : "y"}
style={{ flex: 1, minHeight: 0 }}
styles={{ content: { height: "100%" } }}
>
<Box miw="100%" h="100%" pb={2}>
- {plan.horizontalScroll ? (
- <Group gap={plan.itemGap} wrap="nowrap" h="100%" align="center">
- {cards}
- </Group>
- ) : options.grow ? (
- <Grid grow columns={plan.columns} gap={plan.itemGap}>
- {cards.map((card) => (
- <Grid.Col key={card.key} span={1}>
- {card}
- </Grid.Col>
- ))}
- </Grid>
+ {sections.length > 0 ? (
+ <Stack gap={4}>
+ <Accordion
+ multiple
+ value={sections
+ .filter((section) => !collapsedGroups.includes(section.id))
+ .map((section) => section.id)}
+ onChange={(opened) => {
+ const visibleIds = new Set(sections.map((section) => section.id));
+ setCollapsedGroups((current) => [
+ ...current.filter((id) => !visibleIds.has(id)),
+ ...sections.filter((section) => !opened.includes(section.id)).map((section) => section.id),
+ ]);
+ }}
+ transitionDuration={0}
+ styles={{
+ control: { padding: rem(4), minHeight: rem(28) },
+ label: { padding: 0, fontSize: "var(--mantine-font-size-xxs)", fontWeight: 600 },
+ content: { padding: `0 0 ${rem(4)}` },
+ item: { border: 0 },
+ chevron: zoomCompensatedSize(14),
+ }}
+ >
+ {sections.map((section) => (
+ <Accordion.Item key={section.id} value={section.id}>
+ <Accordion.Control>
+ <Group justify="space-between" gap={4} wrap="nowrap">
+ <Text inherit truncate>
+ {section.name}
+ </Text>
+ <Text inherit c="dimmed">
+ {section.items.length}
+ </Text>
+ </Group>
+ </Accordion.Control>
+ <Accordion.Panel>{renderItems(section.items)}</Accordion.Panel>
+ </Accordion.Item>
+ ))}
+ </Accordion>
+ {ungroupedItems.length > 0 && (
+ <Stack gap={4}>
+ <Text size="xxs" fw={600} px={4}>
+ {t("groups.ungrouped")}
+ </Text>
+ {renderItems(ungroupedItems)}
+ </Stack>
+ )}
+ </Stack>
) : (
- <SimpleGrid cols={plan.columns} spacing={plan.itemGap} verticalSpacing={plan.itemGap}>
- {cards}
- </SimpleGrid>
+ renderItems(data)
)}
</Box>
</ScrollArea>
diff --git a/packages/widgets/src/bookmarks/groups-data.ts b/packages/widgets/src/bookmarks/groups-data.ts
new file mode 100644
index 000000000..1e5eb3072
--- /dev/null
+++ b/packages/widgets/src/bookmarks/groups-data.ts
@@ -0,0 +1,16 @@
+import { z } from "zod/v4";
+
+const bookmarkGroupsSchema = z.array(
+ z.object({
+ id: z.string().min(1),
+ name: z.string().trim().min(1).max(64),
+ itemIds: z.array(z.string()),
+ }),
+);
+export type BookmarkGroup = z.infer<typeof bookmarkGroupsSchema>[number];
+
+export const getBookmarkGroups = (value: unknown): BookmarkGroup[] => {
+ const result = bookmarkGroupsSchema.safeParse(value);
+ if (!result.success) return [];
+ return result.data;
+};
diff --git a/packages/widgets/src/bookmarks/groups.tsx b/packages/widgets/src/bookmarks/groups.tsx
new file mode 100644
index 000000000..30b1b8ced
--- /dev/null
+++ b/packages/widgets/src/bookmarks/groups.tsx
@@ -0,0 +1,130 @@
+"use client";
+
+import { useState } from "react";
+import { ActionIcon, Button, Group, Select, Stack, TextInput } from "@mantine/core";
+import { IconPlus, IconX } from "@tabler/icons-react";
+
+import { createId } from "@homarr/common";
+import { useI18n } from "@homarr/translation/client";
+
+import { useFormContext } from "../_inputs/form";
+
+import { getBookmarkGroups } from "./groups-data";
+
+export const BookmarkGroupsEditor = () => {
+ const form = useFormContext();
+ const t = useI18n("widget.bookmarks.groups");
+ const [name, setName] = useState("");
+ const groups = getBookmarkGroups(form.values.options.groups);
+ const trimmedName = name.trim();
+ const duplicateName = groups.some((group) => group.name.toLowerCase() === trimmedName.toLowerCase());
+ const addGroup = () => {
+ if (!trimmedName || duplicateName) return;
+ form.setFieldValue("options.groups", [...groups, { id: createId(), name: trimmedName, itemIds: [] }]);
+ setName("");
+ };
+ return (
+ <Stack gap="xs">
+ <Group align="end" wrap="nowrap">
+ <TextInput
+ label={t("label")}
+ placeholder={t("placeholder")}
+ value={name}
+ maxLength={64}
+ onChange={(event) => setName(event.currentTarget.value)}
+ onKeyDown={(event) => {
+ if (event.key !== "Enter") return;
+ event.preventDefault();
+ addGroup();
+ }}
+ style={{ flex: 1 }}
+ />
+ <Button
+ variant="light"
+ leftSection={<IconPlus size={16} />}
+ disabled={!trimmedName || duplicateName}
+ onClick={addGroup}
+ >
+ {t("add")}
+ </Button>
+ </Group>
+ {groups.map((group) => (
+ <Group key={group.id} justify="space-between" wrap="nowrap">
+ <TextInput
+ size="xs"
+ aria-label={t("rename", { name: group.name })}
+ defaultValue={group.name}
+ maxLength={64}
+ style={{ flex: 1 }}
+ onKeyDown={(event) => {
+ if (event.key !== "Enter") return;
+ event.preventDefault();
+ event.currentTarget.blur();
+ }}
+ onBlur={(event) => {
+ const nextName = event.currentTarget.value.trim();
+ if (
+ !nextName ||
+ groups.some(
+ (candidate) => candidate.id !== group.id && candidate.name.toLowerCase() === nextName.toLowerCase(),
+ )
+ ) {
+ event.currentTarget.value = group.name;
+ return;
+ }
+ event.currentTarget.value = nextName;
+ form.setFieldValue(
+ "options.groups",
+ groups.map((candidate) => {
+ if (candidate.id !== group.id) return candidate;
+ return { ...candidate, name: nextName };
+ }),
+ );
+ }}
+ />
+ <ActionIcon
+ variant="subtle"
+ color="red"
+ aria-label={t("remove", { name: group.name })}
+ onClick={() =>
+ form.setFieldValue(
+ "options.groups",
+ groups.filter((candidate) => candidate.id !== group.id),
+ )
+ }
+ >
+ <IconX size={16} />
+ </ActionIcon>
+ </Group>
+ ))}
+ </Stack>
+ );
+};
+
+export const BookmarkGroupSelect = ({ itemId, name }: { itemId: string; name: string }) => {
+ const form = useFormContext();
+ const t = useI18n("widget.bookmarks.groups");
+ const groups = getBookmarkGroups(form.values.options.groups);
+ if (groups.length === 0) return null;
+ const selectedGroup = groups.find((group) => group.itemIds.includes(itemId));
+ return (
+ <Select
+ size="xs"
+ aria-label={t("assign", { name })}
+ placeholder={t("ungrouped")}
+ clearable
+ value={selectedGroup?.id ?? null}
+ data={groups.map((group) => ({ value: group.id, label: group.name }))}
+ onChange={(groupId) => {
+ form.setFieldValue(
+ "options.groups",
+ groups.map((group) => {
+ const itemIds = group.itemIds.filter((id) => id !== itemId);
+ if (group.id === groupId) itemIds.push(itemId);
+ return { ...group, itemIds };
+ }),
+ );
+ }}
+ />
+ );
+};
diff --git a/packages/widgets/src/bookmarks/index.tsx b/packages/widgets/src/bookmarks/index.tsx
index dc1ac685c..9335ac2ca 100644
--- a/packages/widgets/src/bookmarks/index.tsx
+++ b/packages/widgets/src/bookmarks/index.tsx
@@ -9,6 +9,8 @@ import { optionsBuilder } from "../options";
import { BookmarkAddButton } from "./add-button";
import type { BookmarkSelectionItem } from "./add-button";
import { createDirectBookmark, getBookmarkFaviconUrl, getDirectBookmarkUrl } from "./bookmark-item";
+import type { BookmarkGroup } from "./groups-data";
+import { BookmarkGroupSelect } from "./groups";
export const { definition, componentLoader } = createWidgetDefinition("bookmarks", {
icon: IconBookmark,
@@ -58,6 +60,7 @@ export const { definition, componentLoader } = createWidgetDefinition("bookmarks
withBorder: factory.switch({ defaultValue: false }),
grow: factory.switch({ defaultValue: false }),
customUrls: factory.internal({ defaultValue: [] as string[] }),
+ groups: factory.internal({ defaultValue: [] as BookmarkGroup[] }),
items: factory.sortableItemList<BookmarkSelectionItem, string>({
ItemComponent: ({ item, handle, removeItem, removeLabel, rootAttributes }) => {
const iconUrl = item.iconUrl ?? getBookmarkFaviconUrl(item.href);
@@ -74,6 +77,7 @@ export const { definition, componentLoader } = createWidgetDefinition("bookmarks
<Text fw={600} truncate>
{item.name}
</Text>
+ <BookmarkGroupSelect itemId={item.id} name={item.name} />
<Text size="xs" c="dimmed" truncate>
{item.href}
</Text>
diff --git a/packages/widgets/src/modals/embedded-app-edit-form.tsx b/packages/widgets/src/modals/embedded-app-edit-form.tsx
index 2eeb9900e..15b706cc4 100644
--- a/packages/widgets/src/modals/embedded-app-edit-form.tsx
+++ b/packages/widgets/src/modals/embedded-app-edit-form.tsx
@@ -48,7 +48,8 @@ export const EmbeddedAppEditForm = ({ appId, handleRef }: EmbeddedAppEditFormPro
handleRef,
() => ({
submitIfDirty: async () => {
- if (!appFormRef.current?.isDirty()) {
+ if (!appFormRef.current) return true;
+ if (!appFormRef.current.isDirty()) {
return true;
}
diff --git a/packages/widgets/src/modals/widget-edit-modal.tsx b/packages/widgets/src/modals/widget-edit-modal.tsx
index c7a93918a..c6536409c 100644
--- a/packages/widgets/src/modals/widget-edit-modal.tsx
+++ b/packages/widgets/src/modals/widget-edit-modal.tsx
@@ -519,37 +519,44 @@ export const WidgetEditModal = createModal<WidgetEditModalProps<WidgetKind>>(({
setActiveIntegrationId(integrationId);
};
- const handleSubmit = form.onSubmit(async (values) => {
- setIsSubmitting(true);
- try {
- const appSaved = showAppTab ? await (appEditRef.current?.submitIfDirty() ?? true) : true;
-
- if (!appSaved) {
- return;
- }
-
- for (const integrationEditHandle of integrationEditHandles.current.values()) {
- const integrationSaved = await integrationEditHandle.submitIfDirty();
- if (!integrationSaved) {
+ const handleSubmit = form.onSubmit(
+ async (values) => {
+ setIsSubmitting(true);
+ try {
+ let appSaved = true;
+ if (showAppTab) appSaved = await (appEditRef.current?.submitIfDirty() ?? false);
+
+ if (!appSaved) {
+ setActiveTab("app");
return;
}
- }
- innerProps.onSuccessfulEdit(
- {
- ...values,
- advancedOptions: {
- ...values.advancedOptions,
- title: values.advancedOptions.title?.trim() || null,
+ for (const [integrationId, integrationEditHandle] of integrationEditHandles.current.entries()) {
+ const integrationSaved = await integrationEditHandle.submitIfDirty();
+ if (!integrationSaved) {
+ beginEditingIntegration(integrationId);
+ setActiveTab("integration");
+ return;
+ }
+ }
+
+ innerProps.onSuccessfulEdit(
+ {
+ ...values,
+ advancedOptions: {
+ ...values.advancedOptions,
+ title: values.advancedOptions.title?.trim() || null,
+ },
},
- },
- previewSize ?? undefined,
- );
- actions.closeModal();
- } finally {
- setIsSubmitting(false);
- }
- });
+ previewSize ?? undefined,
+ );
+ actions.closeModal();
+ } finally {
+ setIsSubmitting(false);
+ }
+ },
+ () => setActiveTab("widget"),
+ );
const onFormSubmit = (event: FormEvent<HTMLFormElement>) => {
handleSubmit(event);
@@ -754,7 +761,7 @@ export const WidgetEditModal = createModal<WidgetEditModalProps<WidgetKind>>(({
<FormProvider form={form}>
<Stack gap="sm">
{showResourceTabs ? (
- <Tabs value={activeTab} onChange={setActiveTab}>
+ <Tabs value={activeTab} onChange={setActiveTab} keepMounted keepMountedMode="display-none">
<Tabs.List grow>
<Tabs.Tab value="widget">{tItem("tab.widget")}</Tabs.Tab>
{showAppTab && <Tabs.Tab value="app">{tItem("tab.app")}</Tabs.Tab>}