Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[App Search] Sample Engines should have access to the Crawler #86502

Merged
merged 2 commits into from
Dec 18, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also just confirmed in the Crawler channel w/ Rich that there's no realistic scenario where a user would have access to document creation (upload/pasting JSON) and not have access to the Crawler, so I think this access check is also safe to remove

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