({
model,
data,
search,
focusIndex,
setFocusIndex,
setSearch,
setSelectedPath,
setRefreshVersion,
entryManagerOverlayPropsAtom,
newFile,
newDirectory,
}: DirectoryTableProps)
| 99 | const columnHelper = createColumnHelper<FileInfo>(); |
| 100 | |
| 101 | function DirectoryTable({ |
| 102 | model, |
| 103 | data, |
| 104 | search, |
| 105 | focusIndex, |
| 106 | setFocusIndex, |
| 107 | setSearch, |
| 108 | setSelectedPath, |
| 109 | setRefreshVersion, |
| 110 | entryManagerOverlayPropsAtom, |
| 111 | newFile, |
| 112 | newDirectory, |
| 113 | }: DirectoryTableProps) { |
| 114 | const env = useWaveEnv<PreviewEnv>(); |
| 115 | const fullConfig = useAtomValue(env.atoms.fullConfigAtom); |
| 116 | const defaultSort = useAtomValue(env.getSettingsKeyAtom("preview:defaultsort")) ?? "name"; |
| 117 | const setErrorMsg = useSetAtom(model.errorMsgAtom); |
| 118 | const getIconFromMimeType = useCallback( |
| 119 | (mimeType: string): string => { |
| 120 | while (mimeType.length > 0) { |
| 121 | const icon = fullConfig.mimetypes?.[mimeType]?.icon ?? null; |
| 122 | if (isIconValid(icon)) { |
| 123 | return `fa fa-solid fa-${icon} fa-fw`; |
| 124 | } |
| 125 | mimeType = mimeType.slice(0, -1); |
| 126 | } |
| 127 | return "fa fa-solid fa-file fa-fw"; |
| 128 | }, |
| 129 | [fullConfig.mimetypes] |
| 130 | ); |
| 131 | const getIconColor = useCallback( |
| 132 | (mimeType: string): string => fullConfig.mimetypes?.[mimeType]?.color ?? "inherit", |
| 133 | [fullConfig.mimetypes] |
| 134 | ); |
| 135 | const columns = useMemo( |
| 136 | () => [ |
| 137 | columnHelper.accessor("mimetype", { |
| 138 | cell: (info) => ( |
| 139 | <i |
| 140 | className={getIconFromMimeType(info.getValue() ?? "")} |
| 141 | style={{ color: getIconColor(info.getValue() ?? "") }} |
| 142 | ></i> |
| 143 | ), |
| 144 | header: () => <span></span>, |
| 145 | id: "logo", |
| 146 | size: 25, |
| 147 | enableSorting: false, |
| 148 | }), |
| 149 | columnHelper.accessor("name", { |
| 150 | cell: (info) => <span className="dir-table-name ellipsis">{info.getValue()}</span>, |
| 151 | header: () => <span className="dir-table-head-name">Name</span>, |
| 152 | sortingFn: "alphanumeric", |
| 153 | size: 200, |
| 154 | minSize: 90, |
| 155 | }), |
| 156 | columnHelper.accessor("modestr", { |
| 157 | cell: (info) => <span className="dir-table-modestr">{info.getValue()}</span>, |
| 158 | header: () => <span>Perm</span>, |
nothing calls this directly
no test coverage detected