New platform cleanup autoload - step 2 (#33807)
* Explicit dependencies to doc_title * Explicit dependencies to - kbn_top_nav - saved_object_save_as_checkbox * Explicit dependencies to filter_bar * Explicit dependency to query_bar * Removed modules from autoloades that never used implicitly: - bound_to_config_obj - debounce - filter_manager - index_patterns - parse_query - persisted_log - timefilter * Removed modules from autoload (never used implicitly) - events * Explicit dependency to bind + typo fix * Explicit dependency to fancy_forms * Explicit dependency to $listen * Explicit dependency to timepicker * Moved kbn-infinite-scroll directive to doc_table * Explicit dependency on directives - css truncate - inequality * Explicit dependecy to input_focus directive * Explicit dependency to json-input directive * Explicit dependency on directives: - input_focus - paginate * Explicit dependency on paginated-selectable-list directive * Explicit dependency on saved-object-finder directive * Moved validate_json directive into agg_types * Don't include directives implicitly * Moved comma list Explicitly included sort_prefix_first filter * Deleted unused filter unique * Deleted unused filter startFrom * Removed unused filter matchAny * Moved filter trustAsHtml to kbn_doc_views Added explicit import to uriescape * Moved markdown filter to notify * Explicitly import label filter * Remove implicit autoload of filters
This commit is contained in:
parent
852b6e9b1a
commit
3fc15bd8f7
|
@ -17,6 +17,7 @@
|
|||
* under the License.
|
||||
*/
|
||||
import { DocTitleProvider } from 'ui/doc_title';
|
||||
|
||||
import { applyResizeCheckerToEditors } from '../sense_editor_resize';
|
||||
import $ from 'jquery';
|
||||
import { initializeInput } from '../input';
|
||||
|
|
|
@ -17,8 +17,8 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { uiModules } from '../modules';
|
||||
const module = uiModules.get('kibana');
|
||||
import { uiModules } from 'ui/modules';
|
||||
const module = uiModules.get('apps/doc_views');
|
||||
|
||||
// Simple filter to allow using ng-bind-html without explicitly calling $sce.trustAsHtml in a controller
|
||||
// (See http://goo.gl/mpj9o2)
|
|
@ -20,6 +20,7 @@
|
|||
import _ from 'lodash';
|
||||
import { DocViewsRegistryProvider } from 'ui/registry/doc_views';
|
||||
|
||||
import '../filters/trust_as_html';
|
||||
import tableHtml from './table.html';
|
||||
import { i18n } from '@kbn/i18n';
|
||||
|
||||
|
|
|
@ -19,7 +19,6 @@
|
|||
|
||||
import 'ui/directives/css_truncate';
|
||||
import 'ui/directives/field_name';
|
||||
import 'ui/filters/unique';
|
||||
import './discover_field';
|
||||
import 'ui/angular_ui_select';
|
||||
import _ from 'lodash';
|
||||
|
|
|
@ -22,7 +22,6 @@ import { render, unmountComponentAtNode } from 'react-dom';
|
|||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
import './sections';
|
||||
import 'ui/filters/start_from';
|
||||
import 'ui/field_editor';
|
||||
import uiRoutes from 'ui/routes';
|
||||
import { I18nContext } from 'ui/i18n';
|
||||
|
|
|
@ -0,0 +1,111 @@
|
|||
/*
|
||||
* 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 angular from 'angular';
|
||||
import expect from '@kbn/expect';
|
||||
import ngMock from 'ng_mock';
|
||||
import '../validate_json';
|
||||
|
||||
// Load the kibana app dependencies.
|
||||
|
||||
let $parentScope;
|
||||
let $elemScope;
|
||||
let $elem;
|
||||
const mockScope = '';
|
||||
|
||||
const input = {
|
||||
valid: '{ "test": "json input" }',
|
||||
invalid: 'strings are not json'
|
||||
};
|
||||
|
||||
const markup = {
|
||||
textarea: '<textarea ng-model="mockModel" validate-json></textarea>',
|
||||
input: '<input type="text" ng-model="mockModel" validate-json>'
|
||||
};
|
||||
|
||||
const init = function (type) {
|
||||
// Load the application
|
||||
ngMock.module('kibana');
|
||||
type = type || 'input';
|
||||
const elMarkup = markup[type];
|
||||
|
||||
// Create the scope
|
||||
ngMock.inject(function ($injector, $rootScope, $compile) {
|
||||
// Give us a scope
|
||||
$parentScope = $rootScope;
|
||||
$parentScope.mockModel = mockScope;
|
||||
|
||||
$elem = angular.element(elMarkup);
|
||||
$compile($elem)($parentScope);
|
||||
$elemScope = $elem.isolateScope();
|
||||
});
|
||||
};
|
||||
|
||||
describe('validate-json directive', function () {
|
||||
const checkValid = function (inputVal, className) {
|
||||
$parentScope.mockModel = inputVal;
|
||||
$elem.scope().$digest();
|
||||
expect($elem.hasClass(className)).to.be(true);
|
||||
};
|
||||
|
||||
describe('initialization', function () {
|
||||
beforeEach(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
it('should use the model', function () {
|
||||
expect($elemScope).to.have.property('ngModel');
|
||||
});
|
||||
|
||||
});
|
||||
|
||||
Object.keys(markup).forEach(function (inputType) {
|
||||
describe(inputType, function () {
|
||||
beforeEach(function () {
|
||||
init(inputType);
|
||||
});
|
||||
|
||||
it('should be an input', function () {
|
||||
expect($elem.get(0).tagName).to.be(inputType.toUpperCase());
|
||||
});
|
||||
|
||||
it('should set valid state', function () {
|
||||
checkValid(input.valid, 'ng-valid');
|
||||
});
|
||||
|
||||
it('should be valid when empty', function () {
|
||||
checkValid('', 'ng-valid');
|
||||
});
|
||||
|
||||
it('should set invalid state', function () {
|
||||
checkValid(input.invalid, 'ng-invalid');
|
||||
});
|
||||
|
||||
it('should be invalid if a number', function () {
|
||||
checkValid('0', 'ng-invalid');
|
||||
});
|
||||
|
||||
it('should update validity on changes', function () {
|
||||
checkValid(input.valid, 'ng-valid');
|
||||
checkValid(input.invalid, 'ng-invalid');
|
||||
checkValid(input.valid, 'ng-valid');
|
||||
});
|
||||
});
|
||||
});
|
||||
});
|
64
src/legacy/ui/public/agg_types/directives/validate_json.js
Normal file
64
src/legacy/ui/public/agg_types/directives/validate_json.js
Normal file
|
@ -0,0 +1,64 @@
|
|||
/*
|
||||
* 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 { uiModules } from '../../modules';
|
||||
|
||||
const module = uiModules.get('kibana');
|
||||
|
||||
module.directive('validateJson', function () {
|
||||
return {
|
||||
restrict: 'A',
|
||||
require: 'ngModel',
|
||||
scope: {
|
||||
'ngModel': '=',
|
||||
'queryInput': '=?',
|
||||
},
|
||||
link: function ($scope, $elem, attr, ngModel) {
|
||||
$scope.$watch('ngModel', validator);
|
||||
|
||||
function validator(newValue) {
|
||||
if (!newValue || newValue.length === 0) {
|
||||
setValid();
|
||||
return;
|
||||
}
|
||||
|
||||
// We actually need a proper object in all JSON inputs
|
||||
newValue = (newValue || '').trim();
|
||||
if (newValue[0] === '{' || newValue[0] === '[') {
|
||||
try {
|
||||
JSON.parse(newValue);
|
||||
setValid();
|
||||
} catch (e) {
|
||||
setInvalid();
|
||||
}
|
||||
} else {
|
||||
setInvalid();
|
||||
}
|
||||
}
|
||||
|
||||
function setValid() {
|
||||
ngModel.$setValidity('jsonInput', true);
|
||||
}
|
||||
|
||||
function setInvalid() {
|
||||
ngModel.$setValidity('jsonInput', false);
|
||||
}
|
||||
}
|
||||
};
|
||||
});
|
|
@ -17,12 +17,12 @@
|
|||
* under the License.
|
||||
*/
|
||||
|
||||
import { uiModules } from '../modules';
|
||||
import { uiModules } from 'ui/modules';
|
||||
|
||||
import {
|
||||
parseCommaSeparatedList,
|
||||
formatListAsProse,
|
||||
} from '../../../utils';
|
||||
} from '../../../../utils';
|
||||
|
||||
uiModules
|
||||
.get('kibana')
|
|
@ -21,6 +21,7 @@ import _ from 'lodash';
|
|||
import { MetricAggType } from './metric_agg_type';
|
||||
import '../directives/auto_select_if_only_one';
|
||||
import '../directives/scroll_bottom';
|
||||
import '../../filters/sort_prefix_first';
|
||||
import topSortEditor from '../controls/top_sort.html';
|
||||
import aggregateAndSizeEditor from '../controls/top_aggregate_and_size.html';
|
||||
import { aggTypeFieldFilters } from '../param_types/filter';
|
||||
|
|
|
@ -20,8 +20,10 @@
|
|||
import { sortBy } from 'lodash';
|
||||
import { SavedObjectNotFound } from '../../errors';
|
||||
import '../directives/scroll_bottom';
|
||||
import '../filter/comma_list';
|
||||
import editorHtml from '../controls/field.html';
|
||||
import { BaseParamType } from './base';
|
||||
import '../../filters/sort_prefix_first';
|
||||
import '../../filters/field_type';
|
||||
import { IndexedArray } from '../../indexed_array';
|
||||
import { toastNotifications } from '../../notify';
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import '../directives/validate_json';
|
||||
import { RawJsonParamEditor } from '../controls/raw_json';
|
||||
import { BaseParamType } from './base';
|
||||
import { createLegacyClass } from '../../utils/legacy_class';
|
||||
|
|
|
@ -18,6 +18,7 @@
|
|||
*/
|
||||
|
||||
import _ from 'lodash';
|
||||
import '../../filters/label';
|
||||
import editorHtml from '../controls/regular_expression.html';
|
||||
import { BaseParamType } from './base';
|
||||
import { createLegacyClass } from '../../utils/legacy_class';
|
||||
|
|
|
@ -19,6 +19,5 @@
|
|||
|
||||
import './accessibility';
|
||||
import './modules';
|
||||
import './filters';
|
||||
import './settings';
|
||||
import './styles';
|
||||
|
|
|
@ -1,21 +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.
|
||||
*/
|
||||
|
||||
const context = require.context('../filters', false, /[\/\\](?!\.|_)[^\/\\]+\.js/);
|
||||
context.keys().forEach(key => context(key));
|
|
@ -22,6 +22,7 @@ import rison from 'rison-node';
|
|||
import { keyMap } from '../utils/key_map';
|
||||
import { SavedObjectRegistryProvider } from '../saved_objects/saved_object_registry';
|
||||
import { uiModules } from '../modules';
|
||||
import '../filters/label';
|
||||
import savedObjectFinderTemplate from '../partials/saved_object_finder.html';
|
||||
import './input_focus';
|
||||
import './paginate';
|
||||
|
|
|
@ -21,7 +21,7 @@ import _ from 'lodash';
|
|||
import $ from 'jquery';
|
||||
import rison from 'rison-node';
|
||||
import '../../doc_viewer';
|
||||
import '../../filters/trust_as_html';
|
||||
import '../../filters/uriescape';
|
||||
import '../../filters/short_dots';
|
||||
import { noWhiteSpace } from '../../../../core_plugins/kibana/common/utils/no_white_space';
|
||||
import openRowHtml from './table_row/open.html';
|
||||
|
|
|
@ -1,55 +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 '../start_from';
|
||||
|
||||
|
||||
let filter;
|
||||
|
||||
const init = function () {
|
||||
// Load the application
|
||||
ngMock.module('kibana');
|
||||
|
||||
// Create the scope
|
||||
ngMock.inject(function ($filter) {
|
||||
filter = $filter('startFrom');
|
||||
});
|
||||
};
|
||||
|
||||
describe('startFrom array filter', function () {
|
||||
|
||||
beforeEach(function () {
|
||||
init();
|
||||
});
|
||||
|
||||
it('should have a startFrom filter', function () {
|
||||
expect(filter).to.not.be(null);
|
||||
});
|
||||
|
||||
it('should return an empty array if passed undefined', function () {
|
||||
expect(filter(undefined, 10)).to.eql([]);
|
||||
});
|
||||
|
||||
it('should return an array with the first 3 elements removed', function () {
|
||||
expect(filter([1, 2, 3, 4, 5, 6, 7, 8, 9], 3).length).to.be(6);
|
||||
});
|
||||
|
||||
});
|
|
@ -1,44 +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 { uiModules } from '../modules';
|
||||
// Gets all fields of a given type.
|
||||
// You may also pass "*" to get all types
|
||||
// Or an array of types to get all fields of that type
|
||||
|
||||
uiModules
|
||||
.get('kibana')
|
||||
.filter('matchAny', function () {
|
||||
return function (items, rules) {
|
||||
if (!Array.isArray(rules)) {
|
||||
rules = [rules];
|
||||
}
|
||||
|
||||
return _.filter(items, function (item) {
|
||||
for (let i = 0; i < rules.length; i++) {
|
||||
if (_.some([item], rules[i])) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
});
|
||||
};
|
||||
});
|
|
@ -1,29 +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 { uiModules } from '../modules';
|
||||
uiModules
|
||||
.get('kibana')
|
||||
.filter('startFrom', function () {
|
||||
return function (input, start) {
|
||||
if (!input) return [];
|
||||
start = +start; //parse to int
|
||||
return input.slice(start);
|
||||
};
|
||||
});
|
|
@ -1,31 +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 { uiModules } from '../modules';
|
||||
// Filters out all duplicate items in an array
|
||||
|
||||
uiModules
|
||||
.get('kibana')
|
||||
.filter('unique', function () {
|
||||
return function (arr) {
|
||||
const list = _.unique(arr);
|
||||
return list;
|
||||
};
|
||||
});
|
|
@ -18,7 +18,7 @@
|
|||
*/
|
||||
|
||||
import MarkdownIt from 'markdown-it';
|
||||
import { uiModules } from '../modules';
|
||||
import { uiModules } from 'ui/modules';
|
||||
import 'angular-sanitize';
|
||||
|
||||
const markdownIt = new MarkdownIt({
|
|
@ -25,7 +25,7 @@ import { fatalError } from './fatal_error';
|
|||
import { banners } from './banners';
|
||||
import { Notifier } from './notifier';
|
||||
import template from './partials/toaster.html';
|
||||
import '../filters/markdown';
|
||||
import './filters/markdown';
|
||||
import './directives/truncated';
|
||||
import { FormattedMessage } from '@kbn/i18n/react';
|
||||
|
||||
|
|
|
@ -22,7 +22,6 @@ import { get } from 'lodash';
|
|||
import { aggTypes } from '../../../agg_types';
|
||||
import { aggTypeFilters } from '../../../agg_types/filter';
|
||||
import { aggTypeFieldFilters } from '../../../agg_types/param_types/filter';
|
||||
import '../../../filters/match_any';
|
||||
import { uiModules } from '../../../modules';
|
||||
import { editorConfigProviders } from '../config/editor_config_providers';
|
||||
import advancedToggleHtml from './advanced_toggle.html';
|
||||
|
|
Loading…
Reference in a new issue