-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[App Search] Allow for query parameter to indicate ingestion mechanis…
…m for new engines (#115188)
- Loading branch information
Showing
8 changed files
with
149 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...enterprise_search/public/applications/app_search/components/engine_creation/utils.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { getRedirectToAfterEngineCreation } from './utils'; | ||
|
||
describe('getRedirectToAfterEngineCreation', () => { | ||
it('returns crawler path when ingestionMethod is crawler', () => { | ||
const engineName = 'elastic'; | ||
const redirectTo = getRedirectToAfterEngineCreation({ ingestionMethod: 'crawler', engineName }); | ||
expect(redirectTo).toEqual('/engines/elastic/crawler'); | ||
}); | ||
|
||
it('returns engine overview path when there is no ingestionMethod', () => { | ||
const engineName = 'elastic'; | ||
const redirectTo = getRedirectToAfterEngineCreation({ ingestionMethod: '', engineName }); | ||
expect(redirectTo).toEqual('/engines/elastic'); | ||
}); | ||
|
||
it('returns engine overview path with query param when there is ingestionMethod', () => { | ||
const engineName = 'elastic'; | ||
const redirectTo = getRedirectToAfterEngineCreation({ ingestionMethod: 'api', engineName }); | ||
expect(redirectTo).toEqual('/engines/elastic?method=api'); | ||
}); | ||
}); |
29 changes: 29 additions & 0 deletions
29
...gins/enterprise_search/public/applications/app_search/components/engine_creation/utils.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the Elastic License | ||
* 2.0; you may not use this file except in compliance with the Elastic License | ||
* 2.0. | ||
*/ | ||
|
||
import { generatePath } from 'react-router-dom'; | ||
|
||
import { ENGINE_CRAWLER_PATH, ENGINE_PATH } from '../../routes'; | ||
|
||
export const getRedirectToAfterEngineCreation = ({ | ||
ingestionMethod, | ||
engineName, | ||
}: { | ||
ingestionMethod?: string; | ||
engineName: string; | ||
}): string => { | ||
if (ingestionMethod === 'crawler') { | ||
return generatePath(ENGINE_CRAWLER_PATH, { engineName }); | ||
} | ||
|
||
let enginePath = generatePath(ENGINE_PATH, { engineName }); | ||
if (ingestionMethod) { | ||
enginePath += `?method=${encodeURIComponent(ingestionMethod)}`; | ||
} | ||
|
||
return enginePath; | ||
}; |