Skip to content

Commit

Permalink
[Session View] [8.2] beta label added to sessions tabs in timeline (#…
Browse files Browse the repository at this point in the history
…129965)

* beta label added to sessions tabs in timeline

* added test for isBeta

* added test for isBeta

* test revised

Co-authored-by: mitodrummer <karlgodard@elastic.co>
(cherry picked from commit bced9d2)
  • Loading branch information
mitodrummer committed Apr 12, 2022
1 parent 27c523b commit e627c3e
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -126,4 +126,22 @@ describe('Table Navigation', () => {
`/app/securitySolutionUI/hosts/siem-window/authentications${SEARCH_QUERY}`
);
});

test('it renders a EuiBetaBadge only on the sessions tab', () => {
Object.keys(HostsTableType).forEach((tableType) => {
if (tableType !== HostsTableType.sessions) {
const wrapper = mount(<TabNavigationComponent {...mockProps} />);

const betaBadge = wrapper.find(
`EuiTab[data-test-subj="navigation-${tableType}"] EuiBetaBadge`
);

if (tableType === HostsTableType.sessions) {
expect(betaBadge).toBeTruthy();
} else {
expect(betaBadge).toEqual({});
}
}
});
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EuiTab, EuiTabs } from '@elastic/eui';
import { EuiTab, EuiTabs, EuiBetaBadge } from '@elastic/eui';
import { getOr } from 'lodash/fp';
import React, { useEffect, useState, useCallback, useMemo } from 'react';
import { useLocation } from 'react-router-dom';
Expand All @@ -14,13 +14,15 @@ import deepEqual from 'fast-deep-equal';
import { useNavigation } from '../../../lib/kibana';
import { track, METRIC_TYPE, TELEMETRY_EVENT } from '../../../lib/telemetry';
import { TabNavigationProps, TabNavigationItemProps } from './types';
import { BETA } from '../../../translations';

const TabNavigationItemComponent = ({
disabled,
hrefWithSearch,
id,
name,
isSelected,
isBeta,
}: TabNavigationItemProps) => {
const { getAppUrl, navigateTo } = useNavigation();

Expand All @@ -45,6 +47,7 @@ const TabNavigationItemComponent = ({
isSelected={isSelected}
href={appHref}
onClick={handleClick}
append={isBeta && <EuiBetaBadge label={BETA} size="s" />}
>
{name}
</EuiTab>
Expand Down Expand Up @@ -92,6 +95,7 @@ export const TabNavigationComponent: React.FC<TabNavigationProps> = ({
name={tab.name}
disabled={tab.disabled}
isSelected={isSelected}
isBeta={tab.isBeta}
/>
);
}),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@ export interface TabNavigationItemProps {
disabled: boolean;
name: string;
isSelected: boolean;
isBeta?: boolean;
}
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ export interface NavTab {
disabled: boolean;
urlKey?: UrlStateType;
pageId?: SecurityPageName;
isBeta?: boolean;
}

export type SecurityNavKey =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,10 @@ export const EMPTY_ACTION_ENDPOINT_DESCRIPTION = i18n.translate(
}
);

export const BETA = i18n.translate('xpack.securitySolution.pages.common.beta', {
defaultMessage: 'Beta',
});

export const UPDATE_ALERT_STATUS_FAILED = (conflicts: number) =>
i18n.translate('xpack.securitySolution.pages.common.updateAlertStatusFailed', {
values: { conflicts },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ export const navTabsHosts = ({
name: i18n.NAVIGATION_SESSIONS_TITLE,
href: getTabsOnHostsUrl(HostsTableType.sessions),
disabled: false,
isBeta: true,
},
};

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
* 2.0.
*/

import { EuiBadge, EuiLoadingContent, EuiTabs, EuiTab } from '@elastic/eui';
import { EuiBadge, EuiBetaBadge, EuiLoadingContent, EuiTabs, EuiTab } from '@elastic/eui';
import { isEmpty } from 'lodash/fp';
import React, { lazy, memo, Suspense, useCallback, useEffect, useMemo } from 'react';
import { useDispatch } from 'react-redux';
Expand Down Expand Up @@ -37,6 +37,7 @@ import {
getEventIdToNoteIdsSelector,
} from './selectors';
import * as i18n from './translations';
import { BETA } from '../../../../common/translations';

const HideShowContainer = styled.div.attrs<{ $isVisible: boolean; isOverflowYScroll: boolean }>(
({ $isVisible = false, isOverflowYScroll = false }) => ({
Expand Down Expand Up @@ -357,6 +358,7 @@ const TabsContentComponent: React.FC<BasicTimelineTab> = ({
isSelected={activeTab === TimelineTabs.session}
disabled={sessionViewConfig === null}
key={TimelineTabs.session}
append={<EuiBetaBadge label={BETA} size="s" />}
>
{i18n.SESSION_TAB}
</EuiTab>
Expand Down

0 comments on commit e627c3e

Please sign in to comment.