Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[7.x] Improve deprecation message for xpack.spaces.enabled #112242

Merged
merged 14 commits into from
Oct 6, 2021
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 @@ -38,10 +38,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 [
"In 8.0.0 and later, using \\"xpack.spaces.enabled\\" is unsupported, and the Spaces plugin is always enabled.",
]
`);
expect(migrated).toEqual(originalConfig);
});

Expand All @@ -54,12 +54,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