Skip to content

Commit

Permalink
Add ml permission check for entity analytics dashboard old menu
Browse files Browse the repository at this point in the history
  • Loading branch information
machadoum committed Aug 16, 2022
1 parent 9d87041 commit 7348fa4
Showing 1 changed file with 10 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ import { SecurityPageName } from '../../../../../common/constants';
import { useCanSeeHostIsolationExceptionsMenu } from '../../../../management/pages/host_isolation_exceptions/view/hooks';
import { useIsExperimentalFeatureEnabled } from '../../../hooks/use_experimental_features';
import { useGlobalQueryString } from '../../../utils/global_query_string';
import { useMlCapabilities } from '../../ml/hooks/use_ml_capabilities';
import { hasMlUserPermissions } from '../../../../../common/machine_learning/has_ml_user_permissions';
import { hasMlLicense } from '../../../../../common/machine_learning/has_ml_license';

export const usePrimaryNavigationItems = ({
navTabs,
Expand Down Expand Up @@ -72,8 +75,10 @@ function usePrimaryNavigationItemsToDisplay(navTabs: Record<string, NavTab>) {
const hasCasesReadPermissions = useGetUserCasesPermissions().read;
const canSeeHostIsolationExceptions = useCanSeeHostIsolationExceptionsMenu();
const isPolicyListEnabled = useIsExperimentalFeatureEnabled('policyListEnabled');
const isEntityAnalyticsDashoardEnabled = useIsExperimentalFeatureEnabled(
'entityAnalyticsDashoardEnabled'
const mlCapabilities = useMlCapabilities();
const hasMlPermissions = hasMlLicense(mlCapabilities) && hasMlUserPermissions(mlCapabilities);
const isEntityAnalyticsDashboardEnabled = useIsExperimentalFeatureEnabled(
'entityAnalyticsDashboardEnabled'
);
const uiCapabilities = useKibana().services.application.capabilities;
return useMemo(
Expand All @@ -94,7 +99,7 @@ function usePrimaryNavigationItemsToDisplay(navTabs: Record<string, NavTab>) {
...(navTabs[SecurityPageName.kubernetes] != null
? [navTabs[SecurityPageName.kubernetes]]
: []),
...(isEntityAnalyticsDashoardEnabled
...(isEntityAnalyticsDashboardEnabled && hasMlPermissions
? [navTabs[SecurityPageName.entityAnalytics]]
: []),
],
Expand Down Expand Up @@ -157,10 +162,11 @@ function usePrimaryNavigationItemsToDisplay(navTabs: Record<string, NavTab>) {
[
uiCapabilities.siem.show,
navTabs,
isEntityAnalyticsDashoardEnabled,
isEntityAnalyticsDashboardEnabled,
hasCasesReadPermissions,
canSeeHostIsolationExceptions,
isPolicyListEnabled,
hasMlPermissions,
]
);
}

0 comments on commit 7348fa4

Please sign in to comment.