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

Bugfix/metric-loading-loop #1309

Merged
merged 2 commits into from
Dec 19, 2023
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
44 changes: 27 additions & 17 deletions public/components/custom_panels/helpers/utils.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -167,14 +167,14 @@
metricVisualization = false
) => {
const finalQuery = metricVisualization
? query
: queryAccumulator(query, timestampField, startTime, endTime, filterQuery);

Check warning on line 171 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L170-L171

Added lines #L170 - L171 were not covered by tests

const res = await pplService.fetch({ query: finalQuery, format: 'jdbc' });

Check warning on line 173 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L173

Added line #L173 was not covered by tests

if (res === undefined) throw new Error('Please check the validity of PPL Filter');

return res;

Check warning on line 177 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L177

Added line #L177 was not covered by tests
};

// Fetches savedVisualization by Id and runs getQueryResponse
Expand Down Expand Up @@ -225,13 +225,13 @@

const updatedVisualizationQuery =
span !== undefined
? updateQuerySpanInterval(visualization.query, visualization.timeField, span, resolution)
: visualization.query;

Check warning on line 229 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L228-L229

Added lines #L228 - L229 were not covered by tests

setVisualizationMetaData({ ...visualization, query: updatedVisualizationQuery });

Check warning on line 231 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L231

Added line #L231 was not covered by tests

try {
const queryData = await getQueryResponse(

Check warning on line 234 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L233-L234

Added lines #L233 - L234 were not covered by tests
pplService,
updatedVisualizationQuery,
visualization.type,
Expand All @@ -240,44 +240,53 @@
filterQuery,
visualization.timeField
);
setVisualizationData(queryData);

Check warning on line 243 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L243

Added line #L243 was not covered by tests
} catch (error) {
setIsError({ error });

Check warning on line 245 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L245

Added line #L245 was not covered by tests
}
setIsLoading(false);

Check warning on line 247 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L247

Added line #L247 was not covered by tests
};

const dynamicLayoutFromQueryData = (queryData) => {
const labelCount = queryData.jsonData.length;
const legendLines = min([labelCount, 10]);

Check warning on line 252 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L251-L252

Added lines #L251 - L252 were not covered by tests

const height = 230 + legendLines * 30;
const y = -0.35 + -0.15 * legendLines;
return {

Check warning on line 256 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L254-L256

Added lines #L254 - L256 were not covered by tests
height,
legend: { orientation: 'h', x: 0, y },
};
};

