pull/3374/head
filip mertens 2 years ago
parent c593b33259
commit 01fd9a4b13
  1. 2
      apps/remix-ide/src/remixEngine.js
  2. 48
      libs/remix-ui/app/src/lib/remix-app/components/modals/modal-wrapper.tsx
  3. 1
      libs/remix-ui/app/src/lib/remix-app/types/index.ts
  4. 2
      libs/remix-ui/modal-dialog/src/lib/types/index.ts
  5. 2
      tsconfig.base.json
  6. 3
      tsconfig.json

@ -15,7 +15,7 @@ export class RemixEngine extends Engine {
if (name === 'hardhat') return { queueTimeout: 60000 * 4 } if (name === 'hardhat') return { queueTimeout: 60000 * 4 }
if (name === 'truffle') return { queueTimeout: 60000 * 4 } if (name === 'truffle') return { queueTimeout: 60000 * 4 }
if (name === 'localPlugin') return { queueTimeout: 60000 * 4 } if (name === 'localPlugin') return { queueTimeout: 60000 * 4 }
if (name === 'notification') return { queueTimeout: 60000 * 4 } if (name === 'notification') return { queueTimeout: 60000 * 10 }
if (name === 'sourcify') return { queueTimeout: 60000 * 4 } if (name === 'sourcify') return { queueTimeout: 60000 * 4 }
if (name === 'fetchAndCompile') return { queueTimeout: 60000 * 4 } if (name === 'fetchAndCompile') return { queueTimeout: 60000 * 4 }
if (name === 'walletconnect') return { queueTimeout: 60000 * 4 } if (name === 'walletconnect') return { queueTimeout: 60000 * 4 }

@ -10,12 +10,26 @@ interface ModalWrapperProps extends ModalDialogProps {
const ModalWrapper = (props: ModalWrapperProps) => { const ModalWrapper = (props: ModalWrapperProps) => {
const [state, setState] = useState<ModalDialogProps>() const [state, setState] = useState<ModalDialogProps>()
const ref = useRef() const ref = useRef()
const formRef = useRef()
const data = useRef() const data = useRef()
const getFormData = () => {
if (formRef.current) {
const formData = new FormData(formRef.current)
const data = {}
for (const pair of formData.entries()) {
data[pair[0]] = pair[1]
}
return data
}
}
const onFinishPrompt = async () => { const onFinishPrompt = async () => {
if (ref.current === undefined) { if (ref.current === undefined && formRef.current === undefined) {
onOkFn() onOkFn()
} else { } else if (formRef.current) {
(props.okFn) ? props.okFn(getFormData()) : props.resolve(getFormData())
} else if(ref.current) {
// @ts-ignore: Object is possibly 'null'. // @ts-ignore: Object is possibly 'null'.
(props.okFn) ? props.okFn(ref.current.value) : props.resolve(ref.current.value) (props.okFn) ? props.okFn(ref.current.value) : props.resolve(ref.current.value)
} }
@ -43,7 +57,27 @@ const ModalWrapper = (props: ModalWrapperProps) => {
<> <>
{props.message} {props.message}
<input onChange={onInputChanged} type={props.modalType === ModalTypes.password ? 'password' : 'text'} defaultValue={defaultValue} data-id="modalDialogCustomPromp" ref={ref} className="form-control" /> <input onChange={onInputChanged} type={props.modalType === ModalTypes.password ? 'password' : 'text'} defaultValue={defaultValue} data-id="modalDialogCustomPromp" ref={ref} className="form-control" />
{!validation.valid && <span className='text-warning'>{validation.message}</span>} {validation && !validation.valid && <span className='text-warning'>{validation.message}</span>}
</>
)
}
const onFormChanged = () => {
if (props.validationFn) {
const validation = props.validationFn(getFormData())
setState(prevState => {
return { ...prevState, message: createForm(validation), validation }
})
}
}
const createForm = (validation: ValidationResult) => {
return (
<>
<form onChange={onFormChanged} ref={formRef}>
{props.message}
</form>
{validation && !validation.valid && <span className='text-warning'>{validation.message}</span>}
</> </>
) )
} }
@ -61,6 +95,14 @@ const ModalWrapper = (props: ModalWrapperProps) => {
message: createModalMessage(props.defaultValue, { valid: true }) message: createModalMessage(props.defaultValue, { valid: true })
}) })
break break
case ModalTypes.form:
setState({
...props,
okFn: onFinishPrompt,
cancelFn: onCancelFn,
message: createForm({ valid: true })
})
break
default: default:
setState({ setState({
...props, ...props,

@ -4,4 +4,5 @@ export const enum ModalTypes {
prompt = 'prompt', prompt = 'prompt',
password = 'password', password = 'password',
default = 'default', default = 'default',
form = 'form',
} }

@ -9,7 +9,7 @@ export interface ModalDialogProps {
timestamp?: number, timestamp?: number,
title?: string | JSX.Element, title?: string | JSX.Element,
validation?: ValidationResult validation?: ValidationResult
validationFn?: (value: string) => ValidationResult validationFn?: (value: any) => ValidationResult
message?: string | JSX.Element, message?: string | JSX.Element,
okLabel?: string | JSX.Element, okLabel?: string | JSX.Element,
okFn?: (value?:any) => void, okFn?: (value?:any) => void,

@ -19,7 +19,7 @@
"target": "ES2015", "target": "ES2015",
"module": "ES2020", "module": "ES2020",
"typeRoots": ["node_modules/@types", "libs/**/*.d.ts"], "typeRoots": ["node_modules/@types", "libs/**/*.d.ts"],
"lib": ["es2017", "es2019", "dom"], "lib": ["es2017", "es2019", "dom", "dom.iterable"],
"skipLibCheck": true, "skipLibCheck": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true,
"baseUrl": "." "baseUrl": "."

@ -15,7 +15,8 @@
"module": "CommonJS", "module": "CommonJS",
"lib": [ "lib": [
"es2017", "es2017",
"dom" "dom",
"dom.iterable"
], ],
"skipLibCheck": true, "skipLibCheck": true,
"skipDefaultLibCheck": true, "skipDefaultLibCheck": true,

Loading…
Cancel
Save