Skip to content

Commit

Permalink
[App Search] Sample Engines should have access to the Crawler (#86502) (
Browse files Browse the repository at this point in the history
#86539)

* Remove logic preventing Crawler from being used on sample engines

* Remove check around crawler button in DocumentCreationButtons

- primarily a UI thing - ideally we always want to show 4 buttons
  • Loading branch information
Constance authored Dec 18, 2020
1 parent e9083ff commit 4166446
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 60 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import { DocumentCreationButtons } from './';
describe('DocumentCreationButtons', () => {
const values = {
engineName: 'test-engine',
isSampleEngine: false,
myRole: { canViewEngineCrawler: true },
};
const actions = {
openDocumentCreation: jest.fn(),
Expand Down Expand Up @@ -56,25 +54,9 @@ describe('DocumentCreationButtons', () => {
expect(actions.openDocumentCreation).toHaveBeenCalledWith('api');
});

describe('crawler card', () => {
it('renders the crawler button with a link to the crawler page', () => {
const wrapper = shallow(<DocumentCreationButtons />);

expect(wrapper.find(EuiCardTo).prop('to')).toEqual('/engines/test-engine/crawler');
});

it('does not render the crawler button if the user does not have access', () => {
setMockValues({ ...values, myRole: { canViewEngineCrawler: false } });
const wrapper = shallow(<DocumentCreationButtons />);

expect(wrapper.find(EuiCardTo)).toHaveLength(0);
});

it('does not render the crawler button for the sample engine', () => {
setMockValues({ ...values, isSampleEngine: true });
const wrapper = shallow(<DocumentCreationButtons />);
it('renders the crawler button with a link to the crawler page', () => {
const wrapper = shallow(<DocumentCreationButtons />);

expect(wrapper.find(EuiCardTo)).toHaveLength(0);
});
expect(wrapper.find(EuiCardTo).prop('to')).toEqual('/engines/test-engine/crawler');
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ import {

import { EuiCardTo } from '../../../shared/react_router_helpers';
import { DOCS_PREFIX, getEngineRoute, ENGINE_CRAWLER_PATH } from '../../routes';
import { AppLogic } from '../../app_logic';
import { EngineLogic } from '../engine';

import { DocumentCreationLogic } from './';
Expand All @@ -34,11 +33,7 @@ interface Props {
export const DocumentCreationButtons: React.FC<Props> = ({ disabled = false }) => {
const { openDocumentCreation } = useActions(DocumentCreationLogic);

const { engineName, isSampleEngine } = useValues(EngineLogic);
const {
myRole: { canViewEngineCrawler },
} = useValues(AppLogic);
const showCrawlerLink = canViewEngineCrawler && !isSampleEngine;
const { engineName } = useValues(EngineLogic);
const crawlerLink = getEngineRoute(engineName) + ENGINE_CRAWLER_PATH;

return (
Expand All @@ -61,7 +56,7 @@ export const DocumentCreationButtons: React.FC<Props> = ({ disabled = false }) =
</p>
</EuiText>
<EuiSpacer />
<EuiFlexGrid columns={showCrawlerLink ? 2 : 3}>
<EuiFlexGrid columns={2}>
<EuiFlexItem>
<EuiCard
title={i18n.translate(
Expand Down Expand Up @@ -98,31 +93,29 @@ export const DocumentCreationButtons: React.FC<Props> = ({ disabled = false }) =
isDisabled={disabled}
/>
</EuiFlexItem>
{showCrawlerLink && (
<EuiFlexItem>
<EuiCardTo
title={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.crawl',
{ defaultMessage: 'Use the Crawler' }
)}
description=""
icon={<EuiIcon type="globe" size="xxl" color="primary" />}
betaBadgeLabel={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.betaTitle',
{ defaultMessage: 'Beta' }
)}
betaBadgeTooltipContent={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.betaTooltip',
{
defaultMessage:
'The Elastic Crawler is not GA. Please help us by reporting any bugs.',
}
)}
to={crawlerLink}
isDisabled={disabled}
/>
</EuiFlexItem>
)}
<EuiFlexItem>
<EuiCardTo
title={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.crawl',
{ defaultMessage: 'Use the Crawler' }
)}
description=""
icon={<EuiIcon type="globe" size="xxl" color="primary" />}
betaBadgeLabel={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.betaTitle',
{ defaultMessage: 'Beta' }
)}
betaBadgeTooltipContent={i18n.translate(
'xpack.enterpriseSearch.appSearch.documentCreation.buttons.betaTooltip',
{
defaultMessage:
'The Elastic Crawler is not GA. Please help us by reporting any bugs.',
}
)}
to={crawlerLink}
isDisabled={disabled}
/>
</EuiFlexItem>
</EuiFlexGrid>
</>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,6 @@ describe('EngineNav', () => {
const wrapper = shallow(<EngineNav />);
expect(wrapper.find('[data-test-subj="EngineCrawlerLink"]')).toHaveLength(0);
});

it('does not render for sample engine', () => {
setMockValues({ ...values, myRole, isSampleEngine: true });
const wrapper = shallow(<EngineNav />);
expect(wrapper.find('[data-test-subj="EngineCrawlerLink"]')).toHaveLength(0);
});
});

describe('meta engine source engines link', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ export const EngineNav: React.FC = () => {
</EuiFlexGroup>
</SideNavLink>
)}
{canViewEngineCrawler && !isMetaEngine && !isSampleEngine && (
{canViewEngineCrawler && !isMetaEngine && (
<SideNavLink
isExternal
to={getAppSearchUrl(engineRoute + ENGINE_CRAWLER_PATH)}
Expand Down

0 comments on commit 4166446

Please sign in to comment.