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

feat: enable open files menu in tauri #1158

Merged
merged 4 commits into from
Oct 31, 2023
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
14 changes: 10 additions & 4 deletions src/command/DefaultMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ define(function (require, exports, module) {
menu.addMenuItem(Commands.FILE_NEW_FOLDER);
menu.addMenuItem(Commands.FILE_NEW_WINDOW);
menu.addMenuDivider();
if(Phoenix.browser.isTauri){
menu.addMenuItem(Commands.FILE_OPEN);
}
menu.addMenuItem(Commands.FILE_OPEN_FOLDER);
menu.addMenuItem(Commands.FILE_CLOSE);
menu.addMenuItem(Commands.FILE_CLOSE_ALL);
Expand Down Expand Up @@ -242,6 +245,9 @@ define(function (require, exports, module) {
var workingset_cmenu = Menus.registerContextMenu(Menus.ContextMenuIds.WORKING_SET_CONTEXT_MENU);
workingset_cmenu.addMenuItem(Commands.FILE_SAVE);
workingset_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_FILE_TREE);
if(Phoenix.browser.isTauri){
workingset_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
}
workingset_cmenu.addMenuDivider();
workingset_cmenu.addMenuItem(Commands.FILE_COPY);
workingset_cmenu.addMenuItem(Commands.FILE_COPY_PATH);
Expand Down Expand Up @@ -273,12 +279,15 @@ define(function (require, exports, module) {
var project_cmenu = Menus.registerContextMenu(Menus.ContextMenuIds.PROJECT_MENU);
project_cmenu.addMenuItem(Commands.FILE_NEW);
project_cmenu.addMenuItem(Commands.FILE_NEW_FOLDER);
if(Phoenix.browser.isTauri){
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
}
project_cmenu.addMenuDivider();
project_cmenu.addMenuItem(Commands.FILE_CUT);
project_cmenu.addMenuItem(Commands.FILE_COPY);
project_cmenu.addMenuItem(Commands.FILE_COPY_PATH);
project_cmenu.addMenuItem(Commands.FILE_PASTE);
project_cmenu.addMenuItem(Commands.FILE_DUPLICATE);
project_cmenu.addMenuItem(Commands.FILE_PASTE);
project_cmenu.addMenuItem(Commands.FILE_DOWNLOAD, undefined, undefined, undefined, {
hideWhenCommandDisabled: true
});
Expand All @@ -290,9 +299,6 @@ define(function (require, exports, module) {
project_cmenu.addMenuItem(Commands.CMD_REPLACE_IN_SUBTREE);
project_cmenu.addMenuDivider();
project_cmenu.addMenuItem(Commands.FILE_REFRESH);
if(Phoenix.browser.isTauri){
project_cmenu.addMenuItem(Commands.NAVIGATE_SHOW_IN_OS);
}

var editor_cmenu = Menus.registerContextMenu(Menus.ContextMenuIds.EDITOR_MENU);
// editor_cmenu.addMenuItem(Commands.NAVIGATE_JUMPTO_DEFINITION);
Expand Down
25 changes: 19 additions & 6 deletions src/filesystem/impls/appshell/AppshellFileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -292,18 +292,31 @@ define(function (require, exports, module) {
* @param {function(?string, Array.<string>=)} callback
*/
function showOpenDialog(allowMultipleSelection, chooseDirectories, title, initialPath, fileTypes, callback) {
// TODO: handle more cases relating to multiple selection and stuff.
const wrappedCallback = _wrap(callback);
if(Phoenix.browser.isTauri){
const wrappedCallback = _wrap(callback);
appshell.fs.openTauriFilePickerAsync({
directory: true
multiple: allowMultipleSelection,
directory: chooseDirectories,
title,
defaultPath: Phoenix.fs.getTauriPlatformPath(initialPath),
filters: fileTypes ? [{
name: "openDialog",
extensions: fileTypes || []
}] : undefined
}).then(directory => {
// todo, may return null/string/array of strings
wrappedCallback(null, [directory]);
if(!directory) {
wrappedCallback(FileSystemError.NOT_READABLE);
return;
}
if(typeof directory === 'string') {
wrappedCallback(null, [directory]);
return;
}
wrappedCallback(null, directory); // is an array of paths
}).catch(wrappedCallback);
return;
}
appshell.fs.mountNativeFolder(_wrap(callback));
appshell.fs.mountNativeFolder(wrappedCallback);
}

/**
Expand Down
2 changes: 1 addition & 1 deletion src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -479,7 +479,7 @@ define({
"CMD_SHOW_IN_TREE": "Show in File Tree",
"CMD_SHOW_IN_EXPLORER": "Show in Explorer",
"CMD_SHOW_IN_FINDER": "Show in Finder",
"CMD_SHOW_IN_OS": "Show in OS",
"CMD_SHOW_IN_OS": "Show in OS Files",
"CMD_SWITCH_PANE_FOCUS": "Switch Pane Focus",

// Debug menu commands
Expand Down
Loading