From 89dd335208e518afd4d4bd0c251902b9ad5666e9 Mon Sep 17 00:00:00 2001 From: jelveh Date: Fri, 15 Aug 2025 23:01:34 -0700 Subject: [PATCH] close #1134 --- src/gui/src/UI/UIWindowSearch.js | 50 +++++++++++++++++++++++++++++ src/gui/src/i18n/translations/en.js | 4 ++- 2 files changed, 53 insertions(+), 1 deletion(-) diff --git a/src/gui/src/UI/UIWindowSearch.js b/src/gui/src/UI/UIWindowSearch.js index d92c96b40..60504ce15 100644 --- a/src/gui/src/UI/UIWindowSearch.js +++ b/src/gui/src/UI/UIWindowSearch.js @@ -22,6 +22,7 @@ import path from "../lib/path.js" import UIAlert from './UIAlert.js' import launch_app from '../helpers/launch_app.js' import item_icon from '../helpers/item_icon.js' +import UIContextMenu from './UIContextMenu.js' async function UIWindowSearch(options){ let h = ''; @@ -253,4 +254,53 @@ $(document).on('click', '.search-result', async function(e){ $(this).closest('.window').close(); }) +// Context menu for search results +$(document).on('contextmenu', '.search-result', async function(e){ + e.preventDefault(); + e.stopPropagation(); + + const fspath = $(this).data('path'); + const fsuid = $(this).data('uid'); + const is_dir = $(this).attr('data-is_dir') === 'true' || $(this).data('is_dir') === '1'; + + // Get the parent directory path + const parent_path = path.dirname(fspath); + + // Build context menu items + const menuItems = [ + { + html: i18n('open'), + onClick: async function() { + // Trigger the same logic as clicking on the search result + $(e.target).trigger('click'); + } + } + ]; + + // Only add "Open enclosing folder" if we're not already at root + if (parent_path && parent_path !== fspath && parent_path !== '/') { + menuItems.push('-'); // divider + menuItems.push({ + html: i18n('open_containing_folder'), + onClick: async function() { + // Open the enclosing folder + UIWindow({ + path: parent_path, + title: path.basename(parent_path) || window.root_dirname, + icon: window.icons['folder.svg'], + is_dir: true, + app: 'explorer', + }); + + // Close search window + $(e.target).closest('.window').close(); + } + }); + } + + UIContextMenu({ + items: menuItems + }); +}) + export default UIWindowSearch \ No newline at end of file diff --git a/src/gui/src/i18n/translations/en.js b/src/gui/src/i18n/translations/en.js index dfe1a7f58..86c3125e6 100644 --- a/src/gui/src/i18n/translations/en.js +++ b/src/gui/src/i18n/translations/en.js @@ -496,7 +496,9 @@ const en = { 'window_folder_empty': 'This folder is empty', // Website Management - 'manage_your_subdomains': 'Manage Your Subdomains' + 'manage_your_subdomains': 'Manage Your Subdomains', + + 'open_containing_folder': 'Open Containing Folder', } };