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] Support "Deprecated" label in advanced settings (#54539) #54660

Merged
merged 1 commit into from
Jan 13, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->

[Home](./index.md) &gt; [kibana-plugin-server](./kibana-plugin-server.md) &gt; [UiSettingsParams](./kibana-plugin-server.uisettingsparams.md) &gt; [deprecation](./kibana-plugin-server.uisettingsparams.deprecation.md)

## UiSettingsParams.deprecation property

optional deprecation information. Used to generate a deprecation warning.

<b>Signature:</b>

```typescript
deprecation?: DeprecationSettings;
```
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ export interface UiSettingsParams
| Property | Type | Description |
| --- | --- | --- |
| [category](./kibana-plugin-server.uisettingsparams.category.md) | <code>string[]</code> | used to group the configured setting in the UI |
| [deprecation](./kibana-plugin-server.uisettingsparams.deprecation.md) | <code>DeprecationSettings</code> | optional deprecation information. Used to generate a deprecation warning. |
| [description](./kibana-plugin-server.uisettingsparams.description.md) | <code>string</code> | description provided to a user in UI |
| [name](./kibana-plugin-server.uisettingsparams.name.md) | <code>string</code> | title in the UI |
| [optionLabels](./kibana-plugin-server.uisettingsparams.optionlabels.md) | <code>Record&lt;string, string&gt;</code> | text labels for 'select' type UI element |
Expand Down
3 changes: 3 additions & 0 deletions src/core/public/doc_links/doc_links_service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,9 @@ export class DocLinksService {
date: {
dateMath: `${ELASTICSEARCH_DOCS}common-options.html#date-math`,
},
management: {
kibanaSearchSettings: `${ELASTIC_WEBSITE_URL}guide/en/kibana/${DOC_LINK_VERSION}/advanced-options.html#kibana-search-settings`,
},
},
});
}
Expand Down
2 changes: 2 additions & 0 deletions src/core/server/server.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -1928,6 +1928,8 @@ export type SharedGlobalConfig = RecursiveReadonly_2<{
// @public
export interface UiSettingsParams {
category?: string[];
// Warning: (ae-forgotten-export) The symbol "DeprecationSettings" needs to be exported by the entry point index.d.ts
deprecation?: DeprecationSettings;
description?: string;
name?: string;
optionLabels?: Record<string, string>;
Expand Down
11 changes: 11 additions & 0 deletions src/core/server/ui_settings/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,15 @@ export interface UserProvidedValues<T = any> {
isOverridden?: boolean;
}

/**
* UiSettings deprecation field options.
* @public
* */
export interface DeprecationSettings {
message: string;
docLinksKey: string;
}

/**
* UI element type to represent the settings.
* @public
Expand Down Expand Up @@ -102,6 +111,8 @@ export interface UiSettingsParams {
readonly?: boolean;
/** defines a type of UI element {@link UiSettingsType} */
type?: UiSettingsType;
/** optional deprecation information. Used to generate a deprecation warning. */
deprecation?: DeprecationSettings;
/*
* Allows defining a custom validation applicable to value change on the client.
* @deprecated
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@

import React, { PureComponent, Fragment } from 'react';
import PropTypes from 'prop-types';
import { npStart } from 'ui/new_platform';

import 'brace/theme/textmate';
import 'brace/mode/markdown';

import { toastNotifications } from 'ui/notify';
import {
EuiBadge,
EuiButton,
EuiButtonEmpty,
EuiCode,
Expand All @@ -41,6 +43,7 @@ import {
EuiImage,
EuiLink,
EuiSpacer,
EuiToolTip,
EuiText,
EuiSelect,
EuiSwitch,
Expand Down Expand Up @@ -565,6 +568,36 @@ export class Field extends PureComponent {

renderDescription(setting) {
let description;
let deprecation;

if (setting.deprecation) {
const { links } = npStart.core.docLinks;

deprecation = (
<>
<EuiToolTip content={setting.deprecation.message}>
<EuiBadge
color="warning"
onClick={() => {
window.open(links.management[setting.deprecation.docLinksKey], '_blank');
}}
onClickAriaLabel={i18n.translate(
'kbn.management.settings.field.deprecationClickAreaLabel',
{
defaultMessage: 'Click to view deprecation documentation for {settingName}.',
values: {
settingName: setting.name,
},
}
)}
>
Deprecated
</EuiBadge>
</EuiToolTip>
<EuiSpacer size="s" />
</>
);
}

if (React.isValidElement(setting.description)) {
description = setting.description;
Expand All @@ -582,6 +615,7 @@ export class Field extends PureComponent {

return (
<Fragment>
{deprecation}
{description}
{this.renderDefaultValue(setting)}
</Fragment>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function toEditableConfig({ def, name, value, isCustom, isOverridden }) {
defVal: def.value,
type: getValType(def, value),
description: def.description,
deprecation: def.deprecation,
validation:
def.validation && def.validation.regexString
? {
Expand Down
6 changes: 6 additions & 0 deletions src/legacy/core_plugins/kibana/ui_setting_defaults.js
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,12 @@ export function getUiSettingDefaults() {
away or update the query. When enabled, dashboard panels will load together when all of the data is loaded, and
searches will not terminate.`,
}),
deprecation: {
message: i18n.translate('kbn.advancedSettings.courier.batchSearchesTextDeprecation', {
defaultMessage: 'This setting is deprecated and will be removed in Kibana 8.0.',
}),
docLinksKey: 'kibanaSearchSettings',
},
category: ['search'],
},
'search:includeFrozen': {
Expand Down
Loading