Skip to content

Commit

Permalink
Merge branch 'master' into so-types
Browse files Browse the repository at this point in the history
  • Loading branch information
mshustov committed Feb 19, 2020
2 parents 22ccf3d + 29ac6fe commit 2acfc3e
Show file tree
Hide file tree
Showing 111 changed files with 2,354 additions and 744 deletions.
2 changes: 0 additions & 2 deletions src/core/types/saved_objects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -46,5 +46,3 @@ export type SavedObjectAttribute = SavedObjectAttributeSingle | SavedObjectAttri
export interface SavedObjectAttributes {
[key: string]: SavedObjectAttribute;
}

export type SavedObjectAttributesType = Record<string, unknown>;

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 3 additions & 0 deletions src/dev/i18n/extract_default_translations.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ export async function matchEntriesWithExctractors(inputPath, options = {}) {
const ignore = [
'**/node_modules/**',
'**/__tests__/**',
'**/dist/**',
'**/target/**',
'**/vendor/**',
'**/*.test.{js,jsx,ts,tsx}',
'**/*.d.ts',
].concat(additionalIgnore);
Expand Down
3 changes: 2 additions & 1 deletion src/dev/i18n/serializers/__snapshots__/json.test.ts.snap

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/dev/i18n/serializers/json.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ export const serializeToJson: Serializer = (messages, formats = i18n.formats) =>
}
}

return JSON.stringify(resultJsonObject, undefined, 2);
return JSON.stringify(resultJsonObject, undefined, 2).concat('\n');
};
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,7 @@ <h1 class="euiScreenReaderOnly">{{screenTitle}}</h1>
data-shared-item
data-title="{{opts.savedSearch.lastSavedTitle}}"
data-description="{{opts.savedSearch.description}}"
data-test-subj="discoverDocTable"
minimum-visible-rows="minimumVisibleRows"
render-complete
on-add-column="addColumn"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import React, { useState } from 'react';
import { SavedObject } from 'kibana/server';
import { SavedObjectIndexPattern } from 'src/plugins/data/public';
import { IndexPatternAttributes } from 'src/plugins/data/public';
import { I18nProvider } from '@kbn/i18n/react';

