| 1 | import { getLastNPathParts } from "core/util/uri"; |
| 2 | import FileIcon from "../../FileIcon"; |
| 3 | import { ToolTip } from "../../gui/Tooltip"; |
| 4 | |
| 5 | export interface FileInfoProps { |
| 6 | filepath: string; |
| 7 | onClick?: () => void; |
| 8 | range?: string; |
| 9 | } |
| 10 | |
| 11 | const TOOLTIP_ID = "file-info-tooltip"; |
| 12 | |
| 13 | export const FileInfo = ({ filepath, range, onClick }: FileInfoProps) => { |
| 14 | return ( |
| 15 | <> |
| 16 | <div |
| 17 | className={`flex select-none flex-row items-center gap-0.5 ${onClick && "cursor-pointer hover:underline"}`} |
| 18 | onClick={onClick} |
| 19 | data-tooltip-id={TOOLTIP_ID} |
| 20 | data-tooltip-content={filepath} |
| 21 | data-tooltip-place="top-end" |
| 22 | > |
| 23 | <div> |
| 24 | <FileIcon height="20px" width="20px" filename={filepath} /> |
| 25 | </div> |
| 26 | <span className="line-clamp-1 break-all"> |
| 27 | {getLastNPathParts(filepath, 1)} |
| 28 | {range && ` ${range}`} |
| 29 | </span> |
| 30 | </div> |
| 31 | <ToolTip |
| 32 | id={TOOLTIP_ID} |
| 33 | style={{ |
| 34 | maxWidth: "200px", |
| 35 | textAlign: "left", |
| 36 | whiteSpace: "normal", |
| 37 | wordBreak: "break-word", |
| 38 | }} |
| 39 | /> |
| 40 | </> |
| 41 | ); |
| 42 | }; |