diff --git a/resources/scripts/components/server/files/FileObjectRow.tsx b/resources/scripts/components/server/files/FileObjectRow.tsx index c95698f4f..934fd6320 100644 --- a/resources/scripts/components/server/files/FileObjectRow.tsx +++ b/resources/scripts/components/server/files/FileObjectRow.tsx @@ -10,27 +10,15 @@ 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 Input from '@/components/elements/Input'; +import SelectFileCheckbox from '@/components/server/files/SelectFileCheckbox'; 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(Input)` - && { - ${tw`border-neutral-500`}; - - &:not(:checked) { - ${tw`hover:border-neutral-300`}; - } - } -`; - 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(); @@ -57,21 +45,7 @@ const FileObjectRow = ({ file }: { file: FileObject }) => { window.dispatchEvent(new CustomEvent(`pterodactyl:files:ctx:${file.uuid}`, { detail: e.clientX })); }} > - + { + const isChecked = ServerContext.useStoreState(state => state.files.selectedFiles.indexOf(name) >= 0); + const appendSelectedFile = ServerContext.useStoreActions(actions => actions.files.appendSelectedFile); + const removeSelectedFile = ServerContext.useStoreActions(actions => actions.files.removeSelectedFile); + + return ( + + ); +}; diff --git a/resources/scripts/state/server/files.ts b/resources/scripts/state/server/files.ts index b2ba1a11b..04098572d 100644 --- a/resources/scripts/state/server/files.ts +++ b/resources/scripts/state/server/files.ts @@ -7,6 +7,8 @@ export interface ServerFileStore { setDirectory: Action; setSelectedFiles: Action; + appendSelectedFile: Action; + removeSelectedFile: Action; } const files: ServerFileStore = { @@ -20,6 +22,14 @@ const files: ServerFileStore = { setSelectedFiles: action((state, payload) => { state.selectedFiles = payload; }), + + appendSelectedFile: action((state, payload) => { + state.selectedFiles = state.selectedFiles.filter(f => f !== payload).concat(payload); + }), + + removeSelectedFile: action((state, payload) => { + state.selectedFiles = state.selectedFiles.filter(f => f !== payload); + }), }; export default files;