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

removes angular from fieldFormatts #17581

Merged
merged 8 commits into from
Apr 12, 2018
Merged
Show file tree
Hide file tree
Changes from 7 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
@@ -1,15 +1,9 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

describe('Boolean Format', function () {

let boolean;
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);
boolean = fieldFormats.getInstance('boolean');
}));
const boolean = fieldFormats.getInstance('boolean');


[
Expand Down
11 changes: 2 additions & 9 deletions src/core_plugins/kibana/public/field_formats/__tests__/_color.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,8 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('Color Format', function () {
let fieldFormats;
let ColorFormat;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
fieldFormats = Private(RegistryFieldFormatsProvider);
ColorFormat = fieldFormats.getType('color');
}));
const ColorFormat = fieldFormats.getType('color');

describe('field is a number', () => {
it('should add colors if the value is in range', function () {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import chrome from 'ui/chrome';
import { fieldFormats } from 'ui/registry/field_formats';
import { FieldFormat } from '../../../../../ui/field_formats/field_format';

let fieldFormats;
let config;
let getConfig;
const config = chrome.getUiSettingsClient();


const formatIds = [
'bytes',
Expand All @@ -27,12 +26,7 @@ const formatIds = [
// eslint-disable-next-line @elastic/kibana-custom/no-default-export
export default describe('conformance', function () {

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private, $injector) {
fieldFormats = Private(RegistryFieldFormatsProvider);
config = $injector.get('config');
getConfig = (...args) => config.get(...args);
}));
const getConfig = (...args) => config.get(...args);

formatIds.forEach(function (id) {
let instance;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import moment from 'moment-timezone';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('Date Format', function () {
let fieldFormats;
let settings;
let convert;
let $scope;
Expand All @@ -14,7 +13,6 @@ describe('Date Format', function () {
$scope = $rootScope;
settings = config;

fieldFormats = Private(RegistryFieldFormatsProvider);
const getConfig = (...args) => config.get(...args);
const DateFormat = fieldFormats.getType('date');
const date = new DateFormat({}, getConfig);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,9 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

describe('Duration Format', function () {
let fieldFormats;
let DurationFormat;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
fieldFormats = Private(RegistryFieldFormatsProvider);
DurationFormat = fieldFormats.getType('duration');
}));

const DurationFormat = fieldFormats.getType('duration');

test({ inputFormat: 'seconds', outputFormat: 'humanize' })
(-60, 'minus a minute')
Expand Down
11 changes: 3 additions & 8 deletions src/core_plugins/kibana/public/field_formats/__tests__/_ip.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,8 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('IP Address Format', function () {
let ip;
beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);
ip = fieldFormats.getInstance('ip');
}));

const ip = fieldFormats.getInstance('ip');

it('converts a value from a decimal to a string', function () {
expect(ip.convert(1186489492)).to.be('70.184.100.148');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,20 @@ import $ from 'jquery';
import _ from 'lodash';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';
import FixturesHitsProvider from 'fixtures/hits';
describe('_source formatting', function () {

let fieldFormats;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
fieldFormats = Private(RegistryFieldFormatsProvider);
}));

describe('Source format', function () {
let indexPattern;
let hits;
let format;
let convertHtml;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
hits = Private(FixturesHitsProvider);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,8 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('String Format', function () {
let StringFormat;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);
StringFormat = fieldFormats.getType('string');
}));
const StringFormat = fieldFormats.getType('string');

it('convert a string to lower case', function () {
const string = new StringFormat({
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,7 @@
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('String Truncate Format', function () {
let fieldFormats;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
fieldFormats = Private(RegistryFieldFormatsProvider);
}));

it('truncate large string', function () {
const Truncate = fieldFormats.getType('truncate');
Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,9 @@
import $ from 'jquery';
import expect from 'expect.js';
import ngMock from 'ng_mock';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
describe('Url Format', function () {

let fieldFormats;

beforeEach(ngMock.module('kibana'));
beforeEach(ngMock.inject(function (Private) {
fieldFormats = Private(RegistryFieldFormatsProvider);
}));

const unwrap = $el => {
expect($el.is('span[ng-non-bindable]')).to.be.ok();
Expand Down
28 changes: 14 additions & 14 deletions src/core_plugins/kibana/public/field_formats/register.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import { createUrlFormat } from '../../common/field_formats/types/url';
import { createBytesFormat } from '../../common/field_formats/types/bytes';
import { createDateFormat } from '../../common/field_formats/types/date';
Expand All @@ -13,16 +13,16 @@ import { createColorFormat } from '../../common/field_formats/types/color';
import { createTruncateFormat } from '../../common/field_formats/types/truncate';
import { createBoolFormat } from '../../common/field_formats/types/boolean';

RegistryFieldFormatsProvider.register(createUrlFormat);
RegistryFieldFormatsProvider.register(createBytesFormat);
RegistryFieldFormatsProvider.register(createDateFormat);
RegistryFieldFormatsProvider.register(createRelativeDateFormat);
RegistryFieldFormatsProvider.register(createDurationFormat);
RegistryFieldFormatsProvider.register(createIpFormat);
RegistryFieldFormatsProvider.register(createNumberFormat);
RegistryFieldFormatsProvider.register(createPercentFormat);
RegistryFieldFormatsProvider.register(createStringFormat);
RegistryFieldFormatsProvider.register(createSourceFormat);
RegistryFieldFormatsProvider.register(createColorFormat);
RegistryFieldFormatsProvider.register(createTruncateFormat);
RegistryFieldFormatsProvider.register(createBoolFormat);
fieldFormats.register(createUrlFormat);
fieldFormats.register(createBytesFormat);
fieldFormats.register(createDateFormat);
fieldFormats.register(createRelativeDateFormat);
fieldFormats.register(createDurationFormat);
fieldFormats.register(createIpFormat);
fieldFormats.register(createNumberFormat);
fieldFormats.register(createPercentFormat);
fieldFormats.register(createStringFormat);
fieldFormats.register(createSourceFormat);
fieldFormats.register(createColorFormat);
fieldFormats.register(createTruncateFormat);
fieldFormats.register(createBoolFormat);
4 changes: 2 additions & 2 deletions src/test_utils/public/stub_index_pattern.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import Promise from 'bluebird';
import { IndexPatternProvider, getRoutes } from 'ui/index_patterns/_index_pattern';
import { formatHit } from 'ui/index_patterns/_format_hit';
import { getComputedFields } from 'ui/index_patterns/_get_computed_fields';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import { IndexPatternsFlattenHitProvider } from 'ui/index_patterns/_flatten_hit';
import { IndexPatternsFieldListProvider } from 'ui/index_patterns/_field_list';

export default function (Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);

const flattenHit = Private(IndexPatternsFlattenHitProvider);
const FieldList = Private(IndexPatternsFieldListProvider);
const IndexPattern = Private(IndexPatternProvider);
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/agg_response/geo_json/_tooltip_formatter.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import $ from 'jquery';
import _ from 'lodash';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

export function TileMapTooltipFormatterProvider($compile, $rootScope) {

export function TileMapTooltipFormatterProvider($compile, $rootScope, Private) {

const fieldFormats = Private(RegistryFieldFormatsProvider);
const $tooltipScope = $rootScope.$new();
const $el = $('<div>').html(require('ui/agg_response/geo_json/_tooltip.html'));
$compile($el)($tooltipScope);
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_table/agg_table.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ import 'ui/agg_table/agg_table.less';
import _ from 'lodash';
import { uiModules } from 'ui/modules';
import aggTableTemplate from 'ui/agg_table/agg_table.html';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

uiModules
.get('kibana', ['RecursionHelper'])
.directive('kbnAggTable', function ($filter, config, Private, RecursionHelper) {
const fieldFormats = Private(RegistryFieldFormatsProvider);

const numberFormatter = fieldFormats.getDefaultInstance('number').getConverterFor('text');

return {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/__tests__/agg_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import ngMock from 'ng_mock';
import 'ui/private';
import { AggParams } from 'ui/agg_types/agg_params';
import { VisProvider } from 'ui/vis';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import { AggTypesAggTypeProvider } from 'ui/agg_types/agg_type';
import FixturesStubbedLogstashIndexPatternProvider from 'fixtures/stubbed_logstash_index_pattern';

Expand All @@ -19,7 +19,7 @@ describe('AggType Class', function () {
beforeEach(ngMock.inject(function (Private) {

Vis = Private(VisProvider);
fieldFormat = Private(RegistryFieldFormatsProvider);
fieldFormat = fieldFormats;
AggType = Private(AggTypesAggTypeProvider);
indexPattern = Private(FixturesStubbedLogstashIndexPatternProvider);
}));
Expand Down
6 changes: 3 additions & 3 deletions src/ui/public/agg_types/agg_type.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import _ from 'lodash';
import { AggParams } from 'ui/agg_types/agg_params';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

export function AggTypesAggTypeProvider() {

export function AggTypesAggTypeProvider(Private) {
const fieldFormats = Private(RegistryFieldFormatsProvider);


/**
Expand Down
3 changes: 1 addition & 2 deletions src/ui/public/agg_types/buckets/date_range.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,12 @@ import 'ui/directives/validate_date_math';
import 'ui/directives/documentation_href';
import { AggTypesBucketsBucketAggTypeProvider } from 'ui/agg_types/buckets/_bucket_agg_type';
import { AggTypesBucketsCreateFilterDateRangeProvider } from 'ui/agg_types/buckets/create_filter/date_range';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import dateRangesTemplate from 'ui/agg_types/controls/date_ranges.html';

export function AggTypesBucketsDateRangeProvider(Private) {
const BucketAggType = Private(AggTypesBucketsBucketAggTypeProvider);
const createFilter = Private(AggTypesBucketsCreateFilterDateRangeProvider);
const fieldFormats = Private(RegistryFieldFormatsProvider);


return new BucketAggType({
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/cardinality.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AggTypesMetricsMetricAggTypeProvider } from 'ui/agg_types/metrics/metric_agg_type';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

export function AggTypesMetricsCardinalityProvider(Private) {
const MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider);
const fieldFormats = Private(RegistryFieldFormatsProvider);


return new MetricAggType({
name: 'cardinality',
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/count.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { AggTypesMetricsMetricAggTypeProvider } from 'ui/agg_types/metrics/metric_agg_type';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

export function AggTypesMetricsCountProvider(Private) {
const MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider);
const fieldFormats = Private(RegistryFieldFormatsProvider);


return new MetricAggType({
name: 'count',
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/metric_agg_type.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import _ from 'lodash';
import { AggTypesAggTypeProvider } from 'ui/agg_types/agg_type';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';

export function AggTypesMetricsMetricAggTypeProvider(Private) {
const AggType = Private(AggTypesAggTypeProvider);
const fieldFormats = Private(RegistryFieldFormatsProvider);


_.class(MetricAggType).inherits(AggType);
function MetricAggType(config) {
Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/agg_types/metrics/percentile_ranks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ import valuesEditor from 'ui/agg_types/controls/percentile_ranks.html';
import 'ui/number_list';
import { AggTypesMetricsMetricAggTypeProvider } from 'ui/agg_types/metrics/metric_agg_type';
import { AggTypesMetricsGetResponseAggConfigClassProvider } from 'ui/agg_types/metrics/get_response_agg_config_class';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import { getPercentileValue } from './percentiles_get_value';

export function AggTypesMetricsPercentileRanksProvider(Private) {
const MetricAggType = Private(AggTypesMetricsMetricAggTypeProvider);
const getResponseAggConfigClass = Private(AggTypesMetricsGetResponseAggConfigClassProvider);
const fieldFormats = Private(RegistryFieldFormatsProvider);


// required by the values editor

Expand Down
4 changes: 2 additions & 2 deletions src/ui/public/field_editor/field_editor.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

import 'ui/field_format_editor';
import _ from 'lodash';
import { RegistryFieldFormatsProvider } from 'ui/registry/field_formats';
import { fieldFormats } from 'ui/registry/field_formats';
import { IndexPatternsFieldProvider } from 'ui/index_patterns/_field';
import { uiModules } from 'ui/modules';
import fieldEditorTemplate from 'ui/field_editor/field_editor.html';
Expand All @@ -19,7 +19,7 @@ uiModules
.get('kibana')
.directive('fieldEditor', function (Private, $sce, confirmModal, config) {
const getConfig = (...args) => config.get(...args);
const fieldFormats = Private(RegistryFieldFormatsProvider);

const Field = Private(IndexPatternsFieldProvider);
const getEnabledScriptingLanguages = Private(GetEnabledScriptingLanguagesProvider);

Expand Down
Loading