Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: cleaned code #6

Merged
merged 9 commits into from
Dec 27, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions .prettierrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,16 @@ module.exports = {
trailingComma: 'es5',
singleQuote: true,
printWidth: 90,
importOrder: [
'<THIRD_PARTY_MODULES>',
'^apps/(.*)$',
'^assets/(.*)$',
'^components/(.*)$',
'^contexts/(.*)$',
'^hooks/(.*)$',
'^pages/(.*)$',
'^utils/(.*)$',
'^test-utils/(.*)$',
'^[./]',
],
};
3 changes: 2 additions & 1 deletion jsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,6 @@
"module": "es2015",
"baseUrl": "src"
},
"include": ["src"]
"include": ["src"],
"exclude": ["node_modules"]
}
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@
"@testing-library/react": "^11.1.0",
"@testing-library/react-hooks": "^7.0.2",
"@testing-library/user-event": "^13.5.0",
"@trivago/prettier-plugin-sort-imports": "^3.1.1",
"blob-polyfill": "^6.0.20211015",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-prettier": "^4.0.0",
Expand Down
12 changes: 5 additions & 7 deletions src/apps/AuthenticatedApp.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
import { useState } from 'react';
import { Route, Switch } from 'react-router';
import GlobalAppBar from 'components/GlobalAppBar';
import GlobalNavBar from 'components/GlobalNavBar';
import FilesPage from 'pages/FilesPage';
import FilesListPage from 'pages/FilesListPage';
import { useState } from 'react';
import { Route, Switch } from 'react-router';
import './AuthenticatedApp.scss';
import FileViewerDialog from 'pages/FileViewerDialog';
import PicturesPage from 'pages/PicturesPage';
import FilesPage from 'pages/FilesPage';
import PicturesListPage from 'pages/PicturesListPage';
import PicturesPage from 'pages/PicturesPage';
import './AuthenticatedApp.scss';

export default function AuthenticatedApp() {
const [isExpanded, setIsExpanded] = useState(false);
Expand Down Expand Up @@ -38,7 +37,6 @@ export default function AuthenticatedApp() {
</Switch>
</div>
</div>
<FileViewerDialog />
</div>
);
}
2 changes: 1 addition & 1 deletion src/apps/MainApp.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Switch, Route } from 'react-router-dom';
import LandingPage from 'pages/LandingPage';
import LoginPage from 'pages/LoginPage';
import AuthenticatedApp from './AuthenticatedApp';
import LogoutPage from 'pages/LogoutPage';
import { AuthenticatedPaths } from 'utils/constants';
import AuthenticatedApp from './AuthenticatedApp';

