mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 17:28:26 -04:00
* Hide timeline bar if user does not have security solution crud capability
* change visibility to be based on show instead of crud
* PR fix
Co-authored-by: Kristof-Pierre Cummings <kristofpierre.cummings@elastic.co>
(cherry picked from commit 5aa26ed37d
)
Co-authored-by: Kristof C <kpac.ja@gmail.com>
This commit is contained in:
parent
b869b7f245
commit
9c546f1a21
2 changed files with 100 additions and 1 deletions
|
@ -0,0 +1,94 @@
|
|||
/*
|
||||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
|
||||
* or more contributor license agreements. Licensed under the Elastic License
|
||||
* 2.0; you may not use this file except in compliance with the Elastic License
|
||||
* 2.0.
|
||||
*/
|
||||
|
||||
import { render } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { TestProviders } from '../../../common/mock';
|
||||
import { SecuritySolutionTemplateWrapper } from './';
|
||||
|
||||
jest.mock('./bottom_bar', () => ({
|
||||
...jest.requireActual('./bottom_bar'),
|
||||
SecuritySolutionBottomBar: () => <div>{'Bottom Bar'}</div>,
|
||||
}));
|
||||
|
||||
const mockSiemUserCanCrud = jest.fn();
|
||||
jest.mock('../../../common/lib/kibana', () => {
|
||||
const original = jest.requireActual('../../../common/lib/kibana');
|
||||
|
||||
return {
|
||||
...original,
|
||||
useKibana: () => ({
|
||||
services: {
|
||||
...original.useKibana().services,
|
||||
application: {
|
||||
capabilities: {
|
||||
siem: mockSiemUserCanCrud(),
|
||||
},
|
||||
},
|
||||
},
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
jest.mock('../../../common/components/navigation/use_security_solution_navigation', () => {
|
||||
return {
|
||||
useSecuritySolutionNavigation: () => ({
|
||||
icon: 'logoSecurity',
|
||||
items: [
|
||||
{
|
||||
id: 'investigate',
|
||||
name: 'Investigate',
|
||||
items: [
|
||||
{
|
||||
'data-href': 'some-data-href',
|
||||
'data-test-subj': 'navigation-cases',
|
||||
disabled: false,
|
||||
href: 'some-href',
|
||||
id: 'cases',
|
||||
isSelected: true,
|
||||
name: 'Cases',
|
||||
},
|
||||
],
|
||||
tabIndex: undefined,
|
||||
},
|
||||
],
|
||||
name: 'Security',
|
||||
}),
|
||||
};
|
||||
});
|
||||
|
||||
const renderComponent = () => {
|
||||
return render(
|
||||
<TestProviders>
|
||||
<SecuritySolutionTemplateWrapper onAppLeave={() => null}>
|
||||
<div>{'child of wrapper'}</div>
|
||||
</SecuritySolutionTemplateWrapper>
|
||||
</TestProviders>
|
||||
);
|
||||
};
|
||||
|
||||
describe('SecuritySolutionTemplateWrapper', () => {
|
||||
beforeEach(() => {
|
||||
jest.clearAllMocks();
|
||||
mockSiemUserCanCrud.mockReturnValue({ show: true });
|
||||
});
|
||||
|
||||
it('Should render to the page with bottom bar if user has SIEM show', async () => {
|
||||
const { getByText } = renderComponent();
|
||||
expect(getByText('child of wrapper')).toBeInTheDocument();
|
||||
expect(getByText('Bottom Bar')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('Should not show bottom bar if user does not have SIEM show', async () => {
|
||||
mockSiemUserCanCrud.mockReturnValue({ show: false });
|
||||
|
||||
const { getByText } = renderComponent();
|
||||
expect(getByText('child of wrapper')).toBeInTheDocument();
|
||||
expect(() => getByText('Bottom Bar')).toThrow();
|
||||
});
|
||||
});
|
|
@ -26,6 +26,7 @@ import {
|
|||
} from './bottom_bar';
|
||||
import { useShowTimeline } from '../../../common/utils/timeline/use_show_timeline';
|
||||
import { gutterTimeline } from '../../../common/lib/helpers';
|
||||
import { useKibana } from '../../../common/lib/kibana';
|
||||
import { useShowPagesWithEmptyView } from '../../../common/utils/empty_view/use_show_pages_with_empty_view';
|
||||
|
||||
/**
|
||||
|
@ -75,6 +76,8 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionPageWrapp
|
|||
const { show: isShowingTimelineOverlay } = useDeepEqualSelector((state) =>
|
||||
getTimelineShowStatus(state, TimelineId.active)
|
||||
);
|
||||
|
||||
const userHasSecuritySolutionVisible = useKibana().services.application.capabilities.siem.show;
|
||||
const showEmptyState = useShowPagesWithEmptyView();
|
||||
const emptyStateProps = showEmptyState ? NO_DATA_PAGE_TEMPLATE_PROPS : {};
|
||||
|
||||
|
@ -89,7 +92,9 @@ export const SecuritySolutionTemplateWrapper: React.FC<SecuritySolutionPageWrapp
|
|||
$isTimelineBottomBarVisible={isTimelineBottomBarVisible}
|
||||
$isShowingTimelineOverlay={isShowingTimelineOverlay}
|
||||
bottomBarProps={SecuritySolutionBottomBarProps}
|
||||
bottomBar={<SecuritySolutionBottomBar onAppLeave={onAppLeave} />}
|
||||
bottomBar={
|
||||
userHasSecuritySolutionVisible && <SecuritySolutionBottomBar onAppLeave={onAppLeave} />
|
||||
}
|
||||
paddingSize="none"
|
||||
solutionNav={solutionNav}
|
||||
restrictWidth={false}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue