Skip to content

Commit 52b33b2

Browse files
authored
Merge pull request #1379 from chhsiao1981/style-hide-display
style-hide display
2 parents d8e18ab + 1f11dd3 commit 52b33b2

38 files changed

+85969
-529
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,6 @@
44
[submodule "testing/sample_dicoms"]
55
path = testing/sample_dicoms
66
url = https://github.com/FNNDSC/sample_dicom_downloader.git
7+
[submodule "third-party/fs2NiiVueColormaps"]
8+
path = third-party/fs2NiiVueColormaps
9+
url = [email protected]:niivue/fs2NiiVueColormaps.git

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
"preview": "vite preview",
3737
"__helper_functions": "",
3838
"get-running-url": "./testing/get_running_url.sh",
39-
"print-version": "node printVersion.js"
39+
"print-version": "node printVersion.js",
40+
"fs2niivue": "if [ -d third-party/fs2NiiVueColormaps ]; then cd third-party/fs2NiiVueColormaps; python3 fs2niivue.py; cp FreesurferColorLUT.v7.4.1.json ../../src/components/Preview/displays; rm *.json; cd ../..; else echo '[WARN] need to git submodule fs2NiiVueColormaps first'; fi"
4041
},
4142
"dependencies": {
4243
"@ant-design/icons": "^5.5.1",
@@ -73,7 +74,6 @@
7374
"marked": "14.1.2",
7475
"micromark": "^4.0.0",
7576
"micromark-extension-gfm": "^3.0.0",
76-
"niivue-react": "github:niivue/niivue-react",
7777
"pako": "^1.0.11",
7878
"papaparse": "^5.4.1",
7979
"preval.macro": "^5.0.0",

pnpm-lock.yaml

Lines changed: 0 additions & 18 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/api/model.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ export const fileViewerMap: any = {
184184
mov: "VideoDisplay", // Add mov format
185185
wmv: "VideoDisplay", // Add wmv format
186186
mkv: "VideoDisplay", // Add mkv format
187+
mha: "NiiVueDisplay",
187188
};
188189

189190
// Description: get file type by file extension

src/components/Common/index.tsx

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,11 +18,11 @@ import {
1818
} from "@patternfly/react-core";
1919
import { Table, Tbody, Td, Th, Thead, Tr } from "@patternfly/react-table";
2020
import { Alert, Popover, Spin } from "antd";
21-
import React, { type ReactNode, useState } from "react";
21+
import React, { type CSSProperties, type ReactNode, useState } from "react";
2222
import Dots from "react-activity/dist/Dots";
2323
import "react-activity/dist/library.css";
24-
import { Cookies } from "react-cookie";
2524
import ReactJson from "@microlink/react-json-view";
25+
import { Cookies } from "react-cookie";
2626
import {
2727
ArchiveIcon,
2828
CubesIcon,
@@ -46,9 +46,18 @@ export const EmptyStateComponent = ({ title }: { title?: string }) => {
4646
);
4747
};
4848

49-
export const SpinContainer = ({ title }: { title: string }) => {
49+
type SpinContainerProps = {
50+
title: string;
51+
isHide?: boolean;
52+
};
53+
export const SpinContainer = (props: SpinContainerProps) => {
54+
const { title, isHide } = props;
55+
const style: CSSProperties = {};
56+
if (isHide) {
57+
style.display = "none";
58+
}
5059
return (
51-
<div className="example">
60+
<div className="example" style={style}>
5261
<Spin tip={title}>
5362
<div className="content" />
5463
</Spin>
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.hide {
2+
display: none;
3+
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import {
2+
EmptyState,
3+
EmptyStateBody,
4+
EmptyStateVariant,
5+
Title,
6+
} from "@patternfly/react-core";
7+
8+
import styles from "./EmptyStateLoader.module.css";
9+
10+
type Props = {
11+
title: string;
12+
isHide?: boolean;
13+
};
14+
15+
export const EmptyStateLoader = (props: Props) => {
16+
const { title, isHide } = props;
17+
const className = isHide ? styles.hide : "";
18+
return (
19+
<EmptyState variant={EmptyStateVariant.lg} className={className}>
20+
<Title headingLevel="h4" size="lg" />
21+
<EmptyStateBody>{title}</EmptyStateBody>
22+
</EmptyState>
23+
);
24+
};
Lines changed: 34 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,20 @@
11
import type { PluginInstance } from "@fnndsc/chrisapi";
2-
import {
3-
EmptyState,
4-
EmptyStateBody,
5-
EmptyStateVariant,
6-
Title,
7-
} from "@patternfly/react-core";
82
import { Alert } from "../Antd";
93
import { SpinContainer } from "../Common";
104
import "./FeedOutputBrowser.css";
5+
import { EmptyStateLoader } from "./EmptyStateLoader";
116
import FileBrowser from "./FileBrowser";
127
import { useFeedBrowser } from "./useFeedBrowser";
138

14-
export interface FeedOutputBrowserProps {
9+
type Props = {
1510
handlePluginSelect: (node: PluginInstance) => void;
1611
explore: boolean;
1712
statuses: {
1813
[id: number]: string;
1914
};
20-
}
15+
};
2116

22-
const FeedOutputBrowser: React.FC<FeedOutputBrowserProps> = (props) => {
17+
export default (props: Props) => {
2318
const {
2419
selected,
2520
pluginFilesPayload,
@@ -43,41 +38,42 @@ const FeedOutputBrowser: React.FC<FeedOutputBrowserProps> = (props) => {
4338
props.statuses,
4439
);
4540

41+
const isHideFetchFilesLoader = finished;
42+
const isHideFileBrowser =
43+
!finished || !pluginFilesPayload || !selected || isError;
44+
const isHideError = !finished || !isError;
45+
const isHideEmptyStateLoader =
46+
!isHideFetchFilesLoader || !isHideFileBrowser || !isHideError;
47+
4648
return (
4749
<div style={{ height: "100%" }} className="feed-output-browser">
48-
{!finished ? (
49-
<FetchFilesLoader title="Plugin executing. Files will be fetched when plugin completes" />
50-
) : pluginFilesPayload && selected && !isError ? (
51-
<FileBrowser
52-
selected={selected}
53-
handleFileClick={handleFileClick}
54-
pluginFilesPayload={pluginFilesPayload}
55-
currentPath={currentPath}
56-
fetchMore={fetchMore}
57-
observerTarget={observerTarget}
58-
handlePagination={handlePagination}
59-
isLoading={filesLoading}
60-
/>
61-
) : isError ? (
62-
<Alert type="error" description={error?.message} />
63-
) : (
64-
<EmptyStateLoader title="" />
65-
)}
50+
<FetchFilesLoader
51+
title="Plugin executing. Files will be fetched when plugin completes"
52+
isHide={isHideFetchFilesLoader}
53+
/>
54+
<FileBrowser
55+
selected={selected}
56+
handleFileClick={handleFileClick}
57+
pluginFilesPayload={pluginFilesPayload}
58+
currentPath={currentPath}
59+
fetchMore={fetchMore}
60+
observerTarget={observerTarget}
61+
handlePagination={handlePagination}
62+
isLoading={filesLoading}
63+
isHide={isHideFileBrowser}
64+
/>
65+
{!isHideError && <Alert type="error" description={error?.message} />}
66+
<EmptyStateLoader title="" isHide={isHideEmptyStateLoader} />
6667
</div>
6768
);
6869
};
6970

70-
export default FeedOutputBrowser;
71-
72-
export const EmptyStateLoader = ({ title }: { title: string }) => {
73-
return (
74-
<EmptyState variant={EmptyStateVariant.lg}>
75-
<Title headingLevel="h4" size="lg" />
76-
<EmptyStateBody>{title}</EmptyStateBody>
77-
</EmptyState>
78-
);
71+
type FetchFilesLoaderProps = {
72+
title: string;
73+
isHide?: boolean;
7974
};
8075

81-
const FetchFilesLoader = ({ title }: { title: string }) => {
82-
return <SpinContainer title={title} />;
76+
const FetchFilesLoader = (props: FetchFilesLoaderProps) => {
77+
const { title, isHide } = props;
78+
return <SpinContainer title={title} isHide={isHide} />;
8379
};
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
.hide {
2+
display: none;
3+
}

0 commit comments

Comments
 (0)