fix(init): improve integrations step UX
- Replace plain Base URL input with a prominent Alert callout so users don't overlook it - Add disableScroll prop to SelectGridLayout and use it in onboarding so integrations expand the page instead of scrolling - Fix Collapse `in` → `expanded` prop for Mantine v9 migration in both the URL helpers panel and the Docker discovery panel
This commit is contained in:
1 parent
1065e30c8d
commit
3ff3d41d7c
4 files changed
+61
-55
No files matched your search
@@ -142,7 +142,7 @@ export const DockerDiscoveryIndicator = ({
|
|||||||
</Group>
|
</Group>
|
||||||
</UnstyledButton>
|
</UnstyledButton>
|
||||||
|
|
||||||
<Collapse in={expanded}>
|
<Collapse expanded={expanded}>
|
||||||
<Stack gap="xs" mt="sm">
|
<Stack gap="xs" mt="sm">
|
||||||
{integrations.length > 0 && (
|
{integrations.length > 0 && (
|
||||||
<Stack gap={4}>
|
<Stack gap={4}>
|
||||||
|
|||||||
@@ -4,8 +4,8 @@ import { useCallback, useEffect, useRef, useState } from "react";
|
|||||||
import { useRouter } from "next/navigation";
|
import { useRouter } from "next/navigation";
|
||||||
import {
|
import {
|
||||||
ActionIcon,
|
ActionIcon,
|
||||||
|
Alert,
|
||||||
Button,
|
Button,
|
||||||
Card,
|
|
||||||
Center,
|
Center,
|
||||||
Collapse,
|
Collapse,
|
||||||
Group,
|
Group,
|
||||||
@@ -18,7 +18,7 @@ import {
|
|||||||
Tooltip,
|
Tooltip,
|
||||||
} from "@mantine/core";
|
} from "@mantine/core";
|
||||||
import { useDisclosure } from "@mantine/hooks";
|
import { useDisclosure } from "@mantine/hooks";
|
||||||
import { IconArrowRight, IconSettings } from "@tabler/icons-react";
|
import { IconArrowRight, IconInfoCircle, IconSettings } from "@tabler/icons-react";
|
||||||
|
|
||||||
import { clientApi } from "@homarr/api/client";
|
import { clientApi } from "@homarr/api/client";
|
||||||
import type { IntegrationKind, UrlTemplateMode } from "@homarr/definitions";
|
import type { IntegrationKind, UrlTemplateMode } from "@homarr/definitions";
|
||||||
@@ -29,6 +29,7 @@ import { IntegrationAvatar } from "@homarr/ui";
|
|||||||
|
|
||||||
import { NewIntegrationForm } from "~/app/[locale]/manage/integrations/new/_integration-new-form";
|
import { NewIntegrationForm } from "~/app/[locale]/manage/integrations/new/_integration-new-form";
|
||||||
import { IntegrationMultiSelectGrid } from "~/components/integration/integration-multi-select-grid";
|
import { IntegrationMultiSelectGrid } from "~/components/integration/integration-multi-select-grid";
|
||||||
|
import { InitStepCard } from "../../_components/init-step-card";
|
||||||
import { DockerDiscoveryIndicator } from "./docker-discovery-panel";
|
import { DockerDiscoveryIndicator } from "./docker-discovery-panel";
|
||||||
|
|
||||||
type Phase = "select" | "configure" | "done";
|
type Phase = "select" | "configure" | "done";
|
||||||
@@ -41,8 +42,6 @@ interface IntegrationDraft {
|
|||||||
source: "manual" | "docker";
|
source: "manual" | "docker";
|
||||||
}
|
}
|
||||||
|
|
||||||
const CARD_WIDTH = 64 * 16;
|
|
||||||
|
|
||||||
export const InitIntegrations = () => {
|
export const InitIntegrations = () => {
|
||||||
const [phase, setPhase] = useState<Phase>("select");
|
const [phase, setPhase] = useState<Phase>("select");
|
||||||
const [drafts, setDrafts] = useState<Map<IntegrationKind, IntegrationDraft>>(new Map());
|
const [drafts, setDrafts] = useState<Map<IntegrationKind, IntegrationDraft>>(new Map());
|
||||||
@@ -171,14 +170,14 @@ export const InitIntegrations = () => {
|
|||||||
|
|
||||||
if (phase === "done") {
|
if (phase === "done") {
|
||||||
return (
|
return (
|
||||||
<Card w={CARD_WIDTH} maw="90vw" withBorder>
|
<InitStepCard>
|
||||||
<Center py="xl">
|
<Center py="xl">
|
||||||
<Stack align="center" gap="md">
|
<Stack align="center" gap="md">
|
||||||
<Loader size="lg" />
|
<Loader size="lg" />
|
||||||
<Text>{t("configure.finishing")}</Text>
|
<Text>{t("configure.finishing")}</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Center>
|
</Center>
|
||||||
</Card>
|
</InitStepCard>
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -200,7 +199,7 @@ export const InitIntegrations = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card w={CARD_WIDTH} maw="90vw" withBorder>
|
<InitStepCard>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Text>{t("description")}</Text>
|
<Text>{t("description")}</Text>
|
||||||
|
|
||||||
@@ -212,32 +211,32 @@ export const InitIntegrations = () => {
|
|||||||
isLoading={isDockerLoading}
|
isLoading={isDockerLoading}
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<Stack gap="xs">
|
<Alert variant="light" color="blue" icon={<IconInfoCircle />} title={t("urlTemplate.label")}>
|
||||||
<Text size="sm" fw={500}>
|
<Stack gap="xs">
|
||||||
{t("urlTemplate.label")}
|
<Text size="sm">{t("urlTemplate.hint")}</Text>
|
||||||
</Text>
|
<Group gap="sm" grow>
|
||||||
<Group gap="sm" grow>
|
<TextInput
|
||||||
<TextInput
|
placeholder={t("urlTemplate.placeholder")}
|
||||||
placeholder={t("urlTemplate.placeholder")}
|
value={baseHost}
|
||||||
value={baseHost}
|
onChange={(e) => setBaseHost(e.currentTarget.value)}
|
||||||
onChange={(e) => setBaseHost(e.currentTarget.value)}
|
/>
|
||||||
/>
|
<SegmentedControl
|
||||||
<SegmentedControl
|
value={urlMode}
|
||||||
value={urlMode}
|
onChange={(value) => setUrlMode(value as UrlTemplateMode)}
|
||||||
onChange={(value) => setUrlMode(value as UrlTemplateMode)}
|
data={[
|
||||||
data={[
|
{ label: t("urlTemplate.mode.subdomain"), value: "subdomain" },
|
||||||
{ label: t("urlTemplate.mode.subdomain"), value: "subdomain" },
|
{ label: t("urlTemplate.mode.hostPort"), value: "hostPort" },
|
||||||
{ label: t("urlTemplate.mode.hostPort"), value: "hostPort" },
|
]}
|
||||||
]}
|
style={{ flex: "0 0 auto" }}
|
||||||
style={{ flex: "0 0 auto" }}
|
/>
|
||||||
/>
|
</Group>
|
||||||
</Group>
|
{baseHost && (
|
||||||
<Text size="xs" c="dimmed">
|
<Text size="xs" c="dimmed">
|
||||||
{baseHost
|
{t("urlTemplate.preview", { example: buildIntegrationUrl("sonarr", baseHost, urlMode) })}
|
||||||
? t("urlTemplate.preview", { example: buildIntegrationUrl("sonarr", baseHost, urlMode) })
|
</Text>
|
||||||
: t("urlTemplate.hint")}
|
)}
|
||||||
</Text>
|
</Stack>
|
||||||
</Stack>
|
</Alert>
|
||||||
|
|
||||||
<IntegrationMultiSelectGrid
|
<IntegrationMultiSelectGrid
|
||||||
selectedKinds={selectedKinds}
|
selectedKinds={selectedKinds}
|
||||||
@@ -259,7 +258,7 @@ export const InitIntegrations = () => {
|
|||||||
</Button>
|
</Button>
|
||||||
</Group>
|
</Group>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</InitStepCard>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -300,7 +299,7 @@ const ConfigurePhase = ({
|
|||||||
: draft?.initialUrl;
|
: draft?.initialUrl;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Card w={CARD_WIDTH} maw="90vw" withBorder>
|
<InitStepCard>
|
||||||
<Stack>
|
<Stack>
|
||||||
<Group justify="space-between" align="center">
|
<Group justify="space-between" align="center">
|
||||||
<Group gap="xs">
|
<Group gap="xs">
|
||||||
@@ -321,7 +320,7 @@ const ConfigurePhase = ({
|
|||||||
</Text>
|
</Text>
|
||||||
</Stack>
|
</Stack>
|
||||||
|
|
||||||
<Collapse in={helpersOpen}>
|
<Collapse expanded={helpersOpen}>
|
||||||
<Stack
|
<Stack
|
||||||
gap="xs"
|
gap="xs"
|
||||||
p="xs"
|
p="xs"
|
||||||
@@ -369,6 +368,6 @@ const ConfigurePhase = ({
|
|||||||
isOnboarding
|
isOnboarding
|
||||||
/>
|
/>
|
||||||
</Stack>
|
</Stack>
|
||||||
</Card>
|
</InitStepCard>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
@@ -51,6 +51,7 @@ export const IntegrationMultiSelectGrid = ({
|
|||||||
search={search}
|
search={search}
|
||||||
onSearchChange={setSearch}
|
onSearchChange={setSearch}
|
||||||
placeholder={`${t("integration.page.list.search")}...`}
|
placeholder={`${t("integration.page.list.search")}...`}
|
||||||
|
disableScroll={onboarding}
|
||||||
>
|
>
|
||||||
{filtered.map((integration) => {
|
{filtered.map((integration) => {
|
||||||
const isSelected = selectedKinds.has(integration.kind);
|
const isSelected = selectedKinds.has(integration.kind);
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ interface SelectGridLayoutProps {
|
|||||||
onSearchChange: (value: string) => void;
|
onSearchChange: (value: string) => void;
|
||||||
placeholder: string;
|
placeholder: string;
|
||||||
onSearchKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
onSearchKeyDown?: (event: KeyboardEvent<HTMLInputElement>) => void;
|
||||||
|
disableScroll?: boolean;
|
||||||
children: ReactNode;
|
children: ReactNode;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -21,22 +22,27 @@ export const SelectGridLayout = ({
|
|||||||
onSearchChange,
|
onSearchChange,
|
||||||
placeholder,
|
placeholder,
|
||||||
onSearchKeyDown,
|
onSearchKeyDown,
|
||||||
|
disableScroll = false,
|
||||||
children,
|
children,
|
||||||
}: SelectGridLayoutProps) => (
|
}: SelectGridLayoutProps) => {
|
||||||
<Stack>
|
const grid = (
|
||||||
<Input
|
<SimpleGrid cols={selectGridCols} spacing="sm">
|
||||||
value={search}
|
{children}
|
||||||
onChange={(event) => onSearchChange(event.currentTarget.value)}
|
</SimpleGrid>
|
||||||
leftSection={<IconSearch />}
|
);
|
||||||
placeholder={placeholder}
|
|
||||||
data-autofocus
|
|
||||||
onKeyDown={onSearchKeyDown}
|
|
||||||
/>
|
|
||||||
|
|
||||||
<ScrollArea.Autosize mah={selectGridScrollMaxHeight}>
|
return (
|
||||||
<SimpleGrid cols={selectGridCols} spacing="sm">
|
<Stack>
|
||||||
{children}
|
<Input
|
||||||
</SimpleGrid>
|
value={search}
|
||||||
</ScrollArea.Autosize>
|
onChange={(event) => onSearchChange(event.currentTarget.value)}
|
||||||
</Stack>
|
leftSection={<IconSearch />}
|
||||||
);
|
placeholder={placeholder}
|
||||||
|
data-autofocus
|
||||||
|
onKeyDown={onSearchKeyDown}
|
||||||
|
/>
|
||||||
|
|
||||||
|
{disableScroll ? grid : <ScrollArea.Autosize mah={selectGridScrollMaxHeight}>{grid}</ScrollArea.Autosize>}
|
||||||
|
</Stack>
|
||||||
|
);
|
||||||
|
};
|
||||||
Reference in new issue
Block a user