const createCatalogVisualizationMetaData = (
catalogSource: string,
visualizationQuery: string,
visualizationType: string,
visualizationTimeField: string,
queryData: object
) => {
const createCatalogVisualizationMetaData = ({
catalogSource,
query,
type,
subType,
timeField,
queryData,
}: {
catalogSource: string;
query: string;
type: string;
subType: string;
timeField: string;
queryData: object;
}) => {

Check warning on line 276 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L276

Added line #L276 was not covered by tests
return {
name: catalogSource,
description: '',
query: visualizationQuery,
type: visualizationType,
query,
type,
subType,
selected_date_range: {
start: 'now/y',
end: 'now',
text: '',
},
selected_timestamp: {
name: visualizationTimeField,
name: timeField,
type: 'timestamp',
},
selected_fields: {
Expand Down Expand Up @@ -332,6 +341,7 @@

const visualizationType = 'line';
const visualizationTimeField = '@timestamp';
const visualizationSubType = visualization.subType;

Check warning on line 344 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L344

Added line #L344 was not covered by tests

const visualizationQuery = updateCatalogVisualizationQuery({
...visualization.queryMetaData,
Expand All @@ -341,11 +351,11 @@
resolution,
});

setVisualizationTitle(visualization.name);
setVisualizationType(visualizationType);

Check warning on line 355 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L354-L355

Added lines #L354 - L355 were not covered by tests

try {
const queryData = await getQueryResponse(

Check warning on line 358 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L357-L358

Added lines #L357 - L358 were not covered by tests
pplService,
visualizationQuery,
visualizationType,
Expand All @@ -355,23 +365,23 @@
visualizationTimeField,
true
);
setVisualizationData(queryData);

Check warning on line 368 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L368

Added line #L368 was not covered by tests

const visualizationMetaData = createCatalogVisualizationMetaData(
const visualizationMetaData = createCatalogVisualizationMetaData({

Check warning on line 370 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L370

Added line #L370 was not covered by tests
catalogSource,
visualizationQuery,
visualizationType,
visualizationTimeField,
queryData
);
query: visualizationQuery,
type: visualizationType,
subType: visualization.subType,
timeField: visualizationTimeField,
queryData,
});

console.log('renderCatalogVisualization', { visualizationMetaData });
setVisualizationMetaData(visualizationMetaData);

Check warning on line 379 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L379

Added line #L379 was not covered by tests
} catch (error) {
setIsError({ error });

Check warning on line 381 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L381

Added line #L381 was not covered by tests
}

setIsLoading(false);

Check warning on line 384 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L384

Added line #L384 was not covered by tests
};

// Function to store recently used time filters and set start and end time.
Expand Down Expand Up @@ -405,7 +415,7 @@
selected_fields: visualization.savedVisualization.selected_fields,
userConfigs: visualization.savedVisualization.userConfigs || {},
subType: visualization.savedVisualization.hasOwnProperty('subType')
? visualization.savedVisualization.subType

Check warning on line 418 in public/components/custom_panels/helpers/utils.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/helpers/utils.tsx#L418

Added line #L418 was not covered by tests
: '',
units_of_measure: visualization.savedVisualization.hasOwnProperty('units_of_measure')
? visualization.savedVisualization.units_of_measure
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@
import { VizContainerError } from '../../../../../common/types/custom_panels';
import { metricQuerySelector } from '../../../metrics/redux/slices/metrics_slice';
import { coreRefs } from '../../../../framework/core_refs';
import { PROMQL_METRIC_SUBTYPE } from '../../../../../common/constants/shared';
import {
observabilityMetricsID,
PROMQL_METRIC_SUBTYPE,
} from '../../../../../common/constants/shared';

/*
* Visualization container - This module is a placeholder to add visualizations in react-grid-layout
Expand Down Expand Up @@ -78,6 +81,7 @@
removeVisualization?: (visualizationId: string) => void;
catalogVisualization?: boolean;
inlineEditor?: JSX.Element;
actionMenuType?: string;
}

export const VisualizationContainer = ({
Expand All @@ -98,6 +102,7 @@
removeVisualization,
catalogVisualization,
inlineEditor,
actionMenuType,
}: Props) => {
const [isPopoverOpen, setIsPopoverOpen] = useState(false);
const [visualizationTitle, setVisualizationTitle] = useState('');
Expand Down Expand Up @@ -175,7 +180,11 @@
disabled={editMode}
onClick={() => {
closeActionsMenu();
onEditClick(savedVisualizationId);
if (visualizationMetaData?.subType === PROMQL_METRIC_SUBTYPE) {
window.location.assign(`${observabilityMetricsID}#/${savedVisualizationId}`);
} else {
onEditClick(savedVisualizationId);

Check warning on line 186 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L184-L186

Added lines #L184 - L186 were not covered by tests
}
}}
>
Edit
Expand Down Expand Up @@ -217,16 +226,19 @@
</EuiContextMenuItem>,
];

if (visualizationMetaData?.subType === PROMQL_METRIC_SUBTYPE) {
if (
visualizationMetaData?.subType === PROMQL_METRIC_SUBTYPE &&
actionMenuType === 'metricsGrid'

Check warning on line 231 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L231

Added line #L231 was not covered by tests
) {
popoverPanel = [showPPLQueryPanel];

Check warning on line 233 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L233

Added line #L233 was not covered by tests
} else if (usedInNotebooks) {
popoverPanel = [popoverPanel[0]];

Check warning on line 235 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L235

Added line #L235 was not covered by tests
}

const fetchVisualization = async () => {
return savedVisualizationId
? await fetchVisualizationById(http, savedVisualizationId, setIsError)
: inputMetaData;

Check warning on line 241 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L241

Added line #L241 was not covered by tests
};

const loadVisaulization = async () => {
Expand All @@ -236,7 +248,7 @@
if (!visualization && !savedVisualizationId) return;

if (visualization.subType === PROMQL_METRIC_SUBTYPE) {
renderCatalogVisualization({

Check warning on line 251 in public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/custom_panels/panel_modules/visualization_container/visualization_container.tsx#L251

Added line #L251 was not covered by tests
visualization,
http,
pplService,
Expand Down
55 changes: 30 additions & 25 deletions public/components/metrics/redux/slices/metrics_slice.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
* SPDX-License-Identifier: Apache-2.0
*/

import { createAsyncThunk, createSlice } from '@reduxjs/toolkit';
import { keyBy, mergeWith, pick, sortBy, merge } from 'lodash';
import { createSlice } from '@reduxjs/toolkit';
import { keyBy, mergeWith, pick, sortBy } from 'lodash';
import { ouiPaletteColorBlindBehindText } from '@elastic/eui';
import {
OBSERVABILITY_CUSTOM_METRIC,
Expand All @@ -18,7 +18,7 @@
import { pplServiceRequestor } from '../../helpers/utils';
import { coreRefs } from '../../../../framework/core_refs';
import { PPL_METRIC_SUBTYPE, PROMQL_METRIC_SUBTYPE } from '../../../../../common/constants/shared';
import { getOSDHttp, getPPLService } from '../../../../../common/utils';
import { getPPLService } from '../../../../../common/utils';

export interface IconAttributes {
color: string;
Expand All @@ -38,6 +38,14 @@
return Object.fromEntries(keyedIcons);
};

export interface DateSpanFilter {
start: string;
end: string;
span: number;
resolution: string;
recentlyUsedRanges: string[];
}

const initialState = {
metrics: {},
selectedIds: [],
Expand All @@ -62,12 +70,17 @@
...srcValue,
availableAttributes:
objValue?.availableAttributes?.length > 0
? objValue.availableAttributes

Check warning on line 73 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L73

Added line #L73 was not covered by tests
: srcValue.availableAttributes,
};
};
export const mergeMetrics = (newMetricMap) => (dispatch, getState) => {
const { metrics } = getState().metrics;
const modifiableMetricsMap = { ...metrics };

const now = () => new Date().getMilliseconds();
const mergedMetrics = mergeWith(modifiableMetricsMap, newMetricMap, mergeMetricCustomizer);
dispatch(setMetrics(mergedMetrics));
};

export const loadMetrics = () => async (dispatch) => {
const pplService = getPPLService();
Expand All @@ -81,15 +94,15 @@
setDataSourceIcons(coloredIconsFrom([OBSERVABILITY_CUSTOM_METRIC, ...remoteDataSources]))
);

const remoteDataRequests = fetchRemoteMetrics(remoteDataSources);
const remoteDataRequests = await fetchRemoteMetrics(remoteDataSources);
const metricsResultSet = await Promise.all([customDataRequest, ...remoteDataRequests]);
const metricsResult = metricsResultSet.flat();

const metricsMapById = keyBy(metricsResult.flat(), 'id');
await dispatch(mergeMetrics(metricsMapById));
dispatch(mergeMetrics(metricsMapById));

const sortedIds = sortBy(metricsResult, 'catalog', 'id').map((m) => m.id);
await dispatch(setSortedIds(sortedIds));
dispatch(setSortedIds(sortedIds));
};

const fetchCustomMetrics = async () => {
Expand Down Expand Up @@ -150,17 +163,9 @@
name: REDUX_SLICE_METRICS,
initialState,
reducers: {
mergeMetrics: (state, { payload }) => {
const { metrics } = state;
const modifiableMetricsMap = { ...metrics };

const mergedMetrics = mergeWith(modifiableMetricsMap, payload, mergeMetricCustomizer);
state.metrics = mergedMetrics;
setMetrics: (state, { payload }) => {
state.metrics = payload;
},

// setMetrics: (state, { payload }) => {
// state.metrics = payload;
// },
setMetric: (state, { payload }) => {
state.metrics[payload.id] = payload;
},
Expand All @@ -177,20 +182,20 @@
},

deSelectMetric: (state, { payload }) => {
state.selectedIds = state.selectedIds.filter((id) => id !== payload);

Check warning on line 185 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L185

Added line #L185 was not covered by tests
},

moveMetric: (state, { payload: { source, destination } }) => {
const movingId = state.selectedIds.splice(source.index, 1);
state.selectedIds.splice(destination.index, 0, movingId[0]);

Check warning on line 190 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L188-L190

Added lines #L188 - L190 were not covered by tests
},

setSearch: (state, { payload }) => {
state.search = payload;
},

updateMetric: (state, { payload: { id, metric } }) => {
state.metrics[id] = metric;

Check warning on line 198 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L197-L198

Added lines #L197 - L198 were not covered by tests
},

setDataSources: (state, { payload }) => {
Expand All @@ -202,15 +207,19 @@
setDataSourceIcons: (state, { payload }) => {
state.dataSourceIcons = payload;
},
setDateSpan: (state, { payload }) => {
state.dateSpanFilter = { ...state.dateSpanFilter, ...payload };

Check warning on line 211 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L210-L211

Added lines #L210 - L211 were not covered by tests
},
setRefresh: (state) => {
state.refresh = Date.now();

Check warning on line 214 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L213-L214

Added lines #L213 - L214 were not covered by tests
},
},
});

export const {
setMetrics,
deSelectMetric,
clearSelectedMetrics,

mergeMetrics,
selectMetric,
moveMetric,
setSearch,
setDateSpan,
Expand All @@ -222,7 +231,7 @@

/** private actions */

const { selectMetric, setMetric, setSortedIds } = metricSlice.actions;
const { setMetrics, setMetric, setSortedIds } = metricSlice.actions;

const getAvailableAttributes = (id, metricIndex) => async (dispatch, getState) => {
const { toasts } = coreRefs;
Expand All @@ -234,13 +243,13 @@
format: 'jdbc',
});
const availableAttributes = columnSchema.jsonData
.map((sch) => sch.COLUMN_NAME)
.filter((col) => col[0] !== '@');

Check warning on line 247 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L246-L247

Added lines #L246 - L247 were not covered by tests

dispatch(updateMetricQuery(id, { availableAttributes }));
} catch (e) {
toasts?.addDanger(`An error occurred retrieving attributes for metric ${id} `);
console.error(`An error occurred retrieving attributes for metric ${id} `, e);

Check warning on line 252 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L251-L252

Added lines #L251 - L252 were not covered by tests
}
};

Expand All @@ -255,7 +264,7 @@
};

export const removeSelectedMetric = ({ id }) => async (dispatch, getState) => {
dispatch(deSelectMetric(id));

Check warning on line 267 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L267

Added line #L267 was not covered by tests
};

export const updateMetricQuery = (id, { availableAttributes, aggregation, attributesGroupBy }) => (
Expand All @@ -275,7 +284,7 @@

export const searchOrTrue = (search, metric) => {
if (search === '') return true;
return metric.name.match(new RegExp(search, 'i'));

Check warning on line 287 in public/components/metrics/redux/slices/metrics_slice.ts

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/redux/slices/metrics_slice.ts#L287

Added line #L287 was not covered by tests
};

export const selectMetricByIdSelector = (id) => (state) => {
Expand All @@ -295,16 +304,12 @@
export const selectedMetricsSelector = (state) =>
pick(state.metrics.metrics, state.metrics.selectedIds) ?? {};

export const selectedMetricByIdSelector = (id) => (state) => state.metrics.metrics[id];

export const selectedMetricsIdsSelector = (state) => state.metrics.selectedIds ?? [];

export const searchSelector = (state) => state.metrics.search;

export const metricIconsSelector = (state) => state.metrics.dataSourceIcons;

export const metricsLayoutSelector = (state) => state.metrics.metricsLayout;

export const dateSpanFilterSelector = (state) => state.metrics.dateSpanFilter;

export const refreshSelector = (state) => state.metrics.refresh;
Expand Down
8 changes: 5 additions & 3 deletions public/components/metrics/sidebar/sidebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,12 @@

useEffect(() => {
if (additionalMetric) {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what's an additional metric?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A badly named variable.

It's used when navigating to a specific metric for "edit", the URL is ./metrics/{savedObjectId}.

I tried a bunch fo names that didn't work and then just gave up trying. (Not the best approach)

dispatch(clearSelectedMetrics());
dispatch(addSelectedMetric(additionalMetric));
(async function () {
await dispatch(clearSelectedMetrics());
await dispatch(addSelectedMetric(additionalMetric));

Check warning on line 48 in public/components/metrics/sidebar/sidebar.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/sidebar/sidebar.tsx#L46-L48

Added lines #L46 - L48 were not covered by tests
})();
}
}, [additionalMetric]);
}, [additionalMetric?.id]);

