Skip to content

Commit

Permalink
Fix after review
Browse files Browse the repository at this point in the history
  • Loading branch information
nchaulet committed May 13, 2021
1 parent 10a3b93 commit 5110781
Showing 1 changed file with 17 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,24 +64,22 @@ export const FleetServerUpgradeModal: React.FunctionComponent<Props> = ({ onClos
}

for (const agent of res.data?.list ?? []) {
if (agent.policy_id) {
if (!agentPoliciesAlreadyChecked[agent.policy_id]) {
agentPoliciesAlreadyChecked[agent.policy_id] = true;
const policyRes = await sendGetOneAgentPolicy(agent.policy_id);
const hasFleetServer =
(policyRes.data?.item.package_policies as PackagePolicy[]).some(
(p: PackagePolicy) => {
return p.package?.name === FLEET_SERVER_PACKAGE;
}
) ?? false;
if (!hasFleetServer) {
await sendPutSettings({
has_seen_fleet_migration_notice: true,
});
onClose();
return;
}
}
if (!agent.policy_id || agentPoliciesAlreadyChecked[agent.policy_id]) {
continue;
}

agentPoliciesAlreadyChecked[agent.policy_id] = true;
const policyRes = await sendGetOneAgentPolicy(agent.policy_id);
const hasFleetServer =
(policyRes.data?.item.package_policies as PackagePolicy[]).some((p: PackagePolicy) => {
return p.package?.name === FLEET_SERVER_PACKAGE;
}) ?? false;
if (!hasFleetServer) {
await sendPutSettings({
has_seen_fleet_migration_notice: true,
});
onClose();
return;
}
}
setAgentsAndPoliciesLoaded(true);
Expand All @@ -95,7 +93,7 @@ export const FleetServerUpgradeModal: React.FunctionComponent<Props> = ({ onClos
}

check();
}, [setAgentsAndPoliciesLoaded, notifications.toasts, onClose]);
}, [notifications.toasts, onClose]);

const onChange = useCallback(async () => {
try {
Expand Down

0 comments on commit 5110781

Please sign in to comment.