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

(Med.)[BFF-403] Add "Go to location" option to FileAccessContextMenu #426

Open
wants to merge 8 commits into
base: main
Choose a base branch
from
30 changes: 30 additions & 0 deletions packages/core/hooks/useFileAccessContextMenu.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,22 @@
import { ContextualMenuItemType, IContextualMenuItem } from "@fluentui/react";
import * as React from "react";
import { useDispatch, useSelector } from "react-redux";
import { shell } from "electron";
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: bff imports are generally alphabetical (tho not enforced by linter), so would go in line 2

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

alphabetical by where it is being imported from? first item imported? I'm not clear. To be fair, it isn't my PR, so if Tyler gets it, good.

Copy link
Contributor

@aswallace aswallace Feb 11, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where it is imported from. Symbols go first, so @ fluent still goes before electron


import useOpenWithMenuItems from "./useOpenWithMenuItems";
import FileDetail from "../entity/FileDetail";
import FileFilter from "../entity/FileFilter";
import { interaction, selection } from "../state";

/**
* Reveals a selected file in the user's native file browser
*/
const openNativeFileBrowser = (fileDetails: FileDetail) => {
if (fileDetails.localPath) {
shell.showItemInFolder(fileDetails.localPath);
}
};

/**
* Custom React hook for creating the file access context menu.
*
Expand Down Expand Up @@ -68,6 +78,26 @@ export default (filters?: FileFilter[], onDismiss?: () => void) => {
items: openWithSubMenuItems,
},
},
...(isQueryingAicsFms && !isOnWeb
? [
{
key: "go-to-file-location",
text: "Go to file location",
title: "Show selected file in your native file browser",
disabled:
fileDetails?.localPath === null ||
fileDetails?.localPath === undefined ||
fileSelection.count() > 1 ||
(!filters && fileSelection.count() === 0),
iconProps: { iconName: "FolderOpen" },
onClick() {
if (fileDetails) {
openNativeFileBrowser(fileDetails);
}
},
},
]
: []),
{
key: "save-as",
text: "Save metadata as",
Expand Down