Skip to content

Commit

Permalink
[7.x] Improve deprecation message for xpack.spaces.enabled (#112242)
Browse files Browse the repository at this point in the history
Co-authored-by: Joe Portner <[email protected]>
Co-authored-by: debadair <[email protected]>
  • Loading branch information
3 people authored Oct 6, 2021
1 parent 7693195 commit e17077c
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 9 deletions.
16 changes: 10 additions & 6 deletions x-pack/plugins/spaces/server/config.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,10 @@ describe('spaces config', () => {
const { messages, migrated } = applyConfigDeprecations({ ...originalConfig });

expect(messages).toMatchInlineSnapshot(`
Array [
"Disabling the Spaces plugin (xpack.spaces.enabled) will not be supported in the next major version (8.0)",
]
`);
Array [
"This setting will be removed in 8.0 and the Spaces plugin will always be enabled.",
]
`);
expect(migrated).toEqual(originalConfig);
});

Expand All @@ -58,12 +58,16 @@ describe('spaces config', () => {
expect(migrated).toEqual(originalConfig);
});

it('does not log a warning if xpack.spaces.enabled is set to true', () => {
it('logs a warning if xpack.spaces.enabled is set to true', () => {
const originalConfig = deepFreeze({ xpack: { spaces: { enabled: true } } });

const { messages, migrated } = applyConfigDeprecations({ ...originalConfig });

expect(messages).toMatchInlineSnapshot(`Array []`);
expect(messages).toMatchInlineSnapshot(`
Array [
"This setting will be removed in 8.0 and the Spaces plugin will always be enabled.",
]
`);
expect(migrated).toEqual(originalConfig);
});
});
Expand Down
17 changes: 14 additions & 3 deletions x-pack/plugins/spaces/server/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import type { Observable } from 'rxjs';

import type { TypeOf } from '@kbn/config-schema';
import { schema } from '@kbn/config-schema';
import { i18n } from '@kbn/i18n';
import type {
ConfigDeprecation,
ConfigDeprecationProvider,
Expand All @@ -25,11 +26,21 @@ export function createConfig$(context: PluginInitializerContext) {
}

const disabledDeprecation: ConfigDeprecation = (config, fromPath, addDeprecation) => {
if (config.xpack?.spaces?.enabled === false) {
if ('enabled' in (config?.xpack?.spaces || {})) {
addDeprecation({
message: `Disabling the Spaces plugin (xpack.spaces.enabled) will not be supported in the next major version (8.0)`,
title: i18n.translate('xpack.spaces.deprecations.enabledTitle', {
defaultMessage: 'Setting "xpack.spaces.enabled" is deprecated',
}),
message: i18n.translate('xpack.spaces.deprecations.enabledMessage', {
defaultMessage:
'This setting will be removed in 8.0 and the Spaces plugin will always be enabled.',
}),
correctiveActions: {
manualSteps: [`Remove "xpack.spaces.enabled: false" from your Kibana configuration`],
manualSteps: [
i18n.translate('xpack.spaces.deprecations.enabled.manualStepOneMessage', {
defaultMessage: `Remove "xpack.spaces.enabled" from kibana.yml.`,
}),
],
},
});
}
Expand Down

0 comments on commit e17077c

Please sign in to comment.