Skip to content

Commit

Permalink
refactor: 💡 use new base embeddable input in explore data
Browse files Browse the repository at this point in the history
  • Loading branch information
streamich committed Jul 23, 2020
1 parent 47f7f30 commit 4c78793
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ export abstract class AbstractExploreDataAction<Context extends { embeddable?: I
if (!this.params.start().plugins.discover.urlGenerator) return false;
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 @@ -10,7 +10,6 @@ import {
RangeSelectContext,
} 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 @@ -53,9 +52,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;
if (input.query) state.query = input.query;
if (input.filters) state.filters = [...input.filters, ...(state.filters || [])];
}

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

0 comments on commit 4c78793

Please sign in to comment.