This is an automated email from the ASF dual-hosted git repository.
mattcasters pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/hop.git
The following commit(s) were added to refs/heads/main by this push:
new 7723e6136f hide profile selector in full client, fixes #7959 (#7967)
7723e6136f is described below
commit 7723e6136fa2f47248058199eb8dc1ea8c51dafb
Author: Hans Van Akelyen <[email protected]>
AuthorDate: Sat Aug 15 15:43:42 2026 +0200
hide profile selector in full client, fixes #7959 (#7967)
---
.../org/apache/hop/ui/core/gui/GuiMenuWidgets.java | 24 +++++++++++++++++
.../main/java/org/apache/hop/ui/hopgui/HopGui.java | 30 ++++++++++++++++++++--
2 files changed, 52 insertions(+), 2 deletions(-)
diff --git a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiMenuWidgets.java
b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiMenuWidgets.java
index f69ecbe278..22c531aebf 100644
--- a/ui/src/main/java/org/apache/hop/ui/core/gui/GuiMenuWidgets.java
+++ b/ui/src/main/java/org/apache/hop/ui/core/gui/GuiMenuWidgets.java
@@ -298,6 +298,30 @@ public class GuiMenuWidgets extends BaseGuiWidgets {
return menuItemMap.get(id);
}
+ /**
+ * Find the menu item with the given ID and remove it from the menu,
together with the separator
+ * that was created in front of it. Use this for menu items which simply
don't apply to the
+ * environment we're running in.
+ *
+ * @param id The ID to look for
+ */
+ public void removeMenuItem(String id) {
+ MenuItem menuItem = menuItemMap.remove(id);
+ menuEnabledMap.remove(id);
+ if (menuItem == null || menuItem.isDisposed()) {
+ return;
+ }
+ Menu parentMenu = menuItem.getParent();
+ int index = parentMenu.indexOf(menuItem);
+ if (index > 0) {
+ MenuItem previousItem = parentMenu.getItem(index - 1);
+ if ((previousItem.getStyle() & SWT.SEPARATOR) != 0) {
+ previousItem.dispose();
+ }
+ }
+ menuItem.dispose();
+ }
+
public KeyboardShortcut findKeyboardShortcut(String id) {
return shortcutMap.get(id);
}
diff --git a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
index d2e3424bb5..29b3a32cd7 100644
--- a/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
+++ b/ui/src/main/java/org/apache/hop/ui/hopgui/HopGui.java
@@ -243,6 +243,14 @@ public class HopGui
*/
public static final String ID_MAIN_TOOLBAR_PRIVILEGE =
"toolbar-10880-privilege";
+ /**
+ * hop-config.json option to show the session controls ({@link
#ID_MAIN_TOOLBAR_PRIVILEGE} and log
+ * off) in the desktop Hop GUI. There is no session to speak of there: the
privilege combo only
+ * simulates roles and logging off does nothing, so both are hidden unless
someone explicitly
+ * wants them to debug the different privilege modes.
+ */
+ public static final String HOP_CONFIG_SHOW_SESSION_CONTROLS =
"showSessionControls";
+
/** Username label immediately left of {@link #ID_MAIN_TOOLBAR_LOG_OFF}. */
public static final String ID_MAIN_TOOLBAR_USER = "toolbar-10890-user";
@@ -1098,9 +1106,11 @@ public class HopGui
if (EnvironmentUtils.getInstance().isWeb()) {
mainMenuWidgets.enableMenuItem(HopGui.ID_MAIN_MENU_FILE_EXIT, false);
- } else {
+ } else if (areSessionControlsVisible()) {
// Log off is Hop Web only
mainMenuWidgets.enableMenuItem(HopGui.ID_MAIN_MENU_FILE_LOG_OFF, false);
+ } else {
+ mainMenuWidgets.removeMenuItem(HopGui.ID_MAIN_MENU_FILE_LOG_OFF);
}
// We build the menu items but don't attach them to the shell.
@@ -1258,6 +1268,16 @@ public class HopGui
}
}
+ /**
+ * The privilege mode combo and the log off action belong with the security
configuration, which
+ * is only available in Hop Web. In the desktop Hop GUI they are hidden
unless option {@link
+ * #HOP_CONFIG_SHOW_SESSION_CONTROLS} is enabled in hop-config.json.
+ */
+ public static boolean areSessionControlsVisible() {
+ return EnvironmentUtils.getInstance().isWeb()
+ || HopConfig.readOptionBoolean(HOP_CONFIG_SHOW_SESSION_CONTROLS,
false);
+ }
+
/**
* Temporary session privilege mode (Full / Operator / Read-only). Values
from {@link
* #getPrivilegeModeList()}.
@@ -1794,7 +1814,13 @@ public class HopGui
mainToolbarWidgets = new GuiToolbarWidgets();
mainToolbarWidgets.registerGuiPluginObject(this);
- mainToolbarWidgets.createToolbarWidgets(mainToolbarContainer,
ID_MAIN_TOOLBAR);
+ List<String> hiddenToolbarItems = new ArrayList<>();
+ if (!areSessionControlsVisible()) {
+ hiddenToolbarItems.add(ID_MAIN_TOOLBAR_PRIVILEGE);
+ hiddenToolbarItems.add(ID_MAIN_TOOLBAR_LOG_OFF);
+ }
+ mainToolbarWidgets.createToolbarWidgets(
+ mainToolbarContainer, ID_MAIN_TOOLBAR, hiddenToolbarItems);
updateLoggedInUserToolbar();
updatePrivilegeModeToolbar();
if (!EnvironmentUtils.getInstance().isWeb()) {