Fleet UI: [small unreleased bug fix] Fix empty team policies search to still show inherited policies table, faster team policies page (#13628)

This commit is contained in:
RachelElysia
2023-09-01 11:55:32 -04:00
committed by GitHub
parent 9a3b4cd365
commit 6173af2b30
@@ -239,7 +239,7 @@ const ManagePolicyPage = ({
return globalPoliciesAPI.loadAllNew(queryKey[0]);
},
{
enabled: isRouteOk,
enabled: isRouteOk && !isAnyTeamSelected,
select: (data) => data.policies,
staleTime: 5000,
}
@@ -362,9 +362,10 @@ const ManagePolicyPage = ({
);
const refetchPolicies = (teamId?: number) => {
refetchGlobalPolicies();
if (teamId) {
refetchTeamPolicies();
} else {
refetchGlobalPolicies(); // Only call on global policies as this is expensive
}
};
@@ -576,9 +577,7 @@ const ManagePolicyPage = ({
isAnyTeamSelected &&
!isFetchingTeamPolicies &&
!teamPoliciesError &&
!isFetchingGlobalPolicies &&
!globalPoliciesError &&
!!globalPolicies?.length;
!!inheritedPolicies?.length; // Returned with team policies
const availablePoliciesForAutomation =
(isAnyTeamSelected ? teamPolicies : globalPolicies) || [];
@@ -735,7 +734,6 @@ const ManagePolicyPage = ({
currentAutomatedPolicies={currentAutomatedPolicies}
isPremiumTier={isPremiumTier}
isSandboxMode={isSandboxMode}
// onClientSidePaginationChange={onClientSidePaginationChange}
renderPoliciesCount={() =>
!isFetchingGlobalCount &&
renderPoliciesCount(globalPoliciesCount)
@@ -748,27 +746,25 @@ const ManagePolicyPage = ({
/>
))}
</div>
{showInheritedPoliciesButton &&
globalPolicies &&
globalPoliciesCount && (
<RevealButton
isShowing={showInheritedTable}
className={baseClass}
hideText={inheritedPoliciesButtonText(
showInheritedTable,
globalPoliciesCount
)}
showText={inheritedPoliciesButtonText(
showInheritedTable,
globalPoliciesCount
)}
caretPosition={"before"}
tooltipHtml={
'"All teams" policies are checked <br/> for this teams hosts.'
}
onClick={toggleShowInheritedPolicies}
/>
)}
{showInheritedPoliciesButton && globalPoliciesCount && (
<RevealButton
isShowing={showInheritedTable}
className={baseClass}
hideText={inheritedPoliciesButtonText(
showInheritedTable,
globalPoliciesCount
)}
showText={inheritedPoliciesButtonText(
showInheritedTable,
globalPoliciesCount
)}
caretPosition={"before"}
tooltipHtml={
'"All teams" policies are checked <br/> for this teams hosts.'
}
onClick={toggleShowInheritedPolicies}
/>
)}
{showInheritedPoliciesButton && showInheritedTable && (
<div className={`${baseClass}__inherited-policies-table`}>
{globalPoliciesError && <TableDataError />}
@@ -784,9 +780,6 @@ const ManagePolicyPage = ({
tableType="inheritedPolicies"
currentTeam={currentTeamSummary}
searchQuery=""
// onClientSidePaginationChange={
// onClientSideInheritedPaginationChange
// }
renderPoliciesCount={() =>
renderPoliciesCount(teamPoliciesCount)
}