Skip to content

Commit

Permalink
feat: add menu items to inspect storage
Browse files Browse the repository at this point in the history
  • Loading branch information
icelam committed Aug 8, 2020
1 parent 22d6ce3 commit d254913
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/menus/menuItems.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
V8_VERSION,
APP_ICON_PATH
} from '@constants';
import { clearStorage } from '@utils';
import { clearStorage, getStoragePath } from '@utils';

export const copyFormatMenuItem: MenuItemConstructorOptions = {
label: translations.menus.copyFormat,
Expand Down Expand Up @@ -88,6 +88,7 @@ export const checkUpdatesMenuItem: MenuItemConstructorOptions = {
label: translations.menus.checkUpdates,
accelerator: 'CmdOrCtrl+U'
// TODO: Check for updates using latest release API from github
// https://api.github.com/repos/{{username}}/{{repo}}/releases/latest
};

export const reportIssueMenuItem: MenuItemConstructorOptions = {
Expand All @@ -107,6 +108,15 @@ export const developerMenuItem: MenuItemConstructorOptions = {
submenu: [
{ label: translations.menus.toggleDevTools, role: 'toggleDevTools' },
{ label: translations.menus.reload, role: 'reload' },
{ type: 'separator' },
{
label: translations.menus.inpsectStorage,
accelerator: 'CmdOrCtrl+Shift+S',
click: (): void => {
const storagePath = getStoragePath();
shell.showItemInFolder(storagePath);
}
},
{
label: translations.menus.clearStorage,
accelerator: 'CmdOrCtrl+Shift+C',
Expand Down
1 change: 1 addition & 0 deletions src/translations/menus.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const menusTranslations = {
developer: 'Developer',
toggleDevTools: 'Toggle developer tools',
reload: 'Reload',
inpsectStorage: 'Inspect storage',
clearStorage: 'Clear storage',
clearStorageSuccess: 'Storage cleared successfully!',
clearStorageSuccessBody: 'All data stored in storage has been removed.',
Expand Down
6 changes: 6 additions & 0 deletions src/utils/storage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ export const saveWindowPositionToStorage = (x?: number, y?: number): void => {
}
};

/**
* Get storage path
* @returns {string} folder path which contains all the stored json
*/
export const getStoragePath = (): string => storage.getDataPath();

/**
* Clear all preference saved in storage
* @return {boolean} whether clear is success
Expand Down

0 comments on commit d254913

Please sign in to comment.