Remove double call to update state from saved query (#45046)
* Changes saved query watchers in Discover to reduce number of calls to updateStateFromSavedQuery * Changes saved query watchers in Dashboard to reduce number of calls to updateStateFromSavedQuery * Changes saved query watchers in Visualize to reduce number of calls to updateStateFromSavedQuery * formatting * fixes test
This commit is contained in:
parent
6ceb62f6e4
commit
0656e4fc00
4 changed files with 35 additions and 34 deletions
|
@ -465,13 +465,11 @@ export class DashboardAppController {
|
|||
}
|
||||
};
|
||||
|
||||
$scope.$watch('savedQuery', (newSavedQuery: SavedQuery, oldSavedQuery: SavedQuery) => {
|
||||
$scope.$watch('savedQuery', (newSavedQuery: SavedQuery) => {
|
||||
if (!newSavedQuery) return;
|
||||
dashboardStateManager.setSavedQueryId(newSavedQuery.id);
|
||||
|
||||
if (newSavedQuery.id === (oldSavedQuery && oldSavedQuery.id)) {
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
}
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
});
|
||||
|
||||
$scope.$watch(
|
||||
|
@ -483,13 +481,14 @@ export class DashboardAppController {
|
|||
$scope.savedQuery = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery: SavedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
if ($scope.savedQuery && newSavedQueryId !== $scope.savedQuery.id) {
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery: SavedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
);
|
||||
|
||||
|
|
|
@ -967,15 +967,14 @@ function discoverController(
|
|||
$scope.fetch();
|
||||
};
|
||||
|
||||
$scope.$watch('savedQuery', (newSavedQuery, oldSavedQuery) => {
|
||||
$scope.$watch('savedQuery', (newSavedQuery) => {
|
||||
if (!newSavedQuery) return;
|
||||
|
||||
$state.savedQuery = newSavedQuery.id;
|
||||
$state.save();
|
||||
|
||||
if (newSavedQuery.id === (oldSavedQuery && oldSavedQuery.id)) {
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
}
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
|
||||
});
|
||||
|
||||
$scope.$watch('state.savedQuery', newSavedQueryId => {
|
||||
|
@ -984,12 +983,14 @@ function discoverController(
|
|||
return;
|
||||
}
|
||||
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
if ($scope.savedQuery && newSavedQueryId !== $scope.savedQuery.id) {
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
async function setupVisualization() {
|
||||
|
|
|
@ -513,14 +513,12 @@ function VisEditor(
|
|||
$scope.fetch();
|
||||
};
|
||||
|
||||
$scope.$watch('savedQuery', (newSavedQuery, oldSavedQuery) => {
|
||||
$scope.$watch('savedQuery', (newSavedQuery) => {
|
||||
if (!newSavedQuery) return;
|
||||
$state.savedQuery = newSavedQuery.id;
|
||||
$state.save();
|
||||
|
||||
if (newSavedQuery.id === (oldSavedQuery && oldSavedQuery.id)) {
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
}
|
||||
updateStateFromSavedQuery(newSavedQuery);
|
||||
});
|
||||
|
||||
$scope.$watch('state.savedQuery', newSavedQueryId => {
|
||||
|
@ -528,13 +526,14 @@ function VisEditor(
|
|||
$scope.savedQuery = undefined;
|
||||
return;
|
||||
}
|
||||
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
if ($scope.savedQuery && newSavedQueryId !== $scope.savedQuery.id) {
|
||||
savedQueryService.getSavedQuery(newSavedQueryId).then((savedQuery) => {
|
||||
$scope.$evalAsync(() => {
|
||||
$scope.savedQuery = savedQuery;
|
||||
updateStateFromSavedQuery(savedQuery);
|
||||
});
|
||||
});
|
||||
});
|
||||
}
|
||||
});
|
||||
|
||||
/**
|
||||
|
|
|
@ -128,11 +128,6 @@ export default function ({ getService, getPageObjects }) {
|
|||
it('does not allow saving a query with leading or trailing whitespace in the name', async () => {
|
||||
await savedQueryManagementComponent.saveNewQueryWithNameError('OkResponse ');
|
||||
});
|
||||
it('allows clearing the currently loaded saved query', async () => {
|
||||
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
|
||||
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
|
||||
expect(await queryBar.getQueryString()).to.eql('');
|
||||
});
|
||||
|
||||
it('resets any changes to a loaded query on reloading the same saved query', async () => {
|
||||
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
|
||||
|
@ -140,6 +135,13 @@ export default function ({ getService, getPageObjects }) {
|
|||
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
|
||||
expect(await queryBar.getQueryString()).to.eql('response:404');
|
||||
});
|
||||
|
||||
it('allows clearing the currently loaded saved query', async () => {
|
||||
await savedQueryManagementComponent.loadSavedQuery('OkResponse');
|
||||
await savedQueryManagementComponent.clearCurrentlyLoadedQuery();
|
||||
expect(await queryBar.getQueryString()).to.eql('');
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue