diff --git a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_context.tsx b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_context.tsx index 54f33e81e1bba..f13c8130bf740 100644 --- a/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_context.tsx +++ b/x-pack/plugins/security_solution/public/detection_engine/rule_management_ui/components/rules_table/add_prebuilt_rules_table/add_prebuilt_rules_table_context.tsx @@ -8,6 +8,7 @@ import type { Dispatch, SetStateAction } from 'react'; import React, { createContext, useCallback, useContext, useMemo, useState } from 'react'; import { EuiButton } from '@elastic/eui'; +import { useUserData } from '../../../../../detections/components/user_info'; import { useFetchPrebuiltRulesStatusQuery } from '../../../../rule_management/api/hooks/prebuilt_rules/use_fetch_prebuilt_rules_status_query'; import { useIsUpgradingSecurityPackages } from '../../../../rule_management/logic/use_upgrade_security_packages'; import type { RuleSignatureId } from '../../../../../../common/api/detection_engine'; @@ -99,6 +100,8 @@ export const AddPrebuiltRulesTableContextProvider = ({ const [loadingRules, setLoadingRules] = useState([]); const [selectedRules, setSelectedRules] = useState([]); + const [{ loading: userInfoLoading, canUserCRUD }] = useUserData(); + const [filterOptions, setFilterOptions] = useState({ filter: '', tags: [], @@ -135,11 +138,13 @@ export const AddPrebuiltRulesTableContextProvider = ({ const filteredRules = useFilterPrebuiltRulesToInstall({ filterOptions, rules }); const { openRulePreview, closeRulePreview, previewedRule } = useRuleDetailsFlyout(filteredRules); - const canPreviewedRuleBeInstalled = Boolean( - (previewedRule?.rule_id && loadingRules.includes(previewedRule.rule_id)) || - isRefetching || - isUpgradingSecurityPackages - ); + + const isPreviewRuleLoading = + previewedRule?.rule_id && loadingRules.includes(previewedRule.rule_id); + const canPreviewedRuleBeInstalled = + !userInfoLoading && + canUserCRUD && + !(isPreviewRuleLoading || isRefetching || isUpgradingSecurityPackages); const installOneRule = useCallback( async (ruleId: RuleSignatureId) => { @@ -237,7 +242,7 @@ export const AddPrebuiltRulesTableContextProvider = ({ closeFlyout={closeRulePreview} ruleActions={ { installOneRule(previewedRule.rule_id ?? ''); closeRulePreview();