import { WebDAV, WebDAVRequestConfig } from 'common/webdav';
import { AuthState } from 'store/auth/auth-reducer';
import { extractFilesData } from 'services/collection-service/collection-service-files-response';
-import { DefaultIcon, DirectoryIcon, FileIcon, BackIcon } from 'components/icon/icon';
+import { DefaultIcon, DirectoryIcon, FileIcon, BackIcon, SidePanelRightArrowIcon } from 'components/icon/icon';
import { setCollectionFiles } from 'store/collection-panel/collection-panel-files/collection-panel-files-actions';
import { sortBy } from 'lodash';
import { formatFileSize } from 'common/formatters';
isWritable: boolean;
isLoading: boolean;
tooManyFiles: boolean;
- onUploadDataClick: () => void;
+ onUploadDataClick: (targetLocation?: string) => void;
onSearchChange: (searchValue: string) => void;
onItemMenuOpen: (event: React.MouseEvent<HTMLElement>, item: TreeItem<FileTreeData>, isWritable: boolean) => void;
onOptionsMenuOpen: (event: React.MouseEvent<HTMLElement>, isWritable: boolean) => void;
wrapper: {
display: 'flex',
minHeight: '600px',
- marginBottom: '1rem',
color: 'rgba(0, 0, 0, 0.87)',
fontSize: '0.875rem',
fontFamily: '"Roboto", "Helvetica", "Arial", sans-serif',
const [path, setPath]: any = React.useState([]);
const [pathData, setPathData]: any = React.useState({});
const [isLoading, setIsLoading] = React.useState(false);
- const [collectionAutofetchEnabled, setCollectionAutofetchEnabled] = React.useState(false);
const [leftSearch, setLeftSearch] = React.useState('');
const [rightSearch, setRightSearch] = React.useState('');
}
}, [rightKey]); // eslint-disable-line react-hooks/exhaustive-deps
+ const currentPDH = (collectionPanel.item || {}).portableDataHash;
React.useEffect(() => {
- const hash = (collectionPanel.item || {}).portableDataHash;
-
- if (hash && collectionAutofetchEnabled) {
+ if (currentPDH) {
fetchData([leftKey, rightKey], true);
}
- }, [(collectionPanel.item || {}).portableDataHash]); // eslint-disable-line react-hooks/exhaustive-deps
+ }, [currentPDH]); // eslint-disable-line react-hooks/exhaustive-deps
React.useEffect(() => {
if (rightData) {
if (id) {
onItemMenuOpen(event, item, isWritable);
-
- if (!collectionAutofetchEnabled) {
- setCollectionAutofetchEnabled(true);
- }
}
},
[onItemMenuOpen, isWritable, rightData] // eslint-disable-line react-hooks/exhaustive-deps
<IconButton
data-cy='collection-files-panel-options-btn'
onClick={(ev) => {
- if (!collectionAutofetchEnabled) {
- setCollectionAutofetchEnabled(true);
- }
onOptionsMenuOpen(ev, isWritable);
}}>
<CustomizeTableIcon />
</Tooltip>
</div>
<div className={classes.wrapper}>
- <div className={classNames(classes.leftPanel, path.length > 1 ? classes.leftPanelVisible : classes.leftPanelHidden)}>
+ <div className={classNames(classes.leftPanel, path.length > 1 ? classes.leftPanelVisible : classes.leftPanelHidden)} data-cy="collection-files-left-panel">
<Tooltip title="Go back" className={path.length > 1 ? classes.backButton : classes.backButtonHidden}>
<IconButton onClick={() => setPath([...path.slice(0, path.length -1)])}>
<BackIcon />
</IconButton>
</Tooltip>
<div className={path.length > 1 ? classes.searchWrapper : classes.searchWrapperHidden}>
- <SearchInput label="Search" value={leftSearch} onSearch={setLeftSearch} />
+ <SearchInput selfClearProp={leftKey} label="Search" value={leftSearch} onSearch={setLeftSearch} />
</div>
<div className={classes.dataWrapper}>
{
data-type={type}
data-parent-path={name}
className={classNames(classes.row, getActiveClass(name))}
- key={id}>{getItemIcon(type, getActiveClass(name))} <div className={classes.rowName}>{name}</div>
+ key={id}>
+ {getItemIcon(type, getActiveClass(name))}
+ <div className={classes.rowName}>
+ {name}
+ </div>
+ {
+ getActiveClass(name) ? <SidePanelRightArrowIcon
+ style={{ display: 'inline', marginTop: '5px', marginLeft: '5px' }} /> : null
+ }
</div>;
}
}
</div>
</div>
- <div className={classes.rightPanel}>
+ <div className={classes.rightPanel} data-cy="collection-files-right-panel">
<div className={classes.searchWrapper}>
- <SearchInput label="Search" value={rightSearch} onSearch={setRightSearch} />
+ <SearchInput selfClearProp={rightKey} label="Search" value={rightSearch} onSearch={setRightSearch} />
</div>
{
isWritable &&
<Button
className={classes.uploadButton}
data-cy='upload-button'
- onClick={onUploadDataClick}
+ onClick={() => {
+ onUploadDataClick(rightKey === leftKey ? undefined : rightKey);
+ }}
variant='contained'
color='primary'
size='small'>
</div>
}
}
- </FixedSizeList> : <div className={classes.rowEmpty}>No data available</div>
+ </FixedSizeList> : <div className={classes.rowEmpty}>This collection is empty</div>
}}
</AutoSizer> : <div className={classes.row}><CircularProgress className={classes.loader} size={30} /></div>
}