diff --git a/src/command/DefaultMenus.js b/src/command/DefaultMenus.js index 6b1a6ce6e9..bb234d459e 100644 --- a/src/command/DefaultMenus.js +++ b/src/command/DefaultMenus.js @@ -19,6 +19,8 @@ * */ +/*global Phoenix*/ + /** * Initializes the default brackets menu items. */ @@ -55,7 +57,8 @@ define(function (require, exports, module) { if (err) { return err; } - _setContextMenuItemsVisible(isPresent, [Commands.FILE_RENAME, Commands.NAVIGATE_SHOW_IN_FILE_TREE]); + _setContextMenuItemsVisible(isPresent, [Commands.FILE_RENAME, + Commands.NAVIGATE_SHOW_IN_FILE_TREE, Commands.NAVIGATE_SHOW_IN_OS]); }); } } @@ -287,6 +290,9 @@ 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); diff --git a/src/document/DocumentCommandHandlers.js b/src/document/DocumentCommandHandlers.js index b8ce14a366..712e3e615d 100644 --- a/src/document/DocumentCommandHandlers.js +++ b/src/document/DocumentCommandHandlers.js @@ -1748,6 +1748,15 @@ define(function (require, exports, module) { }); } + /** Show the selected sidebar (tree or workingset) item in Finder/Explorer */ + function handleShowInOS() { + var entry = ProjectManager.getSelectedItem(); + if (entry) { + brackets.app.openPathInFileBrowser(entry.fullPath) + .catch(err=>console.error("Error showing '" + entry.fullPath + "' in OS folder:", err)); + } + } + /** * Does a full reload of the browser window * @param {string} href The url to reload into the window @@ -1907,9 +1916,13 @@ define(function (require, exports, module) { exports._parseDecoratedPath = _parseDecoratedPath; // Set some command strings - var quitString = Strings.CMD_QUIT; + var quitString = Strings.CMD_QUIT, + showInOS = Strings.CMD_SHOW_IN_OS; if (brackets.platform === "win") { quitString = Strings.CMD_EXIT; + showInOS = Strings.CMD_SHOW_IN_EXPLORER; + } else if (brackets.platform === "mac") { + showInOS = Strings.CMD_SHOW_IN_FINDER; } // Define public API @@ -1948,6 +1961,7 @@ define(function (require, exports, module) { CommandManager.register(Strings.CMD_PREV_DOC_LIST_ORDER, Commands.NAVIGATE_PREV_DOC_LIST_ORDER, handleGoPrevDocListOrder); // Special Commands + CommandManager.register(showInOS, Commands.NAVIGATE_SHOW_IN_OS, handleShowInOS); CommandManager.register(Strings.CMD_NEW_BRACKETS_WINDOW, Commands.FILE_NEW_WINDOW, handleFileNewWindow); CommandManager.register(quitString, Commands.FILE_QUIT, handleFileQuit); CommandManager.register(Strings.CMD_SHOW_IN_TREE, Commands.NAVIGATE_SHOW_IN_FILE_TREE, handleShowInTree); diff --git a/src/extensions/default/DebugCommands/main.js b/src/extensions/default/DebugCommands/main.js index 6880088728..1e1ff1e7b5 100644 --- a/src/extensions/default/DebugCommands/main.js +++ b/src/extensions/default/DebugCommands/main.js @@ -44,6 +44,7 @@ define(function (require, exports, module) { Mustache = brackets.getModule("thirdparty/mustache/mustache"), Locales = brackets.getModule("nls/strings"), ProjectManager = brackets.getModule("project/ProjectManager"), + ExtensionLoader = brackets.getModule("utils/ExtensionLoader"), extensionDevelopment = require("extensionDevelopment"), PerfDialogTemplate = require("text!htmlContent/perf-dialog.html"), LanguageDialogTemplate = require("text!htmlContent/language-dialog.html"); @@ -72,6 +73,7 @@ define(function (require, exports, module) { DEBUG_ENABLE_LOGGING = "debug.enableLogging", DEBUG_LIVE_PREVIEW_LOGGING = "debug.livePreviewLogging", DEBUG_OPEN_VFS = "debug.openVFS", + DEBUG_OPEN_EXTENSION_FOLDER = "debug.openExtensionFolders", DEBUG_OPEN_VIRTUAL_SERVER = "debug.openVirtualServer", DEBUG_OPEN_PREFERENCES_IN_SPLIT_VIEW = "debug.openPrefsInSplitView"; @@ -708,6 +710,10 @@ define(function (require, exports, module) { ProjectManager.openProject("/"); } + function _openExtensionsFolder() { + Phoenix.app.openPathInFileBrowser(ExtensionLoader.getUserExtensionPath()); + } + function _openVirtualServer() { const virtualServingURL = Phoenix.VFS.getVirtualServingURLForPath("/"); if(!virtualServingURL) { @@ -745,6 +751,7 @@ define(function (require, exports, module) { CommandManager.register(Strings.CMD_ENABLE_LOGGING, DEBUG_ENABLE_LOGGING, _handleLogging); CommandManager.register(Strings.CMD_ENABLE_LIVE_PREVIEW_LOGS, DEBUG_LIVE_PREVIEW_LOGGING, _handleLivePreviewLogging); CommandManager.register(Strings.CMD_OPEN_VFS, DEBUG_OPEN_VFS, _openVFS); + CommandManager.register(Strings.CMD_OPEN_EXTENSIONS_FOLDER, DEBUG_OPEN_EXTENSION_FOLDER, _openExtensionsFolder); CommandManager.register(Strings.CMD_OPEN_VIRTUAL_SERVER, DEBUG_OPEN_VIRTUAL_SERVER, _openVirtualServer); CommandManager.register(Strings.CMD_OPEN_PREFERENCES, DEBUG_OPEN_PREFERENCES_IN_SPLIT_VIEW, handleOpenPrefsInSplitView); @@ -767,17 +774,20 @@ define(function (require, exports, module) { debugMenu.addMenuItem(DEBUG_LIVE_PREVIEW_LOGGING); debugMenu.addMenuDivider(); debugMenu.addMenuItem(DEBUG_OPEN_VFS); + debugMenu.addMenuItem(DEBUG_OPEN_EXTENSION_FOLDER, undefined, undefined, undefined, { + hideWhenCommandDisabled: true + }); debugMenu.addMenuItem(DEBUG_OPEN_VIRTUAL_SERVER, undefined, undefined, undefined, { hideWhenCommandDisabled: true }); CommandManager.get(DEBUG_UNLOAD_CURRENT_EXTENSION) .setEnabled(extensionDevelopment.isProjectLoadedAsExtension()); - if(window.__TAURI__) { - // in tauri, virtual server doesnt exist, extensions are served by tauri asset urls. - CommandManager.get(DEBUG_OPEN_VIRTUAL_SERVER) - .setEnabled(false); - } + CommandManager.get(DEBUG_OPEN_EXTENSION_FOLDER) + .setEnabled(Phoenix.browser.isTauri); // only show in tauri + CommandManager.get(DEBUG_OPEN_VIRTUAL_SERVER) + .setEnabled(!Phoenix.browser.isTauri); // don't show in tauri as there is no virtual server in tauri + _updateLogToConsoleMenuItemChecked(); const helpMenu = Menus.getMenu(Menus.AppMenuBar.HELP_MENU); diff --git a/src/nls/root/strings.js b/src/nls/root/strings.js index 9829dd5622..7af46ab694 100644 --- a/src/nls/root/strings.js +++ b/src/nls/root/strings.js @@ -484,6 +484,7 @@ define({ // Debug menu commands "CMD_OPEN_VFS": "Open Virtual File System", + "CMD_OPEN_EXTENSIONS_FOLDER": "Open Extensions Folder\u2026", "CMD_OPEN_VIRTUAL_SERVER": "Open Virtual Server", // Help menu commands diff --git a/src/phoenix/shell.js b/src/phoenix/shell.js index 4ee1b0f7cf..f83b62dcdc 100644 --- a/src/phoenix/shell.js +++ b/src/phoenix/shell.js @@ -64,6 +64,26 @@ Phoenix.app = { } return window.document.title; }, + openPathInFileBrowser: function (fullVFSPath){ + return new Promise((resolve, reject)=>{ + if(!window.__TAURI__ || + !fullVFSPath.startsWith(Phoenix.VFS.getTauriDir())) { + reject("openPathInFileBrowser is only currently supported in Native builds for tauri paths!"); + return; + } + if(fullVFSPath.toLowerCase().startsWith("http://") + || fullVFSPath.toLowerCase().startsWith("https://") + || fullVFSPath.toLowerCase().startsWith("file://")) { + reject("Please use openPathInFileBrowser API to open URLs"); + return; + } + const platformPath = Phoenix.fs.getTauriPlatformPath(fullVFSPath); + window.__TAURI__.tauri + .invoke('show_in_folder', {path: platformPath}) + .then(resolve) + .catch(reject); + }); + }, openURLInDefaultBrowser: function (url){ return new Promise((resolve, reject)=>{ if(!window.__TAURI__) {