run button disable for non json files

pull/5370/head
Aniket-Engg 2 years ago committed by Aniket
parent c1b600f474
commit ac1bec5592
  1. 10
      libs/remix-ui/run-tab/src/lib/components/recorderCardUI.tsx
  2. 6
      libs/remix-ui/run-tab/src/lib/run-tab.tsx
  3. 1
      libs/remix-ui/run-tab/src/lib/types/index.ts

@ -1,11 +1,12 @@
// eslint-disable-next-line no-use-before-define
import React, {useRef, useState} from 'react'
import React, {useRef, useState, useEffect} from 'react'
import { RecorderProps } from '../types'
import { OverlayTrigger, Tooltip } from 'react-bootstrap' // eslint-disable-line
export function RecorderUI (props: RecorderProps) {
const inputLive = useRef<HTMLInputElement>()
const [toggleExpander, setToggleExpander] = useState<boolean>(false)
const [enableRunButton, setEnableRunButton] = useState<boolean>(true)
const triggerRecordButton = () => {
props.storeScenario(props.scenarioPrompt)
}
@ -15,6 +16,11 @@ export function RecorderUI (props: RecorderProps) {
props.runCurrentScenario(liveMode, props.gasEstimationPrompt, props.passphrasePrompt, props.mainnetPrompt)
}
useEffect(() => {
if (props.currentFile.endsWith('.json')) setEnableRunButton(false)
else setEnableRunButton(true)
}, [props.currentFile])
const toggleClass = () => {
setToggleExpander(!toggleExpander)
}
@ -60,7 +66,7 @@ export function RecorderUI (props: RecorderProps) {
</span>
</Tooltip>
}>
<button className="btn btn-sm btn-info runtransaction udapp_runTxs" data-id="runtransaction" onClick={handleClickRunButton}>Run</button>
<button className="btn btn-sm btn-info runtransaction udapp_runTxs" data-id="runtransaction" disabled={enableRunButton} onClick={handleClickRunButton}>Run</button>
</OverlayTrigger>
</div>
</div>

@ -56,10 +56,11 @@ export function RunTabUI (props: RunTabProps) {
storage: null,
contract: null
})
runTabInitialState.selectExEnv = props.plugin.blockchain.getProvider()
runTabInitialState.selectExEnv = plugin.blockchain.getProvider()
runTabInitialState.selectExEnv = runTabInitialState.selectExEnv === 'vm' ? 'vm-london' : runTabInitialState.selectExEnv
const [runTab, dispatch] = useReducer(runTabReducer, runTabInitialState)
const REACT_API = { runTab }
const currentfile = plugin.config.get('currentFile')
useEffect(() => {
initRunTab(plugin)(dispatch)
@ -249,6 +250,7 @@ export function RunTabUI (props: RunTabProps) {
runCurrentScenario={runScenario}
scenarioPrompt={scenarioPrompt}
count={runTab.recorder.transactionCount}
currentFile={currentfile}
/>
<InstanceContainerUI
instances={runTab.instances}
@ -266,7 +268,7 @@ export function RunTabUI (props: RunTabProps) {
</div>
<ModalDialog id='udappNotify' { ...focusModal } handleHide={ handleHideModal } />
<Toaster message={focusToaster} handleHide={handleToaster} />
<PublishToStorage id='udapp' api={props.plugin} resetStorage={resetStorage} storage={publishData.storage} contract={publishData.contract} />
<PublishToStorage id='udapp' api={plugin} resetStorage={resetStorage} storage={publishData.storage} contract={publishData.contract} />
</Fragment>
)
}

@ -173,6 +173,7 @@ export interface RecorderProps {
passphrasePrompt: (msg: string) => JSX.Element,
scenarioPrompt: (msg: string, defaultValue: string) => JSX.Element,
count: number
currentFile: string
}
export interface InstanceContainerProps {

Loading…
Cancel
Save