From 097d308ccd949e6b97f819f902a683d7108270c0 Mon Sep 17 00:00:00 2001 From: Dane Everitt Date: Sun, 27 Feb 2022 12:44:22 -0500 Subject: [PATCH] Update files to new format --- resources/scripts/api/server/files.ts | 142 ++++++++++++++++++ .../scripts/api/server/files/chmodFiles.ts | 14 -- .../scripts/api/server/files/compressFiles.ts | 12 -- .../scripts/api/server/files/copyFile.ts | 9 -- .../api/server/files/createDirectory.ts | 9 -- .../api/server/files/decompressFiles.ts | 8 - .../scripts/api/server/files/deleteFiles.ts | 9 -- .../api/server/files/getFileContents.ts | 13 -- .../api/server/files/getFileDownloadUrl.ts | 9 -- .../api/server/files/getFileUploadUrl.ts | 9 -- .../scripts/api/server/files/loadDirectory.ts | 25 --- .../scripts/api/server/files/pullFile.ts | 9 -- .../scripts/api/server/files/renameFiles.ts | 14 -- .../api/server/files/saveFileContents.ts | 10 -- resources/scripts/api/server/getServer.ts | 3 - .../server/features/EulaModalFeature.tsx | 2 +- .../server/files/ChmodFileModal.tsx | 2 +- .../server/files/FileDropdownMenu.tsx | 27 ++-- .../server/files/FileEditContainer.tsx | 3 +- .../server/files/MassActionsBar.tsx | 9 +- .../server/files/NewDirectoryButton.tsx | 3 +- .../components/server/files/PullFileModal.tsx | 3 +- .../server/files/RenameFileModal.tsx | 2 +- .../components/server/files/UploadButton.tsx | 2 +- .../server/network/AllocationRow.tsx | 4 +- .../scripts/plugins/useFileManagerSwr.ts | 2 +- 26 files changed, 173 insertions(+), 181 deletions(-) create mode 100644 resources/scripts/api/server/files.ts delete mode 100644 resources/scripts/api/server/files/chmodFiles.ts delete mode 100644 resources/scripts/api/server/files/compressFiles.ts delete mode 100644 resources/scripts/api/server/files/copyFile.ts delete mode 100644 resources/scripts/api/server/files/createDirectory.ts delete mode 100644 resources/scripts/api/server/files/decompressFiles.ts delete mode 100644 resources/scripts/api/server/files/deleteFiles.ts delete mode 100644 resources/scripts/api/server/files/getFileContents.ts delete mode 100644 resources/scripts/api/server/files/getFileDownloadUrl.ts delete mode 100644 resources/scripts/api/server/files/getFileUploadUrl.ts delete mode 100644 resources/scripts/api/server/files/loadDirectory.ts delete mode 100644 resources/scripts/api/server/files/pullFile.ts delete mode 100644 resources/scripts/api/server/files/renameFiles.ts delete mode 100644 resources/scripts/api/server/files/saveFileContents.ts delete mode 100644 resources/scripts/api/server/getServer.ts diff --git a/resources/scripts/api/server/files.ts b/resources/scripts/api/server/files.ts new file mode 100644 index 000000000..b86c6d510 --- /dev/null +++ b/resources/scripts/api/server/files.ts @@ -0,0 +1,142 @@ +import http from '@/api/http'; +import { rawDataToFileObject } from '@/api/transformers'; + +export interface FileObject { + key: string; + name: string; + mode: string; + modeBits: string, + size: number; + isFile: boolean; + isSymlink: boolean; + mimetype: string; + createdAt: Date; + modifiedAt: Date; + isArchiveType: () => boolean; + isEditable: () => boolean; +} + +const chmodFiles = (uuid: string, directory: string, files: { file: string; mode: string }[]): Promise => { + return new Promise((resolve, reject) => { + http.post(`/api/client/servers/${uuid}/files/chmod`, { root: directory, files }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const compressFiles = async (uuid: string, directory: string, files: string[]): Promise => { + const { data } = await http.post(`/api/client/servers/${uuid}/files/compress`, { root: directory, files }, { + timeout: 60000, + timeoutErrorMessage: 'It looks like this archive is taking a long time to generate. It will appear once completed.', + }); + + return rawDataToFileObject(data); +}; + +const copyFiles = (uuid: string, location: string): Promise => { + return new Promise((resolve, reject) => { + http.post(`/api/client/servers/${uuid}/files/copy`, { location }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const createDirectory = (uuid: string, root: string, name: string): Promise => { + return new Promise((resolve, reject) => { + http.post(`/api/client/servers/${uuid}/files/create-folder`, { root, name }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const decompressFiles = async (uuid: string, directory: string, file: string): Promise => { + await http.post(`/api/client/servers/${uuid}/files/decompress`, { root: directory, file }, { + timeout: 300000, + timeoutErrorMessage: 'It looks like this archive is taking a long time to be unarchived. Once completed the unarchived files will appear.', + }); +}; + +const deleteFiles = (uuid: string, directory: string, files: string[]): Promise => { + return new Promise((resolve, reject) => { + http.post(`/api/client/servers/${uuid}/files/delete`, { root: directory, files }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const getFileContents = (server: string, file: string): Promise => { + return new Promise((resolve, reject) => { + http.get(`/api/client/servers/${server}/files/contents`, { + params: { file }, + transformResponse: res => res, + responseType: 'text', + }) + .then(({ data }) => resolve(data)) + .catch(reject); + }); +}; + +const getFileDownloadUrl = (uuid: string, file: string): Promise => { + return new Promise((resolve, reject) => { + http.get(`/api/client/servers/${uuid}/files/download`, { params: { file } }) + .then(({ data }) => resolve(data.attributes.url)) + .catch(reject); + }); +}; + +const getFileUploadUrl = (uuid: string): Promise => { + return new Promise((resolve, reject) => { + http.get(`/api/client/servers/${uuid}/files/upload`) + .then(({ data }) => resolve(data.attributes.url)) + .catch(reject); + }); +}; + +const loadDirectory = async (uuid: string, directory?: string): Promise => { + const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, { + params: { directory: directory ?? '/' }, + }); + + return (data.data || []).map(rawDataToFileObject); +}; + +const pullFile = (uuid: string, directory: string, url: string): Promise => { + return new Promise((resolve, reject) => { + http.post(`/api/client/servers/${uuid}/files/pull`, { root: directory, url }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const renameFiles = (uuid: string, directory: string, files: { from: string; to: string }[]): Promise => { + return new Promise((resolve, reject) => { + http.put(`/api/client/servers/${uuid}/files/rename`, { root: directory, files }) + .then(() => resolve()) + .catch(reject); + }); +}; + +const saveFileContents = async (uuid: string, file: string, content: string): Promise => { + await http.post(`/api/client/servers/${uuid}/files/write`, content, { + params: { file }, + headers: { + 'Content-Type': 'text/plain', + }, + }); +}; + +export { + chmodFiles, + compressFiles, + copyFiles, + createDirectory, + decompressFiles, + deleteFiles, + getFileContents, + getFileDownloadUrl, + getFileUploadUrl, + loadDirectory, + pullFile, + renameFiles, + saveFileContents, +}; diff --git a/resources/scripts/api/server/files/chmodFiles.ts b/resources/scripts/api/server/files/chmodFiles.ts deleted file mode 100644 index 8bafd6d6e..000000000 --- a/resources/scripts/api/server/files/chmodFiles.ts +++ /dev/null @@ -1,14 +0,0 @@ -import http from '@/api/http'; - -interface Data { - file: string; - mode: string; -} - -export default (uuid: string, directory: string, files: Data[]): Promise => { - return new Promise((resolve, reject) => { - http.post(`/api/client/servers/${uuid}/files/chmod`, { root: directory, files }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/compressFiles.ts b/resources/scripts/api/server/files/compressFiles.ts deleted file mode 100644 index 4204f0884..000000000 --- a/resources/scripts/api/server/files/compressFiles.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { FileObject } from '@/api/server/files/loadDirectory'; -import http from '@/api/http'; -import { rawDataToFileObject } from '@/api/transformers'; - -export default async (uuid: string, directory: string, files: string[]): Promise => { - const { data } = await http.post(`/api/client/servers/${uuid}/files/compress`, { root: directory, files }, { - timeout: 60000, - timeoutErrorMessage: 'It looks like this archive is taking a long time to generate. It will appear once completed.', - }); - - return rawDataToFileObject(data); -}; diff --git a/resources/scripts/api/server/files/copyFile.ts b/resources/scripts/api/server/files/copyFile.ts deleted file mode 100644 index b19525c40..000000000 --- a/resources/scripts/api/server/files/copyFile.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string, location: string): Promise => { - return new Promise((resolve, reject) => { - http.post(`/api/client/servers/${uuid}/files/copy`, { location }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/createDirectory.ts b/resources/scripts/api/server/files/createDirectory.ts deleted file mode 100644 index 588868655..000000000 --- a/resources/scripts/api/server/files/createDirectory.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string, root: string, name: string): Promise => { - return new Promise((resolve, reject) => { - http.post(`/api/client/servers/${uuid}/files/create-folder`, { root, name }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/decompressFiles.ts b/resources/scripts/api/server/files/decompressFiles.ts deleted file mode 100644 index d674eadb0..000000000 --- a/resources/scripts/api/server/files/decompressFiles.ts +++ /dev/null @@ -1,8 +0,0 @@ -import http from '@/api/http'; - -export default async (uuid: string, directory: string, file: string): Promise => { - await http.post(`/api/client/servers/${uuid}/files/decompress`, { root: directory, file }, { - timeout: 300000, - timeoutErrorMessage: 'It looks like this archive is taking a long time to be unarchived. Once completed the unarchived files will appear.', - }); -}; diff --git a/resources/scripts/api/server/files/deleteFiles.ts b/resources/scripts/api/server/files/deleteFiles.ts deleted file mode 100644 index 1250463ed..000000000 --- a/resources/scripts/api/server/files/deleteFiles.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string, directory: string, files: string[]): Promise => { - return new Promise((resolve, reject) => { - http.post(`/api/client/servers/${uuid}/files/delete`, { root: directory, files }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/getFileContents.ts b/resources/scripts/api/server/files/getFileContents.ts deleted file mode 100644 index ef25b1dbc..000000000 --- a/resources/scripts/api/server/files/getFileContents.ts +++ /dev/null @@ -1,13 +0,0 @@ -import http from '@/api/http'; - -export default (server: string, file: string): Promise => { - return new Promise((resolve, reject) => { - http.get(`/api/client/servers/${server}/files/contents`, { - params: { file }, - transformResponse: res => res, - responseType: 'text', - }) - .then(({ data }) => resolve(data)) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/getFileDownloadUrl.ts b/resources/scripts/api/server/files/getFileDownloadUrl.ts deleted file mode 100644 index 39db97290..000000000 --- a/resources/scripts/api/server/files/getFileDownloadUrl.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string, file: string): Promise => { - return new Promise((resolve, reject) => { - http.get(`/api/client/servers/${uuid}/files/download`, { params: { file } }) - .then(({ data }) => resolve(data.attributes.url)) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/getFileUploadUrl.ts b/resources/scripts/api/server/files/getFileUploadUrl.ts deleted file mode 100644 index 690e8587c..000000000 --- a/resources/scripts/api/server/files/getFileUploadUrl.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string): Promise => { - return new Promise((resolve, reject) => { - http.get(`/api/client/servers/${uuid}/files/upload`) - .then(({ data }) => resolve(data.attributes.url)) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/loadDirectory.ts b/resources/scripts/api/server/files/loadDirectory.ts deleted file mode 100644 index ba137e285..000000000 --- a/resources/scripts/api/server/files/loadDirectory.ts +++ /dev/null @@ -1,25 +0,0 @@ -import http from '@/api/http'; -import { rawDataToFileObject } from '@/api/transformers'; - -export interface FileObject { - key: string; - name: string; - mode: string; - modeBits: string, - size: number; - isFile: boolean; - isSymlink: boolean; - mimetype: string; - createdAt: Date; - modifiedAt: Date; - isArchiveType: () => boolean; - isEditable: () => boolean; -} - -export default async (uuid: string, directory?: string): Promise => { - const { data } = await http.get(`/api/client/servers/${uuid}/files/list`, { - params: { directory: directory ?? '/' }, - }); - - return (data.data || []).map(rawDataToFileObject); -}; diff --git a/resources/scripts/api/server/files/pullFile.ts b/resources/scripts/api/server/files/pullFile.ts deleted file mode 100644 index f7a021fe4..000000000 --- a/resources/scripts/api/server/files/pullFile.ts +++ /dev/null @@ -1,9 +0,0 @@ -import http from '@/api/http'; - -export default (uuid: string, directory: string, url: string): Promise => { - return new Promise((resolve, reject) => { - http.post(`/api/client/servers/${uuid}/files/pull`, { root: directory, url }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/renameFiles.ts b/resources/scripts/api/server/files/renameFiles.ts deleted file mode 100644 index 53f92c4c3..000000000 --- a/resources/scripts/api/server/files/renameFiles.ts +++ /dev/null @@ -1,14 +0,0 @@ -import http from '@/api/http'; - -interface Data { - to: string; - from: string; -} - -export default (uuid: string, directory: string, files: Data[]): Promise => { - return new Promise((resolve, reject) => { - http.put(`/api/client/servers/${uuid}/files/rename`, { root: directory, files }) - .then(() => resolve()) - .catch(reject); - }); -}; diff --git a/resources/scripts/api/server/files/saveFileContents.ts b/resources/scripts/api/server/files/saveFileContents.ts deleted file mode 100644 index b97e60a6b..000000000 --- a/resources/scripts/api/server/files/saveFileContents.ts +++ /dev/null @@ -1,10 +0,0 @@ -import http from '@/api/http'; - -export default async (uuid: string, file: string, content: string): Promise => { - await http.post(`/api/client/servers/${uuid}/files/write`, content, { - params: { file }, - headers: { - 'Content-Type': 'text/plain', - }, - }); -}; diff --git a/resources/scripts/api/server/getServer.ts b/resources/scripts/api/server/getServer.ts deleted file mode 100644 index d89f9eb9b..000000000 --- a/resources/scripts/api/server/getServer.ts +++ /dev/null @@ -1,3 +0,0 @@ -import * as Models from '@definitions/user/models'; - -export type Allocation = Models.Allocation; diff --git a/resources/scripts/components/server/features/EulaModalFeature.tsx b/resources/scripts/components/server/features/EulaModalFeature.tsx index b1f26f22e..f34971f4a 100644 --- a/resources/scripts/components/server/features/EulaModalFeature.tsx +++ b/resources/scripts/components/server/features/EulaModalFeature.tsx @@ -3,7 +3,7 @@ import { ServerContext } from '@/state/server'; import Modal from '@/components/elements/Modal'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; -import saveFileContents from '@/api/server/files/saveFileContents'; +import { saveFileContents } from '@/api/server/files'; import FlashMessageRender from '@/components/FlashMessageRender'; import useFlash from '@/plugins/useFlash'; import { SocketEvent, SocketRequest } from '@/components/server/events'; diff --git a/resources/scripts/components/server/files/ChmodFileModal.tsx b/resources/scripts/components/server/files/ChmodFileModal.tsx index 43c0289bf..117c5989e 100644 --- a/resources/scripts/components/server/files/ChmodFileModal.tsx +++ b/resources/scripts/components/server/files/ChmodFileModal.tsx @@ -4,7 +4,7 @@ import React from 'react'; import Modal, { RequiredModalProps } from '@/components/elements/Modal'; import { Form, Formik, FormikHelpers } from 'formik'; import Field from '@/components/elements/Field'; -import chmodFiles from '@/api/server/files/chmodFiles'; +import { chmodFiles } from '@/api/server/files'; import { ServerContext } from '@/state/server'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; diff --git a/resources/scripts/components/server/files/FileDropdownMenu.tsx b/resources/scripts/components/server/files/FileDropdownMenu.tsx index a18cccc77..94115827e 100644 --- a/resources/scripts/components/server/files/FileDropdownMenu.tsx +++ b/resources/scripts/components/server/files/FileDropdownMenu.tsx @@ -1,22 +1,29 @@ import React, { memo, useRef, useState } from 'react'; import { FontAwesomeIcon } from '@fortawesome/react-fontawesome'; -import { faBoxOpen, faCopy, faEllipsisH, faFileArchive, faFileCode, faFileDownload, faLevelUpAlt, faPencilAlt, faTrashAlt, IconDefinition } from '@fortawesome/free-solid-svg-icons'; +import { + faBoxOpen, + faCopy, + faEllipsisH, + faFileArchive, + faFileCode, + faFileDownload, + faLevelUpAlt, + faPencilAlt, + faTrashAlt, + IconDefinition, +} from '@fortawesome/free-solid-svg-icons'; import RenameFileModal from '@/components/server/files/RenameFileModal'; import { ServerContext } from '@/state/server'; import { join } from 'path'; -import deleteFiles from '@/api/server/files/deleteFiles'; +import { compressFiles, copyFiles, decompressFiles, deleteFiles, getFileDownloadUrl } from '@/api/server/files'; import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; -import copyFile from '@/api/server/files/copyFile'; import Can from '@/components/elements/Can'; -import getFileDownloadUrl from '@/api/server/files/getFileDownloadUrl'; import useFlash from '@/plugins/useFlash'; import tw, { styled } from 'twin.macro'; import { FileObject } from '@/api/server/files/loadDirectory'; import useFileManagerSwr from '@/plugins/useFileManagerSwr'; import DropdownMenu from '@/components/elements/DropdownMenu'; import useEventListener from '@/plugins/useEventListener'; -import compressFiles from '@/api/server/files/compressFiles'; -import decompressFiles from '@/api/server/files/decompressFiles'; import isEqual from 'react-fast-compare'; import ConfirmationModal from '@/components/elements/ConfirmationModal'; import ChmodFileModal from '@/components/server/files/ChmodFileModal'; @@ -24,8 +31,8 @@ import ChmodFileModal from '@/components/server/files/ChmodFileModal'; type ModalType = 'rename' | 'move' | 'chmod'; const StyledRow = styled.div<{ $danger?: boolean }>` - ${tw`p-2 flex items-center rounded`}; - ${props => props.$danger ? tw`hover:bg-red-100 hover:text-red-700` : tw`hover:bg-neutral-100 hover:text-neutral-700`}; + ${tw`p-2 flex items-center rounded`}; + ${props => props.$danger ? tw`hover:bg-red-100 hover:text-red-700` : tw`hover:bg-neutral-100 hover:text-neutral-700`}; `; interface RowProps extends React.HTMLAttributes { @@ -75,7 +82,7 @@ const FileDropdownMenu = ({ file }: { file: FileObject }) => { setShowSpinner(true); clearFlashes('files'); - copyFile(uuid, join(directory, file.name)) + copyFiles(uuid, join(directory, file.name)) .then(async () => await mutate()) .catch(error => clearAndAddHttpError({ key: 'files', error })) .then(() => setShowSpinner(false)); @@ -172,7 +179,7 @@ const FileDropdownMenu = ({ file }: { file: FileObject }) => { } {file.isFile && - + } setShowConfirmation(true)} icon={faTrashAlt} title={'Delete'} $danger/> diff --git a/resources/scripts/components/server/files/FileEditContainer.tsx b/resources/scripts/components/server/files/FileEditContainer.tsx index 34e7e141c..ddd68e445 100644 --- a/resources/scripts/components/server/files/FileEditContainer.tsx +++ b/resources/scripts/components/server/files/FileEditContainer.tsx @@ -3,8 +3,7 @@ import { useHistory, useLocation, useParams } from 'react-router'; import { dirname } from 'path'; import tw from 'twin.macro'; import { httpErrorToHuman } from '@/api/http'; -import getFileContents from '@/api/server/files/getFileContents'; -import saveFileContents from '@/api/server/files/saveFileContents'; +import { getFileContents, saveFileContents } from '@/api/server/files'; import Can from '@/components/elements/Can'; import Editor, { modes } from '@/components/elements/Editor'; import ErrorBoundary from '@/components/elements/ErrorBoundary'; diff --git a/resources/scripts/components/server/files/MassActionsBar.tsx b/resources/scripts/components/server/files/MassActionsBar.tsx index c9c551d8e..fed9bba59 100644 --- a/resources/scripts/components/server/files/MassActionsBar.tsx +++ b/resources/scripts/components/server/files/MassActionsBar.tsx @@ -7,10 +7,9 @@ import { faFileArchive, faLevelUpAlt, faTrashAlt } from '@fortawesome/free-solid import SpinnerOverlay from '@/components/elements/SpinnerOverlay'; import useFileManagerSwr from '@/plugins/useFileManagerSwr'; import useFlash from '@/plugins/useFlash'; -import compressFiles from '@/api/server/files/compressFiles'; +import { compressFiles, deleteFiles } from '@/api/server/files'; import { ServerContext } from '@/state/server'; import ConfirmationModal from '@/components/elements/ConfirmationModal'; -import deleteFiles from '@/api/server/files/deleteFiles'; import RenameFileModal from '@/components/server/files/RenameFileModal'; const MassActionsBar = () => { @@ -79,11 +78,11 @@ const MassActionsBar = () => { Deleting the file(s) listed below is a permanent operation, you cannot undo this action.
- { selectedFiles.slice(0, 15).map(file => ( + {selectedFiles.slice(0, 15).map(file => (
  • {file}
  • )) } - { selectedFiles.length > 15 && -
  • + {selectedFiles.length - 15} other(s)
  • + {selectedFiles.length > 15 && +
  • + {selectedFiles.length - 15} other(s)
  • }
    diff --git a/resources/scripts/components/server/files/NewDirectoryButton.tsx b/resources/scripts/components/server/files/NewDirectoryButton.tsx index c2bd7f944..14b6d9206 100644 --- a/resources/scripts/components/server/files/NewDirectoryButton.tsx +++ b/resources/scripts/components/server/files/NewDirectoryButton.tsx @@ -5,10 +5,9 @@ import { Form, Formik, FormikHelpers } from 'formik'; import Field from '@/components/elements/Field'; import { join } from 'path'; import { object, string } from 'yup'; -import createDirectory from '@/api/server/files/createDirectory'; +import { createDirectory, FileObject } from '@/api/server/files'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; -import { FileObject } from '@/api/server/files/loadDirectory'; import useFlash from '@/plugins/useFlash'; import useFileManagerSwr from '@/plugins/useFileManagerSwr'; import { WithClassname } from '@/components/types'; diff --git a/resources/scripts/components/server/files/PullFileModal.tsx b/resources/scripts/components/server/files/PullFileModal.tsx index 4dbee41fd..9d2902ae7 100644 --- a/resources/scripts/components/server/files/PullFileModal.tsx +++ b/resources/scripts/components/server/files/PullFileModal.tsx @@ -2,7 +2,7 @@ import { Form, Formik, FormikHelpers } from 'formik'; import React, { useEffect, useState } from 'react'; import tw from 'twin.macro'; import { object, string } from 'yup'; -import pullFile from '@/api/server/files/pullFile'; +import { pullFile, FileObject } from '@/api/server/files'; import { WithClassname } from '@/components/types'; import Button from '@/components/elements/Button'; import Field from '@/components/elements/Field'; @@ -10,7 +10,6 @@ import Modal from '@/components/elements/Modal'; import useFileManagerSwr from '@/plugins/useFileManagerSwr'; import useFlash from '@/plugins/useFlash'; import { ServerContext } from '@/state/server'; -import { FileObject } from '@/api/server/files/loadDirectory'; import FlashMessageRender from '@/components/FlashMessageRender'; import { join } from 'path'; diff --git a/resources/scripts/components/server/files/RenameFileModal.tsx b/resources/scripts/components/server/files/RenameFileModal.tsx index 1ccc8d7e3..c6e6ba792 100644 --- a/resources/scripts/components/server/files/RenameFileModal.tsx +++ b/resources/scripts/components/server/files/RenameFileModal.tsx @@ -3,7 +3,7 @@ import Modal, { RequiredModalProps } from '@/components/elements/Modal'; import { Form, Formik, FormikHelpers } from 'formik'; import Field from '@/components/elements/Field'; import { join } from 'path'; -import renameFiles from '@/api/server/files/renameFiles'; +import { renameFiles } from '@/api/server/files'; import { ServerContext } from '@/state/server'; import tw from 'twin.macro'; import Button from '@/components/elements/Button'; diff --git a/resources/scripts/components/server/files/UploadButton.tsx b/resources/scripts/components/server/files/UploadButton.tsx index 67582129b..5fe9104f3 100644 --- a/resources/scripts/components/server/files/UploadButton.tsx +++ b/resources/scripts/components/server/files/UploadButton.tsx @@ -1,5 +1,5 @@ import axios from 'axios'; -import getFileUploadUrl from '@/api/server/files/getFileUploadUrl'; +import { getFileUploadUrl } from '@/api/server/files'; import tw, { styled } from 'twin.macro'; import Button from '@/components/elements/Button'; import React, { useEffect, useRef, useState } from 'react'; diff --git a/resources/scripts/components/server/network/AllocationRow.tsx b/resources/scripts/components/server/network/AllocationRow.tsx index 27a1b9cb3..32c57ff6a 100644 --- a/resources/scripts/components/server/network/AllocationRow.tsx +++ b/resources/scripts/components/server/network/AllocationRow.tsx @@ -8,9 +8,9 @@ import { Textarea } from '@/components/elements/Input'; import Can from '@/components/elements/Can'; import Button from '@/components/elements/Button'; import GreyRowBox from '@/components/elements/GreyRowBox'; -import { Allocation } from '@/api/server/getServer'; +import { Allocation } from '@definitions/user'; import { debounce } from 'debounce'; -import { setServerAllocationNotes, setPrimaryServerAllocation } from '@/api/server/network'; +import { setPrimaryServerAllocation, setServerAllocationNotes } from '@/api/server/network'; import useFlash from '@/plugins/useFlash'; import { ServerContext } from '@/state/server'; import CopyOnClick from '@/components/elements/CopyOnClick'; diff --git a/resources/scripts/plugins/useFileManagerSwr.ts b/resources/scripts/plugins/useFileManagerSwr.ts index e134cb402..fe61a3c3d 100644 --- a/resources/scripts/plugins/useFileManagerSwr.ts +++ b/resources/scripts/plugins/useFileManagerSwr.ts @@ -1,5 +1,5 @@ import useSWR from 'swr'; -import loadDirectory, { FileObject } from '@/api/server/files/loadDirectory'; +import { loadDirectory, FileObject } from '@/api/server/files'; import { cleanDirectoryPath } from '@/helpers'; import { ServerContext } from '@/state/server';