-
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.
[Stateful sidenav] Add cloud yml setting for onboarding default solut…
…ion (#184808)
- Loading branch information
Showing
17 changed files
with
163 additions
and
1 deletion.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type { OnBoardingDefaultSolution } from './types'; |
33 changes: 33 additions & 0 deletions
33
x-pack/plugins/cloud/common/parse_onboarding_default_solution.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,33 @@ | ||
/* | ||
* 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 { parseOnboardingSolution } from './parse_onboarding_default_solution'; | ||
|
||
describe('parseOnboardingSolution', () => { | ||
it('should return undefined if there is no default solution defined', () => { | ||
expect(parseOnboardingSolution()).toBeUndefined(); | ||
}); | ||
|
||
it('should map correctly the cloud values to the Kibana values, regardless of case', () => { | ||
[ | ||
['elasticsearch', 'es'], | ||
['Elasticsearch', 'es'], | ||
['observability', 'oblt'], | ||
['Observability', 'oblt'], | ||
['security', 'security'], | ||
['Security', 'security'], | ||
].forEach(([cloudValue, kibanaValue]) => { | ||
expect(parseOnboardingSolution(cloudValue)).toBe(kibanaValue); | ||
expect(parseOnboardingSolution(cloudValue.toUpperCase())).toBe(kibanaValue); | ||
expect(parseOnboardingSolution(cloudValue.toLowerCase())).toBe(kibanaValue); | ||
}); | ||
}); | ||
|
||
it('should return undefined for unknown values', () => { | ||
expect(parseOnboardingSolution('unknown')).toBeUndefined(); | ||
}); | ||
}); |
39 changes: 39 additions & 0 deletions
39
x-pack/plugins/cloud/common/parse_onboarding_default_solution.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,39 @@ | ||
/* | ||
* 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 type { OnBoardingDefaultSolution } from './types'; | ||
|
||
/** | ||
* Cloud does not type the value of the "use case" that is set during onboarding for a deployment. Any string can | ||
* be passed. This function maps the known values to the Kibana values. | ||
* | ||
* @param value The solution value set by Cloud. | ||
* @returns The default solution value for onboarding that matches Kibana naming. | ||
*/ | ||
export function parseOnboardingSolution(value?: string): OnBoardingDefaultSolution | undefined { | ||
if (!value) return; | ||
|
||
const solutions: Array<{ | ||
cloudValue: 'elasticsearch' | 'observability' | 'security'; | ||
kibanaValue: OnBoardingDefaultSolution; | ||
}> = [ | ||
{ | ||
cloudValue: 'elasticsearch', | ||
kibanaValue: 'es', | ||
}, | ||
{ | ||
cloudValue: 'observability', | ||
kibanaValue: 'oblt', | ||
}, | ||
{ | ||
cloudValue: 'security', | ||
kibanaValue: 'security', | ||
}, | ||
]; | ||
|
||
return solutions.find(({ cloudValue }) => value.toLowerCase() === cloudValue)?.kibanaValue; | ||
} |
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,8 @@ | ||
/* | ||
* 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. | ||
*/ | ||
|
||
export type OnBoardingDefaultSolution = 'es' | 'oblt' | 'security'; |
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
3 changes: 3 additions & 0 deletions
3
x-pack/plugins/cloud/server/__snapshots__/plugin.test.ts.snap
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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