11import type { PluginInstance } from "@fnndsc/chrisapi" ;
2- import {
3- EmptyState ,
4- EmptyStateBody ,
5- EmptyStateVariant ,
6- Title ,
7- } from "@patternfly/react-core" ;
82import { Alert } from "../Antd" ;
93import { SpinContainer } from "../Common" ;
104import "./FeedOutputBrowser.css" ;
5+ import { EmptyStateLoader } from "./EmptyStateLoader" ;
116import FileBrowser from "./FileBrowser" ;
127import { 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} ;
0 commit comments