Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: hovering long dashboard names stretch NavBar #2317

Merged
merged 1 commit into from
Oct 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 30 additions & 21 deletions keep-ui/components/navbar/DashboardLink.tsx
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { useSortable } from '@dnd-kit/sortable';
import { useSortable } from "@dnd-kit/sortable";
import { Subtitle } from "@tremor/react";
import { FiLayout } from "react-icons/fi";
import { LinkWithIcon } from "components/LinkWithIcon"; // Ensure you import this correctly
import classNames from 'classnames';
import { clsx } from "clsx";

interface Dashboard {
id: string;
Expand All @@ -14,31 +14,40 @@ type DashboardLinkProps = {
dashboard: Dashboard;
pathname: string | null;
deleteDashboard: (id: string) => void;
titleClassName?: string;
};

export const DashboardLink = ({ dashboard, pathname, deleteDashboard }: DashboardLinkProps) => {
export const DashboardLink = ({
dashboard,
pathname,
deleteDashboard,
titleClassName,
}: DashboardLinkProps) => {
const href = `/dashboard/${dashboard.dashboard_name}`;
const isActive = decodeURIComponent(pathname|| "") === href;

const { isDragging } =
useSortable({
id: dashboard.id,
});
const isActive = decodeURIComponent(pathname || "") === href;

const { isDragging } = useSortable({
id: dashboard.id,
});

return (
<LinkWithIcon
href={href}
icon={FiLayout}
isDeletable={true}
onDelete={() => deleteDashboard(dashboard.id)}
>
<Subtitle className={classNames({
"text-orange-400": isActive,
"pointer-events-none cursor-auto": isDragging,
})}>
{dashboard.dashboard_name}
</Subtitle>
</LinkWithIcon>
href={href}
icon={FiLayout}
isDeletable={true}
onDelete={() => deleteDashboard(dashboard.id)}
>
<Subtitle
className={clsx(
{
"text-orange-400": isActive,
"pointer-events-none cursor-auto": isDragging,
},
titleClassName
)}
>
{dashboard.dashboard_name}
</Subtitle>
</LinkWithIcon>
);
};
5 changes: 3 additions & 2 deletions keep-ui/components/navbar/DashboardLinks.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { DashboardLink } from "./DashboardLink";
import { Subtitle, Button, Badge, Text } from "@tremor/react";
import { Disclosure } from "@headlessui/react";
import { IoChevronUp } from "react-icons/io5";
import classNames from "classnames";
import clsx from "clsx";
import { useDashboards } from "utils/hooks/useDashboards";
import { useApiUrl } from "utils/hooks/useConfig";

Expand Down Expand Up @@ -105,7 +105,7 @@ export const DashboardLinks = ({ session }: DashboardProps) => {
Beta
</Badge>
<IoChevronUp
className={classNames(
className={clsx(
{ "rotate-180": open },
"mr-2 text-slate-400"
)}
Expand All @@ -132,6 +132,7 @@ export const DashboardLinks = ({ session }: DashboardProps) => {
dashboard={dashboard}
pathname={pathname}
deleteDashboard={deleteDashboard}
titleClassName="max-w-[150px] overflow-hidden overflow-ellipsis"
/>
))
) : (
Expand Down
Loading