diff --git a/src/api/common.ts b/src/api/common.ts
index 6f6daef8b..b21224533 100644
--- a/src/api/common.ts
+++ b/src/api/common.ts
@@ -454,3 +454,7 @@ export function needsQuoting(value: string) {
const quotedValue = quote(value);
return quotedValue !== value;
}
+
+export const getFileName = (name: string) => {
+ return name.split("/").slice(-1).join("");
+};
diff --git a/src/api/model.ts b/src/api/model.ts
index 1f9ece447..7ccb51dcf 100644
--- a/src/api/model.ts
+++ b/src/api/model.ts
@@ -1,5 +1,9 @@
import _ from "lodash";
-import type { FeedFile, PluginInstance } from "@fnndsc/chrisapi";
+import type {
+ FileBrowserFolderFile,
+ PACSFile,
+ PluginInstance,
+} from "@fnndsc/chrisapi";
export interface IActionTypeParam {
type: string;
@@ -162,7 +166,7 @@ export class TreeModel {
export interface IFileBlob {
blob?: Blob;
- file?: FeedFile;
+ file?: FileBrowserFolderFile | PACSFile;
url?: string;
fileType: string;
}
@@ -175,6 +179,7 @@ export const fileViewerMap: any = {
html: "IframeDisplay",
pdf: "PdfDisplay",
csv: "TextDisplay",
+ md: "TextDisplay",
ctab: "TextDisplay",
json: "JsonDisplay",
png: "ImageDisplay",
@@ -209,7 +214,7 @@ export function getFileExtension(filename: string) {
}
export class FileViewerModel {
- public getFileName(item: FeedFile) {
+ public getFileName(item: FileBrowserFolderFile) {
const splitString = item.data.fname.split("/");
const filename = splitString[splitString.length - 1];
return filename;
diff --git a/src/components/Common/index.tsx b/src/components/Common/index.tsx
index 99d79496c..acef8957d 100644
--- a/src/components/Common/index.tsx
+++ b/src/components/Common/index.tsx
@@ -1,5 +1,5 @@
-import { InfoIcon as InfoIconComponent } from "../Icons";
import {
+ ClipboardCopy,
ClipboardCopyButton,
Dropdown,
DropdownItem,
@@ -14,12 +14,22 @@ import {
Hint,
MenuToggle,
TextInput,
- ClipboardCopy,
} from "@patternfly/react-core";
-import { CubesIcon, SearchIcon } from "../Icons";
import { Alert, Popover, Spin, Typography } from "antd";
-import React, { ReactNode, useState } from "react";
+import React, { type ReactNode, useState } from "react";
import Dots from "react-activity/dist/Dots";
+import {
+ ArchiveIcon,
+ CubesIcon,
+ ExternalLinkSquareAltIcon,
+ FileIcon,
+ FileImageIcon,
+ FilePdfIcon,
+ FileTxtIcon,
+ FolderIcon,
+ InfoIcon as InfoIconComponent,
+ SearchIcon,
+} from "../Icons";
import "react-activity/dist/library.css";
import { Cookies } from "react-cookie";
import ReactJson from "react-json-view";
@@ -350,3 +360,26 @@ export const ClipboardCopyFixed = ({
);
};
+
+export const getIcon = (type: string) => {
+ switch (type.toLowerCase()) {
+ case "dir":
+ return ;
+ case "dcm":
+ case "jpg":
+ case "png":
+ return ;
+ case "txt":
+ return ;
+ case "pdf":
+ return ;
+ case "zip":
+ return ;
+ case "link":
+ return ;
+ case "folder":
+ return ;
+ default:
+ return ;
+ }
+};
diff --git a/src/components/FeedOutputBrowser/FileBrowser.tsx b/src/components/FeedOutputBrowser/FileBrowser.tsx
index a151d730a..a818a6ba6 100644
--- a/src/components/FeedOutputBrowser/FileBrowser.tsx
+++ b/src/components/FeedOutputBrowser/FileBrowser.tsx
@@ -20,28 +20,16 @@ import {
setSelectedFile,
} from "../../store/explorer/actions";
import useDownload, { useTypedSelector } from "../../store/hooks";
-import { ClipboardCopyContainer, SpinContainer } from "../Common";
+import { ClipboardCopyContainer, SpinContainer, getIcon } from "../Common";
import { ThemeContext } from "../DarkTheme/useTheme";
import { DrawerActionButton } from "../Feeds/DrawerUtils";
import { handleMaximize, handleMinimize } from "../Feeds/utilties";
-import {
- DownloadIcon,
- ExternalLinkSquareAltIcon,
- FileIcon,
- FileImageIcon,
- FilePdfIcon,
- FileTxtIcon,
- FolderIcon,
- HomeIcon,
-} from "../Icons";
+import { DownloadIcon, HomeIcon } from "../Icons";
import FileDetailView from "../Preview/FileDetailView";
import XtkViewer from "../XtkViewer/XtkViewer";
import type { FileBrowserProps } from "./types";
import { bytesToSize } from "./utilities";
-
-export const getFileName = (name: string) => {
- return name.split("/").slice(-1).join("");
-};
+import { getFileExtension } from "../../api/model";
const previewAnimation = [{ opacity: "0.0" }, { opacity: "1.0" }];
@@ -193,7 +181,7 @@ const FileBrowser = (props: FileBrowserProps) => {
fileName = pathList[pathList.length - 1];
if (type === "file" && fileName.indexOf(".") > -1) {
- iconType = getFileName(fileName)[0].toUpperCase();
+ iconType = getFileExtension(fileName);
fsize = bytesToSize(item.data.fsize);
} else {
iconType = type;
@@ -316,29 +304,3 @@ const FileBrowser = (props: FileBrowserProps) => {
};
export default FileBrowser;
-
-const getIcon = (type: string) => {
- switch (type.toLowerCase()) {
- case "dir":
- return ;
- case "dcm":
- case "jpg":
- case "png":
- return ;
- case "html":
- case "json":
- return ;
- case "txt":
- return ;
- case "pdf":
- return ;
-
- case "link":
- return ;
- case "folder":
- return ;
-
- default:
- return ;
- }
-};
diff --git a/src/components/Icons/index.tsx b/src/components/Icons/index.tsx
index 98f59710d..3dc920fa1 100644
--- a/src/components/Icons/index.tsx
+++ b/src/components/Icons/index.tsx
@@ -40,7 +40,6 @@ const CartIcon = ({
return (