Skip to content

Commit

Permalink
elizabeth revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
AAfghahi committed Jun 3, 2021
1 parent 9fac1eb commit 78d7edb
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@ import { SupersetTheme, JsonObject } from '@superset-ui/core';
import { InputProps } from 'antd/lib/input';
import ValidatedInput from 'src/components/Form/LabeledErrorBoundInput';
import {
StyledFormHeader,
formScrollableStyles,
validatedFormStyles,
StyledFormHeader,
} from './styles';
import { DatabaseForm, DatabaseObject } from '../types';

Expand Down Expand Up @@ -197,14 +197,12 @@ const DatabaseConnectionForm = ({
getValidation: () => void;
}) => (
<>
{!isEditMode && (
<StyledFormHeader>
<h4>Enter the required {name} credentials</h4>
<p className="helper">
Need help? Learn more about connecting to {name}.
</p>
</StyledFormHeader>
)}
<StyledFormHeader>
<h4>Enter the required {name} credentials</h4>
<p className="helper">
Need help? Learn more about connecting to {name}.
</p>
</StyledFormHeader>
<div
// @ts-ignore
css={(theme: SupersetTheme) => [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ function dbReducer(
const trimmedState = {
...(state || {}),
};

switch (action.type) {
case ActionType.inputChange:
if (action.payload.type === 'checkbox') {
Expand Down Expand Up @@ -162,13 +161,7 @@ function dbReducer(
[action.payload.name]: action.payload.value,
};
case ActionType.fetched:
return {
...action.payload,
};
case ActionType.dbSelected:
return {
...action.payload,
};
case ActionType.configMethodChange:
return {
...action.payload,
Expand Down Expand Up @@ -370,6 +363,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
<EditHeaderSubtitle>{dbName}</EditHeaderSubtitle>
</TabHeader>
) : (
// TODO: Fix headers when we get rid of tabs
<TabHeader>
<CreateHeaderTitle>Enter Primary Credentials</CreateHeaderTitle>
<CreateHeaderSubtitle>
Expand Down Expand Up @@ -430,27 +424,29 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({
validationErrors={validationErrors}
/>
)}
<Alert
css={(theme: SupersetTheme) => antDAlertStyles(theme)}
message="Additional fields may be required"
description={
<>
Select databases require additional fields to be completed in
the Advanced tab to successfully connect the database. Learn
what requirements your databases has{' '}
<a
href={DOCUMENTATION_LINK}
target="_blank"
rel="noopener noreferrer"
>
here
</a>
.
</>
}
type="info"
showIcon
/>
{!isEditMode && (
<Alert
css={(theme: SupersetTheme) => antDAlertStyles(theme)}
message="Additional fields may be required"
description={
<>
Select databases require additional fields to be completed in
the Advanced tab to successfully connect the database. Learn
what requirements your databases has{' '}
<a
href={DOCUMENTATION_LINK}
target="_blank"
rel="noopener noreferrer"
>
here
</a>
.
</>
}
type="info"
showIcon
/>
)}
</StyledBasicTab>
<Tabs.TabPane tab={<span>{t('Advanced')}</span>} key="2">
<ExtraOptions
Expand Down
10 changes: 8 additions & 2 deletions superset/databases/schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,8 @@ class DatabaseParametersSchemaMixin:
When using this mixin make sure that `sqlalchemy_uri` is not required.
"""

# currently in a put request we are not passing in an engine,
# but rather a backend. In a future PR we will address that
engine = fields.String(allow_none=True, description="SQLAlchemy engine to use")
parameters = fields.Dict(
keys=fields.String(),
Expand Down Expand Up @@ -256,7 +258,11 @@ def build_sqlalchemy_uri(

# TODO (betodealmeida): remove second expression after making sure
# frontend is not passing engine inside parameters
engine = data.pop("engine", None) or parameters.pop("engine", None)
engine = (
data.pop("engine", None)
or parameters.pop("engine", None)
or data.pop("backend", None)
)

configuration_method = data.get("configuration_method")
if configuration_method == ConfigurationMethod.DYNAMIC_FORM:
Expand Down Expand Up @@ -312,7 +318,7 @@ class DatabaseValidateParametersSchema(Schema):
class Meta: # pylint: disable=too-few-public-methods
unknown = EXCLUDE

engine = fields.String(required=True, description="SQLAlchemy engine to use")
engine = fields.String(allow_none=True, description="SQLAlchemy engine to use")
parameters = fields.Dict(
keys=fields.String(),
values=fields.Raw(allow_none=True),
Expand Down

0 comments on commit 78d7edb

Please sign in to comment.