From 150ed28c5d8b57dd62dd2f3f0d911596ba88fb6b Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Thu, 10 Jun 2021 11:21:49 -0300 Subject: [PATCH 1/4] overhaul selectively showing context menu items --- navigator/navigator.js | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/navigator/navigator.js b/navigator/navigator.js index 83286e4..dc0e145 100644 --- a/navigator/navigator.js +++ b/navigator/navigator.js @@ -247,6 +247,10 @@ class NavEntry { owner.title = owner.innerText = this.stat["owner"]; group.title = group.innerText = this.stat["group"]; size.title = size.innerText = format_bytes(this.stat["size"]); + mode.classList.add("nav-item-title", "no-select"); + owner.classList.add("nav-item-title", "no-select"); + group.classList.add("nav-item-title", "no-select"); + size.classList.add("nav-item-title", "no-select"); this.dom_element.appendChild(mode); this.dom_element.appendChild(owner); this.dom_element.appendChild(group); @@ -934,7 +938,6 @@ class NavContextMenu { this.dom_element.appendChild(elem); this.menu_options[func[0]] = elem; } - this.menu_options["paste"].style.display = "none"; } new_dir() { @@ -1036,29 +1039,30 @@ class NavContextMenu { * @param {NavEntry} target */ show(event, target) { - if (this.nav_window_ref.selected_entries.size > 1) { + if (!this.nav_window_ref.none_selected()) { if (event.shiftKey || event.ctrlKey) this.nav_window_ref.set_selected(target, event.shiftKey, event.ctrlKey); } else { this.nav_window_ref.set_selected(target, false, false); } - this.menu_options["download"].style.display = "flex"; - if (target === this.nav_window_ref.pwd()) { + for (let option of Object.keys(this.menu_options)) { + this.menu_options[option].style.display = "flex"; // show all + } + // selectively hide options based on context + if (this.nav_window_ref.none_selected()) { this.menu_options["copy"].style.display = "none"; this.menu_options["cut"].style.display = "none"; this.menu_options["delete"].style.display = "none"; - } else { - this.menu_options["copy"].style.display = "flex"; - this.menu_options["cut"].style.display = "flex"; - this.menu_options["delete"].style.display = "flex"; + this.menu_options["download"].style.display = "none"; } if (this.nav_window_ref.selected_entries.size > 1) { this.menu_options["rename"].style.display = "none"; } else { - this.menu_options["rename"].style.display = "flex"; - if (target instanceof NavFileLink) + if (target instanceof NavDirLink || target instanceof NavFileLink) this.menu_options["download"].style.display = "none"; } + if (!this.nav_window_ref.clip_board.length) + this.menu_options["paste"].style.display = "none"; this.target = target; this.dom_element.style.display = "inline"; this.dom_element.style.left = event.clientX + "px"; @@ -1582,6 +1586,10 @@ class NavWindow { selected_entry() { return [...this.selected_entries][this.selected_entries.size - 1]; } + + none_selected() { + return this.selected_entries.length === 1 && this.selected_entry() === this.pwd(); + } show_selected_properties() { this.selected_entry().show_properties(); @@ -1855,7 +1863,6 @@ class NavWindow { async paste_clipboard() { this.start_load(); - this.context_menu.hide_paste(); var cmd = ["/usr/share/cockpit/navigator/scripts/paste.py"]; var dest = this.pwd().path_str(); if (this.copy_or_move === "move") { @@ -1866,6 +1873,7 @@ class NavWindow { cmd.push(item.path_str()); } cmd.push(dest); + this.clip_board.length = 0; // clear clipboard var promise = new Promise((resolve, reject) => { var proc = cockpit.spawn( cmd, From b51f0fe860b882cc22a1da9a5e36c8c581f4a508 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Thu, 10 Jun 2021 11:42:23 -0300 Subject: [PATCH 2/4] fix checking if any items are selected --- navigator/navigator.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/navigator/navigator.js b/navigator/navigator.js index dc0e145..baf8568 100644 --- a/navigator/navigator.js +++ b/navigator/navigator.js @@ -1588,7 +1588,7 @@ class NavWindow { } none_selected() { - return this.selected_entries.length === 1 && this.selected_entry() === this.pwd(); + return this.selected_entries.size === 1 && this.selected_entry() === this.pwd(); } show_selected_properties() { From 6ebe4b3df1a8b7898aab946bd3198c71773ef30f Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Thu, 10 Jun 2021 12:15:40 -0300 Subject: [PATCH 3/4] update changelog --- debian/changelog | 7 +++++++ el/cockpit-navigator.spec | 5 ++++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/debian/changelog b/debian/changelog index 70cc9b1..a39e3f4 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,10 @@ +cockpit-navigator (0.4.4-1focal) focal; urgency=medium + + * Hide download option in right click context menu when no items + are explicitly selected. + + -- Josh Boudreau Thu, 10 Jun 2021 12:09:00 -0300 + cockpit-navigator (0.4.3-1focal) focal; urgency=medium * Add sort options for list view. diff --git a/el/cockpit-navigator.spec b/el/cockpit-navigator.spec index e8b98c2..fc201d9 100644 --- a/el/cockpit-navigator.spec +++ b/el/cockpit-navigator.spec @@ -1,5 +1,5 @@ Name: cockpit-navigator -Version: 0.4.3 +Version: 0.4.4 Release: 1%{?dist} Summary: A File System Browser for Cockpit. License: GPL-3.0+ @@ -32,6 +32,9 @@ rm -rf %{buildroot} /usr/share/cockpit/navigator/* %changelog +* Thu Jun 10 2021 Josh Boudreau 0.4.4-1 +- Hide download option in right click context menu when no items + are explicitly selected. * Tue Jun 08 2021 Josh Boudreau 0.4.3-1 - Add sort options for list view. - Add search bar to filter items. From 17df9ca6e139cb7f6c2380101598f35e0a22ede1 Mon Sep 17 00:00:00 2001 From: joshuaboud Date: Thu, 10 Jun 2021 12:15:51 -0300 Subject: [PATCH 4/4] update install URLs --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index adbaf87..6f5358b 100644 --- a/README.md +++ b/README.md @@ -23,12 +23,12 @@ With no command line use needed, you can: # Installation ## From Github Release ### Ubuntu -1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator_0.4.3-1focal_all.deb` -1. `# apt install ./cockpit-navigator_0.4.3-1focal_all.deb` +1. `$ wget https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator_0.4.4-1focal_all.deb` +1. `# apt install ./cockpit-navigator_0.4.4-1focal_all.deb` ### EL7 -1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator-0.4.3-1.el7.noarch.rpm` +1. `# yum install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator-0.4.4-1.el7.noarch.rpm` ### EL8 -1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator-0.4.3-1.el8.noarch.rpm` +1. `# dnf install https://github.com/45Drives/cockpit-navigator/releases/download/v0.4/cockpit-navigator-0.4.4-1.el8.noarch.rpm` ## From Source 1. Ensure dependencies are installed: `cockpit`, `python3`, `rsync`, `zip`. 1. `$ git clone https://github.com/45Drives/cockpit-navigator.git`