Skip to content

Commit

Permalink
update constants
Browse files Browse the repository at this point in the history
  • Loading branch information
shahzad31 committed Mar 31, 2021
1 parent 2b5229b commit f894f18
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one
* or more contributor license agreements. Licensed under the Elastic License
* 2.0; you may not use this file except in compliance with the Elastic License
* 2.0.
*/

export const URL_KEYS = {
METRIC_TYPE: 'mt',
REPORT_TYPE: 'rt',
SERIES_TYPE: 'st',
BREAK_DOWN: 'bd',
FILTERS: 'ft',
REPORT_DEFINITIONS: 'rdf',
};
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,7 @@ import type { AllSeries, AllShortSeries } from '../hooks/use_url_strorage';
import type { SeriesUrl } from '../types';
import { IIndexPattern } from '../../../../../../../../src/plugins/data/common/index_patterns';
import { esFilters } from '../../../../../../../../src/plugins/data/public';

const METRIC_TYPE = 'mt';
const REPORT_TYPE = 'rt';
const SERIES_TYPE = 'st';
const BREAK_DOWN = 'bd';
const FILTERS = 'ft';
const REPORT_DEFINITIONS = 'rdf';
import { URL_KEYS } from './url_constants';

export function convertToShortUrl(series: SeriesUrl) {
const {
Expand All @@ -29,12 +23,12 @@ export function convertToShortUrl(series: SeriesUrl) {
} = series;

return {
[METRIC_TYPE]: metric,
[REPORT_TYPE]: reportType,
[SERIES_TYPE]: seriesType,
[BREAK_DOWN]: breakdown,
[FILTERS]: filters,
[REPORT_DEFINITIONS]: reportDefinitions,
[URL_KEYS.METRIC_TYPE]: metric,
[URL_KEYS.REPORT_TYPE]: reportType,
[URL_KEYS.SERIES_TYPE]: seriesType,
[URL_KEYS.BREAK_DOWN]: breakdown,
[URL_KEYS.FILTERS]: filters,
[URL_KEYS.REPORT_DEFINITIONS]: reportDefinitions,
...restSeries,
};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,18 +10,13 @@ import { IKbnUrlStateStorage } from '../../../../../../../../src/plugins/kibana_
import type { AppDataType, ReportViewTypeId, SeriesUrl, UrlFilter } from '../types';
import { convertToShortUrl } from '../configurations/utils';
import { OperationType, SeriesType } from '../../../../../../lens/public';
import { URL_KEYS } from '../configurations/url_constants';

export const UrlStorageContext = createContext<IKbnUrlStateStorage | null>(null);

interface ProviderProps {
storage: IKbnUrlStateStorage;
}
const METRIC_TYPE = 'mt';
const REPORT_TYPE = 'rt';
const SERIES_TYPE = 'st';
const BREAK_DOWN = 'bd';
const FILTERS = 'ft';
const REPORT_DEFINITIONS = 'rdf';

export function UrlStorageContextProvider({
children,
Expand All @@ -45,12 +40,12 @@ function convertFromShortUrl(newValue: ShortUrlSeries): SeriesUrl {
}

interface ShortUrlSeries {
[METRIC_TYPE]?: OperationType;
[REPORT_TYPE]?: ReportViewTypeId;
[SERIES_TYPE]?: SeriesType;
[BREAK_DOWN]?: string;
[FILTERS]?: UrlFilter[];
[REPORT_DEFINITIONS]?: Record<string, string>;
[URL_KEYS.METRIC_TYPE]?: OperationType;
[URL_KEYS.REPORT_TYPE]?: ReportViewTypeId;
[URL_KEYS.SERIES_TYPE]?: SeriesType;
[URL_KEYS.BREAK_DOWN]?: string;
[URL_KEYS.FILTERS]?: UrlFilter[];
[URL_KEYS.REPORT_DEFINITIONS]?: Record<string, string>;
time?: {
to: string;
from: string;
Expand Down

0 comments on commit f894f18

Please sign in to comment.