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: truncate long permission names with ellipses #2071

Merged
merged 4 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ async function AsyncPageBreadcrumb(props: PageProps) {
</BreadcrumbItem>
<BreadcrumbSeparator />
<BreadcrumbItem>
<BreadcrumbPage>{permissions.name}</BreadcrumbPage>
<BreadcrumbPage className="truncate w-96">{permissions.name}</BreadcrumbPage>
</BreadcrumbItem>
</BreadcrumbList>
</Breadcrumb>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { CopyButton } from "@/components/dashboard/copy-button";
import { PageHeader } from "@/components/dashboard/page-header";
import { Badge } from "@/components/ui/badge";
import { Button } from "@/components/ui/button";
import { Tooltip, TooltipContent, TooltipTrigger } from "@/components/ui/tooltip";
import { getTenantId } from "@/lib/auth";
import { db } from "@/lib/db";
import {
Expand Down Expand Up @@ -79,10 +80,19 @@ export default async function RolesPage(props: Props) {
<Badge
key="permission-name"
variant="secondary"
className="flex justify-between w-full gap-2 font-mono font-medium ph-no-capture"
className="w-40 font-mono font-medium ph-no-capture"
>
{permission.name}
<CopyButton value={permission.name} />
<Tooltip>
<TooltipTrigger className="flex items-center justify-between gap-2 truncate">
<span className="truncate">{permission.name}</span>
<div>
<CopyButton value={permission.name} />
</div>
</TooltipTrigger>
<TooltipContent>
<span className="text-xs font-medium">{permission.name}</span>
</TooltipContent>
</Tooltip>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tooltip implementation enhances usability.

The integration of the Tooltip component within the Badge for the permission name is well-implemented. It addresses the issue of long permission names by truncating them and providing a full view on hover, which aligns with the PR objectives.

However, consider adding a conditional rendering for the tooltip to only appear when the permission name exceeds a certain length. This would prevent unnecessary tooltip triggers for shorter names.

Consider adding a conditional rendering for the tooltip:

+ const shouldShowTooltip = permission.name.length > 20;
+
  <Tooltip>
    <TooltipTrigger className="flex items-center justify-between gap-2 truncate">
      <span className="truncate">{permission.name}</span>
      <div>
        <CopyButton value={permission.name} />
      </div>
    </TooltipTrigger>
+   {shouldShowTooltip && (
    <TooltipContent>
      <span className="text-xs font-medium">{permission.name}</span>
    </TooltipContent>
+   )}
  </Tooltip>

Committable suggestion was skipped due to low confidence.

</Badge>,
<Badge
key="permission-id"
Expand Down