Skip to content

Commit a503bf3

Browse files
committed
more editing documents
1 parent f40519d commit a503bf3

File tree

1 file changed

+22
-14
lines changed

1 file changed

+22
-14
lines changed

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

+22-14
Original file line numberDiff line numberDiff line change
@@ -315,26 +315,27 @@ function ActionsMenu({
315315
.only.toResult(() => new Error("Too many items selected."))
316316
.flatMap<
317317
| {| key: "image", downloadHref: () => Promise<URL> |}
318-
| {| key: "document", url: string |}
318+
| {| key: "collabora", url: string |}
319+
| {| key: "officeonline", url: string |}
319320
>((file) => {
320321
if (file.isImage && typeof file.downloadHref !== "undefined")
321322
return Result.Ok({ key: "image", downloadHref: file.downloadHref });
322323
return canEditWithCollabora(file)
323-
.orElseTry(() => canEditWithOfficeOnline(file))
324-
.map<
325-
Result<
324+
.map((url) => ({
325+
key: "collabora",
326+
url,
327+
}))
328+
.orElseTry(() =>
329+
canEditWithOfficeOnline(file).map<
326330
| {| key: "image", downloadHref: () => Promise<URL> |}
327-
| {| key: "document", url: string |}
328-
>
329-
>((url) =>
330-
Result.Ok({
331-
key: "document",
331+
| {| key: "collabora", url: string |}
332+
| {| key: "officeonline", url: string |}
333+
>((url) => ({
334+
key: "officeonline",
332335
url,
333-
})
336+
}))
334337
)
335-
.orElseGet(() =>
336-
Result.Error<_>([new Error("Cannot edit this item.")])
337-
);
338+
.mapError(() => new Error("Cannot edit this item."));
338339
})
339340
);
340341

@@ -529,7 +530,14 @@ function ActionsMenu({
529530
onClick={() => {
530531
editingAllowed.get().do(
531532
doNotAwait(async (action) => {
532-
if (action.key === "document") window.open(action.url);
533+
if (action.key === "officeonline") {
534+
window.open(action.url);
535+
trackEvent("user:opens:document:officeonline");
536+
}
537+
if (action.key === "collabora") {
538+
window.open(action.url);
539+
trackEvent("user:opens:document:collabora");
540+
}
533541
if (action.key === "image") {
534542
try {
535543
const downloadHref = await action.downloadHref();

0 commit comments

Comments
 (0)