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
|
@ -10,13 +10,13 @@ import { NavLink, useHistory, useRouteMatch } from 'react-router-dom';
|
|||
import tw from 'twin.macro';
|
||||
import isEqual from 'react-fast-compare';
|
||||
import styled from 'styled-components/macro';
|
||||
import FormikCheckbox from '@/components/elements/Checkbox';
|
||||
import Input from '@/components/elements/Input';
|
||||
|
||||
const Row = styled.div`
|
||||
${tw`flex bg-neutral-700 rounded-sm mb-px text-sm hover:text-neutral-100 cursor-pointer items-center no-underline hover:bg-neutral-600`};
|
||||
`;
|
||||
|
||||
const Checkbox = styled(FormikCheckbox)`
|
||||
const Checkbox = styled(Input)`
|
||||
&& {
|
||||
${tw`border-neutral-500`};
|
||||
|
||||
|
@ -28,7 +28,9 @@ const Checkbox = styled(FormikCheckbox)`
|
|||
|
||||
const FileObjectRow = ({ file }: { file: FileObject }) => {
|
||||
const directory = ServerContext.useStoreState(state => state.files.directory);
|
||||
const selectedFiles = ServerContext.useStoreState(state => state.files.selectedFiles);
|
||||
const setDirectory = ServerContext.useStoreActions(actions => actions.files.setDirectory);
|
||||
const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles);
|
||||
|
||||
const history = useHistory();
|
||||
const match = useRouteMatch();
|
||||
|
@ -56,7 +58,19 @@ const FileObjectRow = ({ file }: { file: FileObject }) => {
|
|||
}}
|
||||
>
|
||||
<label css={tw`flex-none p-4 absolute self-center z-30 cursor-pointer`}>
|
||||
<Checkbox name={'selectedFiles'} value={file.name}/>
|
||||
<Checkbox
|
||||
name={'selectedFiles'}
|
||||
value={file.name}
|
||||
checked={selectedFiles.indexOf(file.name) >= 0}
|
||||
type={'checkbox'}
|
||||
onChange={(e: React.ChangeEvent<HTMLInputElement>) => {
|
||||
if (e.currentTarget.checked) {
|
||||
setSelectedFiles(selectedFiles.filter(f => f !== file.name).concat(file.name));
|
||||
} else {
|
||||
setSelectedFiles(selectedFiles.filter(f => f !== file.name));
|
||||
}
|
||||
}}
|
||||
/>
|
||||
</label>
|
||||
<NavLink
|
||||
to={`${match.url}/${file.isFile ? 'edit/' : ''}#${cleanDirectoryPath(`${directory}/${file.name}`)}`}
|
||||
|
|
Reference in a new issue