Rename files and remove inferred return types
This commit is contained in:
+2
-2
@@ -1,9 +1,9 @@
|
||||
import RichHistoryLocalStorage, { MAX_HISTORY_ITEMS } from './richHistoryLocalStorage';
|
||||
import RichHistoryLocalStorage, { MAX_HISTORY_ITEMS } from './RichHistoryLocalStorage';
|
||||
import store from 'app/core/store';
|
||||
import { RichHistoryQuery } from '../../types';
|
||||
import { DataQuery } from '@grafana/data';
|
||||
import { afterEach, beforeEach } from '../../../test/lib/common';
|
||||
import { RichHistoryStorageWarning } from './richHistoryStorage';
|
||||
import { RichHistoryStorageWarning } from './RichHistoryStorage';
|
||||
|
||||
const key = 'grafana.explore.richHistory';
|
||||
|
||||
+7
-11
@@ -1,8 +1,4 @@
|
||||
import RichHistoryStorage, {
|
||||
RichHistoryServiceError,
|
||||
RichHistoryStorageWarning,
|
||||
RichHistoryStorageWarningDetails,
|
||||
} from './richHistoryStorage';
|
||||
import RichHistoryStorage, { RichHistoryServiceError, RichHistoryStorageWarning } from './RichHistoryStorage';
|
||||
import { RichHistoryQuery } from '../../types';
|
||||
import store from '../store';
|
||||
import { DataQuery } from '@grafana/data';
|
||||
@@ -19,13 +15,13 @@ export default class RichHistoryLocalStorage implements RichHistoryStorage {
|
||||
/**
|
||||
* Return all history entries, perform migration and clean up entries not matching retention policy.
|
||||
*/
|
||||
async getRichHistory(): Promise<RichHistoryQuery[]> {
|
||||
async getRichHistory() {
|
||||
const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []);
|
||||
const transformedRichHistory = migrateRichHistory(richHistory);
|
||||
return transformedRichHistory;
|
||||
}
|
||||
|
||||
async addToRichHistory(richHistoryQuery: RichHistoryQuery): Promise<RichHistoryStorageWarningDetails | undefined> {
|
||||
async addToRichHistory(richHistoryQuery: RichHistoryQuery) {
|
||||
const richHistory = cleanUp(await this.getRichHistory());
|
||||
|
||||
/* Compare queries of a new query and last saved queries. If they are the same, (except selected properties,
|
||||
@@ -68,17 +64,17 @@ export default class RichHistoryLocalStorage implements RichHistoryStorage {
|
||||
return undefined;
|
||||
}
|
||||
|
||||
async deleteAll(): Promise<void> {
|
||||
async deleteAll() {
|
||||
store.delete(RICH_HISTORY_KEY);
|
||||
}
|
||||
|
||||
async deleteRichHistory(id: number): Promise<void> {
|
||||
async deleteRichHistory(id: number) {
|
||||
const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []);
|
||||
const updatedHistory = richHistory.filter((query) => query.ts !== id);
|
||||
store.setObject(RICH_HISTORY_KEY, updatedHistory);
|
||||
}
|
||||
|
||||
async updateStarred(id: number, starred: boolean): Promise<void> {
|
||||
async updateStarred(id: number, starred: boolean) {
|
||||
const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []);
|
||||
const updatedHistory = richHistory.map((query) => {
|
||||
if (query.ts === id) {
|
||||
@@ -90,7 +86,7 @@ export default class RichHistoryLocalStorage implements RichHistoryStorage {
|
||||
store.setObject(RICH_HISTORY_KEY, updatedHistory);
|
||||
}
|
||||
|
||||
async updateComment(id: number, comment: string): Promise<void> {
|
||||
async updateComment(id: number, comment: string) {
|
||||
const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []);
|
||||
const updatedHistory = richHistory.map((query) => {
|
||||
if (query.ts === id) {
|
||||
@@ -0,0 +1,18 @@
|
||||
import { RichHistoryQuery } from 'app/types';
|
||||
import RichHistoryStorage from './RichHistoryStorage';
|
||||
|
||||
/**
|
||||
* Object responsible for storing rich history to remote storage. To be implemented for Rich History migration to backend.
|
||||
*/
|
||||
export default class RichHistoryRemoteStorage implements RichHistoryStorage {
|
||||
async getRichHistory() {
|
||||
return [];
|
||||
}
|
||||
async addToRichHistory(richHistoryQuery: RichHistoryQuery) {
|
||||
return undefined;
|
||||
}
|
||||
async deleteAll() {}
|
||||
async deleteRichHistory(id: number) {}
|
||||
async updateComment(id: number, comment: string | undefined) {}
|
||||
async updateStarred(id: number, starred: boolean) {}
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
import { RichHistoryQuery } from 'app/types';
|
||||
import RichHistoryStorage, { RichHistoryStorageWarningDetails } from './richHistoryStorage';
|
||||
|
||||
/**
|
||||
* Object responsible for storing rich history to remote storage. To be implemented for Rich History migration to backend.
|
||||
*/
|
||||
export default class RichHistoryRemoteStorage implements RichHistoryStorage {
|
||||
async getRichHistory(): Promise<RichHistoryQuery[]> {
|
||||
return [];
|
||||
}
|
||||
async addToRichHistory(updatedHistory: RichHistoryQuery): Promise<RichHistoryStorageWarningDetails | undefined> {
|
||||
return;
|
||||
}
|
||||
async deleteAll(): Promise<void> {}
|
||||
async deleteRichHistory(id: number): Promise<void> {}
|
||||
async updateComment(id: number, comment: string | undefined): Promise<void> {}
|
||||
async updateStarred(id: number, starred: boolean): Promise<void> {}
|
||||
}
|
||||
@@ -1,6 +1,6 @@
|
||||
import RichHistoryLocalStorage from './richHistoryLocalStorage';
|
||||
import RichHistoryRemoteStorage from './richHistoryRemoteStorage';
|
||||
import RichHistoryStorage from './richHistoryStorage';
|
||||
import RichHistoryLocalStorage from './RichHistoryLocalStorage';
|
||||
import RichHistoryRemoteStorage from './RichHistoryRemoteStorage';
|
||||
import RichHistoryStorage from './RichHistoryStorage';
|
||||
|
||||
const richHistoryLocalStorage = new RichHistoryLocalStorage();
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import {
|
||||
} from './richHistory';
|
||||
import store from 'app/core/store';
|
||||
import { dateTime, DataQuery } from '@grafana/data';
|
||||
import RichHistoryStorage, { RichHistoryServiceError, RichHistoryStorageWarning } from '../history/richHistoryStorage';
|
||||
import RichHistoryStorage, { RichHistoryServiceError, RichHistoryStorageWarning } from '../history/RichHistoryStorage';
|
||||
|
||||
const richHistoryStorageMock: RichHistoryStorage = {} as RichHistoryStorage;
|
||||
|
||||
|
||||
@@ -16,7 +16,7 @@ import {
|
||||
RichHistoryServiceError,
|
||||
RichHistoryStorageWarning,
|
||||
RichHistoryStorageWarningDetails,
|
||||
} from '../history/richHistoryStorage';
|
||||
} from '../history/RichHistoryStorage';
|
||||
import {
|
||||
filterQueriesByDataSource,
|
||||
filterQueriesBySearchFilter,
|
||||
|
||||
@@ -7,7 +7,7 @@ import { ShowConfirmModalEvent } from '../../../types/events';
|
||||
import { dispatch } from 'app/store/store';
|
||||
import { notifyApp } from 'app/core/actions';
|
||||
import { createSuccessNotification } from 'app/core/copy/appNotification';
|
||||
import { MAX_HISTORY_ITEMS } from 'app/core/history/richHistoryLocalStorage';
|
||||
import { MAX_HISTORY_ITEMS } from 'app/core/history/RichHistoryLocalStorage';
|
||||
|
||||
export interface RichHistorySettingsProps {
|
||||
retentionPeriod: number;
|
||||
|
||||
Reference in New Issue
Block a user