Add create directory button
This commit is contained in:
parent
ba0757f05c
commit
d07ee9a36b
3 changed files with 142 additions and 25 deletions
|
@ -8,6 +8,13 @@ import { CSSTransition } from 'react-transition-group';
|
|||
import Spinner from '@/components/elements/Spinner';
|
||||
import FileObjectRow from '@/components/server/files/FileObjectRow';
|
||||
import FileManagerBreadcrumbs from '@/components/server/files/FileManagerBreadcrumbs';
|
||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
||||
import NewDirectoryButton from '@/components/server/files/NewDirectoryButton';
|
||||
|
||||
const sortFiles = (files: FileObject[]): FileObject[] => {
|
||||
return files.sort((a, b) => a.name.localeCompare(b.name))
|
||||
.sort((a, b) => a.isFile === b.isFile ? 0 : (a.isFile ? 1 : -1));
|
||||
};
|
||||
|
||||
export default () => {
|
||||
const [ loading, setLoading ] = useState(true);
|
||||
|
@ -37,34 +44,46 @@ export default () => {
|
|||
loading ?
|
||||
<Spinner size={'large'} centered={true}/>
|
||||
:
|
||||
!files.length ?
|
||||
<p className={'text-sm text-neutral-600 text-center'}>
|
||||
This directory seems to be empty.
|
||||
</p>
|
||||
:
|
||||
<CSSTransition classNames={'fade'} timeout={250} appear={true} in={true}>
|
||||
<div>
|
||||
{files.length > 250 ?
|
||||
<React.Fragment>
|
||||
<div className={'rounded bg-yellow-400 mb-px p-3'}>
|
||||
<p className={'text-yellow-900 text-sm text-center'}>
|
||||
This directory is too large to display in the browser, limiting
|
||||
the output to the first 250 files.
|
||||
</p>
|
||||
</div>
|
||||
{
|
||||
files.slice(0, 250).map(file => (
|
||||
<React.Fragment>
|
||||
{!files.length ?
|
||||
<p className={'text-sm text-neutral-600 text-center'}>
|
||||
This directory seems to be empty.
|
||||
</p>
|
||||
:
|
||||
<CSSTransition classNames={'fade'} timeout={250} appear={true} in={true}>
|
||||
<React.Fragment>
|
||||
<div>
|
||||
{files.length > 250 ?
|
||||
<React.Fragment>
|
||||
<div className={'rounded bg-yellow-400 mb-px p-3'}>
|
||||
<p className={'text-yellow-900 text-sm text-center'}>
|
||||
This directory is too large to display in the browser,
|
||||
limiting
|
||||
the output to the first 250 files.
|
||||
</p>
|
||||
</div>
|
||||
{
|
||||
sortFiles(files.slice(0, 250)).map(file => (
|
||||
<FileObjectRow key={file.uuid} file={file}/>
|
||||
))
|
||||
}
|
||||
</React.Fragment>
|
||||
:
|
||||
sortFiles(files).map(file => (
|
||||
<FileObjectRow key={file.uuid} file={file}/>
|
||||
))
|
||||
}
|
||||
</React.Fragment>
|
||||
:
|
||||
files.map(file => (
|
||||
<FileObjectRow key={file.uuid} file={file}/>
|
||||
))
|
||||
}
|
||||
</div>
|
||||
</CSSTransition>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
</CSSTransition>
|
||||
}
|
||||
<div className={'flex justify-end mt-8'}>
|
||||
<NewDirectoryButton/>
|
||||
<button className={'btn btn-sm btn-primary'}>
|
||||
New File
|
||||
</button>
|
||||
</div>
|
||||
</React.Fragment>
|
||||
}
|
||||
</React.Fragment>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue