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

Embeddable input #73033

Merged
merged 4 commits into from
Aug 21, 2020
Merged
Show file tree
Hide file tree
Changes from all 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
16 changes: 16 additions & 0 deletions src/plugins/embeddable/public/lib/embeddables/i_embeddable.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { Adapters } from '../types';
import { IContainer } from '../containers/i_container';
import { ViewMode } from '../types';
import { TriggerContextMapping } from '../../../../ui_actions/public';
import type { TimeRange, Query, Filter } from '../../../../data/common';

export interface EmbeddableError {
name: string;
Expand Down Expand Up @@ -55,6 +56,21 @@ export interface EmbeddableInput {
*/
disableTriggers?: boolean;

/**
* Time range of the chart.
*/
timeRange?: TimeRange;

/**
* Visualization query string used to narrow down results.
*/
query?: Query;

/**
* Visualization filters used to narrow down results.
*/
filters?: Filter[];

[key: string]: unknown;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,6 @@ export interface VisualizeEmbeddableConfiguration {
}

export interface VisualizeInput extends EmbeddableInput {
timeRange?: TimeRange;
query?: Query;
filters?: Filter[];
vis?: {
colors?: { [key: string]: string };
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ export abstract class AbstractExploreDataAction<Context extends { embeddable?: I

if (!shared.hasExactlyOneIndexPattern(embeddable)) return false;
if (embeddable.getInput().viewMode !== ViewMode.VIEW) return false;

return true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@
import { Action } from '../../../../../../src/plugins/ui_actions/public';
import { DiscoverUrlGeneratorState } from '../../../../../../src/plugins/discover/public';
import {
isTimeRange,
isQuery,
isFilters,
ApplyGlobalFilterActionContext,
esFilters,
} from '../../../../../../src/plugins/data/public';
Expand Down Expand Up @@ -64,9 +61,9 @@ export class ExploreDataChartAction extends AbstractExploreDataAction<ExploreDat

const input = embeddable.getInput();

if (isTimeRange(input.timeRange) && !state.timeRange) state.timeRange = input.timeRange;
if (isQuery(input.query)) state.query = input.query;
if (isFilters(input.filters)) state.filters = [...input.filters, ...(state.filters || [])];
if (input.timeRange && !state.timeRange) state.timeRange = input.timeRange;
if (input.query) state.query = input.query;
if (input.filters) state.filters = [...input.filters, ...(state.filters || [])];
}

const path = await urlGenerator.createUrl(state);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
import { Action } from '../../../../../../src/plugins/ui_actions/public';
import { EmbeddableContext } from '../../../../../../src/plugins/embeddable/public';
import { DiscoverUrlGeneratorState } from '../../../../../../src/plugins/discover/public';
import { isTimeRange, isQuery, isFilters } from '../../../../../../src/plugins/data/public';
import { KibanaURL } from './kibana_url';
import * as shared from './shared';
import { AbstractExploreDataAction } from './abstract_explore_data_action';
Expand Down Expand Up @@ -42,9 +41,9 @@ export class ExploreDataContextMenuAction extends AbstractExploreDataAction<Embe

const input = embeddable.getInput();

if (isTimeRange(input.timeRange) && !state.timeRange) state.timeRange = input.timeRange;
if (isQuery(input.query)) state.query = input.query;
if (isFilters(input.filters)) state.filters = [...input.filters, ...(state.filters || [])];
if (input.timeRange && !state.timeRange) state.timeRange = input.timeRange;
streamich marked this conversation as resolved.
Show resolved Hide resolved
if (input.query) state.query = input.query;
if (input.filters) state.filters = [...input.filters, ...(state.filters || [])];
}

const path = await urlGenerator.createUrl(state);
Expand Down