Skip to content

Commit

Permalink
fix CI
Browse files Browse the repository at this point in the history
  • Loading branch information
alexwizp committed Jan 22, 2020
1 parent 08c845d commit 7752b6e
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 35 deletions.
10 changes: 5 additions & 5 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,15 +244,15 @@ module.exports = {
{
target: [
'(src|x-pack)/plugins/**/*',
'!(src|x-pack)/plugins/*/server/**/*',
'!(src|x-pack)/plugins/**/server/**/*',

'src/legacy/core_plugins/**/*',
'!src/legacy/core_plugins/*/server/**/*',
'!src/legacy/core_plugins/*/index.{js,ts,tsx}',
'!src/legacy/core_plugins/**/server/**/*',
'!src/legacy/core_plugins/**/index.{js,ts,tsx}',

'x-pack/legacy/plugins/**/*',
'!x-pack/legacy/plugins/*/server/**/*',
'!x-pack/legacy/plugins/*/index.{js,ts,tsx}',
'!x-pack/legacy/plugins/**/server/**/*',
'!x-pack/legacy/plugins/**/index.{js,ts,tsx}',

'examples/**/*',
'!examples/**/server/**/*',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,6 @@ import sinon from 'sinon';
import nodeCrypto from '@elastic/node-crypto';

import { CancellationToken } from '../../../../common/cancellation_token';

// Reporting uses an unconventional directory structure so the linter marks this as a violation
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { StringFormat, FieldFormats } from '../../../../../../../../src/plugins/data/server';

import { executeJobFactory } from '../execute_job';
Expand Down Expand Up @@ -84,8 +81,7 @@ describe('CSV Execute Job', function() {
uiConfigMock['format:defaultTypeMap'] = {
_default_: { id: 'string', params: {} },
};

return new FieldFormats([StringFormat], uiConfigMock);
return new FieldFormats([StringFormat], key => uiConfigMock[key]);
},
plugins: {
elasticsearch: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,7 @@
*/

import { i18n } from '@kbn/i18n';
import {
ExecuteJobFactory,
ESQueueWorkerExecuteFn,
FieldFormats,
ServerFacade,
} from '../../../types';
import { ExecuteJobFactory, ESQueueWorkerExecuteFn, ServerFacade } from '../../../types';
import { CSV_JOB_TYPE, PLUGIN_ID } from '../../../common/constants';
import { cryptoFactory, LevelLogger } from '../../../server/lib';
import { JobDocPayloadDiscoverCsv } from '../types';
Expand Down Expand Up @@ -89,7 +84,7 @@ export const executeJobFactory: ExecuteJobFactory<ESQueueWorkerExecuteFn<

const [formatsMap, uiSettings] = await Promise.all([
(async () => {
const fieldFormats = (await server.fieldFormatServiceFactory(uiConfig)) as FieldFormats;
const fieldFormats = await server.fieldFormatServiceFactory(uiConfig);
return fieldFormatMapFactory(indexPatternSavedObject, fieldFormats);
})(),
(async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,12 @@
*/

import expect from '@kbn/expect';
import { FieldFormatsService } from '../../../../../../../../src/legacy/ui/field_formats/mixin/field_formats_service';
// Reporting uses an unconventional directory structure so the linter marks this as a violation
// eslint-disable-next-line @kbn/eslint/no-restricted-paths
import { BytesFormat, NumberFormat } from '../../../../../../../../src/plugins/data/server';

import {
BytesFormat,
NumberFormat,
FieldFormats,
} from '../../../../../../../../src/plugins/data/server';
import { fieldFormatMapFactory } from './field_format_map';

type ConfigValue = { number: { id: string; params: {} } } | string;
Expand All @@ -34,7 +36,7 @@ describe('field format map', function() {
const getConfig = (key: string) => configMock[key];
const testValue = '4000';

const fieldFormats = new FieldFormatsService([BytesFormat, NumberFormat], getConfig);
const fieldFormats = new FieldFormats([BytesFormat, NumberFormat], getConfig);

const formatMap = fieldFormatMapFactory(indexPatternSavedObject, fieldFormats);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

import _ from 'lodash';
import { FieldFormats } from '../../../../types';
import { FieldFormats } from '../../../../../../../../src/plugins/data/server';

interface IndexPatternSavedObject {
attributes: {
Expand Down
14 changes: 12 additions & 2 deletions x-pack/legacy/plugins/reporting/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import { resolve } from 'path';
import { i18n } from '@kbn/i18n';
import { Legacy } from 'kibana';
import { IUiSettingsClient } from 'kibana/server';
import { PLUGIN_ID, UI_SETTINGS_CUSTOM_PDF_LOGO } from './common/constants';
import { ReportingConfigOptions, ReportingPluginSpecOptions } from './types.d';
import { config as reportingConfig } from './config';
Expand All @@ -23,6 +24,10 @@ const kbToBase64Length = (kb: number) => {
return Math.floor((kb * 1024 * 8) / 6);
};

interface ReportingDeps {
data: DataPluginStart;
}

export const reporting = (kibana: any) => {
return new kibana.Plugin({
id: PLUGIN_ID,
Expand Down Expand Up @@ -73,7 +78,12 @@ export const reporting = (kibana: any) => {
usageCollection: server.newPlatform.setup.plugins.usageCollection,
};

const data = server.newPlatform.setup.plugins.data as DataPluginStart;
const fieldFormatServiceFactory = async (uiSettings: IUiSettingsClient) => {
const [, plugins] = await coreSetup.getStartServices();
const { fieldFormats } = (plugins as ReportingDeps).data;

return fieldFormats.fieldFormatServiceFactory(uiSettings);
};

const __LEGACY: LegacySetup = {
config: server.config,
Expand All @@ -85,7 +95,7 @@ export const reporting = (kibana: any) => {
security: server.plugins.security,
},
savedObjects: server.savedObjects,
fieldFormatServiceFactory: data.fieldFormats.fieldFormatServiceFactory,
fieldFormatServiceFactory,
uiSettingsServiceFactory: server.uiSettingsServiceFactory,
log: server.log.bind(server),
};
Expand Down
11 changes: 1 addition & 10 deletions x-pack/legacy/plugins/reporting/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,7 @@
import { ResponseObject } from 'hapi';
import { EventEmitter } from 'events';
import { Legacy } from 'kibana';
import {
ElasticsearchPlugin,
CallCluster,
} from '../../../../src/legacy/core_plugins/elasticsearch';
import { CallCluster } from '../../../../src/legacy/core_plugins/elasticsearch';
import { CancellationToken } from './common/cancellation_token';
import { LevelLogger } from './server/lib/level_logger';
import { HeadlessChromiumDriverFactory } from './server/browsers/chromium/driver_factory';
Expand Down Expand Up @@ -355,9 +352,3 @@ export interface InterceptedRequest {
frameId: string;
resourceType: string;
}

export interface FieldFormats {
getConfig: number;
getInstance: (config: any) => any;
getDefaultInstance: (key: string) => any;
}

0 comments on commit 7752b6e

Please sign in to comment.