mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 17:59:23 -04:00
Deprecate expression based scripted fields (#14281)
This PR adds deprecation messages in two places in the Kibana UI. The first is the scripted field creation page, where a message is shown if you've chosen a deprecated language for your script. The second is the index pattern scripted field list page, where a message is shown if any existing scripted fields use a deprecated language. It also adds an error message to the list page if a completely unsupported language is detected.
This commit is contained in:
parent
076cea1694
commit
b20e31fe11
5 changed files with 96 additions and 5 deletions
|
@ -6,6 +6,48 @@
|
|||
These scripted fields are computed on the fly from your data. They can be used in visualizations and displayed in your documents, however they can not be searched. You can manage them here and add new ones as you see fit, but be careful, scripts can be tricky!
|
||||
</p>
|
||||
|
||||
<div class="kuiInfoPanel kuiInfoPanel--warning kuiVerticalRhythm" ng-if="getDeprecatedLanguagesInUse().length !== 0">
|
||||
<div class="kuiInfoPanelHeader">
|
||||
<span
|
||||
class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--warning fa-bolt"
|
||||
aria-label="Warning"
|
||||
role="img"
|
||||
></span>
|
||||
<span class="kuiInfoPanelHeader__title">
|
||||
Deprecation Warning
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="kuiInfoPanelBody">
|
||||
<div class="kuiInfoPanelBody__message">
|
||||
We've detected that the following deprecated languages are in use: {{ getDeprecatedLanguagesInUse().join(', ') }}.
|
||||
Support for these languages will be removed in the next major version of Kibana and Elasticsearch.
|
||||
We recommend converting your scripted fields to
|
||||
<a class="kuiLink" ng-href="{{docLinks.painless}}">Painless</a>.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="kuiInfoPanel kuiInfoPanel--error kuiVerticalRhythm" ng-if="getUnsupportedLanguagesInUse().length !== 0">
|
||||
<div class="kuiInfoPanelHeader">
|
||||
<span
|
||||
class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--error fa-warning"
|
||||
aria-label="Error"
|
||||
role="img"
|
||||
></span>
|
||||
<span class="kuiInfoPanelHeader__title">
|
||||
Unsupported Languages
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="kuiInfoPanelBody">
|
||||
<div class="kuiInfoPanelBody__message">
|
||||
We've detected that the following unsupported languages are in use: {{ getUnsupportedLanguagesInUse().join(', ') }}.
|
||||
All scripted fields should be converted to <a class="kuiLink" ng-href="{{docLinks.painless}}">Painless</a>.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<a
|
||||
data-test-subj="addScriptedFieldLink"
|
||||
ng-href="{{ kbnUrl.getRouteHref(indexPattern, 'addField') }}"
|
||||
|
|
|
@ -4,6 +4,8 @@ import fieldControlsHtml from '../field_controls.html';
|
|||
import { dateScripts } from './date_scripts';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import template from './scripted_fields_table.html';
|
||||
import { getSupportedScriptingLanguages, getDeprecatedScriptingLanguages } from 'ui/scripting_languages';
|
||||
import { documentationLinks } from 'ui/documentation_links/documentation_links';
|
||||
|
||||
uiModules.get('apps/management')
|
||||
.directive('scriptedFieldsTable', function (kbnUrl, Notifier, $filter, confirmModal) {
|
||||
|
@ -21,6 +23,7 @@ uiModules.get('apps/management')
|
|||
const fieldCreatorPath = '/management/kibana/indices/{{ indexPattern }}/scriptedField';
|
||||
const fieldEditorPath = fieldCreatorPath + '/{{ fieldName }}';
|
||||
|
||||
$scope.docLinks = documentationLinks.scriptedFields;
|
||||
$scope.perPage = 25;
|
||||
$scope.columns = [
|
||||
{ title: 'name' },
|
||||
|
@ -110,6 +113,19 @@ uiModules.get('apps/management')
|
|||
};
|
||||
confirmModal(`Are you sure want to delete ${field.name}? This action is irreversible!`, confirmModalOptions);
|
||||
};
|
||||
|
||||
function getLanguagesInUse() {
|
||||
const fields = $scope.indexPattern.getScriptedFields();
|
||||
return _.uniq(_.map(fields, 'lang'));
|
||||
}
|
||||
|
||||
$scope.getDeprecatedLanguagesInUse = function () {
|
||||
return _.intersection(getLanguagesInUse(), getDeprecatedScriptingLanguages());
|
||||
};
|
||||
|
||||
$scope.getUnsupportedLanguagesInUse = function () {
|
||||
return _.difference(getLanguagesInUse(), _.union(getSupportedScriptingLanguages(), getDeprecatedScriptingLanguages()));
|
||||
};
|
||||
}
|
||||
};
|
||||
});
|
||||
|
|
|
@ -28,12 +28,33 @@
|
|||
|
||||
<div ng-if="editor.field.scripted" class="form-group">
|
||||
<label for="scriptedFieldLang">Language</label>
|
||||
<div class="kuiInfoPanel kuiInfoPanel--warning kuiVerticalRhythm" ng-if="editor.field.lang && editor.isDeprecatedLang(editor.field.lang)">
|
||||
<div class="kuiInfoPanelHeader">
|
||||
<span
|
||||
class="kuiInfoPanelHeader__icon kuiIcon kuiIcon--warning fa-bolt"
|
||||
aria-label="Warning"
|
||||
role="img"
|
||||
></span>
|
||||
<span class="kuiInfoPanelHeader__title">
|
||||
Deprecation Warning
|
||||
</span>
|
||||
</div>
|
||||
|
||||
<div class="kuiInfoPanelBody">
|
||||
<div class="kuiInfoPanelBody__message">
|
||||
<span class="text-capitalize">{{editor.field.lang}}</span> is deprecated and support will be removed in the
|
||||
next major version of Kibana and Elasticsearch. We recommend using
|
||||
<a class="kuiLink" ng-href="{{editor.docLinks.painless}}">Painless</a>
|
||||
for new scripted fields.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<select
|
||||
ng-model="editor.field.lang"
|
||||
id="scriptedFieldLang"
|
||||
ng-options="lang as lang for lang in editor.scriptingLangs"
|
||||
required
|
||||
class="form-control"
|
||||
class="form-control kuiVerticalRhythm"
|
||||
data-test-subj="editorFieldLang">
|
||||
<option value="">-- Select Language --</option>
|
||||
</select>
|
||||
|
|
|
@ -8,7 +8,11 @@ import { uiModules } from 'ui/modules';
|
|||
import fieldEditorTemplate from 'ui/field_editor/field_editor.html';
|
||||
import '../directives/documentation_href';
|
||||
import './field_editor.less';
|
||||
import { GetEnabledScriptingLanguagesProvider, getSupportedScriptingLanguages } from '../scripting_languages';
|
||||
import {
|
||||
GetEnabledScriptingLanguagesProvider,
|
||||
getSupportedScriptingLanguages,
|
||||
getDeprecatedScriptingLanguages
|
||||
} from '../scripting_languages';
|
||||
import { getKbnTypeNames } from '../../../utils';
|
||||
|
||||
uiModules
|
||||
|
@ -38,7 +42,7 @@ uiModules
|
|||
const notify = new Notifier({ location: 'Field Editor' });
|
||||
|
||||
getScriptingLangs().then((langs) => {
|
||||
self.scriptingLangs = _.intersection(langs, ['expression', 'painless']);
|
||||
self.scriptingLangs = langs;
|
||||
if (!_.includes(self.scriptingLangs, self.field.lang)) {
|
||||
self.field.lang = undefined;
|
||||
}
|
||||
|
@ -103,6 +107,10 @@ uiModules
|
|||
);
|
||||
};
|
||||
|
||||
self.isDeprecatedLang = function (lang) {
|
||||
return _.contains(getDeprecatedScriptingLanguages(), lang);
|
||||
};
|
||||
|
||||
$scope.$watch('editor.selectedFormatId', function (cur, prev) {
|
||||
const format = self.field.format;
|
||||
const changedFormat = cur !== prev;
|
||||
|
@ -179,7 +187,7 @@ uiModules
|
|||
function getScriptingLangs() {
|
||||
return getEnabledScriptingLanguages()
|
||||
.then((enabledLanguages) => {
|
||||
return _.intersection(enabledLanguages, getSupportedScriptingLanguages());
|
||||
return _.intersection(enabledLanguages, _.union(getSupportedScriptingLanguages(), getDeprecatedScriptingLanguages()));
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -4,7 +4,11 @@ import { Notifier } from 'ui/notify/notifier';
|
|||
const notify = new Notifier({ location: 'Scripting Language Service' });
|
||||
|
||||
export function getSupportedScriptingLanguages() {
|
||||
return ['expression', 'painless'];
|
||||
return ['painless'];
|
||||
}
|
||||
|
||||
export function getDeprecatedScriptingLanguages() {
|
||||
return ['expression'];
|
||||
}
|
||||
|
||||
export function GetEnabledScriptingLanguagesProvider($http) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue