Skip to content

Commit

Permalink
[App Search] Put History tab behind platinum check (#115636)
Browse files Browse the repository at this point in the history
  • Loading branch information
JasonStoltz authored Oct 20, 2021
1 parent eb5af49 commit 109e966
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 31 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ import { CurationsSettings } from './curations_settings';

describe('Curations', () => {
const values = {
// CurationsLogic
dataLoading: false,
curations: [
{
Expand All @@ -46,6 +47,8 @@ describe('Curations', () => {
},
},
selectedPageTab: 'overview',
// LicensingLogic
hasPlatinumLicense: true,
};

const actions = {
Expand Down Expand Up @@ -75,6 +78,20 @@ describe('Curations', () => {

tabs.at(2).simulate('click');
expect(actions.onSelectPageTab).toHaveBeenNthCalledWith(3, 'settings');
// The settings tab should NOT have an icon next to it
expect(tabs.at(2).prop('prepend')).toBeUndefined();
});

it('renders less tabs when less than platinum license', () => {
setMockValues({ ...values, hasPlatinumLicense: false });
const wrapper = shallow(<Curations />);

expect(getPageTitle(wrapper)).toEqual('Curated results');

const tabs = getPageHeaderTabs(wrapper).find(EuiTab);
expect(tabs.length).toBe(2);
// The settings tab should have an icon next to it
expect(tabs.at(1).prop('prepend')).not.toBeUndefined();
});

it('renders an overview view', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,10 @@ import React, { useEffect } from 'react';

import { useValues, useActions } from 'kea';

import { EuiIcon } from '@elastic/eui';
import { i18n } from '@kbn/i18n';

import { LicensingLogic } from '../../../../shared/licensing';
import { EuiButtonTo } from '../../../../shared/react_router_helpers';

import { ENGINE_CURATIONS_NEW_PATH } from '../../../routes';
Expand All @@ -28,39 +30,47 @@ import { CurationsSettings } from './curations_settings';
export const Curations: React.FC = () => {
const { dataLoading, curations, meta, selectedPageTab } = useValues(CurationsLogic);
const { loadCurations, onSelectPageTab } = useActions(CurationsLogic);
const { hasPlatinumLicense } = useValues(LicensingLogic);

const pageTabs = [
{
label: i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.curations.overviewPageTabLabel',
{
defaultMessage: 'Overview',
}
),
isSelected: selectedPageTab === 'overview',
onClick: () => onSelectPageTab('overview'),
},
{
label: i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.curations.historyPageTabLabel',
{
defaultMessage: 'History',
}
),
isSelected: selectedPageTab === 'history',
onClick: () => onSelectPageTab('history'),
},
{
label: i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.curations.settingsPageTabLabel',
const OVERVIEW_TAB = {
label: i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.curations.overviewPageTabLabel',
{
defaultMessage: 'Overview',
}
),
isSelected: selectedPageTab === 'overview',
onClick: () => onSelectPageTab('overview'),
};

const HISTORY_TAB = {
label: i18n.translate('xpack.enterpriseSearch.appSearch.engine.curations.historyPageTabLabel', {
defaultMessage: 'History',
}),
isSelected: selectedPageTab === 'history',
onClick: () => onSelectPageTab('history'),
};

const SETTINGS_TAB = {
label: i18n.translate(
'xpack.enterpriseSearch.appSearch.engine.curations.settingsPageTabLabel',
{
defaultMessage: 'Settings',
}
),
isSelected: selectedPageTab === 'settings',
onClick: () => onSelectPageTab('settings'),
};

const pageTabs = hasPlatinumLicense
? [OVERVIEW_TAB, HISTORY_TAB, SETTINGS_TAB]
: [
OVERVIEW_TAB,
{
defaultMessage: 'Settings',
}
),
isSelected: selectedPageTab === 'settings',
onClick: () => onSelectPageTab('settings'),
},
];
...SETTINGS_TAB,
prepend: <EuiIcon type="cheer" />,
},
];

useEffect(() => {
loadCurations();
Expand Down

0 comments on commit 109e966

Please sign in to comment.