array[any] readonly

pull/21369/head
JzoNg 11 months ago
parent 0f73f6b20c
commit 44f51994c1

@ -7,6 +7,7 @@ type SchemaEditorProps = {
onUpdate: (schema: string) => void onUpdate: (schema: string) => void
hideTopMenu?: boolean hideTopMenu?: boolean
className?: string className?: string
readonly?: boolean
} }
const SchemaEditor: FC<SchemaEditorProps> = ({ const SchemaEditor: FC<SchemaEditorProps> = ({
@ -14,9 +15,11 @@ const SchemaEditor: FC<SchemaEditorProps> = ({
onUpdate, onUpdate,
hideTopMenu, hideTopMenu,
className, className,
readonly = false,
}) => { }) => {
return ( return (
<CodeEditor <CodeEditor
readOnly={readonly}
className={cn('rounded-xl', className)} className={cn('rounded-xl', className)}
editorWrapperClassName='grow' editorWrapperClassName='grow'
value={schema} value={schema}

@ -261,6 +261,7 @@ export enum VarType {
arrayObject = 'array[object]', arrayObject = 'array[object]',
arrayFile = 'array[file]', arrayFile = 'array[file]',
any = 'any', any = 'any',
arrayAny = 'array[any]',
} }
export enum ValueType { export enum ValueType {

@ -36,9 +36,10 @@ const ValueContent = ({
const [editorHeight, setEditorHeight] = useState(0) const [editorHeight, setEditorHeight] = useState(0)
const showTextEditor = currentVar.value_type === 'secret' || currentVar.value_type === 'string' || currentVar.value_type === 'number' const showTextEditor = currentVar.value_type === 'secret' || currentVar.value_type === 'string' || currentVar.value_type === 'number'
const isSysFiles = currentVar.type === VarInInspectType.system && currentVar.name === 'files' 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 showJSONEditor = !isSysFiles && (currentVar.value_type === 'object' || currentVar.value_type === 'array[string]' || currentVar.value_type === 'array[number]' || currentVar.value_type === 'array[object]' || currentVar.value_type === 'array[any]')
const showFileEditor = isSysFiles || currentVar.value_type === 'file' || currentVar.value_type === 'array[file]' 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 textEditorDisabled = currentVar.type === VarInInspectType.environment || (currentVar.type === VarInInspectType.system && currentVar.name !== 'query' && currentVar.name !== 'files')
const JSONEditorDisabled = currentVar.value_type === 'array[any]'
const [value, setValue] = useState<any>() const [value, setValue] = useState<any>()
const [json, setJson] = useState('') const [json, setJson] = useState('')
@ -185,6 +186,7 @@ const ValueContent = ({
)} )}
{showJSONEditor && ( {showJSONEditor && (
<SchemaEditor <SchemaEditor
readonly={JSONEditorDisabled}
className='overflow-y-auto' className='overflow-y-auto'
hideTopMenu hideTopMenu
schema={json} schema={json}

Loading…
Cancel
Save