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

🐛 Wrap long file paths in issues drawer #1761

Merged
merged 5 commits into from
Mar 22, 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
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import {
import { SimplePagination } from "@app/components/SimplePagination";
import { FileIncidentsDetailModal } from "./file-incidents-detail-modal";
import { FilterToolbar, FilterType } from "@app/components/FilterToolbar";
import PathDisplay from "./path-display";

export interface IIssueAffectedFilesTableProps {
issue: AnalysisIssue;
Expand Down Expand Up @@ -152,17 +153,13 @@ export const IssueAffectedFilesTable: React.FC<
item={fileReport}
rowIndex={rowIndex}
>
<Td
width={70}
{...getTdProps({ columnKey: "file" })}
modifier="truncate"
>
<Td {...getTdProps({ columnKey: "file" })}>
<Button
variant="link"
isInline
onClick={() => setSelectedFileForDetailModal(fileReport)}
>
{fileReport?.file || "<unknown>"}
<PathDisplay path={fileReport?.file || "<unknown>"} />
</Button>
</Td>
<Td
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
import React from "react";

interface PathDisplayProps {
path: string;
}

const PathDisplay: React.FC<PathDisplayProps> = ({ path }) => {
const normalizedPath = path.replace(/\\/g, "/");
const formattedPath = normalizedPath
.split("/")
sjd78 marked this conversation as resolved.
Show resolved Hide resolved
.reduce<React.ReactNode[]>((acc, segment, index, array) => {
acc.push(segment);
if (index < array.length - 1) {
acc.push(<wbr key={`wbr-${index}`} />);
acc.push(<span key={`slash-${index}`}>/</span>);
}
return acc;
}, []);

return <>{formattedPath}</>;
};

export default PathDisplay;
Loading