mirror of
https://github.com/getredash/redash.git
synced 2025-12-25 01:03:20 -05:00
Refactor dialog wrapper component (#4594)
* Dialog wrapper: stop using promises to handle results - replace with callbacks * Dialog wrapper: handle async operation on close
This commit is contained in:
@@ -121,16 +121,18 @@ class QuerySnippetsList extends React.Component {
|
||||
showSnippetDialog = (querySnippet = null) => {
|
||||
const canSave = !querySnippet || canEditQuerySnippet(querySnippet);
|
||||
navigateTo("query_snippets/" + get(querySnippet, "id", "new"), true);
|
||||
const goToSnippetsList = () => navigateTo("query_snippets", true);
|
||||
QuerySnippetDialog.showModal({
|
||||
querySnippet,
|
||||
onSubmit: this.saveQuerySnippet,
|
||||
readOnly: !canSave,
|
||||
})
|
||||
.result.then(() => this.props.controller.update())
|
||||
.catch(() => {}) // ignore dismiss
|
||||
.finally(() => {
|
||||
navigateTo("query_snippets", true);
|
||||
});
|
||||
.onClose(querySnippet =>
|
||||
this.saveQuerySnippet(querySnippet).then(() => {
|
||||
this.props.controller.update();
|
||||
goToSnippetsList();
|
||||
})
|
||||
)
|
||||
.onDismiss(goToSnippetsList);
|
||||
};
|
||||
|
||||
render() {
|
||||
|
||||
Reference in New Issue
Block a user