mirror of
https://github.com/elastic/kibana.git
synced 2025-04-23 09:19:04 -04:00
# Backport This will backport the following commits from `main` to `8.x`: - [[Spaces] Add defaultSolution to spaces config (#218360)](https://github.com/elastic/kibana/pull/218360) <!--- Backport version: 9.6.6 --> ### Questions ? Please refer to the [Backport tool documentation](https://github.com/sorenlouv/backport) <!--BACKPORT [{"author":{"name":"Krzysztof Kowalczyk","email":"krzysztof.kowalczyk@elastic.co"},"sourceCommit":{"committedDate":"2025-04-16T17:22:10Z","message":"[Spaces] Add defaultSolution to spaces config (#218360)\n\n## Summary\n\nThis PR adds new config option `defaultSolution`\n(`xpack.spaces.defaultSolution`) which lets you specify a default\nsolution, similar to the way cloud plugin does it.\n\nAddresses: #213144","sha":"31f0f211d9d76fc757adaff91e41f94bafbacfb4","branchLabelMapping":{"^v9.1.0$":"main","^v8.19.0$":"8.x","^v(\\d+).(\\d+).\\d+$":"$1.$2"}},"sourcePullRequest":{"labels":["release_note:enhancement","Team:Security","enhancement","Feature:Security/Spaces","backport:version","v9.1.0","v8.19.0"],"title":"[Spaces] Add defaultSolution to spaces config","number":218360,"url":"https://github.com/elastic/kibana/pull/218360","mergeCommit":{"message":"[Spaces] Add defaultSolution to spaces config (#218360)\n\n## Summary\n\nThis PR adds new config option `defaultSolution`\n(`xpack.spaces.defaultSolution`) which lets you specify a default\nsolution, similar to the way cloud plugin does it.\n\nAddresses: #213144","sha":"31f0f211d9d76fc757adaff91e41f94bafbacfb4"}},"sourceBranch":"main","suggestedTargetBranches":["8.x"],"targetPullRequestStates":[{"branch":"main","label":"v9.1.0","branchLabelMappingKey":"^v9.1.0$","isSourceBranch":true,"state":"MERGED","url":"https://github.com/elastic/kibana/pull/218360","number":218360,"mergeCommit":{"message":"[Spaces] Add defaultSolution to spaces config (#218360)\n\n## Summary\n\nThis PR adds new config option `defaultSolution`\n(`xpack.spaces.defaultSolution`) which lets you specify a default\nsolution, similar to the way cloud plugin does it.\n\nAddresses: #213144","sha":"31f0f211d9d76fc757adaff91e41f94bafbacfb4"}},{"branch":"8.x","label":"v8.19.0","branchLabelMappingKey":"^v8.19.0$","isSourceBranch":false,"state":"NOT_CREATED"}]}] BACKPORT--> Co-authored-by: Krzysztof Kowalczyk <krzysztof.kowalczyk@elastic.co>
This commit is contained in:
parent
95e63f8260
commit
ef1ea91f38
4 changed files with 42 additions and 3 deletions
|
@ -96,4 +96,12 @@ describe('config schema', () => {
|
|||
)
|
||||
).toThrow();
|
||||
});
|
||||
|
||||
it('should not throw error if defaultSolution uses valid value', () => {
|
||||
expect(() => ConfigSchema.validate({ defaultSolution: 'es' })).not.toThrow();
|
||||
});
|
||||
|
||||
it('should throw error if defaultSolution uses invalid value', () => {
|
||||
expect(() => ConfigSchema.validate({ defaultSolution: 'test' })).toThrow();
|
||||
});
|
||||
});
|
||||
|
|
|
@ -10,6 +10,13 @@ import type { Observable } from 'rxjs';
|
|||
import type { TypeOf } from '@kbn/config-schema';
|
||||
import { offeringBasedSchema, schema } from '@kbn/config-schema';
|
||||
import type { PluginInitializerContext } from '@kbn/core/server';
|
||||
import type { SolutionId } from '@kbn/core-chrome-browser';
|
||||
|
||||
const solutions = ['es', 'oblt', 'security'] as const;
|
||||
|
||||
const solutionSchemaLiterals = [...solutions].map((s) => schema.literal(s)) as [
|
||||
ReturnType<typeof schema.literal<Exclude<SolutionId, 'chat'>>>
|
||||
];
|
||||
|
||||
export const ConfigSchema = schema.object({
|
||||
enabled: schema.conditional(
|
||||
|
@ -54,6 +61,7 @@ export const ConfigSchema = schema.object({
|
|||
defaultValue: true,
|
||||
}),
|
||||
}),
|
||||
defaultSolution: schema.maybe(schema.oneOf(solutionSchemaLiterals)),
|
||||
});
|
||||
|
||||
export function createConfig$(context: PluginInitializerContext) {
|
||||
|
|
|
@ -82,7 +82,7 @@ describe('Spaces plugin', () => {
|
|||
expect(usageCollection.getCollectorByType('spaces')).toBeDefined();
|
||||
});
|
||||
|
||||
it('can setup space with default solution', async () => {
|
||||
it('can setup space with default solution for cloud', async () => {
|
||||
const initializerContext = coreMock.createPluginInitializerContext({ maxSpaces: 1000 });
|
||||
const core = coreMock.createSetup() as CoreSetup<PluginsStart>;
|
||||
const features = featuresPluginMock.createSetup();
|
||||
|
@ -100,6 +100,23 @@ describe('Spaces plugin', () => {
|
|||
expect.objectContaining({ solution: 'security' })
|
||||
);
|
||||
});
|
||||
|
||||
it('can setup space with default solution for onprem', async () => {
|
||||
const initializerContext = coreMock.createPluginInitializerContext({
|
||||
maxSpaces: 1000,
|
||||
defaultSolution: 'oblt',
|
||||
});
|
||||
const core = coreMock.createSetup() as CoreSetup<PluginsStart>;
|
||||
const features = featuresPluginMock.createSetup();
|
||||
const licensing = licensingMock.createSetup();
|
||||
|
||||
const plugin = new SpacesPlugin(initializerContext);
|
||||
plugin.setup(core, { features, licensing });
|
||||
|
||||
expect(createDefaultSpace).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ solution: 'oblt' })
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('#start', () => {
|
||||
|
|
|
@ -6,7 +6,7 @@
|
|||
*/
|
||||
|
||||
import type { Observable } from 'rxjs';
|
||||
import { map } from 'rxjs';
|
||||
import { map, take } from 'rxjs';
|
||||
|
||||
import type { CloudSetup } from '@kbn/cloud-plugin/server';
|
||||
import type {
|
||||
|
@ -155,6 +155,12 @@ export class SpacesPlugin
|
|||
|
||||
const { license } = this.spacesLicenseService.setup({ license$: plugins.licensing.license$ });
|
||||
|
||||
let defaultSolution;
|
||||
|
||||
this.config$.pipe(take(1)).subscribe((config) => {
|
||||
defaultSolution = config.defaultSolution;
|
||||
});
|
||||
|
||||
this.defaultSpaceService = new DefaultSpaceService();
|
||||
this.defaultSpaceService.setup({
|
||||
coreStatus: core.status,
|
||||
|
@ -162,7 +168,7 @@ export class SpacesPlugin
|
|||
license$: plugins.licensing.license$,
|
||||
spacesLicense: license,
|
||||
logger: this.log,
|
||||
solution: plugins.cloud?.onboarding?.defaultSolution,
|
||||
solution: plugins.cloud?.onboarding?.defaultSolution || defaultSolution,
|
||||
});
|
||||
|
||||
initSpacesViewsRoutes({
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue