Skip to content

Commit

Permalink
fix: DB Connection UI R2 Fixes (#15232)
Browse files Browse the repository at this point in the history
* fix display name refill

* fix order of additional params to always be at the bottom

* remove schema check on validation

* make encryption last

* fix json file upload

* fix additional params issue

* remove comments

* add back validation
  • Loading branch information
hughhhh authored Jun 17, 2021
1 parent 7505601 commit 7270d26
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 12 deletions.
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 @@ -358,8 +358,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

0 comments on commit 7270d26

Please sign in to comment.