Apply new eslint rules; default to prettier for styling
This commit is contained in:
parent
f22cce8881
commit
dc84af9937
218 changed files with 3876 additions and 3564 deletions
|
@ -20,63 +20,53 @@ const Row = styled.div`
|
|||
`;
|
||||
|
||||
const Clickable: React.FC<{ file: FileObject }> = memo(({ file, children }) => {
|
||||
const [ canReadContents ] = usePermissions([ 'file.read-content' ]);
|
||||
const directory = ServerContext.useStoreState(state => state.files.directory);
|
||||
const [canReadContents] = usePermissions(['file.read-content']);
|
||||
const directory = ServerContext.useStoreState((state) => state.files.directory);
|
||||
|
||||
const match = useRouteMatch();
|
||||
|
||||
return (
|
||||
(!canReadContents || (file.isFile && !file.isEditable())) ?
|
||||
<div css={tw`flex flex-1 text-neutral-300 no-underline p-3 cursor-default overflow-hidden truncate`}>
|
||||
{children}
|
||||
</div>
|
||||
:
|
||||
<NavLink
|
||||
to={`${match.url}${file.isFile ? '/edit' : ''}#${encodePathSegments(join(directory, file.name))}`}
|
||||
css={tw`flex flex-1 text-neutral-300 no-underline p-3 overflow-hidden truncate`}
|
||||
>
|
||||
{children}
|
||||
</NavLink>
|
||||
return !canReadContents || (file.isFile && !file.isEditable()) ? (
|
||||
<div css={tw`flex flex-1 text-neutral-300 no-underline p-3 cursor-default overflow-hidden truncate`}>
|
||||
{children}
|
||||
</div>
|
||||
) : (
|
||||
<NavLink
|
||||
to={`${match.url}${file.isFile ? '/edit' : ''}#${encodePathSegments(join(directory, file.name))}`}
|
||||
css={tw`flex flex-1 text-neutral-300 no-underline p-3 overflow-hidden truncate`}
|
||||
>
|
||||
{children}
|
||||
</NavLink>
|
||||
);
|
||||
}, isEqual);
|
||||
|
||||
const FileObjectRow = ({ file }: { file: FileObject }) => (
|
||||
<Row
|
||||
key={file.name}
|
||||
onContextMenu={e => {
|
||||
onContextMenu={(e) => {
|
||||
e.preventDefault();
|
||||
window.dispatchEvent(new CustomEvent(`pterodactyl:files:ctx:${file.key}`, { detail: e.clientX }));
|
||||
}}
|
||||
>
|
||||
<SelectFileCheckbox name={file.name}/>
|
||||
<SelectFileCheckbox name={file.name} />
|
||||
<Clickable file={file}>
|
||||
<div css={tw`flex-none self-center text-neutral-400 ml-6 mr-4 text-lg pl-3`}>
|
||||
{file.isFile ?
|
||||
<FontAwesomeIcon icon={file.isSymlink ? faFileImport : file.isArchiveType() ? faFileArchive : faFileAlt}/>
|
||||
:
|
||||
<FontAwesomeIcon icon={faFolder}/>
|
||||
}
|
||||
{file.isFile ? (
|
||||
<FontAwesomeIcon
|
||||
icon={file.isSymlink ? faFileImport : file.isArchiveType() ? faFileArchive : faFileAlt}
|
||||
/>
|
||||
) : (
|
||||
<FontAwesomeIcon icon={faFolder} />
|
||||
)}
|
||||
</div>
|
||||
<div css={tw`flex-1 truncate`}>
|
||||
{file.name}
|
||||
</div>
|
||||
{file.isFile &&
|
||||
<div css={tw`w-1/6 text-right mr-4 hidden sm:block`}>
|
||||
{bytesToString(file.size)}
|
||||
</div>
|
||||
}
|
||||
<div
|
||||
css={tw`w-1/5 text-right mr-4 hidden md:block`}
|
||||
title={file.modifiedAt.toString()}
|
||||
>
|
||||
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48 ?
|
||||
format(file.modifiedAt, 'MMM do, yyyy h:mma')
|
||||
:
|
||||
formatDistanceToNow(file.modifiedAt, { addSuffix: true })
|
||||
}
|
||||
<div css={tw`flex-1 truncate`}>{file.name}</div>
|
||||
{file.isFile && <div css={tw`w-1/6 text-right mr-4 hidden sm:block`}>{bytesToString(file.size)}</div>}
|
||||
<div css={tw`w-1/5 text-right mr-4 hidden md:block`} title={file.modifiedAt.toString()}>
|
||||
{Math.abs(differenceInHours(file.modifiedAt, new Date())) > 48
|
||||
? format(file.modifiedAt, 'MMM do, yyyy h:mma')
|
||||
: formatDistanceToNow(file.modifiedAt, { addSuffix: true })}
|
||||
</div>
|
||||
</Clickable>
|
||||
<FileDropdownMenu file={file}/>
|
||||
<FileDropdownMenu file={file} />
|
||||
</Row>
|
||||
);
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue