Skip to content

Commit

Permalink
Fix comments
Browse files Browse the repository at this point in the history
  • Loading branch information
sulemanof committed Mar 11, 2020
1 parent 05a4eee commit 85e40c0
Showing 1 changed file with 6 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,7 @@ function VisualizeAppController(
savedVis.vis.on('apply', _applyVis);
// vis is instance of src/legacy/ui/public/vis/vis.js.
// SearchSource is a promise-based stream of search results that can inherit from other search sources.
const { vis, searchSource, savedSearchId } = savedVis;
const searchSourceParent = searchSource.getParent();
const { vis, searchSource, savedSearch } = savedVis;

$scope.vis = vis;

Expand Down Expand Up @@ -381,14 +380,11 @@ function VisualizeAppController(
};

const handleLinkedSearch = linked => {
if (linked && !savedVis.savedSearchId) {
savedVis.savedSearchId = savedSearchId;
vis.savedSearchId = savedSearchId;

searchSource.setParent(searchSourceParent);
if (linked && !savedVis.savedSearchId && savedSearch) {
savedVis.savedSearchId = savedSearch.id;
searchSource.setParent(savedSearch.searchSource);
} else if (!linked && savedVis.savedSearchId) {
delete savedVis.savedSearchId;
delete vis.savedSearchId;
}
};

Expand Down Expand Up @@ -662,10 +658,7 @@ function VisualizeAppController(
}

const unlinkFromSavedSearch = () => {
if (!searchSourceParent) {
return;
}

const searchSourceParent = savedSearch.searchSource;
const searchSourceGrandparent = searchSourceParent.getParent();
const currentIndex = searchSourceParent.getField('index');

Expand All @@ -681,7 +674,7 @@ function VisualizeAppController(
i18n.translate('kbn.visualize.linkedToSearch.unlinkSuccessNotificationText', {
defaultMessage: `Unlinked from saved search '{searchTitle}'`,
values: {
searchTitle: savedVis.savedSearch.title,
searchTitle: savedSearch.title,
},
})
);
Expand Down

0 comments on commit 85e40c0

Please sign in to comment.