From 45174aa258a88dd1f9ec07fc636afd12f48ae287 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Wed, 12 Apr 2023 09:37:22 -0400 Subject: [PATCH] Fleet UI: Remove hosts pack information from observers and observer plus (#11141) --- ...11074-hide-hosts-packs-info-from-observers | 1 + .../HostDetailsPage/HostDetailsPage.tsx | 25 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) create mode 100644 changes/11074-hide-hosts-packs-info-from-observers diff --git a/changes/11074-hide-hosts-packs-info-from-observers b/changes/11074-hide-hosts-packs-info-from-observers new file mode 100644 index 0000000000..939e649061 --- /dev/null +++ b/changes/11074-hide-hosts-packs-info-from-observers @@ -0,0 +1 @@ +- UI: Remove any host's packs information for observers and observer plus diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index ecdbafbffd..1c2be7696a 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -40,6 +40,7 @@ import { humanHostDiskEncryptionEnabled, wrapFleetHelper, } from "utilities/helpers"; +import permissions from "utilities/permissions"; import HostSummaryCard from "../cards/HostSummary"; import AboutCard from "../cards/About"; @@ -107,10 +108,11 @@ const HostDetailsPage = ({ const hostIdFromURL = parseInt(host_id, 10); const { config, + currentUser, isGlobalAdmin = false, + isGlobalObserver, isPremiumTier = false, isOnlyObserver, - isObserverPlus, filteredHostsPath, } = useContext(AppContext); const { @@ -606,6 +608,23 @@ const HostDetailsPage = ({ host?.mdm.name === "Fleet" && host?.mdm.macos_settings.disk_encryption === "action_required"; + /* Context team id might be different that host's team id + Observer plus must be checked against host's team id */ + const isGlobalOrHostsTeamObserverPlus = + currentUser && host?.team_id + ? permissions.isObserverPlus(currentUser, host.team_id) + : false; + + const isHostsTeamObserver = + currentUser && host?.team_id + ? permissions.isTeamObserver(currentUser, host.team_id) + : false; + + const canViewPacks = + !isGlobalObserver && + !isGlobalOrHostsTeamObserverPlus && + !isHostsTeamObserver; + return (
@@ -704,7 +723,9 @@ const HostDetailsPage = ({ scheduleState={scheduleState} isLoading={isLoadingHost} /> - + {canViewPacks && ( + + )}