import { IndexPatternRef } from './types';
Expand All @@ -27,11 +27,11 @@ export interface DiscoverIndexPatternProps {
/**
* list of available index patterns, if length > 1, component offers a "change" link
*/
indexPatternList: Array<SavedObject<SavedObjectIndexPattern>>;
indexPatternList: Array<SavedObject<IndexPatternAttributes>>;
/**
* currently selected index pattern, due to angular issues it's undefined at first rendering
*/
selectedIndexPattern: SavedObject<SavedObjectIndexPattern>;
selectedIndexPattern: SavedObject<IndexPatternAttributes>;
/**
* triggered when user selects a new index pattern
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,14 +31,14 @@ import { TelemetryPluginStart } from '../../../../../plugins/telemetry/public';
import {
Environment,
HomePublicPluginSetup,
TutorialStart,
HomePublicPluginStart,
} from '../../../../../plugins/home/public';
import { KibanaLegacySetup } from '../../../../../plugins/kibana_legacy/public';

export interface HomeKibanaServices {
indexPatternService: any;
kibanaVersion: string;
getInjected: (name: string, defaultValue?: any) => unknown;
chrome: ChromeStart;
uiSettings: IUiSettingsClient;
config: KibanaLegacySetup['config'];
Expand All @@ -54,6 +54,7 @@ export interface HomeKibanaServices {
addBasePath: (url: string) => string;
environment: Environment;
telemetry?: TelemetryPluginStart;
tutorialVariables: TutorialStart['get'];
}

let services: HomeKibanaServices | null = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import { FeatureCatalogueCategory } from '../../../../../../../plugins/home/publ
jest.mock('../../kibana_services', () => ({
getServices: () => ({
getBasePath: () => 'path',
getInjected: () => '',
tutorialVariables: () => ({}),
homeConfig: { disableWelcomeScreen: false },
}),
}));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,15 @@ mustacheWriter.escapedValue = function escapedValue(token, context) {
};

export function replaceTemplateStrings(text, params = {}) {
const { getInjected, kibanaVersion, docLinks } = getServices();
const { tutorialVariables, kibanaVersion, docLinks } = getServices();

const variables = {
// '{' and '}' can not be used in template since they are used as template tags.
// Must use '{curlyOpen}'' and '{curlyClose}'
curlyOpen: '{',
curlyClose: '}',
config: {
cloud: {
id: getInjected('cloudId'),
},
...tutorialVariables(),
docs: {
base_url: docLinks.ELASTIC_WEBSITE_URL,
beats: {
Expand Down
9 changes: 6 additions & 3 deletions src/legacy/core_plugins/kibana/public/home/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -57,20 +57,22 @@ export class HomePlugin implements Plugin {

constructor(private initializerContext: PluginInitializerContext) {}

setup(core: CoreSetup, { home, kibanaLegacy, usageCollection }: HomePluginSetupDependencies) {
setup(
core: CoreSetup<HomePluginStartDependencies>,
{ home, kibanaLegacy, usageCollection }: HomePluginSetupDependencies
) {
kibanaLegacy.registerLegacyApp({
id: 'home',
title: 'Home',
mount: async (params: AppMountParameters) => {
const trackUiMetric = usageCollection.reportUiStats.bind(usageCollection, 'Kibana_home');
const [coreStart] = await core.getStartServices();
const [coreStart, { home: homeStart }] = await core.getStartServices();
setServices({
trackUiMetric,
kibanaVersion: this.initializerContext.env.packageInfo.version,
http: coreStart.http,
toastNotifications: core.notifications.toasts,
banners: coreStart.overlays.banners,
getInjected: core.injectedMetadata.getInjectedVar,
docLinks: coreStart.docLinks,
savedObjectsClient: this.savedObjectsClient!,
chrome: coreStart.chrome,
Expand All @@ -82,6 +84,7 @@ export class HomePlugin implements Plugin {
environment: this.environment!,
config: kibanaLegacy.config,
homeConfig: home.config,
tutorialVariables: homeStart.tutorials.get,
featureCatalogue: this.featureCatalogue!,
});
const { renderApp } = await import('./np_ready/application');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { FormattedMessage } from '@kbn/i18n/react';
import {
indexPatterns,
DataPublicPluginStart,
SavedObjectIndexPattern,
IndexPatternAttributes,
} from '../../../../../../../../../../plugins/data/public';
import { SavedObjectsClient, IUiSettingsClient } from '../../../../../../../../../../core/public';
import { MAX_SEARCH_SIZE } from '../../constants';
Expand Down Expand Up @@ -97,7 +97,7 @@ export class StepIndexPattern extends Component<StepIndexPatternProps, StepIndex
}

fetchExistingIndexPatterns = async () => {
const { savedObjects } = await this.props.savedObjectsClient.find<SavedObjectIndexPattern>({
const { savedObjects } = await this.props.savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title'],
perPage: 10000,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ import { getIndexPatterns, getSavedObjectsClient } from './plugin_services';
import { TimelionFunctionArgs } from '../../../../../plugins/timelion/common/types';
import {
indexPatterns as indexPatternsUtils,
SavedObjectIndexPattern,
IndexPatternAttributes,
} from '../../../../../plugins/data/public';

export interface Location {
Expand Down Expand Up @@ -56,7 +56,7 @@ export function getArgValueSuggestions() {
}
const indexPatternTitle = get(indexPatternArg, 'value.text');

const { savedObjects } = await savedObjectsClient.find<SavedObjectIndexPattern>({
const { savedObjects } = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title'],
search: `"${indexPatternTitle}"`,
Expand Down Expand Up @@ -87,7 +87,7 @@ export function getArgValueSuggestions() {
es: {
async index(partial: string) {
const search = partial ? `${partial}*` : '*';
const resp = await savedObjectsClient.find<SavedObjectIndexPattern>({
const resp = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'type'],
search: `${search}`,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { VisSavedObject } from './visualize_embeddable';
import {
indexPatterns,
IIndexPattern,
SavedObjectIndexPattern,
IndexPatternAttributes,
} from '../../../../../plugins/data/public';
import { getUISettings, getSavedObjects } from '../np_ready/public/services';

Expand All @@ -36,7 +36,7 @@ export async function getIndexPattern(
const defaultIndex = getUISettings().get('defaultIndex');

if (savedVis.vis.params.index_pattern) {
const indexPatternObjects = await savedObjectsClient.find<SavedObjectIndexPattern>({
const indexPatternObjects = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'fields'],
search: `"${savedVis.vis.params.index_pattern}"`,
Expand All @@ -46,7 +46,7 @@ export async function getIndexPattern(
return indexPattern;
}

const savedObject = await savedObjectsClient.get<SavedObjectIndexPattern>(
const savedObject = await savedObjectsClient.get<IndexPatternAttributes>(
'index-pattern',
defaultIndex
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -301,13 +301,15 @@ export class VisualizeEmbeddable extends Embeddable<VisualizeInput, VisualizeOut
return;
}

const eventName = event.name === 'brush' ? SELECT_RANGE_TRIGGER : VALUE_CLICK_TRIGGER;
if (!this.input.disableTriggers) {
const eventName = event.name === 'brush' ? SELECT_RANGE_TRIGGER : VALUE_CLICK_TRIGGER;

npStart.plugins.uiActions.executeTriggerActions(eventName, {
embeddable: this,
timeFieldName: this.vis.indexPattern.timeFieldName,
data: event.data,
});
npStart.plugins.uiActions.executeTriggerActions(eventName, {
embeddable: this,
timeFieldName: this.vis.indexPattern.timeFieldName,
data: event.data,
});
}
})
);

Expand Down
3 changes: 2 additions & 1 deletion src/plugins/data/common/index_patterns/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,10 @@ export interface IIndexPattern {
>;
}

export interface SavedObjectIndexPattern {
export interface IndexPatternAttributes {
type: string;
fields: string;
title: string;
typeMeta: string;
timeFieldName?: string;
}
2 changes: 1 addition & 1 deletion src/plugins/data/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -261,7 +261,7 @@ export {
IFieldSubType,
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
SavedObjectIndexPattern,
IndexPatternAttributes,
} from '../common';

/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@

import { SavedObject } from 'src/core/public';
import { get } from 'lodash';
import { IIndexPattern, SavedObjectIndexPattern } from '../..';
import { IIndexPattern, IndexPatternAttributes } from '../..';

export function getFromSavedObject(
savedObject: SavedObject<SavedObjectIndexPattern>
savedObject: SavedObject<IndexPatternAttributes>
): IIndexPattern | undefined {
if (get(savedObject, 'attributes.fields') === undefined) {
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/
import { isEmpty } from 'lodash';
import { IUiSettingsClient, SavedObjectsClientContract } from 'src/core/public';
import { indexPatterns, SavedObjectIndexPattern } from '../..';
import { indexPatterns, IndexPatternAttributes } from '../..';

export async function fetchIndexPatterns(
savedObjectsClient: SavedObjectsClientContract,
Expand All @@ -30,7 +30,7 @@ export async function fetchIndexPatterns(
}

const searchString = indexPatternStrings.map(string => `"${string}"`).join(' | ');
const indexPatternsFromSavedObjects = await savedObjectsClient.find<SavedObjectIndexPattern>({
const indexPatternsFromSavedObjects = await savedObjectsClient.find<IndexPatternAttributes>({
type: 'index-pattern',
fields: ['title', 'fields'],
search: searchString,
Expand All @@ -48,7 +48,7 @@ export async function fetchIndexPatterns(
? exactMatches
: [
...exactMatches,
await savedObjectsClient.get<SavedObjectIndexPattern>('index-pattern', defaultIndex),
await savedObjectsClient.get<IndexPatternAttributes>('index-pattern', defaultIndex),
];

return allMatches.map(indexPatterns.getFromSavedObject);
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/data/server/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ export {
IFieldSubType,
ES_FIELD_TYPES,
KBN_FIELD_TYPES,
SavedObjectIndexPattern,
IndexPatternAttributes,
} from '../common';

/**
Expand Down
6 changes: 6 additions & 0 deletions src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,16 @@ export interface EmbeddableInput {
lastReloadRequestTime?: number;
hidePanelTitles?: boolean;
isEmptyState?: boolean;

/**
* List of action IDs that this embeddable should not render.
*/
disabledActions?: string[];

/**
* Whether this embeddable should not execute triggers.
*/
disableTriggers?: boolean;
}

export interface EmbeddableOutput {
Expand Down
6 changes: 4 additions & 2 deletions src/plugins/expressions/common/execution/execution.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,16 +336,18 @@ describe('Execution', () => {
});

test('execution state is "pending" while execution is in progress', async () => {
jest.useFakeTimers();
const execution = createExecution('sleep 20');
execution.start(null);
await new Promise(r => setTimeout(r, 5));
jest.advanceTimersByTime(5);
expect(execution.state.get().state).toBe('pending');
jest.useRealTimers();
});

test('execution state is "result" when execution successfully completes', async () => {
const execution = createExecution('sleep 1');
execution.start(null);
await new Promise(r => setTimeout(r, 30));
await execution.result;
expect(execution.state.get().state).toBe('result');
});

Expand Down
Loading

0 comments on commit 2acfc3e

Please sign in to comment.