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

New platform cleanup autoload - step 2 #33807

Merged
merged 29 commits into from
Mar 31, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
18b7801
Explicit dependencies to doc_title
Mar 24, 2019
6604266
Explicit dependencies to
Mar 24, 2019
c0d574c
Explicit dependencies to filter_bar
Mar 24, 2019
cf27a5c
Explicit dependency to query_bar
Mar 24, 2019
337b3b6
Removed modules from autoloades that never
Mar 24, 2019
b833bec
Removed modules from autoload (never used implicitly)
Mar 24, 2019
f23515b
Explicit dependency to bind + typo fix
Mar 24, 2019
e75119e
Explicit dependency to fancy_forms
Mar 24, 2019
4808b02
Explicit dependency to $listen
Mar 24, 2019
08982e8
Explicit dependency to timepicker
Mar 24, 2019
fd530a0
Moved kbn-infinite-scroll directive to doc_table
Mar 24, 2019
43e084e
Explicit dependency on directives
Mar 24, 2019
10f46ee
Explicit dependecy to input_focus directive
Mar 24, 2019
799bc10
Explicit dependency to json-input directive
Mar 24, 2019
a3ef24a
Explicit dependency on directives:
Mar 24, 2019
386e51a
Explicit dependency on paginated-selectable-list directive
Mar 24, 2019
4b7565b
Explicit dependency on saved-object-finder directive
Mar 24, 2019
e0e6489
Moved validate_json directive into agg_types
Mar 24, 2019
915c0ee
Don't include directives implicitly
Mar 24, 2019
1d4475e
Moved comma list
Mar 25, 2019
86dfc46
Deleted unused filter unique
Mar 25, 2019
b5125a3
Deleted unused filter startFrom
Mar 25, 2019
9bfed2b
Removed unused filter matchAny
Mar 25, 2019
eb13594
Moved filter trustAsHtml to kbn_doc_views
Mar 25, 2019
8de4a18
Moved markdown filter to notify
Mar 25, 2019
b1015cf
Explicitly import label filter
Mar 25, 2019
afc6aca
Remove implicit autoload of filters
Mar 25, 2019
c662ddc
Merge remote-tracking branch 'upstream/master' into new-platform-clea…
Mar 26, 2019
c3ecb01
Merge remote-tracking branch 'upstream/master' into new-platform-clea…
Mar 28, 2019
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
Expand Up @@ -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';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion src/legacy/core_plugins/kibana/public/management/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
111 changes: 111 additions & 0 deletions src/legacy/ui/public/agg_types/directives/__tests__/validate_json.js
Original file line number Diff line number Diff line change
@@ -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 changes: 64 additions & 0 deletions src/legacy/ui/public/agg_types/directives/validate_json.js
Original file line number Diff line number Diff line change
@@ -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);
}
}
};
});
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/agg_types/metrics/top_hit.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 2 additions & 0 deletions src/legacy/ui/public/agg_types/param_types/field.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/agg_types/param_types/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 1 addition & 0 deletions src/legacy/ui/public/agg_types/param_types/regex.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
1 change: 0 additions & 1 deletion src/legacy/ui/public/autoload/all.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@

import './accessibility';
import './modules';
import './filters';
import './settings';
import './styles';
21 changes: 0 additions & 21 deletions src/legacy/ui/public/autoload/filters.js

This file was deleted.

1 change: 1 addition & 0 deletions src/legacy/ui/public/directives/saved_object_finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
2 changes: 1 addition & 1 deletion src/legacy/ui/public/doc_table/components/table_row.js
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
55 changes: 0 additions & 55 deletions src/legacy/ui/public/filters/__tests__/start_from.js

This file was deleted.

Loading