diff --git a/public/app/core/history/richHistoryLocalStorage.test.ts b/public/app/core/history/RichHistoryLocalStorage.test.ts similarity index 98% rename from public/app/core/history/richHistoryLocalStorage.test.ts rename to public/app/core/history/RichHistoryLocalStorage.test.ts index b260f9554fb..00f20f48e09 100644 --- a/public/app/core/history/richHistoryLocalStorage.test.ts +++ b/public/app/core/history/RichHistoryLocalStorage.test.ts @@ -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'; diff --git a/public/app/core/history/richHistoryLocalStorage.ts b/public/app/core/history/RichHistoryLocalStorage.ts similarity index 90% rename from public/app/core/history/richHistoryLocalStorage.ts rename to public/app/core/history/RichHistoryLocalStorage.ts index 074961a4c44..d0b1c0b4ccd 100644 --- a/public/app/core/history/richHistoryLocalStorage.ts +++ b/public/app/core/history/RichHistoryLocalStorage.ts @@ -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 { + async getRichHistory() { const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []); const transformedRichHistory = migrateRichHistory(richHistory); return transformedRichHistory; } - async addToRichHistory(richHistoryQuery: RichHistoryQuery): Promise { + 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 { + async deleteAll() { store.delete(RICH_HISTORY_KEY); } - async deleteRichHistory(id: number): Promise { + 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 { + 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 { + async updateComment(id: number, comment: string) { const richHistory: RichHistoryQuery[] = store.getObject(RICH_HISTORY_KEY, []); const updatedHistory = richHistory.map((query) => { if (query.ts === id) { diff --git a/public/app/core/history/RichHistoryRemoteStorage.ts b/public/app/core/history/RichHistoryRemoteStorage.ts new file mode 100644 index 00000000000..c3b8a562b39 --- /dev/null +++ b/public/app/core/history/RichHistoryRemoteStorage.ts @@ -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) {} +} diff --git a/public/app/core/history/richHistoryStorage.ts b/public/app/core/history/RichHistoryStorage.ts similarity index 100% rename from public/app/core/history/richHistoryStorage.ts rename to public/app/core/history/RichHistoryStorage.ts diff --git a/public/app/core/history/richHistoryRemoteStorage.ts b/public/app/core/history/richHistoryRemoteStorage.ts deleted file mode 100644 index 91804c1abd5..00000000000 --- a/public/app/core/history/richHistoryRemoteStorage.ts +++ /dev/null @@ -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 { - return []; - } - async addToRichHistory(updatedHistory: RichHistoryQuery): Promise { - return; - } - async deleteAll(): Promise {} - async deleteRichHistory(id: number): Promise {} - async updateComment(id: number, comment: string | undefined): Promise {} - async updateStarred(id: number, starred: boolean): Promise {} -} diff --git a/public/app/core/history/richHistoryStorageProvider.ts b/public/app/core/history/richHistoryStorageProvider.ts index ac40dc56f57..c215d9722f4 100644 --- a/public/app/core/history/richHistoryStorageProvider.ts +++ b/public/app/core/history/richHistoryStorageProvider.ts @@ -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(); diff --git a/public/app/core/utils/richHistory.test.ts b/public/app/core/utils/richHistory.test.ts index db681badb5f..62036265d2d 100644 --- a/public/app/core/utils/richHistory.test.ts +++ b/public/app/core/utils/richHistory.test.ts @@ -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; diff --git a/public/app/core/utils/richHistory.ts b/public/app/core/utils/richHistory.ts index 1ba8a951860..5502b5706e7 100644 --- a/public/app/core/utils/richHistory.ts +++ b/public/app/core/utils/richHistory.ts @@ -16,7 +16,7 @@ import { RichHistoryServiceError, RichHistoryStorageWarning, RichHistoryStorageWarningDetails, -} from '../history/richHistoryStorage'; +} from '../history/RichHistoryStorage'; import { filterQueriesByDataSource, filterQueriesBySearchFilter, diff --git a/public/app/features/explore/RichHistory/RichHistorySettings.tsx b/public/app/features/explore/RichHistory/RichHistorySettings.tsx index 7d2baed0737..2a83c6d04be 100644 --- a/public/app/features/explore/RichHistory/RichHistorySettings.tsx +++ b/public/app/features/explore/RichHistory/RichHistorySettings.tsx @@ -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;