mirror of
https://github.com/elastic/kibana.git
synced 2025-04-24 09:48:58 -04:00
[vis: Default Editor] Remove regex control (#34530)
* Remove usued regex control * Remove dependency on removed file
This commit is contained in:
parent
954d3e1093
commit
5c2267f2ca
7 changed files with 0 additions and 196 deletions
|
@ -22,7 +22,6 @@ import { AggParams } from '../agg_params';
|
|||
import { BaseParamType } from '../param_types/base';
|
||||
import { FieldParamType } from '../param_types/field';
|
||||
import { OptionedParamType } from '../param_types/optioned';
|
||||
import { RegexParamType } from '../param_types/regex';
|
||||
|
||||
describe('AggParams class', function () {
|
||||
|
||||
|
@ -64,19 +63,6 @@ describe('AggParams class', function () {
|
|||
expect(aggParams[0]).to.be.a(OptionedParamType);
|
||||
});
|
||||
|
||||
it('Uses the RegexParamType class for params of type "regex"', function () {
|
||||
const params = [
|
||||
{
|
||||
name: 'exclude',
|
||||
type: 'regex'
|
||||
}
|
||||
];
|
||||
const aggParams = new AggParams(params);
|
||||
|
||||
expect(aggParams).to.have.length(params.length);
|
||||
expect(aggParams[0]).to.be.a(RegexParamType);
|
||||
});
|
||||
|
||||
it('Always converts the params to a BaseParamType', function () {
|
||||
const params = [
|
||||
{
|
||||
|
|
|
@ -1,93 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import { BaseParamType } from '../../param_types/base';
|
||||
import { RegexParamType } from '../../param_types/regex';
|
||||
import { VisProvider } from '../../../vis';
|
||||
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
|
||||
|
||||
describe('Regex', function () {
|
||||
|
||||
let Vis;
|
||||
let indexPattern;
|
||||
|
||||
beforeEach(ngMock.module('kibana'));
|
||||
// fetch out deps
|
||||
beforeEach(ngMock.inject(function (Private) {
|
||||
Vis = Private(VisProvider);
|
||||
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
|
||||
}));
|
||||
|
||||
describe('constructor', function () {
|
||||
it('should be an instance of BaseParamType', function () {
|
||||
const aggParam = new RegexParamType({
|
||||
name: 'some_param',
|
||||
type: 'regex'
|
||||
});
|
||||
|
||||
expect(aggParam).to.be.a(BaseParamType);
|
||||
expect(aggParam).to.have.property('write');
|
||||
});
|
||||
});
|
||||
|
||||
describe('write results', function () {
|
||||
let aggParam;
|
||||
let aggConfig;
|
||||
const output = { params: {} };
|
||||
const paramName = 'exclude';
|
||||
|
||||
beforeEach(function () {
|
||||
const vis = new Vis(indexPattern, {
|
||||
type: 'pie',
|
||||
aggs: [
|
||||
{ type: 'terms', schema: 'split', params: { field: 'extension' } },
|
||||
]
|
||||
});
|
||||
aggConfig = vis.aggs[0];
|
||||
|
||||
aggParam = new RegexParamType({
|
||||
name: paramName,
|
||||
type: 'regex'
|
||||
});
|
||||
});
|
||||
|
||||
it('should not include param in output', function () {
|
||||
aggConfig.params[paramName] = {
|
||||
pattern: ''
|
||||
};
|
||||
|
||||
aggParam.write(aggConfig, output);
|
||||
expect(output).to.be.an('object');
|
||||
expect(output).to.have.property('params');
|
||||
expect(output.params).not.to.have.property(paramName);
|
||||
});
|
||||
|
||||
it('should include param in output', function () {
|
||||
aggConfig.params[paramName] = {
|
||||
pattern: 'testing'
|
||||
};
|
||||
|
||||
aggParam.write(aggConfig, output);
|
||||
expect(output.params).to.have.property(paramName);
|
||||
expect(output.params[paramName]).to.eql({ pattern: 'testing' });
|
||||
});
|
||||
});
|
||||
});
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
import './_field';
|
||||
import './_optioned';
|
||||
import './_regex';
|
||||
import './_string';
|
||||
import './_json';
|
||||
describe('ParamTypes', function () {
|
||||
|
|
|
@ -21,7 +21,6 @@ import '../filters/label';
|
|||
import { IndexedArray } from '../indexed_array';
|
||||
import { FieldParamType } from './param_types/field';
|
||||
import { OptionedParamType } from './param_types/optioned';
|
||||
import { RegexParamType } from './param_types/regex';
|
||||
import { StringParamType } from './param_types/string';
|
||||
import { JsonParamType } from './param_types/json';
|
||||
import { BaseParamType } from './param_types/base';
|
||||
|
@ -30,7 +29,6 @@ import { createLegacyClass } from '../utils/legacy_class';
|
|||
const paramTypeMap = {
|
||||
field: FieldParamType,
|
||||
optioned: (OptionedParamType),
|
||||
regex: (RegexParamType),
|
||||
string: (StringParamType),
|
||||
json: (JsonParamType),
|
||||
_default: (BaseParamType)
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
<div ng-if="!aggParam.disabled(agg)">
|
||||
<div class="form-group regex">
|
||||
<label
|
||||
for="visEditorRegexInput{{agg.id}}{{aggParam.name}}"
|
||||
i18n-id="common.ui.aggTypes.paramNamePatternLabel"
|
||||
i18n-default-message="{aggParamName} Pattern"
|
||||
i18n-values="{ aggParamName: (aggParam.name | label) }"
|
||||
></label>
|
||||
<input
|
||||
id="visEditorRegexInput{{agg.id}}{{aggParam.name}}"
|
||||
type="text"
|
||||
class="form-control"
|
||||
ng-model="agg.params[aggParam.name].pattern"
|
||||
>
|
||||
</div>
|
||||
</div>
|
|
@ -1,69 +0,0 @@
|
|||
/*
|
||||
* Licensed to Elasticsearch B.V. under one or more contributor
|
||||
* license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright
|
||||
* ownership. Elasticsearch B.V. licenses this file to you under
|
||||
* the Apache License, Version 2.0 (the "License"); you may
|
||||
* not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import '../../filters/label';
|
||||
import editorHtml from '../controls/regular_expression.html';
|
||||
import { BaseParamType } from './base';
|
||||
import { createLegacyClass } from '../../utils/legacy_class';
|
||||
|
||||
createLegacyClass(RegexParamType).inherits(BaseParamType);
|
||||
function RegexParamType(config) {
|
||||
_.defaults(config, { pattern: '' });
|
||||
RegexParamType.Super.call(this, config);
|
||||
}
|
||||
|
||||
RegexParamType.prototype.editor = editorHtml;
|
||||
|
||||
/**
|
||||
* Disabled state of the agg param
|
||||
*
|
||||
* @return {bool}
|
||||
*/
|
||||
RegexParamType.prototype.disabled = function () {
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Write the aggregation parameter.
|
||||
*
|
||||
* @param {AggConfig} aggConfig - the entire configuration for this agg
|
||||
* @param {object} output - the result of calling write on all of the aggregations
|
||||
* parameters.
|
||||
* @param {object} output.params - the final object that will be included as the params
|
||||
* for the agg
|
||||
* @return {undefined}
|
||||
*/
|
||||
RegexParamType.prototype.write = function (aggConfig, output) {
|
||||
const param = aggConfig.params[this.name];
|
||||
const paramType = aggConfig.type.params.byName[this.name];
|
||||
|
||||
// clear aggParam if pattern is not set or is disabled
|
||||
if (!param || !param.pattern || !param.pattern.length || paramType.disabled(aggConfig)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const obj = {
|
||||
pattern: param.pattern
|
||||
};
|
||||
|
||||
output.params[this.name] = obj;
|
||||
};
|
||||
|
||||
export { RegexParamType };
|
|
@ -239,7 +239,6 @@
|
|||
"common.ui.aggTypes.otherBucket.labelForOtherBucketLabel": "其他存储桶的标签",
|
||||
"common.ui.aggTypes.otherBucket.showMissingValuesLabel": "显示缺失值",
|
||||
"common.ui.aggTypes.otherBucket.showMissingValuesTooltip": "仅对“字符串”类型的字段有效。启用后,在搜索中包括缺失值的文档。如果此存储桶在排名前 N 中,其将会显示在图表中。如果不在排名前 N 中,并且启用了“在单独的存储桶中对其他值分组”,Elasticsearch 会将缺失值添加到“其他”存储桶。",
|
||||
"common.ui.aggTypes.paramNamePatternLabel": "{aggParamName} 模式",
|
||||
"common.ui.aggTypes.paramTypes.field.invalidSavedFieldParameterErrorMessage": "已保存的 {fieldParameter} 参数现在无效。请选择新字段。",
|
||||
"common.ui.aggTypes.paramTypes.field.requiredFieldParameterErrorMessage": "{fieldParameter} 是必需字段",
|
||||
"common.ui.aggTypes.percentsLabel": "百分数",
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue