Skip to content

Commit

Permalink
[Fleet] Disable Keep policies up to date button if user is missing pe…
Browse files Browse the repository at this point in the history
…rmissions (#205295)

(cherry picked from commit 4a32b50)
  • Loading branch information
nchaulet committed Jan 2, 2025
1 parent 61982ac commit 7d766b8
Showing 1 changed file with 7 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ import {
useStartServices,
useUpgradePackagePolicyDryRunQuery,
useUpdatePackageMutation,
useAuthz,
} from '../../../../../hooks';
import {
PACKAGE_POLICY_SAVED_OBJECT_TYPE,
Expand Down Expand Up @@ -118,6 +119,7 @@ interface Props {

export const SettingsPage: React.FC<Props> = memo(
({ packageInfo, packageMetadata, startServices }: Props) => {
const authz = useAuthz();
const { name, title, latestVersion, version, keepPoliciesUpToDate } = packageInfo;
const [isUpgradingPackagePolicies, setIsUpgradingPackagePolicies] = useState<boolean>(false);
const [isChangelogModalOpen, setIsChangelogModalOpen] = useState(false);
Expand Down Expand Up @@ -160,8 +162,11 @@ export const SettingsPage: React.FC<Props> = memo(
}, [name]);

const isShowKeepPoliciesUpToDateSwitchDisabled = useMemo(() => {
return AUTO_UPGRADE_POLICIES_PACKAGES.some((pkg) => pkg.name === name);
}, [name]);
return (
!authz.integrations.writePackageSettings ||
AUTO_UPGRADE_POLICIES_PACKAGES.some((pkg) => pkg.name === name)
);
}, [authz.integrations.writePackageSettings, name]);

const [keepPoliciesUpToDateSwitchValue, setKeepPoliciesUpToDateSwitchValue] = useState<boolean>(
keepPoliciesUpToDate ?? false
Expand Down

0 comments on commit 7d766b8

Please sign in to comment.