mirror of
https://github.com/apache/superset.git
synced 2026-04-13 21:24:28 +00:00
fix: make database connection modal ace fields uncontrolled (#22350)
This commit is contained in:
committed by
GitHub
parent
c3a6327ff0
commit
608ffcbfb9
@@ -50,7 +50,16 @@ const ExtraOptions = ({
|
||||
const createAsOpen = !!(db?.allow_ctas || db?.allow_cvas);
|
||||
const isFileUploadSupportedByEngine =
|
||||
db?.engine_information?.supports_file_upload;
|
||||
const extraJson: ExtraJson = JSON.parse(db?.extra || '{}');
|
||||
|
||||
// JSON.parse will deep parse engine_params
|
||||
// if it's an object, and we want to keep it a string
|
||||
const extraJson: ExtraJson = JSON.parse(db?.extra || '{}', (key, value) => {
|
||||
if (key === 'engine_params' && typeof value === 'object') {
|
||||
// keep this as a string
|
||||
return JSON.stringify(value);
|
||||
}
|
||||
return value;
|
||||
});
|
||||
|
||||
return (
|
||||
<Collapse
|
||||
@@ -123,9 +132,9 @@ const ExtraOptions = ({
|
||||
<input
|
||||
type="text"
|
||||
name="force_ctas_schema"
|
||||
value={db?.force_ctas_schema || ''}
|
||||
placeholder={t('Create or select schema...')}
|
||||
onChange={onInputChange}
|
||||
value={db?.force_ctas_schema || ''}
|
||||
/>
|
||||
</div>
|
||||
<div className="helper">
|
||||
@@ -442,17 +451,17 @@ const ExtraOptions = ({
|
||||
<div className="input-container">
|
||||
<StyledJsonEditor
|
||||
name="metadata_params"
|
||||
value={
|
||||
!Object.keys(extraJson?.metadata_params || {}).length
|
||||
? ''
|
||||
: extraJson?.metadata_params
|
||||
}
|
||||
placeholder={t('Metadata Parameters')}
|
||||
onChange={(json: string) =>
|
||||
onExtraEditorChange({ json, name: 'metadata_params' })
|
||||
}
|
||||
width="100%"
|
||||
height="160px"
|
||||
defaultValue={
|
||||
!Object.keys(extraJson?.metadata_params || {}).length
|
||||
? ''
|
||||
: extraJson?.metadata_params
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="helper">
|
||||
@@ -468,17 +477,17 @@ const ExtraOptions = ({
|
||||
<div className="input-container">
|
||||
<StyledJsonEditor
|
||||
name="engine_params"
|
||||
value={
|
||||
!Object.keys(extraJson?.engine_params || {}).length
|
||||
? ''
|
||||
: extraJson?.engine_params
|
||||
}
|
||||
placeholder={t('Engine Parameters')}
|
||||
onChange={(json: string) =>
|
||||
onExtraEditorChange({ json, name: 'engine_params' })
|
||||
}
|
||||
width="100%"
|
||||
height="160px"
|
||||
defaultValue={
|
||||
!Object.keys(extraJson?.engine_params || {}).length
|
||||
? ''
|
||||
: extraJson?.engine_params
|
||||
}
|
||||
/>
|
||||
</div>
|
||||
<div className="helper">
|
||||
@@ -497,9 +506,9 @@ const ExtraOptions = ({
|
||||
<input
|
||||
type="number"
|
||||
name="version"
|
||||
value={extraJson?.version || ''}
|
||||
placeholder={t('Version number')}
|
||||
onChange={onExtraInputChange}
|
||||
value={extraJson?.version || ''}
|
||||
/>
|
||||
</div>
|
||||
<div className="helper">
|
||||
|
||||
Reference in New Issue
Block a user