-
Notifications
You must be signed in to change notification settings - Fork 14.1k
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
feat: add Back button to extra options #15300
Merged
hughhhh
merged 22 commits into
apache:pexdax/db-connection-ui
from
preset-io:arash/backButton
Jun 22, 2021
Merged
Changes from 21 commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
dbbf58c
fix: add icons (#15122)
AAfghahi e5b66dc
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 03d3326
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 5cfe664
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 7a7f39b
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 54965a1
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 9a2a58e
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi be0408b
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi be5ea73
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi a7425e4
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 8a8998e
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi fc31ea2
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 8a4ff62
spinner
AAfghahi 34e8de1
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi cd6744f
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 4a0eefa
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi de00e6d
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 33764a3
Merge branch 'pexdax/db-connection-ui' of ssh://github.com/apache/sup…
AAfghahi 8fe27f6
first draft
AAfghahi bddb335
working
AAfghahi aa22011
added back button to create modal
AAfghahi 4ccac81
revisions and testing
AAfghahi File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -296,6 +296,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
] = useDatabaseValidation(); | ||
const [hasConnectedDb, setHasConnectedDb] = useState<boolean>(false); | ||
const [dbName, setDbName] = useState(''); | ||
const [editNewDb, setEditNewDb] = useState<boolean>(false); | ||
const [isLoading, setLoading] = useState<boolean>(false); | ||
const conf = useCommonConf(); | ||
const dbImages = getDatabaseImages(); | ||
|
@@ -350,6 +351,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
setDB({ type: ActionType.reset }); | ||
setHasConnectedDb(false); | ||
setValidationErrors(null); // reset validation errors on close | ||
setEditNewDb(false); | ||
onHide(); | ||
}; | ||
|
||
|
@@ -405,7 +407,9 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
if (onDatabaseAdd) { | ||
onDatabaseAdd(); | ||
} | ||
onClose(); | ||
if (!editNewDb) { | ||
onClose(); | ||
} | ||
} | ||
} else if (db) { | ||
// Create | ||
|
@@ -438,6 +442,7 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
} | ||
} | ||
} | ||
setEditNewDb(false); | ||
setLoading(false); | ||
}; | ||
|
||
|
@@ -537,10 +542,19 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
</div> | ||
); | ||
|
||
const renderModalFooter = () => | ||
db // if db show back + connect | ||
? [ | ||
!hasConnectedDb && ( | ||
const handleBackButton = () => { | ||
if (dbFetched) { | ||
fetchResource(dbFetched.id as number); | ||
} | ||
setEditNewDb(true); | ||
}; | ||
|
||
const renderModalFooter = () => { | ||
if (db) { | ||
// if db show back + connenct | ||
if (!hasConnectedDb || editNewDb) { | ||
return ( | ||
<> | ||
<StyledFooterButton | ||
key="back" | ||
onClick={() => { | ||
|
@@ -549,26 +563,34 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
> | ||
Back | ||
</StyledFooterButton> | ||
), | ||
!hasConnectedDb ? ( // if hasConnectedDb show back + finish | ||
<StyledFooterButton | ||
key="submit" | ||
buttonStyle="primary" | ||
onClick={onSave} | ||
> | ||
Connect | ||
</StyledFooterButton> | ||
) : ( | ||
<StyledFooterButton | ||
key="submit" | ||
buttonStyle="primary" | ||
onClick={onClose} | ||
> | ||
Finish | ||
</StyledFooterButton> | ||
), | ||
] | ||
: []; | ||
</> | ||
); | ||
} | ||
|
||
return ( | ||
<> | ||
<StyledFooterButton key="back" onClick={handleBackButton}> | ||
Back | ||
</StyledFooterButton> | ||
<StyledFooterButton | ||
key="submit" | ||
buttonStyle="primary" | ||
onClick={onClose} | ||
> | ||
Finish | ||
</StyledFooterButton> | ||
</> | ||
); | ||
} | ||
return []; | ||
}; | ||
|
||
const renderEditModalFooter = () => ( | ||
<> | ||
|
@@ -613,6 +635,68 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
setTabKey(key); | ||
}; | ||
|
||
const renderExtraOptions = () => { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Can change the name to renderFinishState or something that extent? |
||
if (!editNewDb) { | ||
return ( | ||
<ExtraOptions | ||
db={db as DatabaseObject} | ||
onInputChange={({ target }: { target: HTMLInputElement }) => | ||
onChange(ActionType.inputChange, { | ||
type: target.type, | ||
name: target.name, | ||
checked: target.checked, | ||
value: target.value, | ||
}) | ||
} | ||
onTextChange={({ target }: { target: HTMLTextAreaElement }) => | ||
onChange(ActionType.textChange, { | ||
name: target.name, | ||
value: target.value, | ||
}) | ||
} | ||
onEditorChange={(payload: { name: string; json: any }) => | ||
onChange(ActionType.editorChange, payload) | ||
} | ||
onExtraInputChange={({ target }: { target: HTMLInputElement }) => { | ||
onChange(ActionType.extraInputChange, { | ||
type: target.type, | ||
name: target.name, | ||
checked: target.checked, | ||
value: target.value, | ||
}); | ||
}} | ||
onExtraEditorChange={(payload: { name: string; json: any }) => | ||
onChange(ActionType.extraEditorChange, payload) | ||
} | ||
/> | ||
); | ||
} | ||
return ( | ||
<DatabaseConnectionForm | ||
isEditMode | ||
sslForced={sslForced} | ||
dbModel={dbModel} | ||
db={dbFetched as DatabaseObject} | ||
onParametersChange={({ target }: { target: HTMLInputElement }) => | ||
onChange(ActionType.parametersChange, { | ||
type: target.type, | ||
name: target.name, | ||
checked: target.checked, | ||
value: target.value, | ||
}) | ||
} | ||
onChange={({ target }: { target: HTMLInputElement }) => | ||
onChange(ActionType.textChange, { | ||
name: target.name, | ||
value: target.value, | ||
}) | ||
} | ||
getValidation={() => getValidation(db)} | ||
validationErrors={validationErrors} | ||
/> | ||
); | ||
}; | ||
|
||
const isDynamic = (engine: string | undefined) => | ||
availableDbs?.databases.filter( | ||
(DB: DatabaseObject) => DB.backend === engine || DB.engine === engine, | ||
|
@@ -807,39 +891,9 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
db={db} | ||
dbName={dbName} | ||
dbModel={dbModel} | ||
editNewDb={editNewDb} | ||
/> | ||
|
||
<ExtraOptions | ||
db={db as DatabaseObject} | ||
onInputChange={({ target }: { target: HTMLInputElement }) => | ||
onChange(ActionType.inputChange, { | ||
type: target.type, | ||
name: target.name, | ||
checked: target.checked, | ||
value: target.value, | ||
}) | ||
} | ||
onTextChange={({ target }: { target: HTMLTextAreaElement }) => | ||
onChange(ActionType.textChange, { | ||
name: target.name, | ||
value: target.value, | ||
}) | ||
} | ||
onEditorChange={(payload: { name: string; json: any }) => | ||
onChange(ActionType.editorChange, payload) | ||
} | ||
onExtraInputChange={({ target }: { target: HTMLInputElement }) => { | ||
onChange(ActionType.extraInputChange, { | ||
type: target.type, | ||
name: target.name, | ||
checked: target.checked, | ||
value: target.value, | ||
}); | ||
}} | ||
onExtraEditorChange={(payload: { name: string; json: any }) => | ||
onChange(ActionType.extraEditorChange, payload) | ||
} | ||
/> | ||
{renderExtraOptions()} | ||
</> | ||
) : ( | ||
<> | ||
|
@@ -875,8 +929,8 @@ const DatabaseModal: FunctionComponent<DatabaseModalProps> = ({ | |
css={(theme: SupersetTheme) => antDAlertStyles(theme)} | ||
type="info" | ||
showIcon | ||
message={t('Whitelisting IPs')} | ||
description={connectionAlert.WHITELISTED_IPS} | ||
message={t('IP Allowlist')} | ||
description={connectionAlert.ALLOWED_IPS} | ||
/> | ||
)} | ||
<DatabaseConnectionForm | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
handleBackButtonOnFinish