Skip to content

Commit

Permalink
Fix engine routes that are meta engine or non-meta-engine specific (e…
Browse files Browse the repository at this point in the history
…lastic#104757)

- to include conditionals in their routing

- this matches their nav link behavior - we should have checks in routes as well just in case
# Conflicts:
#	x-pack/plugins/enterprise_search/public/applications/app_search/components/engine/engine_router.test.tsx
  • Loading branch information
Constance authored and cee-chen committed Jul 8, 2021
1 parent 0b282ef commit 98cea53
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ describe('EngineRouter', () => {
...mockEngineValues,
dataLoading: false,
engineNotFound: false,
isMetaEngine: false,
myRole: {},
};
const actions = {
Expand Down Expand Up @@ -181,8 +182,19 @@ describe('EngineRouter', () => {
expect(wrapper.find(SearchUI)).toHaveLength(1);
});

it('renders a source engines view', () => {
setMockValues({
...values,
myRole: { canViewMetaEngineSourceEngines: true },
isMetaEngine: true,
});
const wrapper = shallow(<EngineRouter />);

expect(wrapper.find(SourceEngines)).toHaveLength(1);
});

it('renders a crawler view', () => {
setMockValues({ ...values, myRole: { canViewEngineCrawler: true } });
setMockValues({ ...values, myRole: { canViewEngineCrawler: true }, isMetaEngine: false });
const wrapper = shallow(<EngineRouter />);

expect(wrapper.find(CrawlerRouter)).toHaveLength(1);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ export const EngineRouter: React.FC = () => {
} = useValues(AppLogic);

const { engineName: engineNameFromUrl } = useParams() as { engineName: string };
const { engineName, dataLoading, engineNotFound } = useValues(EngineLogic);
const { engineName, dataLoading, engineNotFound, isMetaEngine } = useValues(EngineLogic);
const { setEngineName, initializeEngine, pollEmptyEngine, stopPolling, clearEngine } = useActions(
EngineLogic
);
Expand Down Expand Up @@ -120,12 +120,12 @@ export const EngineRouter: React.FC = () => {
<SchemaRouter />
</Route>
)}
{canViewMetaEngineSourceEngines && (
{canViewMetaEngineSourceEngines && isMetaEngine && (
<Route path={META_ENGINE_SOURCE_ENGINES_PATH}>
<SourceEngines />
</Route>
)}
{canViewEngineCrawler && (
{canViewEngineCrawler && !isMetaEngine && (
<Route path={ENGINE_CRAWLER_PATH}>
<CrawlerRouter />
</Route>
Expand Down

0 comments on commit 98cea53

Please sign in to comment.