Open History to see the last commit
1import type { EnvironmentId } from "@t3tools/contracts";
2import { formatAttachmentSize } from "@t3tools/client-runtime/state/attachments";
3import { useFormattingLocale } from "~/i18n/I18nProvider";
4import { useMessages } from "gt-react";
5
6import { useFileMetadata } from "../../hooks/useFileMetadata";
7import { PierreEntryIcon } from "./PierreEntryIcon";
8
9export function WorkspaceEntryIcon(props: {
10 path: string;
11 environmentId?: EnvironmentId | null | undefined;
12 cwd?: string | undefined;
13 theme: "light" | "dark";
14}) {
15 const metadata = useFileMetadata(props.environmentId, props.path, props.cwd);
16 return (
17 <PierreEntryIcon
18 pathValue={props.path}
19 kind={metadata?.kind === "directory" ? "directory" : "file"}
20 mimeType={metadata?.mimeType}
21 theme={props.theme}
22 />
23 );
24}
25
26export function WorkspaceEntryTooltip(props: {
27 path: string;
28 label?: string;
29 environmentId?: EnvironmentId | null | undefined;
30 cwd?: string | undefined;
31}) {
32 const metadata = useFileMetadata(props.environmentId, props.path, props.cwd);
33 const messages = useMessages();
34 const locale = useFormattingLocale();
35 return (
36 <>
37 {props.label ?? props.path}
38 {metadata?.byteLength === undefined
39 ? null
40 : ` · ${formatAttachmentSize(metadata.byteLength, messages, locale)}`}
41 </>
42 );
43}