Skip to content

Commit 249c5fb

Browse files
authored
[Core deprecations] Add title field to deprecation info (#109840)
1 parent f686164 commit 249c5fb

34 files changed

+572
-212
lines changed

.i18nrc.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"paths": {
33
"alerts": "packages/kbn-alerts/src",
44
"autocomplete": "packages/kbn-securitysolution-autocomplete/src",
5+
"kbnConfig": "packages/kbn-config/src",
56
"console": "src/plugins/console",
67
"core": "src/core",
78
"discover": "src/plugins/discover",

docs/development/core/server/kibana-plugin-core-server.deprecationsdetails.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ export interface DeprecationsDetails
1818
| [deprecationType](./kibana-plugin-core-server.deprecationsdetails.deprecationtype.md) | <code>'config' &#124; 'feature'</code> | (optional) Used to identify between different deprecation types. Example use case: in Upgrade Assistant, we may want to allow the user to sort by deprecation type or show each type in a separate tab.<!-- -->Feel free to add new types if necessary. Predefined types are necessary to reduce having similar definitions with different keywords across kibana deprecations. |
1919
| [documentationUrl](./kibana-plugin-core-server.deprecationsdetails.documentationurl.md) | <code>string</code> | |
2020
| [level](./kibana-plugin-core-server.deprecationsdetails.level.md) | <code>'warning' &#124; 'critical' &#124; 'fetch_error'</code> | levels: - warning: will not break deployment upon upgrade - critical: needs to be addressed before upgrade. - fetch\_error: Deprecations service failed to grab the deprecation details for the domain. |
21-
| [message](./kibana-plugin-core-server.deprecationsdetails.message.md) | <code>string</code> | |
21+
| [message](./kibana-plugin-core-server.deprecationsdetails.message.md) | <code>string</code> | The description message to be displayed for the deprecation. Check the README for writing deprecations in <code>src/core/server/deprecations/README.mdx</code> |
2222
| [requireRestart](./kibana-plugin-core-server.deprecationsdetails.requirerestart.md) | <code>boolean</code> | |
23+
| [title](./kibana-plugin-core-server.deprecationsdetails.title.md) | <code>string</code> | The title of the deprecation. Check the README for writing deprecations in <code>src/core/server/deprecations/README.mdx</code> |
2324

docs/development/core/server/kibana-plugin-core-server.deprecationsdetails.message.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
## DeprecationsDetails.message property
66

7+
The description message to be displayed for the deprecation. Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
8+
79
<b>Signature:</b>
810

911
```typescript
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
2+
3+
[Home](./index.md) &gt; [kibana-plugin-core-server](./kibana-plugin-core-server.md) &gt; [DeprecationsDetails](./kibana-plugin-core-server.deprecationsdetails.md) &gt; [title](./kibana-plugin-core-server.deprecationsdetails.title.md)
4+
5+
## DeprecationsDetails.title property
6+
7+
The title of the deprecation. Check the README for writing deprecations in `src/core/server/deprecations/README.mdx`
8+
9+
<b>Signature:</b>
10+
11+
```typescript
12+
title: string;
13+
```

docs/development/core/server/kibana-plugin-core-server.deprecationsservicesetup.md

Lines changed: 30 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ export interface DeprecationsServiceSetup
2121

2222
```ts
2323
import { DeprecationsDetails, GetDeprecationsContext, CoreSetup } from 'src/core/server';
24+
import { i18n } from '@kbn/i18n';
2425

2526
async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecationsContext): Promise<DeprecationsDetails[]> {
2627
const deprecations: DeprecationsDetails[] = [];
@@ -29,52 +30,44 @@ async function getDeprecations({ esClient, savedObjectsClient }: GetDeprecations
2930
if (count > 0) {
3031
// Example of a manual correctiveAction
3132
deprecations.push({
32-
message: `You have ${count} Timelion worksheets. The Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard.`,
33+
title: i18n.translate('xpack.timelion.deprecations.worksheetsTitle', {
34+
defaultMessage: 'Found Timelion worksheets.'
35+
}),
36+
message: i18n.translate('xpack.timelion.deprecations.worksheetsMessage', {
37+
defaultMessage: 'You have {count} Timelion worksheets. The Timelion app will be removed in 8.0. To continue using your Timelion worksheets, migrate them to a dashboard.',
38+
values: { count },
39+
}),
3340
documentationUrl:
3441
'https://www.elastic.co/guide/en/kibana/current/create-panels-with-timelion.html',
3542
level: 'warning',
3643
correctiveActions: {
3744
manualSteps: [
38-
'Navigate to the Kibana Dashboard and click "Create dashboard".',
39-
'Select Timelion from the "New Visualization" window.',
40-
'Open a new tab, open the Timelion app, select the chart you want to copy, then copy the chart expression.',
41-
'Go to Timelion, paste the chart expression in the Timelion expression field, then click Update.',
42-
'In the toolbar, click Save.',
43-
'On the Save visualization window, enter the visualization Title, then click Save and return.',
45+
i18n.translate('xpack.timelion.deprecations.worksheets.manualStepOneMessage', {
46+
defaultMessage: 'Navigate to the Kibana Dashboard and click "Create dashboard".',
47+
}),
48+
i18n.translate('xpack.timelion.deprecations.worksheets.manualStepTwoMessage', {
49+
defaultMessage: 'Select Timelion from the "New Visualization" window.',
50+
}),
4451
],
52+
api: {
53+
path: '/internal/security/users/test_dashboard_user',
54+
method: 'POST',
55+
body: {
56+
username: 'test_dashboard_user',
57+
roles: [
58+
"machine_learning_user",
59+
"enrich_user",
60+
"kibana_admin"
61+
],
62+
full_name: "Alison Goryachev",
63+
email: "alisongoryachev@gmail.com",
64+
metadata: {},
65+
enabled: true
66+
}
67+
},
4568
},
4669
});
4770
}
48-
49-
// Example of an api correctiveAction
50-
deprecations.push({
51-
"message": "User 'test_dashboard_user' is using a deprecated role: 'kibana_user'",
52-
"documentationUrl": "https://www.elastic.co/guide/en/elasticsearch/reference/current/security-api-put-user.html",
53-
"level": "critical",
54-
"correctiveActions": {
55-
"api": {
56-
"path": "/internal/security/users/test_dashboard_user",
57-
"method": "POST",
58-
"body": {
59-
"username": "test_dashboard_user",
60-
"roles": [
61-
"machine_learning_user",
62-
"enrich_user",
63-
"kibana_admin"
64-
],
65-
"full_name": "Alison Goryachev",
66-
"email": "alisongoryachev@gmail.com",
67-
"metadata": {},
68-
"enabled": true
69-
}
70-
},
71-
"manualSteps": [
72-
"Using Kibana user management, change all users using the kibana_user role to the kibana_admin role.",
73-
"Using Kibana role-mapping management, change all role-mappings which assing the kibana_user role to the kibana_admin role."
74-
]
75-
},
76-
});
77-
7871
return deprecations;
7972
}
8073

packages/kbn-config/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ RUNTIME_DEPS = [
3535
"//packages/kbn-logging",
3636
"//packages/kbn-std",
3737
"//packages/kbn-utility-types",
38+
"//packages/kbn-i18n",
3839
"@npm//js-yaml",
3940
"@npm//load-json-file",
4041
"@npm//lodash",
@@ -48,6 +49,7 @@ TYPES_DEPS = [
4849
"//packages/kbn-logging",
4950
"//packages/kbn-std",
5051
"//packages/kbn-utility-types",
52+
"//packages/kbn-i18n",
5153
"@npm//load-json-file",
5254
"@npm//rxjs",
5355
"@npm//@types/jest",

packages/kbn-config/src/deprecation/deprecation_factory.test.ts

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ describe('DeprecationFactory', () => {
4848
"Replace \\"myplugin.deprecated\\" with \\"myplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
4949
],
5050
},
51-
"message": "\\"myplugin.deprecated\\" is deprecated and has been replaced by \\"myplugin.renamed\\"",
51+
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\"",
52+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
5253
},
5354
],
5455
]
@@ -103,7 +104,8 @@ describe('DeprecationFactory', () => {
103104
"Replace \\"myplugin.oldsection.deprecated\\" with \\"myplugin.newsection.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
104105
],
105106
},
106-
"message": "\\"myplugin.oldsection.deprecated\\" is deprecated and has been replaced by \\"myplugin.newsection.renamed\\"",
107+
"message": "Setting \\"myplugin.oldsection.deprecated\\" has been replaced by \\"myplugin.newsection.renamed\\"",
108+
"title": "Setting \\"myplugin.oldsection.deprecated\\" is deprecated",
107109
},
108110
],
109111
]
@@ -130,7 +132,8 @@ describe('DeprecationFactory', () => {
130132
"Remove \\"myplugin.deprecated\\" from the config.",
131133
],
132134
},
133-
"message": "\\"myplugin.deprecated\\" is deprecated and has been replaced by \\"myplugin.renamed\\". However both key are present, ignoring \\"myplugin.deprecated\\"",
135+
"message": "Setting \\"$myplugin.deprecated\\" has been replaced by \\"$myplugin.renamed\\". However, both keys are present. Ignoring \\"$myplugin.deprecated\\"",
136+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
134137
},
135138
],
136139
]
@@ -172,7 +175,8 @@ describe('DeprecationFactory', () => {
172175
"Replace \\"myplugin.deprecated\\" with \\"myplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
173176
],
174177
},
175-
"message": "\\"myplugin.deprecated\\" is deprecated and has been replaced by \\"myplugin.renamed\\"",
178+
"message": "Setting \\"myplugin.deprecated\\" has been replaced by \\"myplugin.renamed\\"",
179+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
176180
},
177181
],
178182
]
@@ -212,7 +216,8 @@ describe('DeprecationFactory', () => {
212216
"Replace \\"oldplugin.deprecated\\" with \\"newplugin.renamed\\" in the Kibana config file, CLI flag, or environment variable (in Docker only).",
213217
],
214218
},
215-
"message": "\\"oldplugin.deprecated\\" is deprecated and has been replaced by \\"newplugin.renamed\\"",
219+
"message": "Setting \\"oldplugin.deprecated\\" has been replaced by \\"newplugin.renamed\\"",
220+
"title": "Setting \\"oldplugin.deprecated\\" is deprecated",
216221
},
217222
],
218223
]
@@ -264,7 +269,8 @@ describe('DeprecationFactory', () => {
264269
"Remove \\"myplugin.deprecated\\" from the config.",
265270
],
266271
},
267-
"message": "\\"myplugin.deprecated\\" is deprecated and has been replaced by \\"myplugin.renamed\\". However both key are present, ignoring \\"myplugin.deprecated\\"",
272+
"message": "Setting \\"$myplugin.deprecated\\" has been replaced by \\"$myplugin.renamed\\". However, both keys are present. Ignoring \\"$myplugin.deprecated\\"",
273+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
268274
},
269275
],
270276
]
@@ -293,10 +299,11 @@ describe('DeprecationFactory', () => {
293299
Object {
294300
"correctiveActions": Object {
295301
"manualSteps": Array [
296-
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only)",
302+
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
297303
],
298304
},
299-
"message": "myplugin.deprecated is deprecated and is no longer used",
305+
"message": "You no longer need to configure \\"myplugin.deprecated\\".",
306+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
300307
},
301308
],
302309
]
@@ -325,10 +332,11 @@ describe('DeprecationFactory', () => {
325332
Object {
326333
"correctiveActions": Object {
327334
"manualSteps": Array [
328-
"Remove \\"myplugin.section.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only)",
335+
"Remove \\"myplugin.section.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
329336
],
330337
},
331-
"message": "myplugin.section.deprecated is deprecated and is no longer used",
338+
"message": "You no longer need to configure \\"myplugin.section.deprecated\\".",
339+
"title": "Setting \\"myplugin.section.deprecated\\" is deprecated",
332340
},
333341
],
334342
]
@@ -375,10 +383,11 @@ describe('DeprecationFactory', () => {
375383
Object {
376384
"correctiveActions": Object {
377385
"manualSteps": Array [
378-
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only)",
386+
"Remove \\"myplugin.deprecated\\" from the Kibana config file, CLI flag, or environment variable (in Docker only).",
379387
],
380388
},
381-
"message": "myplugin.deprecated is deprecated and is no longer used",
389+
"message": "You no longer need to configure \\"myplugin.deprecated\\".",
390+
"title": "Setting \\"myplugin.deprecated\\" is deprecated",
382391
},
383392
],
384393
]

