Skip to content

Commit

Permalink
Add wipe engine action
Browse files Browse the repository at this point in the history
  • Loading branch information
mhammond committed Sep 19, 2023
1 parent 9ca3d7d commit 9e35cae
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 10 deletions.
2 changes: 1 addition & 1 deletion src/CollectionsViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ class CollectionViewer extends React.Component {
</TabPanel>
)}
{this.renderAdditionalTabs()}
{this.props.provider.isLocal && engine && engine.resetClient && (
{this.props.provider.isLocal && engine && (
<TabPanel name="Engine Actions" key="actions">
<EngineActions
engine={engine}/>
Expand Down
48 changes: 39 additions & 9 deletions src/EngineActions.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,17 +25,47 @@ class EngineActions extends React.Component {
});
}

wipe(event) {
let e = this.props.engine;
e._log.info("about:sync wiping engine due to user request");
e.wipeServer().then(() => {
alert("Wipe complete");
}).catch(err => {
console.error("Failed to wipe the engine", err);
});
}

render() {
let reset;
if (this.props.engine.resetClient) {
reset =
<div>
<span>Resetting an engine clears all local state, so the next Sync will
act as though this was the first sync for that engine's data -
all records will be downloaded, compared against local records
and missing records uploaded -
</span>
<button onClick={event => this.reset(event)}>Reset {this.props.engine.name}</button>
</div>
}
let canWipe = !["crypto", "meta"].includes(this.props.engine.name);
let wipe;
if (canWipe) {
wipe =
<div>
<span>Wiping an engine removes data from the server. <em>It does not remove local data</em>.
This device will upload all its data. Other devices will act like a <i>Reset</i>, as described above.
-
</span>
<button onClick={event => this.wipe(event)}>Wipe {this.props.engine.name}</button>
</div>
};
return (
<div>
<span>Resetting an engine clears all local state, so the next Sync will
act as though this was the first sync for that engine's data -
all records will be downloaded, compared against local records
and missing records uploaded -
</span>
<button onClick={event => this.reset(event)}>Reset {this.props.engine.name}</button>
</div>
);
<>
{ reset }
{ wipe }
</>
);
}
}

Expand Down

0 comments on commit 9e35cae

Please sign in to comment.