diff --git a/frontend/src/component/strategies/StrategiesList/StrategySwitch/StrategySwitch.tsx b/frontend/src/component/strategies/StrategiesList/StrategySwitch/StrategySwitch.tsx index 58c9c394f4..2f76af138e 100644 --- a/frontend/src/component/strategies/StrategiesList/StrategySwitch/StrategySwitch.tsx +++ b/frontend/src/component/strategies/StrategiesList/StrategySwitch/StrategySwitch.tsx @@ -1,8 +1,9 @@ -import { VFC } from 'react'; +import { useMemo, VFC } from 'react'; import PermissionSwitch from 'component/common/PermissionSwitch/PermissionSwitch'; import { UPDATE_STRATEGY } from 'component/providers/AccessProvider/permissions'; import { Tooltip } from '@mui/material'; import { useId } from 'hooks/useId'; +import { useHasRootAccess } from 'hooks/useHasAccess'; interface IStrategySwitchProps { deprecated: boolean; @@ -19,17 +20,24 @@ export const StrategySwitch: VFC = ({ onToggle(deprecated); }; const id = useId(); + const access = useHasRootAccess(UPDATE_STRATEGY); - const title = deprecated - ? 'Excluded from strategy list' - : 'Included in strategy list'; + const title = useMemo(() => { + if (!access) { + return ''; + } + + if (disabled) { + return 'You cannot disable default strategy'; + } + + return deprecated + ? 'Excluded from strategy list' + : 'Included in strategy list'; + }, [deprecated, disabled, access]); return ( - +