Skip to content

Commit

Permalink
Move select range trigger to uiActions (#60168)
Browse files Browse the repository at this point in the history
* move select range trigger to uiActions
  • Loading branch information
mattkime authored Mar 14, 2020
1 parent 5fb747e commit 02ee4b1
Show file tree
Hide file tree
Showing 10 changed files with 37 additions and 20 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,10 @@ import {
EmbeddableOutput,
Embeddable,
Container,
selectRangeTrigger,
valueClickTrigger,
EmbeddableVisTriggerContext,
} from '../../../../../../../plugins/embeddable/public';
import { selectRangeTrigger } from '../../../../../../../plugins/ui_actions/public';
import { dispatchRenderComplete } from '../../../../../../../plugins/kibana_utils/public';
import {
IExpressionLoaderParams,
Expand Down
7 changes: 2 additions & 5 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,8 @@ import {
} from './services';
import { createSearchBar } from './ui/search_bar/create_search_bar';
import { esaggs } from './search/expressions';
import {
APPLY_FILTER_TRIGGER,
SELECT_RANGE_TRIGGER,
VALUE_CLICK_TRIGGER,
} from '../../embeddable/public';
import { APPLY_FILTER_TRIGGER, VALUE_CLICK_TRIGGER } from '../../embeddable/public';
import { SELECT_RANGE_TRIGGER } from '../../ui_actions/public';
import { ACTION_GLOBAL_APPLY_FILTER, createFilterAction, createFiltersFromEvent } from './actions';
import { ApplyGlobalFilterActionContext } from './actions/apply_filter_action';
import {
Expand Down
4 changes: 0 additions & 4 deletions src/plugins/embeddable/public/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,14 +23,12 @@ import {
contextMenuTrigger,
createFilterAction,
panelBadgeTrigger,
selectRangeTrigger,
valueClickTrigger,
EmbeddableVisTriggerContext,
IEmbeddable,
EmbeddableContext,
APPLY_FILTER_TRIGGER,
VALUE_CLICK_TRIGGER,
SELECT_RANGE_TRIGGER,
CONTEXT_MENU_TRIGGER,
PANEL_BADGE_TRIGGER,
ACTION_ADD_PANEL,
Expand All @@ -44,7 +42,6 @@ import {

declare module '../../ui_actions/public' {
export interface TriggerContextMapping {
[SELECT_RANGE_TRIGGER]: EmbeddableVisTriggerContext;
[VALUE_CLICK_TRIGGER]: EmbeddableVisTriggerContext;
[APPLY_FILTER_TRIGGER]: {
embeddable: IEmbeddable;
Expand Down Expand Up @@ -72,7 +69,6 @@ export const bootstrap = (uiActions: UiActionsSetup) => {
uiActions.registerTrigger(contextMenuTrigger);
uiActions.registerTrigger(applyFilterTrigger);
uiActions.registerTrigger(panelBadgeTrigger);
uiActions.registerTrigger(selectRangeTrigger);
uiActions.registerTrigger(valueClickTrigger);

const actionApplyFilter = createFilterAction();
Expand Down
2 changes: 0 additions & 2 deletions src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
SELECT_RANGE_TRIGGER,
selectRangeTrigger,
VALUE_CLICK_TRIGGER,
valueClickTrigger,
ViewMode,
Expand Down
7 changes: 0 additions & 7 deletions src/plugins/embeddable/public/lib/triggers/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,6 @@ export interface EmbeddableVisTriggerContext {
};
}

export const SELECT_RANGE_TRIGGER = 'SELECT_RANGE_TRIGGER';
export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = {
id: SELECT_RANGE_TRIGGER,
title: 'Select range',
description: 'Applies a range filter',
};

export const VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER';
export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = {
id: VALUE_CLICK_TRIGGER,
Expand Down
2 changes: 1 addition & 1 deletion src/plugins/ui_actions/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,6 @@ export { UiActionsSetup, UiActionsStart } from './plugin';
export { UiActionsServiceParams, UiActionsService } from './service';
export { Action, createAction, IncompatibleActionError } from './actions';
export { buildContextMenuForActions } from './context_menu';
export { Trigger, TriggerContext } from './triggers';
export { Trigger, TriggerContext, SELECT_RANGE_TRIGGER, selectRangeTrigger } from './triggers';
export { TriggerContextMapping, TriggerId, ActionContextMapping, ActionType } from './types';
export { ActionByType } from './actions';
2 changes: 2 additions & 0 deletions src/plugins/ui_actions/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@

import { CoreStart, CoreSetup, Plugin, PluginInitializerContext } from 'src/core/public';
import { UiActionsService } from './service';
import { selectRangeTrigger } from './triggers';

export type UiActionsSetup = Pick<
UiActionsService,
Expand All @@ -33,6 +34,7 @@ export class UiActionsPlugin implements Plugin<UiActionsSetup, UiActionsStart> {
constructor(initializerContext: PluginInitializerContext) {}

public setup(core: CoreSetup): UiActionsSetup {
this.service.registerTrigger(selectRangeTrigger);
return this.service;
}

Expand Down
1 change: 1 addition & 0 deletions src/plugins/ui_actions/public/triggers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,3 +20,4 @@
export * from './trigger';
export * from './trigger_contract';
export * from './trigger_internal';
export * from './select_range_trigger';
27 changes: 27 additions & 0 deletions src/plugins/ui_actions/public/triggers/select_range_trigger.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
/*
* Licensed to Elasticsearch B.V. under one or more contributor
* license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright
* ownership. Elasticsearch B.V. licenses this file to you under
* the Apache License, Version 2.0 (the "License"); you may
* not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing,
* software distributed under the License is distributed on an
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
* KIND, either express or implied. See the License for the
* specific language governing permissions and limitations
* under the License.
*/

import { Trigger } from '.';

export const SELECT_RANGE_TRIGGER = 'SELECT_RANGE_TRIGGER';
export const selectRangeTrigger: Trigger<'SELECT_RANGE_TRIGGER'> = {
id: SELECT_RANGE_TRIGGER,
title: 'Select range',
description: 'Applies a range filter',
};
3 changes: 3 additions & 0 deletions src/plugins/ui_actions/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@

import { ActionByType } from './actions/action';
import { TriggerInternal } from './triggers/trigger_internal';
import { EmbeddableVisTriggerContext } from '../../embeddable/public';
import { SELECT_RANGE_TRIGGER } from './triggers';

export type TriggerRegistry = Map<TriggerId, TriggerInternal<any>>;
export type ActionRegistry = Map<string, ActionByType<any>>;
Expand All @@ -33,6 +35,7 @@ export type TriggerContext = BaseContext;

export interface TriggerContextMapping {
[DEFAULT_TRIGGER]: TriggerContext;
[SELECT_RANGE_TRIGGER]: EmbeddableVisTriggerContext;
}

const DEFAULT_ACTION = '';
Expand Down

0 comments on commit 02ee4b1

Please sign in to comment.