mirror of
https://github.com/Azure/cosmos-explorer.git
synced 2025-12-26 20:31:33 +00:00
* Infrastructure to save app state * Save filters * Replace read/save methods with more generic ones * Make datalist for filter unique per database/container combination * Disable saving middle split position for now * Fix unit tests * Turn off confusing auto-complete from input box * Disable tabStateData for now * Save and restore split position * Fix replace autocomplete="off" by removing id on Input tag * Properly set allotment width * Fix saved percentage * Save splitter per collection * Add error handling and telemetry * Fix compiling issue * Add ability to delete filter history. Bug fix when hitting Enter on filter input box. * Replace delete filter modal with dropdown menu * Add code to remove oldest record if max limit is reached in app state persistence * Only save new splitter position on drag end (not onchange) * Add unit tests * Add Clear all in settings. Update snapshots * Fix format * Remove filter delete and keep filter history to a max. Reword clear button and message in settings pane. * Fix setting button label * Update test snapshots * Reword Clear history button text * Update unit test snapshot * Enable Settings pane for Fabric, but turn off Rbac dial for Fabric. * Change union type to enum * Update src/Shared/AppStatePersistenceUtility.ts Assert that path does not include slash char. Co-authored-by: Ashley Stanton-Nurse <ashleyst@microsoft.com> * Update src/Shared/AppStatePersistenceUtility.ts Assert that path does not contain slash. Co-authored-by: Ashley Stanton-Nurse <ashleyst@microsoft.com> * Fix format --------- Co-authored-by: Ashley Stanton-Nurse <ashleyst@microsoft.com>
34 lines
1.3 KiB
TypeScript
34 lines
1.3 KiB
TypeScript
import { StorageKey } from "./StorageUtility";
|
|
import * as StringUtility from "./StringUtility";
|
|
|
|
export const hasItem = (key: StorageKey): boolean => !!localStorage.getItem(StorageKey[key]);
|
|
|
|
export const getEntryString = (key: StorageKey): string | null => localStorage.getItem(StorageKey[key]);
|
|
|
|
export const getEntryNumber = (key: StorageKey): number =>
|
|
StringUtility.toNumber(localStorage.getItem(StorageKey[key]));
|
|
|
|
export const getEntryBoolean = (key: StorageKey): boolean =>
|
|
StringUtility.toBoolean(localStorage.getItem(StorageKey[key]));
|
|
|
|
export const setEntryString = (key: StorageKey, value: string): void => localStorage.setItem(StorageKey[key], value);
|
|
|
|
export const removeEntry = (key: StorageKey): void => localStorage.removeItem(StorageKey[key]);
|
|
|
|
export const setEntryNumber = (key: StorageKey, value: number): void =>
|
|
localStorage.setItem(StorageKey[key], value.toString());
|
|
|
|
export const setEntryBoolean = (key: StorageKey, value: boolean): void =>
|
|
localStorage.setItem(StorageKey[key], value.toString());
|
|
|
|
export const setEntryObject = (key: StorageKey, value: unknown): void => {
|
|
localStorage.setItem(StorageKey[key], JSON.stringify(value));
|
|
};
|
|
export const getEntryObject = <T>(key: StorageKey): T | null => {
|
|
const item = localStorage.getItem(StorageKey[key]);
|
|
if (item) {
|
|
return JSON.parse(item) as T;
|
|
}
|
|
return null;
|
|
};
|