Mass actions for moving files, mostly working?
This commit is contained in:
parent
121f163b81
commit
80ecd58b30
6 changed files with 66 additions and 41 deletions
|
@ -15,7 +15,6 @@ import Button from '@/components/elements/Button';
|
|||
import useServer from '@/plugins/useServer';
|
||||
import { ServerContext } from '@/state/server';
|
||||
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
|
||||
import { Form, Formik } from 'formik';
|
||||
import MassActionsBar from '@/components/server/files/MassActionsBar';
|
||||
|
||||
const sortFiles = (files: FileObject[]): FileObject[] => {
|
||||
|
@ -28,12 +27,14 @@ export default () => {
|
|||
const { hash } = useLocation();
|
||||
const { data: files, error, mutate } = useFileManagerSwr();
|
||||
const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory);
|
||||
const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles);
|
||||
|
||||
useEffect(() => {
|
||||
// We won't automatically mutate the store when the component re-mounts, otherwise because of
|
||||
// my (horrible) programming this fires off way more than we intend it to.
|
||||
mutate();
|
||||
|
||||
setSelectedFiles([]);
|
||||
setDirectory(hash.length > 0 ? hash : '/');
|
||||
}, [ hash ]);
|
||||
|
||||
|
@ -58,27 +59,20 @@ export default () => {
|
|||
:
|
||||
<CSSTransition classNames={'fade'} timeout={150} appear in>
|
||||
<div>
|
||||
<Formik
|
||||
onSubmit={() => undefined}
|
||||
initialValues={{ selectedFiles: [] }}
|
||||
>
|
||||
<Form>
|
||||
{files.length > 250 &&
|
||||
<div css={tw`rounded bg-yellow-400 mb-px p-3`}>
|
||||
<p css={tw`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}/>
|
||||
))
|
||||
}
|
||||
<MassActionsBar/>
|
||||
</Form>
|
||||
</Formik>
|
||||
{files.length > 250 &&
|
||||
<div css={tw`rounded bg-yellow-400 mb-px p-3`}>
|
||||
<p css={tw`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}/>
|
||||
))
|
||||
}
|
||||
<MassActionsBar/>
|
||||
</div>
|
||||
</CSSTransition>
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue