Commit 26ba7ab5 by Andrej Ocenas Committed by GitHub

Chore: Remove loki version hack in explore (#27966)

parent 43c389d1
......@@ -331,6 +331,7 @@ export enum DataSourceStatus {
Disconnected,
}
// TODO: not really needed but used as type in some data sources and in DataQueryRequest
export enum ExploreMode {
Logs = 'Logs',
Metrics = 'Metrics',
......
......@@ -155,7 +155,7 @@ export function buildQueryTransaction(
__interval_ms: { text: intervalMs, value: intervalMs },
},
maxDataPoints: queryOptions.maxDataPoints,
exploreMode: queryOptions.mode,
exploreMode: undefined,
liveStreaming: queryOptions.liveStreaming,
/**
* @deprecated (external API) showingGraph and showingTable are always set to true and set to true
......
......@@ -128,7 +128,6 @@ export interface SyncTimesPayload {
export interface UpdateDatasourceInstancePayload {
exploreId: ExploreId;
datasourceInstance: DataSourceApi;
version?: string;
}
export interface ToggleLogLevelPayload {
......
......@@ -123,13 +123,11 @@ export function changeDatasource(
const currentDataSourceInstance = getState().explore[exploreId].datasourceInstance;
const queries = getState().explore[exploreId].queries;
const orgId = getState().user.orgId;
const datasourceVersion = newDataSourceInstance.getVersion && (await newDataSourceInstance.getVersion());
dispatch(
updateDatasourceInstanceAction({
exploreId,
datasourceInstance: newDataSourceInstance,
version: datasourceVersion,
})
);
......
......@@ -2,7 +2,6 @@ import {
DataQuery,
DataSourceApi,
dateTime,
ExploreMode,
LoadingState,
RawTimeRange,
UrlQueryMap,
......@@ -99,7 +98,6 @@ describe('Explore item reducer', () => {
graphResult: null,
logsResult: null,
tableResult: null,
supportedModes: [ExploreMode.Metrics, ExploreMode.Logs],
latency: 0,
loading: false,
queryResponse: createEmptyQueryResponse(),
......
......@@ -3,14 +3,12 @@ import { AnyAction } from 'redux';
import { PayloadAction } from '@reduxjs/toolkit';
import {
DataQuery,
DataSourceApi,
DefaultTimeRange,
LoadingState,
PanelData,
PanelEvents,
TimeZone,
toLegacyResponseData,
ExploreMode,
LogsDedupStrategy,
sortLogsResult,
DataQueryErrorType,
......@@ -107,7 +105,6 @@ export const makeExploreItemState = (): ExploreItemState => ({
urlState: null,
update: makeInitialUpdateState(),
latency: 0,
supportedModes: [],
isLive: false,
isPaused: false,
urlReplaced: false,
......@@ -259,33 +256,14 @@ export const itemReducer = (state: ExploreItemState = makeExploreItemState(), ac
}
if (updateDatasourceInstanceAction.match(action)) {
const { datasourceInstance, version } = action.payload;
const { datasourceInstance } = action.payload;
// Custom components
stopQueryState(state.querySubscription);
let newMetadata = datasourceInstance.meta;
// HACK: Temporary hack for Loki datasource. Can remove when plugin.json structure is changed.
if (version && version.length && datasourceInstance.meta.name === 'Loki') {
const lokiVersionMetadata: Record<string, { metrics: boolean }> = {
v0: {
metrics: false,
},
v1: {
metrics: true,
},
};
newMetadata = { ...newMetadata, ...lokiVersionMetadata[version] };
}
const updatedDatasourceInstance = Object.assign(datasourceInstance, { meta: newMetadata });
const supportedModes = getModesForDatasource(updatedDatasourceInstance);
return {
...state,
datasourceInstance: updatedDatasourceInstance,
datasourceInstance,
graphResult: null,
tableResult: null,
logsResult: null,
......@@ -293,7 +271,6 @@ export const itemReducer = (state: ExploreItemState = makeExploreItemState(), ac
queryResponse: createEmptyQueryResponse(),
loading: false,
queryKeys: [],
supportedModes,
originPanelId: state.urlState && state.urlState.originPanelId,
};
}
......@@ -588,28 +565,6 @@ export const updateChildRefreshState = (
};
};
const getModesForDatasource = (dataSource: DataSourceApi): ExploreMode[] => {
const supportsGraph = dataSource.meta.metrics;
const supportsLogs = dataSource.meta.logs;
const supportsTracing = dataSource.meta.tracing;
const supportedModes: ExploreMode[] = [];
if (supportsGraph) {
supportedModes.push(ExploreMode.Metrics);
}
if (supportsLogs) {
supportedModes.push(ExploreMode.Logs);
}
if (supportsTracing) {
supportedModes.push(ExploreMode.Tracing);
}
return supportedModes;
};
/**
* Global Explore reducer that handles multiple Explore areas (left and right).
* Actions that have an `exploreId` get routed to the ExploreItemReducer.
......
......@@ -14,7 +14,6 @@ import {
AbsoluteTimeRange,
GraphSeriesXY,
DataFrame,
ExploreMode,
ExploreUrlState,
} from '@grafana/data';
......@@ -157,7 +156,6 @@ export interface ExploreItemState {
update: ExploreUpdateState;
latency: number;
supportedModes: ExploreMode[];
/**
* If true, the view is in live tailing mode.
......@@ -197,7 +195,6 @@ export interface QueryOptions {
minInterval?: string;
maxDataPoints?: number;
liveStreaming?: boolean;
mode?: ExploreMode;
}
export interface QueryTransaction {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment