fix save unsave

pull/4538/head
aniket-engg 8 months ago committed by Aniket
parent 146bfa6cc6
commit 51c1076bf2
  1. 4
      apps/remix-ide/src/app/tabs/locales/en/udapp.json
  2. 2
      libs/remix-ui/run-tab/src/lib/components/instanceContainerUI.tsx
  3. 13
      libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx

@ -72,7 +72,7 @@
"udapp.savedContracts": "Saved Contracts",
"udapp.NoSavedInstanceText": "Currently you have no saved contracts to interact with.",
"udapp.tooltipTextUnsave": "Delete from saved list",
"udapp.tooltipTextUnsave": "Unsave & move to Deployed Contracts list",
"udapp.savedOn": "Saved On",
"udapp.filePath": "File Path",
@ -105,7 +105,7 @@
"udapp._comment_universalDappUI.tsx": "libs/remix-ui/run-tab/src/lib/components/universalDappUI.tsx",
"udapp.tooltipText7": "Remove from the list",
"udapp.tooltipText14": "Save contract",
"udapp.tooltipText14": "Save & move to Saved Contracts list",
"udapp.tooltipText8": "Click for docs about using 'receive'/'fallback'",
"udapp.tooltipText9": "The Calldata to send to fallback function of the contract.",
"udapp.tooltipText10": "Send data to contract.",

@ -21,7 +21,7 @@ export function InstanceContainerUI(props: InstanceContainerProps) {
if (savedContracts && savedContracts[network.id]) {
const instances = savedContracts[network.id]
for (const inst of instances)
if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.contractData.abi, inst.name, inst.savedOn, inst.filePath)
if (inst) await props.plugin.call('udapp', 'addSavedInstance', inst.address, inst.abi || inst.contractData.abi, inst.name, inst.savedOn, inst.filePath)
}
}
}

@ -147,11 +147,11 @@ export function UniversalDappUI(props: UdappProps) {
}
}
props.instance.savedOn = Date.now()
props.instance.filePath = `${workspace.name}/${props.instance.contractData.contract.file}`
props.instance.filePath = props.instance.filePath || `${workspace.name}/${props.instance.contractData.contract.file}`
objToSave[network.id].push(props.instance)
localStorage.setItem('savedContracts', JSON.stringify(objToSave))
// Add contract to saved contracts list on UI
await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.contractData.abi, props.instance.name, props.instance.savedOn, props.instance.filePath)
await props.plugin.call('udapp', 'addSavedInstance', props.instance.address, props.instance.abi || props.instance.contractData.abi, props.instance.name, props.instance.savedOn, props.instance.filePath)
// Remove contract from deployed contracts list on UI
props.removeInstance(props.index, false)
}
@ -278,14 +278,9 @@ export function UniversalDappUI(props: UdappProps) {
</CustomTooltip>
</div> ) : null }
</div>
{ !props.isSavedContract ?
( <CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappCloseTooltip" tooltipText={<FormattedMessage id="udapp.tooltipText7" />}>
<CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappCloseTooltip" tooltipText={ !props.isSavedContract ? (<FormattedMessage id="udapp.tooltipText7" />) : (<FormattedMessage id="udapp.tooltipTextUnsave" />)}>
<i className="udapp_closeIcon m-1 fas fa-times align-self-center" aria-hidden="true" data-id="universalDappUiUdappClose" onClick={remove}></i>
</CustomTooltip> ) :
( <CustomTooltip placement="top" tooltipClasses="text-nowrap" tooltipId="udapp_udappUnsaveTooltip" tooltipText={<FormattedMessage id="udapp.tooltipTextUnsave" />}>
<i className="udapp_closeIcon m-1 far fa-trash-alt align-self-center" aria-hidden="true" data-id="universalDappUiUdappUnsave" onClick={remove}></i>
</CustomTooltip> )}
</CustomTooltip>
</div>
<div className="udapp_cActionsWrapper" data-id="universalDappUiContractActionWrapper">
<div className="udapp_contractActionsContainer">

Loading…
Cancel
Save