From 650c540ea989e8ce5926eb2ace40fcb9184de046 Mon Sep 17 00:00:00 2001
From: aniket-engg <aniketengg.225@gmail.com>
Date: Thu, 16 Jan 2025 13:47:47 +0530
Subject: [PATCH] reset instead of delete

---
 apps/remix-dapp/src/locales/en/udapp.json     |  9 ++++---
 apps/remix-ide-e2e/src/tests/vm_state.test.ts |  4 +--
 .../src/app/tabs/locales/en/udapp.json        |  9 ++++---
 .../src/lib/components/environment.tsx        | 27 ++++++++++---------
 4 files changed, 27 insertions(+), 22 deletions(-)

diff --git a/apps/remix-dapp/src/locales/en/udapp.json b/apps/remix-dapp/src/locales/en/udapp.json
index f73cd69e98..3d28dc9dc0 100644
--- a/apps/remix-dapp/src/locales/en/udapp.json
+++ b/apps/remix-dapp/src/locales/en/udapp.json
@@ -54,10 +54,11 @@
   "udapp.forkVmStateDesc1":"Forking state will create a new environment with same state as selected environment",
   "udapp.forkVmStateDesc2":"New environment will be pinned, which can be unpinned or deleted using Envionment Explorer",
   "udapp.fork": "Fork",
-  "udapp.deleteVmStateTitle": "Delete VM state",
-  "udapp.deleteVmStateDesc1": "Deleting the state of this VM will delete the associated transaction details in this Workspace.",
-  "udapp.deleteVmStateDesc2": "It will also delete the data of contracts deployed and pinned in this Workspace.",
-  "udapp.deleteVmStateDesc3": "Do you want to continue?",
+  "udapp.resetVmStateTitle": "Reset VM state",
+  "udapp.resetVmStateDesc1": "Resetting the state of this VM will delete the associated transaction details in this Workspace.",
+  "udapp.resetVmStateDesc2": "It will also delete the data of contracts deployed and pinned in this Workspace.",
+  "udapp.resetVmStateDesc3": "Do you want to continue?",
+  "udapp.reset": "Reset",
   "udapp.delete": "Delete",
   "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",