packages/kbn-config/src/deprecation/deprecation_factory.ts

Lines changed: 44 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
*/
88

99
import { get } from 'lodash';
10+
import { i18n } from '@kbn/i18n';
11+
1012
import {
1113
ConfigDeprecation,
1214
AddConfigDeprecation,
@@ -15,6 +17,13 @@ import {
1517
ConfigDeprecationCommand,
1618
} from './types';
1719

20+
const getDeprecationTitle = (deprecationPath: string) => {
21+
return i18n.translate('kbnConfig.deprecations.deprecatedSettingTitle', {
22+
defaultMessage: 'Setting "{deprecationPath}" is deprecated',
23+
values: { deprecationPath },
24+
});
25+
};
26+
1827
const _rename = (
1928
config: Record<string, any>,
2029
rootPath: string,
@@ -33,10 +42,18 @@ const _rename = (
3342
const newValue = get(config, fullNewPath);
3443
if (newValue === undefined) {
3544
addDeprecation({
36-
message: `"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}"`,
45+
title: getDeprecationTitle(fullOldPath),
46+
message: i18n.translate('kbnConfig.deprecations.replacedSettingMessage', {
47+
defaultMessage: `Setting "{fullOldPath}" has been replaced by "{fullNewPath}"`,
48+
values: { fullOldPath, fullNewPath },
49+
}),
3750
correctiveActions: {
3851
manualSteps: [
39-
`Replace "${fullOldPath}" with "${fullNewPath}" in the Kibana config file, CLI flag, or environment variable (in Docker only).`,
52+
i18n.translate('kbnConfig.deprecations.replacedSetting.manualStepOneMessage', {
53+
defaultMessage:
54+
'Replace "{fullOldPath}" with "{fullNewPath}" in the Kibana config file, CLI flag, or environment variable (in Docker only).',
55+
values: { fullOldPath, fullNewPath },
56+
}),
4057
],
4158
},
4259
...details,
@@ -47,11 +64,23 @@ const _rename = (
4764
};
4865
} else {
4966
addDeprecation({
50-
message: `"${fullOldPath}" is deprecated and has been replaced by "${fullNewPath}". However both key are present, ignoring "${fullOldPath}"`,
67+
title: getDeprecationTitle(fullOldPath),
68+
message: i18n.translate('kbnConfig.deprecations.conflictSettingMessage', {
69+
defaultMessage:
70+
'Setting "${fullOldPath}" has been replaced by "${fullNewPath}". However, both keys are present. Ignoring "${fullOldPath}"',
71+
values: { fullOldPath, fullNewPath },
72+
}),
5173
correctiveActions: {
5274
manualSteps: [
53-
`Make sure "${fullNewPath}" contains the correct value in the config file, CLI flag, or environment variable (in Docker only).`,
54-
`Remove "${fullOldPath}" from the config.`,
75+
i18n.translate('kbnConfig.deprecations.conflictSetting.manualStepOneMessage', {
76+
defaultMessage:
77+
'Make sure "{fullNewPath}" contains the correct value in the config file, CLI flag, or environment variable (in Docker only).',
78+
values: { fullNewPath },
79+
}),
80+
i18n.translate('kbnConfig.deprecations.conflictSetting.manualStepTwoMessage', {
81+
defaultMessage: 'Remove "{fullOldPath}" from the config.',
82+
values: { fullOldPath },
83+
}),
5584
],
5685
},
5786
...details,
@@ -75,10 +104,18 @@ const _unused = (
75104
return;
76105
}
77106
addDeprecation({
78-
message: `${fullPath} is deprecated and is no longer used`,
107+
title: getDeprecationTitle(fullPath),
108+
message: i18n.translate('kbnConfig.deprecations.unusedSettingMessage', {
109+
defaultMessage: 'You no longer need to configure "{fullPath}".',
110+
values: { fullPath },
111+
}),
79112
correctiveActions: {
80113
manualSteps: [
81-
`Remove "${fullPath}" from the Kibana config file, CLI flag, or environment variable (in Docker only)`,
114+
i18n.translate('kbnConfig.deprecations.unusedSetting.manualStepOneMessage', {
115+
defaultMessage:
116+
'Remove "{fullPath}" from the Kibana config file, CLI flag, or environment variable (in Docker only).',
117+
values: { fullPath },
118+
}),
82119
],
83120
},
84121
...details,

packages/kbn-config/src/deprecation/types.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ export type AddConfigDeprecation = (details: DeprecatedConfigDetails) => void;
1919
* @public
2020
*/
2121
export interface DeprecatedConfigDetails {
22+
/* The title to be displayed for the deprecation. */
23+
title?: string;
2224
/* The message to be displayed for the deprecation. */
2325
message: string;
2426
/* (optional) set false to prevent the config service from logging the deprecation message. */

0 commit comments

Comments
 (0)