From 3df4d433f00971a26d76dc191d5329284ba6f671 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sat, 11 Jul 2020 17:09:54 -0700 Subject: [PATCH] Support checking all --- .../server/files/FileManagerBreadcrumbs.tsx | 18 ++++++++++++++++++ .../server/files/SelectFileCheckbox.tsx | 4 ++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx b/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx index fba1938ea..15a5f39c4 100644 --- a/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx +++ b/resources/scripts/components/server/files/FileManagerBreadcrumbs.tsx @@ -3,6 +3,8 @@ import { ServerContext } from '@/state/server'; import { NavLink } from 'react-router-dom'; import { cleanDirectoryPath } from '@/helpers'; import tw from 'twin.macro'; +import { FileActionCheckbox } from '@/components/server/files/SelectFileCheckbox'; +import useFileManagerSwr from '@/plugins/useFileManagerSwr'; interface Props { withinFileEditor?: boolean; @@ -14,6 +16,10 @@ export default ({ withinFileEditor, isNewFile }: Props) => { const id = ServerContext.useStoreState(state => state.server.data!.id); const directory = ServerContext.useStoreState(state => state.files.directory); + const { data: files } = useFileManagerSwr(); + const setSelectedFiles = ServerContext.useStoreActions(actions => actions.files.setSelectedFiles); + const selectedFilesLength = ServerContext.useStoreState(state => state.files.selectedFiles.length); + useEffect(() => { const parts = cleanDirectoryPath(window.location.hash).split('/'); @@ -32,8 +38,20 @@ export default ({ withinFileEditor, isNewFile }: Props) => { return { name: decodeURIComponent(directory), path: `/${dirs.slice(0, index + 1).join('/')}` }; }); + const onSelectAllClick = (e: React.ChangeEvent) => { + setSelectedFiles(e.currentTarget.checked ? (files?.map(file => file.name) || []) : []); + }; + return (
+ {!!(files && files.length) && + + } /home/ { return (