vm reset modal

pull/5563/head
aniket-engg 1 month ago committed by Aniket
parent 743bef2bfb
commit 85e272a9b6
  1. 5
      apps/remix-dapp/src/locales/en/udapp.json
  2. 5
      apps/remix-ide/src/app/tabs/locales/en/udapp.json
  3. 33
      libs/remix-ui/run-tab/src/lib/components/environment.tsx

@ -52,6 +52,11 @@
"udapp.saveVmStateTitle": "Save VM state",
"udapp.saveVmStateLabel": "State Name",
"udapp.saveVmStateTip": "Saved VM states can be pinned as environment using Environment Explorer",
"udapp.resetVmStateTitle": "Reset VM state",
"udapp.resetVmStateDesc1": "Resetting state of selected environment will delete all your previously saved transaction details for selected workspace.",
"udapp.resetVmStateDesc2": "It will also delete data for deployed and pinned contracts.",
"udapp.resetVmStateDesc3": "Do you want to continue?",
"udapp.reset": "Reset",
"udapp.injectedTitle": "Unfortunately it's not possible to create an account using injected provider. Please create the account directly from your provider (i.e metamask or other of the same type).",
"udapp.createNewAccount": "Create a new account",
"udapp.web3Title": "Creating an account is possible only in Personal mode. Please go to Settings to enable it.",

@ -52,6 +52,10 @@
"udapp.saveVmStateTitle": "Save VM state",
"udapp.saveVmStateLabel": "State Name",
"udapp.saveVmStateTip": "Saved VM states can be pinned as environment using Environment Explorer",
"udapp.resetVmStateTitle": "Reset VM state",
"udapp.resetVmStateDesc1": "Resetting state of selected environment will delete all your previously saved transaction details for selected workspace.",
"udapp.resetVmStateDesc2": "It will also delete data for deployed and pinned contracts.",
"udapp.resetVmStateDesc3": "Do you want to continue?",
"udapp.injectedTitle": "Unfortunately it's not possible to create an account using injected provider. Please create the account directly from your provider (i.e metamask or other of the same type).",
"udapp.createNewAccount": "Create new account",
"udapp.web3Title": "Creating an account is possible only in Personal mode. Please go to Settings to enable it.",
@ -68,6 +72,7 @@
"udapp.environmentDocs": "Click for docs about Environment",
"udapp.saveVmState": "Save VM state",
"udapp.resetVmStateTooltip": "Reset VM state",
"udapp.reset": "Reset",
"udapp.tooltipText2": "Open chainlist.org and get the connection specs of the chain you want to interact with.",
"udapp.tooltipText3": "Click to open a bridge for converting L1 mainnet ETH to the selected network currency.",

@ -30,7 +30,7 @@ export function EnvironmentUI(props: EnvironmentProps) {
const saveVmStatePrompt = (defaultName: string) => {
return (
<div>
<label id="wsName" className="form-check-label" style={{ fontWeight: 'bolder' }}>
<label id="stateName" className="form-check-label" style={{ fontWeight: 'bolder' }}>
<FormattedMessage id="udapp.saveVmStateLabel" />
</label>
<input
@ -48,6 +48,18 @@ export function EnvironmentUI(props: EnvironmentProps) {
)
}
const resetVmStatePrompt = (context: string) => {
return (
<div>
<div>
<FormattedMessage id="udapp.resetVmStateDesc1"/><br/>
<FormattedMessage id="udapp.resetVmStateDesc2"/><br/><br/>
<FormattedMessage id="udapp.resetVmStateDesc3"/>
</div>
</div>
)
}
const saveVmState = async () => {
const context = currentProvider.name
vmStateName.current = `${context}_${Date.now()}`
@ -73,10 +85,25 @@ export function EnvironmentUI(props: EnvironmentProps) {
} else props.runTabPlugin.call('notification', 'toast', `VM state doesn't exist for selected environment.`)
}
const resetVmState = () => {
console.log('reset')
const resetVmState = async() => {
const context = currentProvider.name
const contextExists = await props.runTabPlugin.call('fileManager', 'exists', `.states/${context}/state.json`)
if (contextExists) {
props.modal(
intl.formatMessage({ id: 'udapp.resetVmStateTitle' }),
resetVmStatePrompt(context),
intl.formatMessage({ id: 'udapp.reset' }),
async () => {
// let currentStateDb = await props.runTabPlugin.call('fileManager', 'readFile', `.states/${context}/state.json`)
props.runTabPlugin.call('notification', 'toast', `VM state reset successfully`)
},
intl.formatMessage({ id: 'udapp.cancel' }),
null
)
} else props.runTabPlugin.call('notification', 'toast', `VM state doesn't exist for selected environment.`)
}
const isL2 = (providerDisplayName: string) => providerDisplayName && (providerDisplayName.startsWith('L2 - Optimism') || providerDisplayName.startsWith('L2 - Arbitrum'))
return (
<div className="udapp_crow">

Loading…
Cancel
Save