Skip to content

Commit addaeb2

Browse files
committed
eslint
1 parent 68dd53f commit addaeb2

File tree

7 files changed

+140
-98
lines changed

7 files changed

+140
-98
lines changed

src/main/webapp/ui/src/eln/gallery/components/ActionsMenu.js

+85-57
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,12 @@ import FolderOpenIcon from "@mui/icons-material/FolderOpen";
1818
import VisibilityIcon from "@mui/icons-material/Visibility";
1919
import { observer } from "mobx-react-lite";
2020
import { computed } from "mobx";
21-
import { type GalleryFile, idToString, type Id, Filestore } from "../useGalleryListing";
21+
import {
22+
type GalleryFile,
23+
idToString,
24+
type Id,
25+
Filestore,
26+
} from "../useGalleryListing";
2227
import { useGalleryActions } from "../useGalleryActions";
2328
import { useGallerySelection } from "../useGallerySelection";
2429
import Dialog from "@mui/material/Dialog";
@@ -452,9 +457,15 @@ function ActionsMenu({
452457
const logOutAllowed = computed((): Result<Filestore> => {
453458
return selection
454459
.asSet()
455-
.only.toResult(() => new Error("Only one item may be logged out of at once."))
460+
.only.toResult(
461+
() => new Error("Only one item may be logged out of at once.")
462+
)
456463
.flatMapDiscarding((file) => file.canBeLoggedOutOf)
457-
.flatMap((f: GalleryFile) => f instanceof Filestore ? Result.Ok(f) : Result.Error([new Error("Cannot log out of this item.")]));
464+
.flatMap((f: GalleryFile) =>
465+
f instanceof Filestore
466+
? Result.Ok(f)
467+
: Result.Error([new Error("Cannot log out of this item.")])
468+
);
458469
});
459470
const { logout } = useFilestoresEndpoint();
460471

@@ -695,28 +706,35 @@ function ActionsMenu({
695706
disabled={exportAllowed.get().isError}
696707
/>
697708
<EventBoundary>
698-
{Result.all(...selection.asSet().toArray().map(({ id }) => idToString(id))).map(exportIds => (
699-
<ExportDialog
700-
open={exportOpen}
701-
onClose={() => {
702-
setExportOpen(false);
703-
setActionsMenuAnchorEl(null);
704-
}}
705-
exportSelection={{
706-
type: "selection",
707-
exportTypes: selection
708-
.asSet()
709-
.toArray()
710-
.map((f) => (f.isFolder ? "FOLDER" : "MEDIA_FILE")),
711-
exportNames: selection
712-
.asSet()
713-
.toArray()
714-
.map(({ name }) => name),
715-
exportIds,
716-
}}
717-
allowFileStores={false}
718-
/>
719-
)).orElse(null)}
709+
{Result.all(
710+
...selection
711+
.asSet()
712+
.toArray()
713+
.map(({ id }) => idToString(id))
714+
)
715+
.map((exportIds) => (
716+
<ExportDialog
717+
open={exportOpen}
718+
onClose={() => {
719+
setExportOpen(false);
720+
setActionsMenuAnchorEl(null);
721+
}}
722+
exportSelection={{
723+
type: "selection",
724+
exportTypes: selection
725+
.asSet()
726+
.toArray()
727+
.map((f) => (f.isFolder ? "FOLDER" : "MEDIA_FILE")),
728+
exportNames: selection
729+
.asSet()
730+
.toArray()
731+
.map(({ name }) => name),
732+
exportIds,
733+
}}
734+
allowFileStores={false}
735+
/>
736+
))
737+
.orElse(null)}
720738
</EventBoundary>
721739
<AccentMenuItem
722740
title="Move to iRODS"
@@ -734,44 +752,54 @@ function ActionsMenu({
734752
disabled={moveToIrodsAllowed.get().isError}
735753
aria-haspopup="dialog"
736754
/>
737-
{Result.all(...selection.asSet().toArray().map(({ id }) => idToString(id))).map(selectedIds => (
738-
<MoveToIrods
739-
selectedIds={selectedIds}
740-
dialogOpen={irodsOpen}
741-
setDialogOpen={(newState) => {
742-
setIrodsOpen(newState);
743-
if (!newState) {
744-
setActionsMenuAnchorEl(null);
745-
void refreshListing();
746-
}
747-
}}
748-
/>
749-
)).orElse(null)}
755+
{Result.all(
756+
...selection
757+
.asSet()
758+
.toArray()
759+
.map(({ id }) => idToString(id))
760+
)
761+
.map((selectedIds) => (
762+
<MoveToIrods
763+
selectedIds={selectedIds}
764+
dialogOpen={irodsOpen}
765+
setDialogOpen={(newState) => {
766+
setIrodsOpen(newState);
767+
if (!newState) {
768+
setActionsMenuAnchorEl(null);
769+
void refreshListing();
770+
}
771+
}}
772+
/>
773+
))
774+
.orElse(null)}
750775
<Divider aria-orientation="horizontal" />
751776
{/*
752777
* We hide the log out option rather than disabling it because it
753778
* is only available for filestores so doesn't apply in the vast,
754779
* vast majority of cases.
755780
*/}
756-
{logOutAllowed.get().map(filestore => (
757-
<AccentMenuItem
758-
title="Log Out"
759-
subheader={logOutAllowed
760-
.get()
761-
.map(() => "")
762-
.orElseGet(([e]) => e.message)}
763-
backgroundColor={lighten(theme.palette.warning.light, 0.5)}
764-
foregroundColor={darken(theme.palette.warning.dark, 0.3)}
765-
avatar={<LogoutIcon />}
766-
onClick={() => {
767-
void logout(filestore).then(() => {
768-
void refreshListing();
769-
setActionsMenuAnchorEl(null);
770-
});
771-
}}
772-
compact
773-
/>
774-
)).orElse(null)}
781+
{logOutAllowed
782+
.get()
783+
.map((filestore) => (
784+
<AccentMenuItem
785+
title="Log Out"
786+
subheader={logOutAllowed
787+
.get()
788+
.map(() => "")
789+
.orElseGet(([e]) => e.message)}
790+
backgroundColor={lighten(theme.palette.warning.light, 0.5)}
791+
foregroundColor={darken(theme.palette.warning.dark, 0.3)}
792+
avatar={<LogoutIcon />}
793+
onClick={() => {
794+
void logout(filestore).then(() => {
795+
void refreshListing();
796+
setActionsMenuAnchorEl(null);
797+
});
798+
}}
799+
compact
800+
/>
801+
))
802+
.orElse(null)}
775803
<AccentMenuItem
776804
title="Delete"
777805
subheader={deleteAllowed

src/main/webapp/ui/src/eln/gallery/components/CallableAsposePreview.js

+7-2
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,9 @@ export function CallableAsposePreview({
7171
setLoading(true);
7272
try {
7373
const { data } = await axios.get<mixed>(
74-
"/Streamfile/ajax/convert/" + idToString(file.id).elseThrow() + "?outputFormat=pdf"
74+
"/Streamfile/ajax/convert/" +
75+
idToString(file.id).elseThrow() +
76+
"?outputFormat=pdf"
7577
);
7678
const fileName = Parsers.isObject(data)
7779
.flatMap(Parsers.isNotNull)
@@ -80,7 +82,10 @@ export function CallableAsposePreview({
8082
.orElse(null);
8183
if (fileName) {
8284
openPdfPreview(
83-
"/Streamfile/direct/" + idToString(file.id).elseThrow() + "?fileName=" + fileName
85+
"/Streamfile/direct/" +
86+
idToString(file.id).elseThrow() +
87+
"?fileName=" +
88+
fileName
8489
);
8590
} else {
8691
Parsers.isObject(data)

src/main/webapp/ui/src/eln/gallery/components/MainPanel.js

+2-5
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import CardActionArea from "@mui/material/CardActionArea";
2626
import Avatar from "@mui/material/Avatar";
2727
import BrokenImageIcon from "@mui/icons-material/BrokenImage";
2828
import * as FetchingData from "../../../util/fetchingData";
29-
import { type GalleryFile, type Id, idToString } from "../useGalleryListing";
29+
import { type GalleryFile, type Id } from "../useGalleryListing";
3030
import {
3131
useGalleryActions,
3232
folderDestination,
@@ -1735,10 +1735,7 @@ function GalleryMainPanel({
17351735
* new info panel when the selection changes to reset any
17361736
* modified state.
17371737
*/
1738-
<InfoPanelForSmallViewports
1739-
key={file.key}
1740-
file={file}
1741-
/>
1738+
<InfoPanelForSmallViewports key={file.key} file={file} />
17421739
))
17431740
.orElse(null)}
17441741
</Grid>

src/main/webapp/ui/src/eln/gallery/components/TreeView.js

+1-5
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,7 @@ import Avatar from "@mui/material/Avatar";
1212
import FileIcon from "@mui/icons-material/InsertDriveFile";
1313
import * as FetchingData from "../../../util/fetchingData";
1414
import * as MapUtils from "../../../util/MapUtils";
15-
import {
16-
useGalleryListing,
17-
type GalleryFile,
18-
idToString,
19-
} from "../useGalleryListing";
15+
import { useGalleryListing, type GalleryFile } from "../useGalleryListing";
2016
import { useGalleryActions, folderDestination } from "../useGalleryActions";
2117
import { useGallerySelection, GallerySelection } from "../useGallerySelection";
2218
import { doNotAwait } from "../../../util/Util";

src/main/webapp/ui/src/eln/gallery/index.js

+12-10
Original file line numberDiff line numberDiff line change
@@ -100,15 +100,15 @@ const WholePage = styled(
100100
const selection = useGallerySelection();
101101
React.useEffect(() => {
102102
try {
103-
FetchingData.getSuccessValue(galleryListing).do((listing) => {
104-
if (listing.tag === "empty") return;
105-
for (const f of new RsSet(listing.list).intersectionMap(
106-
({ id }) => idToString(id).elseThrow(),
107-
new RsSet(autoSelect ?? []).map((id) => `${id}`)
108-
)) {
109-
selection.append(f);
110-
}
111-
});
103+
FetchingData.getSuccessValue(galleryListing).do((listing) => {
104+
if (listing.tag === "empty") return;
105+
for (const f of new RsSet(listing.list).intersectionMap(
106+
({ id }) => idToString(id).elseThrow(),
107+
new RsSet(autoSelect ?? []).map((id) => `${id}`)
108+
)) {
109+
selection.append(f);
110+
}
111+
});
112112
} catch (e) {
113113
/*
114114
* This will throw when processing files from external filestores that
@@ -159,7 +159,9 @@ const WholePage = styled(
159159
}
160160
if (newPath.length > 0) {
161161
navigate(
162-
`/gallery/${idToString(newPath[newPath.length - 1].id).elseThrow()}`
162+
`/gallery/${idToString(
163+
newPath[newPath.length - 1].id
164+
).elseThrow()}`
163165
);
164166
} else {
165167
try {

src/main/webapp/ui/src/eln/gallery/useFilestoresEndpoint.js

+27-17
Original file line numberDiff line numberDiff line change
@@ -1,32 +1,42 @@
11
//@flow
22

3-
import React from 'react';
4-
import axios from 'axios';
3+
import React from "react";
4+
import axios from "axios";
55
import useOauthToken from "../../common/useOauthToken";
6-
import { type Filestore, idToString } from "./useGalleryListing";
6+
import { type Filestore } from "./useGalleryListing";
77
import AlertContext, { mkAlert } from "../../stores/contexts/Alert";
88

9-
export default function useFilestoresEndpoint(): {| logout: (Filestore) => Promise<void> |} {
9+
export default function useFilestoresEndpoint(): {|
10+
logout: (Filestore) => Promise<void>,
11+
|} {
1012
const { getToken } = useOauthToken();
1113
const { addAlert } = React.useContext(AlertContext);
1214

1315
const logout = async (filestore: Filestore) => {
1416
try {
15-
await axios.post<_, mixed>(`/api/v1/gallery/filesystems/${filestore.filesystemId}/logout`, {}, {
16-
headers: {
17-
Authorization: `Bearer ${await getToken()}`,
18-
},
19-
});
20-
addAlert(mkAlert({
21-
variant: "success",
22-
message: `Logged out of ${filestore.name}`,
23-
}));
17+
await axios.post<_, mixed>(
18+
`/api/v1/gallery/filesystems/${filestore.filesystemId}/logout`,
19+
{},
20+
{
21+
headers: {
22+
Authorization: `Bearer ${await getToken()}`,
23+
},
24+
}
25+
);
26+
addAlert(
27+
mkAlert({
28+
variant: "success",
29+
message: `Logged out of ${filestore.name}`,
30+
})
31+
);
2432
} catch (e) {
2533
console.error(e);
26-
addAlert(mkAlert({
27-
variant: "error",
28-
message: `Failed to log out of ${filestore.name}`,
29-
}));
34+
addAlert(
35+
mkAlert({
36+
variant: "error",
37+
message: `Failed to log out of ${filestore.name}`,
38+
})
39+
);
3040
}
3141
};
3242

src/main/webapp/ui/src/eln/gallery/useGalleryActions.js

+6-2
Original file line numberDiff line numberDiff line change
@@ -327,7 +327,9 @@ export function useGalleryActions(): {|
327327
const formData = new FormData();
328328
formData.append(
329329
"target",
330-
destination.key === "root" ? "0" : idToString(destination.folder.id).elseThrow()
330+
destination.key === "root"
331+
? "0"
332+
: idToString(destination.folder.id).elseThrow()
331333
);
332334
for (const file of files)
333335
formData.append("filesId[]", idToString(file.id).elseThrow());
@@ -433,7 +435,9 @@ export function useGalleryActions(): {|
433435
},
434436
});
435437
try {
436-
await api.delete<mixed>(`filestores/${idToString(filestore.id).elseThrow()}`);
438+
await api.delete<mixed>(
439+
`filestores/${idToString(filestore.id).elseThrow()}`
440+
);
437441
addAlert(
438442
mkAlert({
439443
message: "Successfully deleted filestore.",

0 commit comments

Comments
 (0)