diff --git a/apps/remix-ide-e2e/src/tests/vm_state.test.ts b/apps/remix-ide-e2e/src/tests/vm_state.test.ts
index 45dc3e979c..d22db4809c 100644
--- a/apps/remix-ide-e2e/src/tests/vm_state.test.ts
+++ b/apps/remix-ide-e2e/src/tests/vm_state.test.ts
@@ -33,7 +33,7 @@ const tests = {
       .click('*[data-id="delete-state-icon"]')
       .waitForElementVisible(
         {
-          selector: "//*[@data-shared='tooltipPopup' and contains(.,'State not available to delete')]",
+          selector: "//*[@data-shared='tooltipPopup' and contains(.,'State not available to reset')]",
           locateStrategy: 'xpath'
         }
       )
@@ -140,7 +140,7 @@ const tests = {
       .modalFooterOKClick('udappNotify')
       .waitForElementVisible('*[data-shared="tooltipPopup"]', 10000)
       // check if toaster is shown
-      .assert.textContains('*[data-shared="tooltipPopup"]', `VM state deleted successfully.`)
+      .assert.textContains('*[data-shared="tooltipPopup"]', `VM state reset successfully.`)
       // check that there are no instances
       .assert.textContains('*[data-id="deployedContractsBadge"]', '0')
       // check if state file is deleted
diff --git a/apps/remix-ide/src/app/tabs/locales/en/udapp.json b/apps/remix-ide/src/app/tabs/locales/en/udapp.json
index 0cd598bb0f..c4a376cd20 100644
--- a/apps/remix-ide/src/app/tabs/locales/en/udapp.json
+++ b/apps/remix-ide/src/app/tabs/locales/en/udapp.json
@@ -54,10 +54,11 @@
   "udapp.forkVmStateDesc1":"Forking state will create a new environment with same state as selected environment",
   "udapp.forkVmStateDesc2":"After forking, new environment will be pinned and selected automatically. It can be unpinned or deleted using Envionment Explorer",
   "udapp.fork": "Fork",
-  "udapp.deleteVmStateTitle": "Delete VM state",
-  "udapp.deleteVmStateDesc1": "Deleting the state of this VM will delete the associated transaction details in this Workspace.",
-  "udapp.deleteVmStateDesc2": "It will also delete the data of contracts deployed and pinned in this Workspace.",
-  "udapp.deleteVmStateDesc3": "Do you want to continue?",
+  "udapp.resetVmStateTitle": "Reset VM state",
+  "udapp.resetVmStateDesc1": "Resetting the state of this VM will delete the associated transaction details in this Workspace.",
+  "udapp.resetVmStateDesc2": "It will also delete the data of contracts deployed and pinned in this Workspace.",
+  "udapp.resetVmStateDesc3": "Do you want to continue?",
+  "udapp.reset": "Reset",
   "udapp.delete": "Delete",
   "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",
diff --git a/libs/remix-ui/run-tab/src/lib/components/environment.tsx b/libs/remix-ui/run-tab/src/lib/components/environment.tsx
index e5f3653925..272860c0fd 100644
--- a/libs/remix-ui/run-tab/src/lib/components/environment.tsx
+++ b/libs/remix-ui/run-tab/src/lib/components/environment.tsx
@@ -53,10 +53,10 @@ export function EnvironmentUI(props: EnvironmentProps) {
     return (
       <div data-id="deleteVmStateModal">
         <ul className='ml-3'>
-          <li><FormattedMessage id="udapp.deleteVmStateDesc1"/></li>
-          <li><FormattedMessage id="udapp.deleteVmStateDesc2"/></li>
+          <li><FormattedMessage id="udapp.resetVmStateDesc1"/></li>
+          <li><FormattedMessage id="udapp.resetVmStateDesc2"/></li>
         </ul>
-        <FormattedMessage id="udapp.deleteVmStateDesc3"/>
+        <FormattedMessage id="udapp.resetVmStateDesc3"/>
       </div>
     )
   }
@@ -87,15 +87,15 @@ export function EnvironmentUI(props: EnvironmentProps) {
     } else props.runTabPlugin.call('notification', 'toast', `State not available to fork, as no transactions have been made for selected environment & selected workspace.`)
   }
 
-  const deleteVmState = async() => {
+  const resetVmState = async() => {
     _paq.push(['trackEvent', 'udapp', 'deleteState', `deleteState clicked`])
     const context = currentProvider.name
     const contextExists = await props.runTabPlugin.call('fileManager', 'exists', `.states/${context}/state.json`)
     if (contextExists) {
       props.modal(
-        intl.formatMessage({ id: 'udapp.deleteVmStateTitle' }),
+        intl.formatMessage({ id: 'udapp.resetVmStateTitle' }),
         deleteVmStatePrompt(),
-        intl.formatMessage({ id: 'udapp.delete' }),
+        intl.formatMessage({ id: 'udapp.reset' }),
         async () => {
           const currentProvider = await props.runTabPlugin.call('blockchain', 'getCurrentProvider')
           // Reset environment blocks and account data
@@ -107,25 +107,28 @@ export function EnvironmentUI(props: EnvironmentProps) {
           // If there are pinned contracts, delete pinned contracts folder
           const isPinnedContracts = await props.runTabPlugin.call('fileManager', 'exists', `.deploys/pinned-contracts/${context}`)
           if (isPinnedContracts) await props.runTabPlugin.call('fileManager', 'remove', `.deploys/pinned-contracts/${context}`)
-          props.runTabPlugin.call('notification', 'toast', `VM state deleted successfully.`)
-          _paq.push(['trackEvent', 'udapp', 'deleteState', `VM state deleted`])
+          props.runTabPlugin.call('notification', 'toast', `VM state reset successfully.`)
+          _paq.push(['trackEvent', 'udapp', 'deleteState', `VM state reset`])
         },
         intl.formatMessage({ id: 'udapp.cancel' }),
         null
       )
-    } else props.runTabPlugin.call('notification', 'toast', `State not available to delete, as no transactions have been made for selected environment & selected workspace.`)
+    } else props.runTabPlugin.call('notification', 'toast', `State not available to reset, as no transactions have been made for selected environment & selected workspace.`)
   }
 
   const isL2 = (providerDisplayName: string) => providerDisplayName && (providerDisplayName.startsWith('L2 - Optimism') || providerDisplayName.startsWith('L2 - Arbitrum'))
   return (
     <div className="udapp_crow">
-      <label id="selectExEnv" className="udapp_settingsLabel">
+      <label id="selectExEnv" className="udapp_settingsLabel w-100">
         <FormattedMessage id="udapp.environment" />
         { currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="forkStatetooltip" tooltipText={<FormattedMessage id="udapp.forkStateTitle" />}>
           <i className="udapp_infoDeployAction ml-2 fas fa-code-branch" style={{ cursor: 'pointer' }} onClick={forkState} data-id="fork-state-icon"></i>
         </CustomTooltip> }
-        { currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="deleteVMStatetooltip" tooltipText={<FormattedMessage id="udapp.deleteVmStateTitle" />}>
-          <i className="udapp_infoDeployAction ml-2 fas fa-trash" style={{ cursor: 'pointer' }} onClick={deleteVmState} data-id="delete-state-icon"></i>
+        { currentProvider && currentProvider.isVM && isSaveEvmStateChecked && <CustomTooltip placement={'auto-end'} tooltipClasses="text-wrap" tooltipId="deleteVMStatetooltip" tooltipText={<FormattedMessage id="udapp.resetVmStateTitle" />}>
+          <span onClick={resetVmState} style={{ cursor: 'pointer', float: 'right', textTransform: 'none' }}>
+            <i className="udapp_infoDeployAction ml-2 fas fa-refresh"  data-id="delete-state-icon"></i>
+            <span className="ml-1" style = {{textTransform: 'none', fontSize: '13px' }}>Reset State</span>
+          </span>
         </CustomTooltip> }
       </label>
       <div className="udapp_environment" data-id={`selected-provider-${currentProvider && currentProvider.name}`}>