const selectedMetricsList = useMemo(() => {
return selectedMetricsIds.map((id) => selectedMetrics[id]).filter((m) => m); // filter away null entries
Expand All @@ -55,7 +57,7 @@
const handleAddMetric = (metric: any) => dispatch(addSelectedMetric(metric));

const handleRemoveMetric = (metric: any) => {
dispatch(removeSelectedMetric(metric));

Check warning on line 60 in public/components/metrics/sidebar/sidebar.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/sidebar/sidebar.tsx#L60

Added line #L60 was not covered by tests
};

return (
Expand Down
16 changes: 15 additions & 1 deletion public/components/metrics/view/metrics_grid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

import React, { useEffect, useMemo } from 'react';
import { EuiDragDropContext, EuiDraggable, EuiDroppable } from '@elastic/eui';
import { EuiContextMenuItem, EuiDragDropContext, EuiDraggable, EuiDroppable } from '@elastic/eui';
import { useObservable } from 'react-use';
import { connect } from 'react-redux';
import { CoreStart } from '../../../../../../src/core/public';
Expand Down Expand Up @@ -53,14 +53,27 @@
},
});

const promQLActionMenu = [
<EuiContextMenuItem
data-test-subj="showCatalogPPLQuery"
key="view_query"
onClick={() => {
closeActionsMenu();
showModal('catalogModal');

Check warning on line 62 in public/components/metrics/view/metrics_grid.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/view/metrics_grid.tsx#L60-L62

Added lines #L60 - L62 were not covered by tests
}}
>
View query
</EuiContextMenuItem>,
];

