Skip to content

Commit

Permalink
Group ViewEvents option and bug fix (#4309)
Browse files Browse the repository at this point in the history
Signed-off-by: Ashish Agrawal <[email protected]>
  • Loading branch information
lezzago authored Jun 19, 2023
1 parent 2362c35 commit 12b6d44
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 5 deletions.
5 changes: 3 additions & 2 deletions src/plugins/vis_augmenter/public/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { PLUGIN_AUGMENTATION_ENABLE_SETTING } from '../../common/constants';
import { getUISettings } from '../services';
import { IUiSettingsClient } from '../../../../core/public';

export const isEligibleForVisLayers = (vis: Vis): boolean => {
export const isEligibleForVisLayers = (vis: Vis, uiSettingsClient?: IUiSettingsClient): boolean => {
// Only support date histogram and ensure there is only 1 x-axis and it has to be on the bottom.
// Additionally to have a valid x-axis, there needs to be a segment aggregation
const hasValidXaxis =
Expand All @@ -45,8 +45,9 @@ export const isEligibleForVisLayers = (vis: Vis): boolean => {
(seriesParam: { type: string }) => seriesParam.type === 'line'
) &&
vis.params?.type === 'line';

// Checks if the augmentation setting is enabled
const config = getUISettings();
const config = uiSettingsClient ?? getUISettings();
const isAugmentationEnabled = config.get(PLUGIN_AUGMENTATION_ENABLE_SETTING);
return isAugmentationEnabled && hasValidXaxis && hasCorrectAggregationCount && hasOnlyLineSeries;
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,16 @@ export class ViewEventsOptionAction implements Action<EmbeddableContext> {
public readonly id = VIEW_EVENTS_OPTION_ACTION;
public order = 1;

public grouping: Action['grouping'] = [
{
id: VIEW_EVENTS_OPTION_ACTION,
getDisplayName: this.getDisplayName,
getIconType: this.getIconType,
category: 'vis_augmenter',
order: 10,
},
];

constructor() {}

public getIconType(): EuiIconType {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import { get } from 'lodash';
import { ErrorEmbeddable } from '../../../../embeddable/public';
import { EmbeddableStart, ErrorEmbeddable } from '../../../../embeddable/public';
import { VisualizeEmbeddable, VisualizeInput } from '../../../../visualizations/public';
import { getEmbeddable, getQueryService } from '../../services';
import {
Expand Down Expand Up @@ -47,9 +47,14 @@ function getValueAxisPositions(embeddable: VisualizeEmbeddable): { left: boolean
* Fetching the base vis to show in the flyout, based on the saved object ID. Add constraints
* such that it is static and won't auto-refresh within the flyout.
* @param savedObjectId the saved object id of the base vis
* @param embeddableStart Optional EmbeddableStart passed in for plugins to utilize the function
*/
export async function fetchVisEmbeddable(savedObjectId: string): Promise<VisualizeEmbeddable> {
const embeddableVisFactory = getEmbeddable().getEmbeddableFactory('visualization');
export async function fetchVisEmbeddable(
savedObjectId: string,
embeddableStart?: EmbeddableStart
): Promise<VisualizeEmbeddable> {
const embeddableLoader = embeddableStart ?? getEmbeddable();
const embeddableVisFactory = embeddableLoader.getEmbeddableFactory('visualization');
const contextInput = {
filters: getQueryService().filterManager.getFilters(),
query: getQueryService().queryString.getQuery(),
Expand Down

0 comments on commit 12b6d44

Please sign in to comment.