From fb6cf4c280c40162146546c0959211b00e97e375 Mon Sep 17 00:00:00 2001
From: jacobshandling <61553566+jacobshandling@users.noreply.github.com>
Date: Tue, 2 Jul 2024 09:50:01 -0700
Subject: [PATCH] Hide `Run script` option from Observer/+s (#20068)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
## Addresses #19055
- [x] Changes file added for user-visible changes in `changes/`
- [x] Added/updated tests
- [x] Manual QA for all new/changed functionality
---------
Co-authored-by: Jacob Shandling
---
changes/19055-hide-run-script | 1 +
.../HostActionsDropdown.tests.tsx | 54 +++++++++++++++++++
.../HostActionsDropdown/helpers.tsx | 9 +---
3 files changed, 56 insertions(+), 8 deletions(-)
create mode 100644 changes/19055-hide-run-script
diff --git a/changes/19055-hide-run-script b/changes/19055-hide-run-script
new file mode 100644
index 0000000000..b45a211ea2
--- /dev/null
+++ b/changes/19055-hide-run-script
@@ -0,0 +1 @@
+* Hide the host detail page's "Run script" action from Global and Team Observer/+s.
diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx
index 8ec9181d04..51beb650fe 100644
--- a/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx
+++ b/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/HostActionsDropdown.tests.tsx
@@ -1135,6 +1135,60 @@ describe("Host Actions Dropdown", () => {
await user.click(screen.getByText("Actions"));
+ expect(screen.queryByText("Run script")).not.toBeInTheDocument();
+ });
+ it("does not render the Run script action for global observers/+", async () => {
+ // Global observer
+ const render = createCustomRenderer({
+ context: {
+ app: {
+ isGlobalObserver: true,
+ currentUser: createMockUser(),
+ },
+ },
+ });
+ const { user } = render(
+
+ );
+
+ await user.click(screen.getByText("Actions"));
+
+ expect(screen.queryByText("Run script")).not.toBeInTheDocument();
+ });
+ it("does not render the Run script action for team observers/+", async () => {
+ // team observer
+ const render = createCustomRenderer({
+ context: {
+ app: {
+ isTeamObserver: true,
+ currentUser: createMockUser(),
+ },
+ },
+ });
+ const { user } = render(
+
+ );
+
+ await user.click(screen.getByText("Actions"));
+
expect(screen.queryByText("Run script")).not.toBeInTheDocument();
});
});
diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx
index 8f35c89a72..3665687d03 100644
--- a/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx
+++ b/frontend/pages/hosts/details/HostDetailsPage/HostActionsDropdown/helpers.tsx
@@ -226,18 +226,11 @@ const canRunScript = ({
hostPlatform,
isGlobalAdmin,
isGlobalMaintainer,
- isGlobalObserver,
isTeamAdmin,
isTeamMaintainer,
- isTeamObserver,
}: IHostActionConfigOptions) => {
return (
- (isGlobalAdmin ||
- isGlobalMaintainer ||
- isGlobalObserver ||
- isTeamAdmin ||
- isTeamMaintainer ||
- isTeamObserver) &&
+ (isGlobalAdmin || isGlobalMaintainer || isTeamAdmin || isTeamMaintainer) &&
isScriptSupportedPlatform(hostPlatform)
);
};