const navigateToEventExplorerVisualization = (savedVisualizationId: string) => {
window.location.assign(`${observabilityLogsID}#/explorer/${savedVisualizationId}`);

Check warning on line 70 in public/components/metrics/view/metrics_grid.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/view/metrics_grid.tsx#L70

Added line #L70 was not covered by tests
};

export const InnerGridVisualization = ({ id, idx, dateSpanFilter, metric, refresh }) => {
if (!metric) return <></>;

return (

Check warning on line 76 in public/components/metrics/view/metrics_grid.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/view/metrics_grid.tsx#L76

Added line #L76 was not covered by tests
<EuiDraggable key={id} index={idx} draggableId={id}>
<VisualizationContainer
key={id}
Expand All @@ -80,6 +93,7 @@
inlineEditor={
metric.subType === PROMQL_METRIC_SUBTYPE && <MetricsEditInline visualization={metric} />
}
actionMenuType="metricsGrid"
/>
</EuiDraggable>
);
Expand All @@ -99,15 +113,15 @@
const isLocked = useObservable(chrome!.getIsNavDrawerLocked$());

const onDragEnd = ({ source, destination }) => {
moveMetric({ source, destination });

Check warning on line 116 in public/components/metrics/view/metrics_grid.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/view/metrics_grid.tsx#L116

Added line #L116 was not covered by tests
};

const visualizationComponents = useMemo(() => {
if (selectedMetrics.length < 1) return <EmptyMetricsView />;

return selectedMetricsIds.map((id, idx) => {
const metric = allMetrics[id];
return (

Check warning on line 124 in public/components/metrics/view/metrics_grid.tsx

View check run for this annotation

Codecov / codecov/patch

public/components/metrics/view/metrics_grid.tsx#L123-L124

Added lines #L123 - L124 were not covered by tests
<GridVisualization
id={id}
idx={idx}
Expand Down
2 changes: 1 addition & 1 deletion public/services/requests/ppl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { PPL_BASE, PPL_SEARCH } from '../../../common/constants/shared';
/* eslint-disable import/no-default-export */
export default class PPLService {
private http;

constructor(http: CoreStart['http']) {
this.http = http;
}
Expand All @@ -20,7 +21,6 @@ export default class PPLService {
},
errorHandler?: (error: any) => void
) => {
console.log('real fetch');
return this.http
.post(`${PPL_BASE}${PPL_SEARCH}`, {
body: JSON.stringify(params),
Expand Down
Loading