update variables option
This commit is contained in:
parent
f0cdf48d54
commit
3126442e67
|
|
@ -55,25 +55,31 @@ const AddEditVariableDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
|
||||||
const [variableValue, setVariableValue] = useState('')
|
const [variableValue, setVariableValue] = useState('')
|
||||||
const [variableType, setVariableType] = useState('static')
|
const [variableType, setVariableType] = useState('static')
|
||||||
const [dialogType, setDialogType] = useState('ADD')
|
const [dialogType, setDialogType] = useState('ADD')
|
||||||
|
|
||||||
const [variable, setVariable] = useState({})
|
const [variable, setVariable] = useState({})
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (dialogProps.type === 'EDIT') {
|
if (dialogProps.type === 'EDIT' && dialogProps.data) {
|
||||||
// When variable dialog is opened from Variables dashboard
|
|
||||||
setVariableName(dialogProps.data.name)
|
setVariableName(dialogProps.data.name)
|
||||||
setVariableValue(dialogProps.data.value)
|
setVariableValue(dialogProps.data.value)
|
||||||
setVariableType(dialogProps.data.type)
|
setVariableType(dialogProps.data.type)
|
||||||
setVariable(dialogProps.data)
|
|
||||||
setDialogType('EDIT')
|
setDialogType('EDIT')
|
||||||
|
setVariable(dialogProps.data)
|
||||||
} else if (dialogProps.type === 'ADD') {
|
} else if (dialogProps.type === 'ADD') {
|
||||||
// When variable dialog is to add a new variable
|
|
||||||
setVariableName('')
|
setVariableName('')
|
||||||
setVariableValue('')
|
setVariableValue('')
|
||||||
setVariableType('static')
|
setVariableType('static')
|
||||||
setDialogType('ADD')
|
setDialogType('ADD')
|
||||||
|
setVariable({})
|
||||||
}
|
}
|
||||||
}, [dialogProps.data, dialogProps.type])
|
|
||||||
|
return () => {
|
||||||
|
setVariableName('')
|
||||||
|
setVariableValue('')
|
||||||
|
setVariableType('static')
|
||||||
|
setDialogType('ADD')
|
||||||
|
setVariable({})
|
||||||
|
}
|
||||||
|
}, [dialogProps])
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (show) dispatch({ type: SHOW_CANVAS_DIALOG })
|
if (show) dispatch({ type: SHOW_CANVAS_DIALOG })
|
||||||
|
|
@ -226,10 +232,11 @@ const AddEditVariableDialog = ({ show, dialogProps, onCancel, onConfirm }) => {
|
||||||
<div style={{ flexGrow: 1 }}></div>
|
<div style={{ flexGrow: 1 }}></div>
|
||||||
</div>
|
</div>
|
||||||
<Dropdown
|
<Dropdown
|
||||||
|
key={variableType}
|
||||||
name='variableType'
|
name='variableType'
|
||||||
options={variableTypes}
|
options={variableTypes}
|
||||||
onSelect={(newValue) => setVariableType(newValue)}
|
onSelect={(newValue) => setVariableType(newValue)}
|
||||||
value={variableType}
|
value={variableType ?? 'choose an option'}
|
||||||
/>
|
/>
|
||||||
</Box>
|
</Box>
|
||||||
{variableType === 'static' && (
|
{variableType === 'static' && (
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue