mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Explore: Remove support for legacy, compact format URLs (#49350)
* Remove function, start changing tests * Fix tests * Remove deprecated parameter from function
This commit is contained in:
@@ -165,16 +165,6 @@ export function buildQueryTransaction(
|
||||
|
||||
export const clearQueryKeys: (query: DataQuery) => DataQuery = ({ key, ...rest }) => rest;
|
||||
|
||||
const isSegment = (segment: { [key: string]: string }, ...props: string[]) =>
|
||||
props.some((prop) => segment.hasOwnProperty(prop));
|
||||
|
||||
enum ParseUrlStateIndex {
|
||||
RangeFrom = 0,
|
||||
RangeTo = 1,
|
||||
Datasource = 2,
|
||||
SegmentsStart = 3,
|
||||
}
|
||||
|
||||
export const safeParseJson = (text?: string): any | undefined => {
|
||||
if (!text) {
|
||||
return;
|
||||
@@ -229,25 +219,7 @@ export function parseUrlState(initial: string | undefined): ExploreUrlState {
|
||||
return errorResult;
|
||||
}
|
||||
|
||||
if (!Array.isArray(parsed)) {
|
||||
return parsed;
|
||||
}
|
||||
|
||||
if (parsed.length <= ParseUrlStateIndex.SegmentsStart) {
|
||||
console.error('Error parsing compact URL state for Explore.');
|
||||
return errorResult;
|
||||
}
|
||||
|
||||
const range = {
|
||||
from: parsed[ParseUrlStateIndex.RangeFrom],
|
||||
to: parsed[ParseUrlStateIndex.RangeTo],
|
||||
};
|
||||
const datasource = parsed[ParseUrlStateIndex.Datasource];
|
||||
const parsedSegments = parsed.slice(ParseUrlStateIndex.SegmentsStart);
|
||||
const queries = parsedSegments.filter((segment) => !isSegment(segment, 'ui', 'mode', '__panelsState'));
|
||||
|
||||
const panelsState = parsedSegments.find((segment) => isSegment(segment, '__panelsState'))?.__panelsState;
|
||||
return { datasource, queries, range, panelsState };
|
||||
return parsed;
|
||||
}
|
||||
|
||||
export function generateKey(index = 0): string {
|
||||
|
Reference in New Issue
Block a user