Skip to content

Commit

Permalink
add reset workspace option
Browse files Browse the repository at this point in the history
  • Loading branch information
Ross Bulat committed Mar 9, 2024
1 parent 286896b commit ca0273e
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 5 deletions.
7 changes: 6 additions & 1 deletion src/IntegrityChecks/Local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ export const checkLocalChainFilter = () => {

// Tidy up local storage on invalid active tabs. Requires any local storage dependent on tabs config
// to be removed.
export const removeLocalStorageState = () => {
export const removeLocalStorageState = (includeTags = false) => {
localStorage.removeItem('activeTabs');
localStorage.removeItem('activeTabId');
localStorage.removeItem('activeTabIndex');
Expand All @@ -127,6 +127,11 @@ export const removeLocalStorageState = () => {
localStorage.removeItem('appliedTags');
localStorage.removeItem('pageSections');
localStorage.removeItem('pageRedirects');

if (includeTags) {
localStorage.removeItem('tags');
localStorage.removeItem('tagsConfig');
}
};

// Call all local integrity checks.
Expand Down
39 changes: 35 additions & 4 deletions src/screens/Settings/WorkspaceSettings/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { useMenu } from 'contexts/Menu';
import { InDevelopment } from 'library/HelpMenu/InDevelopment';
import { exportWorkspace } from './Utils';
import { NotificationsController } from 'controllers/NotificationsController';
import { removeLocalStorageState } from 'IntegrityChecks/Local';

export const WorkspaceSettings = () => {
const { openMenu } = useMenu();
Expand All @@ -30,8 +31,8 @@ export const WorkspaceSettings = () => {
<div className="text">
<h4>Export Workspace</h4>
<h3>
Back up your current workspace state. Exports your tabs, tags, and
chain search settings.
Back up your current workspace state. Exports your tabs, tags, chain
search, and active page settings.
</h3>
</div>
</SettingsToggleWrapper>
Expand All @@ -57,8 +58,7 @@ export const WorkspaceSettings = () => {
<SettingsToggleWrapper>
<div className="text">
<h4>Import Workspace</h4>
<h3>Import a workspace configuration.</h3>
<h3 className="inline danger">
<h3 className="danger">
<FontAwesomeIcon icon={faTriangleExclamation} />
&nbsp; Importing a workspace will replace your current workspace -
all current state, including your current tabs and custom tag
Expand All @@ -78,6 +78,37 @@ export const WorkspaceSettings = () => {
</button>
</div>
</SettingsSubmitWrapper>

<SettingsToggleWrapper>
<div className="text">
<h4>Reset Workspace</h4>
<h3 className="danger">
<FontAwesomeIcon icon={faTriangleExclamation} />
&nbsp; Your workspace will be reset. Export your current workspace
first if you wish to restore it later.
</h3>
</div>
</SettingsToggleWrapper>

<SettingsSubmitWrapper>
<div className="buttons">
<button
onClick={() => {
if (
confirm(
'Are you sure you want to reset your workspace? Confirming will reload the console.'
)
) {
removeLocalStorageState(true);
window.location.href = '/';
}
}}
>
<FontAwesomeIcon icon={faFileImport} />
Reset Workspace
</button>
</div>
</SettingsSubmitWrapper>
</>
);
};

0 comments on commit ca0273e

Please sign in to comment.