mirror of
https://github.com/apache/superset.git
synced 2026-04-19 08:04:53 +00:00
refactor: serialize extra json in state (#21523)
This commit is contained in:
committed by
GitHub
parent
df3b5a8305
commit
196c3671e2
@@ -29,7 +29,7 @@ import {
|
||||
antdCollapseStyles,
|
||||
no_margin_bottom,
|
||||
} from './styles';
|
||||
import { DatabaseObject } from '../types';
|
||||
import { DatabaseObject, ExtraJson } from '../types';
|
||||
|
||||
const ExtraOptions = ({
|
||||
db,
|
||||
@@ -50,6 +50,7 @@ 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 || '{}');
|
||||
|
||||
return (
|
||||
<Collapse
|
||||
@@ -155,7 +156,7 @@ const ExtraOptions = ({
|
||||
<IndeterminateCheckbox
|
||||
id="cost_estimate_enabled"
|
||||
indeterminate={false}
|
||||
checked={!!db?.extra_json?.cost_estimate_enabled}
|
||||
checked={!!extraJson?.cost_estimate_enabled}
|
||||
onChange={onExtraInputChange}
|
||||
labelText={t('Enable query cost estimation')}
|
||||
/>
|
||||
@@ -171,7 +172,7 @@ const ExtraOptions = ({
|
||||
<IndeterminateCheckbox
|
||||
id="allows_virtual_table_explore"
|
||||
indeterminate={false}
|
||||
checked={!!db?.extra_json?.allows_virtual_table_explore}
|
||||
checked={!!extraJson?.allows_virtual_table_explore}
|
||||
onChange={onExtraInputChange}
|
||||
labelText={t('Allow this database to be explored')}
|
||||
/>
|
||||
@@ -187,7 +188,7 @@ const ExtraOptions = ({
|
||||
<IndeterminateCheckbox
|
||||
id="disable_data_preview"
|
||||
indeterminate={false}
|
||||
checked={!!db?.extra_json?.disable_data_preview}
|
||||
checked={!!extraJson?.disable_data_preview}
|
||||
onChange={onExtraInputChange}
|
||||
labelText={t('Disable SQL Lab data preview queries')}
|
||||
/>
|
||||
@@ -240,8 +241,7 @@ const ExtraOptions = ({
|
||||
type="number"
|
||||
name="schema_cache_timeout"
|
||||
value={
|
||||
db?.extra_json?.metadata_cache_timeout?.schema_cache_timeout ||
|
||||
''
|
||||
extraJson?.metadata_cache_timeout?.schema_cache_timeout || ''
|
||||
}
|
||||
placeholder={t('Enter duration in seconds')}
|
||||
onChange={onExtraInputChange}
|
||||
@@ -262,8 +262,7 @@ const ExtraOptions = ({
|
||||
type="number"
|
||||
name="table_cache_timeout"
|
||||
value={
|
||||
db?.extra_json?.metadata_cache_timeout?.table_cache_timeout ||
|
||||
''
|
||||
extraJson?.metadata_cache_timeout?.table_cache_timeout || ''
|
||||
}
|
||||
placeholder={t('Enter duration in seconds')}
|
||||
onChange={onExtraInputChange}
|
||||
@@ -301,7 +300,7 @@ const ExtraOptions = ({
|
||||
<IndeterminateCheckbox
|
||||
id="cancel_query_on_windows_unload"
|
||||
indeterminate={false}
|
||||
checked={!!db?.extra_json?.cancel_query_on_windows_unload}
|
||||
checked={!!extraJson?.cancel_query_on_windows_unload}
|
||||
onChange={onExtraInputChange}
|
||||
labelText={t('Cancel query on window unload event')}
|
||||
/>
|
||||
@@ -414,9 +413,9 @@ const ExtraOptions = ({
|
||||
<input
|
||||
type="text"
|
||||
name="schemas_allowed_for_file_upload"
|
||||
value={(
|
||||
db?.extra_json?.schemas_allowed_for_file_upload || []
|
||||
).join(',')}
|
||||
value={(extraJson?.schemas_allowed_for_file_upload || []).join(
|
||||
',',
|
||||
)}
|
||||
placeholder="schema1,schema2"
|
||||
onChange={onExtraInputChange}
|
||||
/>
|
||||
@@ -443,7 +442,11 @@ const ExtraOptions = ({
|
||||
<div className="input-container">
|
||||
<StyledJsonEditor
|
||||
name="metadata_params"
|
||||
value={db?.extra_json?.metadata_params || ''}
|
||||
value={
|
||||
!Object.keys(extraJson?.metadata_params || {}).length
|
||||
? ''
|
||||
: extraJson?.metadata_params
|
||||
}
|
||||
placeholder={t('Metadata Parameters')}
|
||||
onChange={(json: string) =>
|
||||
onExtraEditorChange({ json, name: 'metadata_params' })
|
||||
@@ -465,7 +468,11 @@ const ExtraOptions = ({
|
||||
<div className="input-container">
|
||||
<StyledJsonEditor
|
||||
name="engine_params"
|
||||
value={db?.extra_json?.engine_params || ''}
|
||||
value={
|
||||
!Object.keys(extraJson?.engine_params || {}).length
|
||||
? ''
|
||||
: JSON.stringify(extraJson?.engine_params)
|
||||
}
|
||||
placeholder={t('Engine Parameters')}
|
||||
onChange={(json: string) =>
|
||||
onExtraEditorChange({ json, name: 'engine_params' })
|
||||
@@ -490,7 +497,7 @@ const ExtraOptions = ({
|
||||
<input
|
||||
type="number"
|
||||
name="version"
|
||||
value={db?.extra_json?.version || ''}
|
||||
value={extraJson?.version || ''}
|
||||
placeholder={t('Version number')}
|
||||
onChange={onExtraInputChange}
|
||||
/>
|
||||
|
||||
Reference in New Issue
Block a user