mirror of
https://github.com/grafana/grafana.git
synced 2024-11-25 18:30:41 -06:00
62c824e3a4
* Explore: Refactor active buttons css * Explore: Add query history button * WIP: Creating drawer * WIP: Create custom drawer (for now) * Revert changes to Drawer.tsx * WIP: Layout finished * Rich History: Set up boilerplate for Settings * WIP: Query history cards * Refactor, split components * Add resizability, interactivity * Save history to local storage * Visualise queries from queryhistory local storage * Set up query history settings * Refactor * Create link, un-refactored verison * Copyable url * WIP: Add slider * Commenting feature * Slider filtration * Add headings * Hide Rich history behind feature toggle * Cleaning up, refactors * Update tests * Implement getQueryDisplayText * Update lockfile for new dependencies * Update heading based on sorting * Fix typescript strinctNullCheck errors * Fix Forms, new forms * Fixes based on provided feedback * Fixes, splitting component into two * Add tooltips, add delete history button * Clicking on card adds queries to query rows * Delete history, width of drawers * UI/UX changes, updates * Add number of queries to headings, box shadows * Fix slider, remove feature toggle * Fix typo in the beta announcement * Fix how the rich history state is rendered when initialization * Move updateFilters when activeDatasourceFilter onlyto RichHistory, remove duplicated code * Fix typescript strictnull errors, not used variables errors
108 lines
2.6 KiB
TypeScript
108 lines
2.6 KiB
TypeScript
import { ExploreId, ExploreItemState, ExploreState, RichHistoryQuery } from 'app/types/explore';
|
|
import { makeExploreItemState } from 'app/features/explore/state/reducers';
|
|
import { StoreState, UserState } from 'app/types';
|
|
import { TimeRange, dateTime, DataSourceApi } from '@grafana/data';
|
|
|
|
export const mockExploreState = (options: any = {}) => {
|
|
const isLive = options.isLive || false;
|
|
const history: any[] = [];
|
|
const eventBridge = {
|
|
emit: jest.fn(),
|
|
};
|
|
const streaming = options.streaming || undefined;
|
|
const datasourceInterval = options.datasourceInterval || '';
|
|
const refreshInterval = options.refreshInterval || '';
|
|
const containerWidth = options.containerWidth || 1980;
|
|
const queries = options.queries || [];
|
|
const datasourceError = options.datasourceError || null;
|
|
const scanner = options.scanner || jest.fn();
|
|
const scanning = options.scanning || false;
|
|
const datasourceId = options.datasourceId || '1337';
|
|
const exploreId = ExploreId.left;
|
|
const datasourceInstance: DataSourceApi<any> = options.datasourceInstance || {
|
|
id: 1337,
|
|
query: jest.fn(),
|
|
name: 'test',
|
|
testDatasource: jest.fn(),
|
|
meta: {
|
|
id: datasourceId,
|
|
streaming,
|
|
},
|
|
interval: datasourceInterval,
|
|
};
|
|
const range: TimeRange = options.range || {
|
|
from: dateTime('2019-01-01 10:00:00.000Z'),
|
|
to: dateTime('2019-01-01 16:00:00.000Z'),
|
|
raw: {
|
|
from: 'now-6h',
|
|
to: 'now',
|
|
},
|
|
};
|
|
const urlReplaced = options.urlReplaced || false;
|
|
const left: ExploreItemState = options.left || {
|
|
...makeExploreItemState(),
|
|
containerWidth,
|
|
datasourceError,
|
|
datasourceInstance,
|
|
eventBridge,
|
|
history,
|
|
isLive,
|
|
queries,
|
|
refreshInterval,
|
|
scanner,
|
|
scanning,
|
|
urlReplaced,
|
|
range,
|
|
};
|
|
const right: ExploreItemState = options.right || {
|
|
...makeExploreItemState(),
|
|
containerWidth,
|
|
datasourceError,
|
|
datasourceInstance,
|
|
eventBridge,
|
|
history,
|
|
isLive,
|
|
queries,
|
|
refreshInterval,
|
|
scanner,
|
|
scanning,
|
|
urlReplaced,
|
|
range,
|
|
};
|
|
const split: boolean = options.split || false;
|
|
const syncedTimes: boolean = options.syncedTimes || false;
|
|
const richHistory: RichHistoryQuery[] = [];
|
|
const explore: ExploreState = {
|
|
left,
|
|
right,
|
|
syncedTimes,
|
|
split,
|
|
richHistory,
|
|
};
|
|
|
|
const user: UserState = {
|
|
orgId: 1,
|
|
timeZone: 'browser',
|
|
};
|
|
|
|
const state: Partial<StoreState> = {
|
|
explore,
|
|
user,
|
|
};
|
|
|
|
return {
|
|
containerWidth,
|
|
datasourceId,
|
|
datasourceInstance,
|
|
datasourceInterval,
|
|
eventBridge,
|
|
exploreId,
|
|
history,
|
|
queries,
|
|
refreshInterval,
|
|
state,
|
|
scanner,
|
|
range,
|
|
};
|
|
};
|