From dc971098412783673b28f55a34c1ed65af223850 Mon Sep 17 00:00:00 2001 From: RachelElysia <71795832+RachelElysia@users.noreply.github.com> Date: Mon, 28 Aug 2023 13:11:19 -0400 Subject: [PATCH] Fleet UI: Store host's team on details page for correct RBAC dropdown (#13530) --- changes/13495-host-details-rbac | 1 + .../details/HostDetailsPage/HostDetailsPage.tsx | 12 ++++++++++++ 2 files changed, 13 insertions(+) create mode 100644 changes/13495-host-details-rbac diff --git a/changes/13495-host-details-rbac b/changes/13495-host-details-rbac new file mode 100644 index 0000000000..e1b4f41948 --- /dev/null +++ b/changes/13495-host-details-rbac @@ -0,0 +1 @@ +- Host details page - Bug fix RBAC dropdown options on refresh diff --git a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx index 788e6fceb3..ad0570a256 100644 --- a/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx +++ b/frontend/pages/hosts/details/HostDetailsPage/HostDetailsPage.tsx @@ -124,6 +124,8 @@ const HostDetailsPage = ({ isSandboxMode, isOnlyObserver, filteredHostsPath, + availableTeams, + setCurrentTeam, } = useContext(AppContext); const { setLastEditedQueryName, @@ -346,6 +348,16 @@ const HostDetailsPage = ({ setPathname(location.pathname + location.search); }, [location]); + // Used to set host's team in AppContext for RBAC action dropdown + useEffect(() => { + if (host?.team_id) { + const hostsTeam = availableTeams?.find( + (team) => team.id === host.team_id + ); + setCurrentTeam(hostsTeam); + } + }, [host]); + const titleData = normalizeEmptyValues( pick(host, [ "id",