Skip to content

Commit

Permalink
[7.x] Move VALUE_CLICK_TRIGGER and APPLY_FILTER_TRIGGER to ui_… (#60215)
Browse files Browse the repository at this point in the history
* move triggers

* move triggers

* fix import path

* fix import path

Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>

Co-authored-by: Matthew Kime <matt@mattki.me>
Co-authored-by: Elastic Machine <elasticmachine@users.noreply.github.com>
  • Loading branch information
3 people authored Mar 15, 2020
1 parent 1a77fa3 commit a6f2b2e
Show file tree
Hide file tree
Showing 13 changed files with 93 additions and 50 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,10 @@ import _ from 'lodash';
import * as Rx from 'rxjs';
import { Subscription } from 'rxjs';
import { i18n } from '@kbn/i18n';
import { UiActionsStart } from 'src/plugins/ui_actions/public';
import {
UiActionsStart,
APPLY_FILTER_TRIGGER,
} from '../../../../../../..//plugins/ui_actions/public';
import { RequestAdapter, Adapters } from '../../../../../../../plugins/inspector/public';
import {
esFilters,
Expand All @@ -31,11 +34,7 @@ import {
Query,
IFieldType,
} from '../../../../../../../plugins/data/public';
import {
APPLY_FILTER_TRIGGER,
Container,
Embeddable,
} from '../../../../../embeddable_api/public/np_ready/public';
import { Container, Embeddable } from '../../../../../embeddable_api/public/np_ready/public';
import * as columnActions from '../angular/doc_table/actions/columns';
import searchTemplate from './search_template.html';
import { ISearchEmbeddable, SearchInput, SearchOutput } from './types';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,12 @@ import {
EmbeddableOutput,
Embeddable,
Container,
valueClickTrigger,
EmbeddableVisTriggerContext,
} from '../../../../../../../plugins/embeddable/public';
import { selectRangeTrigger } from '../../../../../../../plugins/ui_actions/public';
import {
selectRangeTrigger,
valueClickTrigger,
} from '../../../../../../../plugins/ui_actions/public';
import { dispatchRenderComplete } from '../../../../../../../plugins/kibana_utils/public';
import {
IExpressionLoaderParams,
Expand Down
7 changes: 5 additions & 2 deletions src/plugins/data/public/plugin.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,8 +49,11 @@ import {
} from './services';
import { createSearchBar } from './ui/search_bar/create_search_bar';
import { esaggs } from './search/expressions';
import { APPLY_FILTER_TRIGGER, VALUE_CLICK_TRIGGER } from '../../embeddable/public';
import { SELECT_RANGE_TRIGGER } from '../../ui_actions/public';
import {
SELECT_RANGE_TRIGGER,
VALUE_CLICK_TRIGGER,
APPLY_FILTER_TRIGGER,
} from '../../ui_actions/public';
import { ACTION_GLOBAL_APPLY_FILTER, createFilterAction, createFiltersFromEvent } from './actions';
import { ApplyGlobalFilterActionContext } from './actions/apply_filter_action';
import {
Expand Down
14 changes: 0 additions & 14 deletions src/plugins/embeddable/public/bootstrap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,11 @@
* under the License.
*/
import { UiActionsSetup } from '../../ui_actions/public';
import { Filter } from '../../data/public';
import {
applyFilterTrigger,
contextMenuTrigger,
createFilterAction,
panelBadgeTrigger,
valueClickTrigger,
EmbeddableVisTriggerContext,
IEmbeddable,
EmbeddableContext,
APPLY_FILTER_TRIGGER,
VALUE_CLICK_TRIGGER,
CONTEXT_MENU_TRIGGER,
PANEL_BADGE_TRIGGER,
ACTION_ADD_PANEL,
Expand All @@ -42,11 +35,6 @@ import {

declare module '../../ui_actions/public' {
export interface TriggerContextMapping {
[VALUE_CLICK_TRIGGER]: EmbeddableVisTriggerContext;
[APPLY_FILTER_TRIGGER]: {
embeddable: IEmbeddable;
filters: Filter[];
};
[CONTEXT_MENU_TRIGGER]: EmbeddableContext;
[PANEL_BADGE_TRIGGER]: EmbeddableContext;
}
Expand All @@ -67,9 +55,7 @@ declare module '../../ui_actions/public' {
*/
export const bootstrap = (uiActions: UiActionsSetup) => {
uiActions.registerTrigger(contextMenuTrigger);
uiActions.registerTrigger(applyFilterTrigger);
uiActions.registerTrigger(panelBadgeTrigger);
uiActions.registerTrigger(valueClickTrigger);

const actionApplyFilter = createFilterAction();

Expand Down
4 changes: 0 additions & 4 deletions src/plugins/embeddable/public/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ export {
ACTION_ADD_PANEL,
AddPanelAction,
ACTION_APPLY_FILTER,
APPLY_FILTER_TRIGGER,
applyFilterTrigger,
Container,
ContainerInput,
ContainerOutput,
Expand Down Expand Up @@ -62,8 +60,6 @@ export {
PanelNotFoundError,
PanelState,
PropertySpec,
VALUE_CLICK_TRIGGER,
valueClickTrigger,
ViewMode,
withEmbeddableSubscription,
} from './lib';
Expand Down
14 changes: 0 additions & 14 deletions src/plugins/embeddable/public/lib/triggers/triggers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,27 +33,13 @@ export interface EmbeddableVisTriggerContext {
};
}

export const VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER';
export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = {
id: VALUE_CLICK_TRIGGER,
title: 'Value clicked',
description: 'Value was clicked',
};

export const CONTEXT_MENU_TRIGGER = 'CONTEXT_MENU_TRIGGER';
export const contextMenuTrigger: Trigger<'CONTEXT_MENU_TRIGGER'> = {
id: CONTEXT_MENU_TRIGGER,
title: 'Context menu',
description: 'Triggered on top-right corner context-menu select.',
};

export const APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER';
export const applyFilterTrigger: Trigger<'FILTER_TRIGGER'> = {
id: APPLY_FILTER_TRIGGER,
title: 'Filter click',
description: 'Triggered when user applies filter to an embeddable.',
};

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

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

export type UiActionsSetup = Pick<
UiActionsService,
Expand All @@ -35,6 +35,8 @@ export class UiActionsPlugin implements Plugin<UiActionsSetup, UiActionsStart> {

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

Expand Down
27 changes: 27 additions & 0 deletions src/plugins/ui_actions/public/triggers/apply_filter_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 APPLY_FILTER_TRIGGER = 'FILTER_TRIGGER';
export const applyFilterTrigger: Trigger<'FILTER_TRIGGER'> = {
id: APPLY_FILTER_TRIGGER,
title: 'Filter click',
description: 'Triggered when user applies filter to an embeddable.',
};
2 changes: 2 additions & 0 deletions src/plugins/ui_actions/public/triggers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,3 +21,5 @@ export * from './trigger';
export * from './trigger_contract';
export * from './trigger_internal';
export * from './select_range_trigger';
export * from './value_click_trigger';
export * from './apply_filter_trigger';
27 changes: 27 additions & 0 deletions src/plugins/ui_actions/public/triggers/value_click_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 VALUE_CLICK_TRIGGER = 'VALUE_CLICK_TRIGGER';
export const valueClickTrigger: Trigger<'VALUE_CLICK_TRIGGER'> = {
id: VALUE_CLICK_TRIGGER,
title: 'Value clicked',
description: 'Value was clicked',
};
10 changes: 8 additions & 2 deletions src/plugins/ui_actions/public/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,9 @@

import { ActionByType } from './actions/action';
import { TriggerInternal } from './triggers/trigger_internal';
import { EmbeddableVisTriggerContext } from '../../embeddable/public';
import { SELECT_RANGE_TRIGGER } from './triggers';
import { EmbeddableVisTriggerContext, IEmbeddable } from '../../embeddable/public';
import { Filter } from '../../data/public';
import { SELECT_RANGE_TRIGGER, VALUE_CLICK_TRIGGER, APPLY_FILTER_TRIGGER } from './triggers';

export type TriggerRegistry = Map<TriggerId, TriggerInternal<any>>;
export type ActionRegistry = Map<string, ActionByType<any>>;
Expand All @@ -36,6 +37,11 @@ export type TriggerContext = BaseContext;
export interface TriggerContextMapping {
[DEFAULT_TRIGGER]: TriggerContext;
[SELECT_RANGE_TRIGGER]: EmbeddableVisTriggerContext;
[VALUE_CLICK_TRIGGER]: EmbeddableVisTriggerContext;
[APPLY_FILTER_TRIGGER]: {
embeddable: IEmbeddable;
filters: Filter[];
};
}

const DEFAULT_ACTION = '';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,8 @@ import { Provider } from 'react-redux';
import { render, unmountComponentAtNode } from 'react-dom';
import 'mapbox-gl/dist/mapbox-gl.css';

import {
Embeddable,
APPLY_FILTER_TRIGGER,
} from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { Embeddable } from '../../../../../../src/legacy/core_plugins/embeddable_api/public/np_ready/public';
import { APPLY_FILTER_TRIGGER } from '../../../../../../src/plugins/ui_actions/public';
import { esFilters } from '../../../../../../src/plugins/data/public';

import { I18nContext } from 'ui/i18n';
Expand Down

0 comments on commit a6f2b2e

Please sign in to comment.