diff --git a/resources/scripts/components/server/files/FileManagerContainer.tsx b/resources/scripts/components/server/files/FileManagerContainer.tsx index 12e192851..80ea020d4 100644 --- a/resources/scripts/components/server/files/FileManagerContainer.tsx +++ b/resources/scripts/components/server/files/FileManagerContainer.tsx @@ -5,19 +5,10 @@ import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory'; import { Actions, useStoreActions } from 'easy-peasy'; import { ApplicationStore } from '@/state'; import { httpErrorToHuman } from '@/api/http'; -import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faFolder } from '@fortawesome/free-solid-svg-icons/faFolder'; -import { faFileAlt } from '@fortawesome/free-solid-svg-icons/faFileAlt'; -import format from 'date-fns/format'; -import differenceInHours from 'date-fns/difference_in_hours'; -import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; -import { bytesToHuman } from '@/helpers'; import { CSSTransition } from 'react-transition-group'; import { Link } from 'react-router-dom'; import Spinner from '@/components/elements/Spinner'; -import { faEllipsisH } from '@fortawesome/free-solid-svg-icons/faEllipsisH'; -import { faFile } from '@fortawesome/free-solid-svg-icons/faFile'; -import { faFileImport } from '@fortawesome/free-solid-svg-icons/faFileImport'; +import FileObjectRow from '@/components/server/files/FileObjectRow'; export default () => { const [ loading, setLoading ] = useState(true); @@ -98,48 +89,7 @@ export default () => {
{ files.map(file => ( - { - if (file.isFile) { - return e.preventDefault(); - } - }} - > -
- {file.isFile ? - - : - - } -
-
- {file.name} -
- {file.isFile && -
- {bytesToHuman(file.size)} -
- } -
- {Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ? - format(file.modifiedAt, 'MMM Do, YYYY h:mma') - : - distanceInWordsToNow(file.modifiedAt, { includeSeconds: true }) - } -
-
- -
-
+ )) }
diff --git a/resources/scripts/components/server/files/FileObjectRow.tsx b/resources/scripts/components/server/files/FileObjectRow.tsx new file mode 100644 index 000000000..b284b56cd --- /dev/null +++ b/resources/scripts/components/server/files/FileObjectRow.tsx @@ -0,0 +1,58 @@ +import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; +import { faFileImport } from '@fortawesome/free-solid-svg-icons/faFileImport'; +import { faFileAlt } from '@fortawesome/free-solid-svg-icons/faFileAlt'; +import { faFolder } from '@fortawesome/free-solid-svg-icons/faFolder'; +import { bytesToHuman } from '@/helpers'; +import differenceInHours from 'date-fns/difference_in_hours'; +import format from 'date-fns/format'; +import distanceInWordsToNow from 'date-fns/distance_in_words_to_now'; +import { faEllipsisH } from '@fortawesome/free-solid-svg-icons/faEllipsisH'; +import React from 'react'; +import { FileObject } from '@/api/server/files/loadDirectory'; + +export default ({ file, directory }: { file: FileObject; directory: string }) => { + return ( + { + if (file.isFile) { + return e.preventDefault(); + } + }} + > +
+ {file.isFile ? + + : + + } +
+
+ {file.name} +
+ {file.isFile && +
+ {bytesToHuman(file.size)} +
+ } +
+ {Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ? + format(file.modifiedAt, 'MMM Do, YYYY h:mma') + : + distanceInWordsToNow(file.modifiedAt, { includeSeconds: true }) + } +
+
+ +
+
+ ); +};