Update missed deps
This commit is contained in:
parent
097d308ccd
commit
3d266ba41e
5 changed files with 52 additions and 56 deletions
|
@ -1,5 +1,4 @@
|
||||||
import http from '@/api/http';
|
import http, { FractalResponseData } from '@/api/http';
|
||||||
import { rawDataToFileObject } from '@/api/transformers';
|
|
||||||
|
|
||||||
export interface FileObject {
|
export interface FileObject {
|
||||||
key: string;
|
key: string;
|
||||||
|
@ -16,6 +15,49 @@ export interface FileObject {
|
||||||
isEditable: () => boolean;
|
isEditable: () => boolean;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
||||||
|
key: `${data.attributes.is_file ? 'file' : 'dir'}_${data.attributes.name}`,
|
||||||
|
name: data.attributes.name,
|
||||||
|
mode: data.attributes.mode,
|
||||||
|
modeBits: data.attributes.mode_bits,
|
||||||
|
size: Number(data.attributes.size),
|
||||||
|
isFile: data.attributes.is_file,
|
||||||
|
isSymlink: data.attributes.is_symlink,
|
||||||
|
mimetype: data.attributes.mimetype,
|
||||||
|
createdAt: new Date(data.attributes.created_at),
|
||||||
|
modifiedAt: new Date(data.attributes.modified_at),
|
||||||
|
|
||||||
|
isArchiveType: function () {
|
||||||
|
return this.isFile && [
|
||||||
|
'application/vnd.rar', // .rar
|
||||||
|
'application/x-rar-compressed', // .rar (2)
|
||||||
|
'application/x-tar', // .tar
|
||||||
|
'application/x-br', // .tar.br
|
||||||
|
'application/x-bzip2', // .tar.bz2, .bz2
|
||||||
|
'application/gzip', // .tar.gz, .gz
|
||||||
|
'application/x-gzip',
|
||||||
|
'application/x-lzip', // .tar.lz4, .lz4 (not sure if this mime type is correct)
|
||||||
|
'application/x-sz', // .tar.sz, .sz (not sure if this mime type is correct)
|
||||||
|
'application/x-xz', // .tar.xz, .xz
|
||||||
|
'application/zstd', // .tar.zst, .zst
|
||||||
|
'application/zip', // .zip
|
||||||
|
].indexOf(this.mimetype) >= 0;
|
||||||
|
},
|
||||||
|
|
||||||
|
isEditable: function () {
|
||||||
|
if (this.isArchiveType() || !this.isFile) return false;
|
||||||
|
|
||||||
|
const matches = [
|
||||||
|
'application/jar',
|
||||||
|
'application/octet-stream',
|
||||||
|
'inode/directory',
|
||||||
|
/^image\//,
|
||||||
|
];
|
||||||
|
|
||||||
|
return matches.every(m => !this.mimetype.match(m));
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
const chmodFiles = (uuid: string, directory: string, files: { file: string; mode: string }[]): Promise<void> => {
|
const chmodFiles = (uuid: string, directory: string, files: { file: string; mode: string }[]): Promise<void> => {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
http.post(`/api/client/servers/${uuid}/files/chmod`, { root: directory, files })
|
http.post(`/api/client/servers/${uuid}/files/chmod`, { root: directory, files })
|
||||||
|
|
|
@ -1,48 +0,0 @@
|
||||||
import { FractalResponseData } from '@/api/http';
|
|
||||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
|
||||||
import { Transformers } from '@definitions/user';
|
|
||||||
|
|
||||||
export const rawDataToFileObject = (data: FractalResponseData): FileObject => ({
|
|
||||||
key: `${data.attributes.is_file ? 'file' : 'dir'}_${data.attributes.name}`,
|
|
||||||
name: data.attributes.name,
|
|
||||||
mode: data.attributes.mode,
|
|
||||||
modeBits: data.attributes.mode_bits,
|
|
||||||
size: Number(data.attributes.size),
|
|
||||||
isFile: data.attributes.is_file,
|
|
||||||
isSymlink: data.attributes.is_symlink,
|
|
||||||
mimetype: data.attributes.mimetype,
|
|
||||||
createdAt: new Date(data.attributes.created_at),
|
|
||||||
modifiedAt: new Date(data.attributes.modified_at),
|
|
||||||
|
|
||||||
isArchiveType: function () {
|
|
||||||
return this.isFile && [
|
|
||||||
'application/vnd.rar', // .rar
|
|
||||||
'application/x-rar-compressed', // .rar (2)
|
|
||||||
'application/x-tar', // .tar
|
|
||||||
'application/x-br', // .tar.br
|
|
||||||
'application/x-bzip2', // .tar.bz2, .bz2
|
|
||||||
'application/gzip', // .tar.gz, .gz
|
|
||||||
'application/x-gzip',
|
|
||||||
'application/x-lzip', // .tar.lz4, .lz4 (not sure if this mime type is correct)
|
|
||||||
'application/x-sz', // .tar.sz, .sz (not sure if this mime type is correct)
|
|
||||||
'application/x-xz', // .tar.xz, .xz
|
|
||||||
'application/zstd', // .tar.zst, .zst
|
|
||||||
'application/zip', // .zip
|
|
||||||
].indexOf(this.mimetype) >= 0;
|
|
||||||
},
|
|
||||||
|
|
||||||
isEditable: function () {
|
|
||||||
if (this.isArchiveType() || !this.isFile) return false;
|
|
||||||
|
|
||||||
const matches = [
|
|
||||||
'application/jar',
|
|
||||||
'application/octet-stream',
|
|
||||||
'inode/directory',
|
|
||||||
/^image\//,
|
|
||||||
];
|
|
||||||
|
|
||||||
return matches.every(m => !this.mimetype.match(m));
|
|
||||||
},
|
|
||||||
});
|
|
||||||
|
|
||||||
export const rawDataToServerAllocation = Transformers.toServerAllocation;
|
|
|
@ -15,12 +15,11 @@ import {
|
||||||
import RenameFileModal from '@/components/server/files/RenameFileModal';
|
import RenameFileModal from '@/components/server/files/RenameFileModal';
|
||||||
import { ServerContext } from '@/state/server';
|
import { ServerContext } from '@/state/server';
|
||||||
import { join } from 'path';
|
import { join } from 'path';
|
||||||
import { compressFiles, copyFiles, decompressFiles, deleteFiles, getFileDownloadUrl } from '@/api/server/files';
|
import { compressFiles, copyFiles, decompressFiles, deleteFiles, getFileDownloadUrl, FileObject } from '@/api/server/files';
|
||||||
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
import SpinnerOverlay from '@/components/elements/SpinnerOverlay';
|
||||||
import Can from '@/components/elements/Can';
|
import Can from '@/components/elements/Can';
|
||||||
import useFlash from '@/plugins/useFlash';
|
import useFlash from '@/plugins/useFlash';
|
||||||
import tw, { styled } from 'twin.macro';
|
import tw, { styled } from 'twin.macro';
|
||||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
|
||||||
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
|
import useFileManagerSwr from '@/plugins/useFileManagerSwr';
|
||||||
import DropdownMenu from '@/components/elements/DropdownMenu';
|
import DropdownMenu from '@/components/elements/DropdownMenu';
|
||||||
import useEventListener from '@/plugins/useEventListener';
|
import useEventListener from '@/plugins/useEventListener';
|
||||||
|
|
|
@ -4,7 +4,7 @@ import { CSSTransition } from 'react-transition-group';
|
||||||
import Spinner from '@/components/elements/Spinner';
|
import Spinner from '@/components/elements/Spinner';
|
||||||
import FileObjectRow from '@/components/server/files/FileObjectRow';
|
import FileObjectRow from '@/components/server/files/FileObjectRow';
|
||||||
import FileManagerBreadcrumbs from '@/components/server/files/FileManagerBreadcrumbs';
|
import FileManagerBreadcrumbs from '@/components/server/files/FileManagerBreadcrumbs';
|
||||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
import { FileObject } from '@/api/server/files';
|
||||||
import NewDirectoryButton from '@/components/server/files/NewDirectoryButton';
|
import NewDirectoryButton from '@/components/server/files/NewDirectoryButton';
|
||||||
import { NavLink, useLocation } from 'react-router-dom';
|
import { NavLink, useLocation } from 'react-router-dom';
|
||||||
import Can from '@/components/elements/Can';
|
import Can from '@/components/elements/Can';
|
||||||
|
|
|
@ -3,7 +3,7 @@ import { faFileAlt, faFileArchive, faFileImport, faFolder } from '@fortawesome/f
|
||||||
import { bytesToHuman, encodePathSegments } from '@/helpers';
|
import { bytesToHuman, encodePathSegments } from '@/helpers';
|
||||||
import { differenceInHours, format, formatDistanceToNow } from 'date-fns';
|
import { differenceInHours, format, formatDistanceToNow } from 'date-fns';
|
||||||
import React, { memo } from 'react';
|
import React, { memo } from 'react';
|
||||||
import { FileObject } from '@/api/server/files/loadDirectory';
|
import { FileObject } from '@/api/server/files';
|
||||||
import FileDropdownMenu from '@/components/server/files/FileDropdownMenu';
|
import FileDropdownMenu from '@/components/server/files/FileDropdownMenu';
|
||||||
import { ServerContext } from '@/state/server';
|
import { ServerContext } from '@/state/server';
|
||||||
import { NavLink, useRouteMatch } from 'react-router-dom';
|
import { NavLink, useRouteMatch } from 'react-router-dom';
|
||||||
|
@ -70,7 +70,10 @@ const FileObjectRow = ({ file }: { file: FileObject }) => (
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<div css={tw`hidden w-48 md:flex`}>
|
<div css={tw`hidden w-48 md:flex`}>
|
||||||
<span css={tw`ml-auto text-sm font-normal leading-none text-right text-neutral-300`} title={file.modifiedAt.toString()}>
|
<span
|
||||||
|
css={tw`ml-auto text-sm font-normal leading-none text-right text-neutral-300`}
|
||||||
|
title={file.modifiedAt.toString()}
|
||||||
|
>
|
||||||
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
|
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
|
||||||
format(file.modifiedAt, 'MMM do, yyyy h:mma')
|
format(file.modifiedAt, 'MMM do, yyyy h:mma')
|
||||||
:
|
:
|
||||||
|
|
Loading…
Reference in a new issue