export default function MainApp() {
return (
Expand Down
7 changes: 2 additions & 5 deletions src/apps/__tests__/AuthenticatedApp.test.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,21 @@
import AuthenticatedApp from 'apps/AuthenticatedApp';
import GlobalAppBar from 'components/GlobalAppBar';
import GlobalNavBar from 'components/GlobalNavBar';
import FilesListPage from 'pages/FilesListPage';
import FilesPage from 'pages/FilesPage';
import PicturesListPage from 'pages/PicturesListPage';
import PicturesPage from 'pages/PicturesPage';
import FileViewerDialog from 'pages/FileViewerDialog';
import { act, customRender } from 'test-utils/react';
import GlobalAppBar from 'components/GlobalAppBar';
import GlobalNavBar from 'components/GlobalNavBar';

jest.mock('pages/FilesListPage');
jest.mock('pages/FilesPage');
jest.mock('pages/PicturesListPage');
jest.mock('pages/PicturesPage');
jest.mock('pages/FileViewerDialog');
jest.mock('components/GlobalAppBar');
jest.mock('components/GlobalNavBar');

describe('AuthenticatedApp', () => {
beforeEach(() => {
FileViewerDialog.mockReturnValue(null);
GlobalAppBar.mockReturnValue(null);
GlobalNavBar.mockReturnValue(null);
});
Expand Down
2 changes: 1 addition & 1 deletion src/apps/__tests__/MainApp.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ import MainApp from 'apps/MainApp';
import LandingPage from 'pages/LandingPage';
import LoginPage from 'pages/LoginPage';
import LogoutPage from 'pages/LogoutPage';
import { customRender } from 'test-utils/react';
import { AuthenticatedPaths } from 'utils/constants';
import { customRender } from 'test-utils/react';

jest.mock('pages/LandingPage');
jest.mock('pages/LoginPage');
Expand Down
3 changes: 2 additions & 1 deletion src/components/Breadcrumbs.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Breadcrumbs, Typography } from '@mui/material';
import Breadcrumbs from '@mui/material/Breadcrumbs';
import Typography from '@mui/material/Typography';
import { useMemo } from 'react';
import { Link } from 'react-router-dom';
import { hashRemotePath } from 'utils/remote-paths-url';
Expand Down
12 changes: 8 additions & 4 deletions src/components/FileListTable/ContextMenu.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,14 @@
import { Divider, ListItemIcon, ListItemText, Menu, MenuItem } from '@mui/material';
import FileOpenIcon from '@mui/icons-material/FileOpen';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import DeleteIcon from '@mui/icons-material/Delete';
import DownloadIcon from '@mui/icons-material/Download';
import DriveFileMoveIcon from '@mui/icons-material/DriveFileMove';
import ContentCopyIcon from '@mui/icons-material/ContentCopy';
import DriveFileRenameOutlineIcon from '@mui/icons-material/DriveFileRenameOutline';
import DeleteIcon from '@mui/icons-material/Delete';
import FileOpenIcon from '@mui/icons-material/FileOpen';
import Divider from '@mui/material/Divider';
import ListItemIcon from '@mui/material/ListItemIcon';
import ListItemText from '@mui/material/ListItemText';
import Menu from '@mui/material/Menu';
import MenuItem from '@mui/material/MenuItem';

export default function ContextMenu({
open,
Expand Down
4 changes: 2 additions & 2 deletions src/components/FileListTable/FileIcon.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import FolderIcon from '@mui/icons-material/Folder';
import DescriptionIcon from '@mui/icons-material/Description';
import FolderIcon from '@mui/icons-material/Folder';
import ImageIcon from '@mui/icons-material/Image';
import Icon from '@mui/material/Icon';
import './FileIcon.scss';
import LazyImage from 'components/LazyImage';
import './FileIcon.scss';

export default function FileIcon({ file, iconSize, showPreview }) {
if (file.isDirectory) {
Expand Down
8 changes: 4 additions & 4 deletions src/components/FileListTable/Row.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import cx from 'classnames';
import prettyBytes from 'pretty-bytes';
import PropTypes from 'prop-types';
import { useState } from 'react';
import { Table } from 'semantic-ui-react';
import { ICON_SIZE } from 'utils/constants';
import './Row.scss';
import prettyBytes from 'pretty-bytes';
import { useState } from 'react';
import cx from 'classnames';
import ContextMenu from './ContextMenu';
import FileIcon from './FileIcon';
import './Row.scss';

export default function Row({
file,
Expand Down
4 changes: 2 additions & 2 deletions src/components/FileListTable/__tests__/ContextMenu.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const { customRender } = require('test-utils/react');
const { default: ContextMenu } = require('../ContextMenu');
import { customRender } from 'test-utils/react';
import ContextMenu from '../ContextMenu';

describe('ContextMenu', () => {
it('should match snapshot given it is open', () => {
Expand Down
2 changes: 1 addition & 1 deletion src/components/FileListTable/__tests__/index.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { customRender } from 'test-utils/react';
import FileListTable from '../index';
import Row from '../Row';
import FileListTable from '../index';

jest.mock('../Row');

Expand Down
4 changes: 2 additions & 2 deletions src/components/FileListTableSkeleton.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Table } from 'semantic-ui-react';
import PropTypes from 'prop-types';
import Skeleton from '@mui/material/Skeleton';
import PropTypes from 'prop-types';
import { Table } from 'semantic-ui-react';
import './FileListTableSkeleton.scss';

export default function FileListTableSkeleton({ numRows }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Document, Page } from 'react-pdf/dist/umd/entry.webpack';
import { useState } from 'react';
import 'react-pdf/dist/umd/Page/AnnotationLayer.css';
import { Document, Page } from 'react-pdf/dist/umd/entry.webpack';
import './PDFDialogContent.scss';

export default function PDFDialogContent({ fileUrl }) {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { DialogContent, DialogContentText } from '@mui/material';
import DialogContent from '@mui/material/DialogContent';
import DialogContentText from '@mui/material/DialogContentText';
import { useState, useEffect } from 'react';
import './TextDialogContent.scss';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ exports[`FileViewerDialog should match snapshot and download file when fileInfo
/>
<div
class="MuiModal-root fileviewer-dialog__root MuiDialog-root fileviewer-dialog css-zw3mfo-MuiModal-root-MuiDialog-root"
data-testid="fileviewer-dialog"
role="presentation"
>
<div
Expand Down Expand Up @@ -102,6 +103,26 @@ exports[`FileViewerDialog should match snapshot and download file when fileInfo
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium fileviewer-dialog__header-content css-i4bv87-MuiSvgIcon-root"
data-testid="close-button"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
<img
Expand All @@ -127,6 +148,7 @@ exports[`FileViewerDialog should match snapshot when api is not resolved yet 1`]
/>
<div
class="MuiModal-root fileviewer-dialog__root MuiDialog-root fileviewer-dialog css-zw3mfo-MuiModal-root-MuiDialog-root"
data-testid="fileviewer-dialog"
role="presentation"
>
<div
Expand Down Expand Up @@ -220,6 +242,26 @@ exports[`FileViewerDialog should match snapshot when api is not resolved yet 1`]
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium fileviewer-dialog__header-content css-i4bv87-MuiSvgIcon-root"
data-testid="close-button"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
<div
Expand Down Expand Up @@ -264,6 +306,7 @@ exports[`FileViewerDialog should match snapshot when fileInfo is an unknown file
/>
<div
class="MuiModal-root fileviewer-dialog__root MuiDialog-root fileviewer-dialog css-zw3mfo-MuiModal-root-MuiDialog-root"
data-testid="fileviewer-dialog"
role="presentation"
>
<div
Expand Down Expand Up @@ -357,6 +400,26 @@ exports[`FileViewerDialog should match snapshot when fileInfo is an unknown file
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium fileviewer-dialog__header-content css-i4bv87-MuiSvgIcon-root"
data-testid="close-button"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
<div
Expand Down Expand Up @@ -401,6 +464,7 @@ exports[`FileViewerDialog should match snapshot when user zooms into the dialog
/>
<div
class="MuiModal-root fileviewer-dialog__root MuiDialog-root fileviewer-dialog css-zw3mfo-MuiModal-root-MuiDialog-root"
data-testid="fileviewer-dialog"
role="presentation"
>
<div
Expand Down Expand Up @@ -503,6 +567,26 @@ exports[`FileViewerDialog should match snapshot when user zooms into the dialog
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium fileviewer-dialog__header-content css-i4bv87-MuiSvgIcon-root"
data-testid="close-button"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
<div
Expand Down Expand Up @@ -547,6 +631,7 @@ exports[`FileViewerDialog should match snapshot when user zooms out of the dialo
/>
<div
class="MuiModal-root fileviewer-dialog__root MuiDialog-root fileviewer-dialog css-zw3mfo-MuiModal-root-MuiDialog-root"
data-testid="fileviewer-dialog"
role="presentation"
>
<div
Expand Down Expand Up @@ -649,6 +734,26 @@ exports[`FileViewerDialog should match snapshot when user zooms out of the dialo
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
<button
class="MuiButtonBase-root MuiIconButton-root MuiIconButton-sizeMedium css-78trlr-MuiButtonBase-root-MuiIconButton-root"
tabindex="0"
type="button"
>
<svg
aria-hidden="true"
class="MuiSvgIcon-root MuiSvgIcon-fontSizeMedium fileviewer-dialog__header-content css-i4bv87-MuiSvgIcon-root"
data-testid="close-button"
focusable="false"
viewBox="0 0 24 24"
>
<path
d="M19 6.41 17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z"
/>
</svg>
<span
class="MuiTouchRipple-root css-8je8zh-MuiTouchRipple-root"
/>
</button>
</div>
</div>
<div
Expand Down
Loading