Skip to content

Commit

Permalink
Snippets: Don't change url when not needed
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrieldutra committed Sep 15, 2019
1 parent 95795d9 commit 2f346f3
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions client/app/pages/query-snippets/QuerySnippetsList.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ class QuerySnippetsList extends React.Component {
if (isNewOrEditPage) {
if (querySnippetId === 'new') {
if (policy.isCreateQuerySnippetEnabled()) {
this.showSnippetDialog();
this.showSnippetDialog(null, false);
} else {
navigateTo('/query_snippets');
}
} else {
QuerySnippet.get({ id: querySnippetId }).$promise
.then(this.showSnippetDialog)
.then(querySnippet => this.showSnippetDialog(querySnippet, false))
.catch((error = {}) => {
// ANGULAR_REMOVE_ME This code is related to Angular's HTTP services
if (error.status && error.data) {
Expand Down Expand Up @@ -116,17 +116,20 @@ class QuerySnippetsList extends React.Component {
});
}

showSnippetDialog = (querySnippet = null) => {
showSnippetDialog = (querySnippet = null, updateUrl = true) => {
const canSave = !querySnippet || canEditQuerySnippet(querySnippet);
navigateTo('/query_snippets/' + get(querySnippet, 'id', 'new'), true, false);
if (updateUrl) {
navigateTo('/query_snippets/' + get(querySnippet, 'id', 'new'), true, false);
}
QuerySnippetDialog.showModal({
querySnippet,
onSubmit: this.saveQuerySnippet,
readOnly: !canSave,
}).result
.then(() => this.props.controller.update())
.finally(() => {
navigateTo('/query_snippets', true, false);
const toggleNavigationReload = !updateUrl;
navigateTo('/query_snippets', true, toggleNavigationReload);
});
};

Expand Down

0 comments on commit 2f346f3

Please sign in to comment.