chore: add sys files detect

pull/21369/head
Joel 12 months ago
parent 9bad1d6630
commit f218b23fb7

@ -35,9 +35,10 @@ const ValueContent = ({
const errorMessageRef = useRef<HTMLDivElement>(null)
const [editorHeight, setEditorHeight] = useState(0)
const showTextEditor = currentVar.value_type === 'secret' || currentVar.value_type === 'string' || currentVar.value_type === 'number'
const showJSONEditor = currentVar.value_type === 'object' || currentVar.value_type === 'array[string]' || currentVar.value_type === 'array[number]' || currentVar.value_type === 'array[object]'
const showFileEditor = currentVar.value_type === 'file' || currentVar.value_type === 'array[file]'
const textEditorDisabled = currentVar.type === VarInInspectType.environment || (currentVar.type === VarInInspectType.system && currentVar.name !== 'query')
const isSysFiles = currentVar.type === VarInInspectType.system && currentVar.name === 'files'
const showJSONEditor = !isSysFiles && (currentVar.value_type === 'object' || currentVar.value_type === 'array[string]' || currentVar.value_type === 'array[number]' || currentVar.value_type === 'array[object]')
const showFileEditor = isSysFiles || currentVar.value_type === 'file' || currentVar.value_type === 'array[file]'
const textEditorDisabled = currentVar.type === VarInInspectType.environment || (currentVar.type === VarInInspectType.system && currentVar.name !== 'query' && currentVar.name !== 'files')
const [value, setValue] = useState<any>()
const [json, setJson] = useState('')
@ -67,12 +68,15 @@ const ValueContent = ({
setJson(currentVar.value ? JSON.stringify(currentVar.value, null, 2) : '')
if (showFileEditor) {
setFileValue(currentVar.value_type === 'array[file]'
setFileValue(
(currentVar.value_type === 'array[file]' || isSysFiles)
? currentVar.value || []
: currentVar.value
? [currentVar.value]
: [])
: [],
)
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentVar.id, currentVar.value])
const handleTextChange = (value: string) => {
@ -141,7 +145,7 @@ const ValueContent = ({
return
if (currentVar.value_type === 'file')
debounceValueChange(currentVar.id, value[0])
if (currentVar.value_type === 'array[file]')
if (currentVar.value_type === 'array[file]' || isSysFiles)
debounceValueChange(currentVar.id, value)
}

Loading…
Cancel
Save