Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: DB Connection UI R2 Fixes #15232

Merged
merged 8 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,13 +44,11 @@ export const FormFieldOrder = [
'username',
'password',
'database_name',
'credentials_info',
'query',
'encryption',
'credentials_info',
];

const selectedFile = document.getElementById('selectedFile');

interface FieldPropTypes {
required: boolean;
onParametersChange: (value: any) => string;
Expand All @@ -68,7 +66,7 @@ interface FieldPropTypes {

const CredentialsInfo = ({ changeMethods, isEditMode, db }: FieldPropTypes) => {
const [uploadOption, setUploadOption] = useState<number>(
CredentialInfoOptions.copyPaste.valueOf(),
CredentialInfoOptions.jsonUpload.valueOf(),
);
const [fileToUpload, setFileToUpload] = useState<string | null | undefined>(
null,
Expand Down Expand Up @@ -153,7 +151,9 @@ const CredentialsInfo = ({ changeMethods, isEditMode, db }: FieldPropTypes) => {
checked: false,
},
});
(selectedFile as HTMLInputElement).value = null as any;
(document.getElementById(
'selectedFile',
) as HTMLInputElement).value = null as any;
}}
/>
</div>
Expand Down Expand Up @@ -269,13 +269,12 @@ const displayField = ({
getValidation,
validationErrors,
db,
defaultDBName,
}: FieldPropTypes) => (
<ValidatedInput
id="database_name"
name="database_name"
required={required}
value={db?.database_name || defaultDBName}
value={db?.database_name}
validationMethods={{ onBlur: getValidation }}
errorMessage={validationErrors?.database_name}
placeholder=""
Expand Down Expand Up @@ -348,7 +347,7 @@ const FORM_FIELD_MAP = {
};

const DatabaseConnectionForm = ({
dbModel: { name: defaultDBName, parameters },
dbModel: { parameters },
onParametersChange,
onChange,
onParametersUploadFileChange,
Expand Down Expand Up @@ -395,7 +394,6 @@ const DatabaseConnectionForm = ({
onChange,
onParametersUploadFileChange,
},
defaultDBName,
validationErrors,
getValidation,
db,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -356,8 +356,6 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
.replace(/&/g, '","')
.replace(/=/g, '":"')}"}`,
);
} else if (update.parameters) {
update.parameters.query = {};
}

if (db?.id) {
Expand Down
2 changes: 1 addition & 1 deletion superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,7 +353,7 @@ def validate_parameters( # pylint: disable=no-self-use
"""
Validate the DB engine spec specific parameters schema.
"""
# TODO (aafghahi): use a single parameter
# TODO (aafghahi): Move this onCreate instead of validation
engine_spec = get_engine_spec(data.get("engine") or data.get("backend"))
engine_spec.parameters_schema.load(data["parameters"]) # type: ignore

Expand Down