Allow team admins to view inherited policy details (#26896)

## Details

Quick fix to an issue where when a team admin attempted to via an
inherited policy, they would encounter an eternal spinner / flickering
page. The issue stemmed from a reload cycle being set off by the stored
policy being returned with a team ID of `null`, and existing code that
works around the fact that the `useTeamId` hook modifies the router
state.

## Testing

1. Create an All Teams policy on an instance with at least one team
2. Create an admin for the team
3. Log in as the team admin
4. Go to Policies page, select the team from the dropdown, click on the
inherited policy in the list to view its details.

On main, the details never load.  On this branch, they do.
This commit is contained in:
Scott Gress 2025-03-12 12:30:32 -05:00 committed by GitHub
parent 6e86b02bec
commit 20109fa7f8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -213,6 +213,7 @@ const PolicyPage = ({
!isOnGlobalTeam &&
!isStoredPolicyLoading &&
storedPolicy?.team_id !== undefined &&
storedPolicy?.team_id !== null &&
!(storedPolicy?.team_id?.toString() === location.query.team_id)
) {
router.push(