Skip to content

Commit

Permalink
Add sub-buttons visibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Blakko committed Mar 21, 2018
1 parent 30f66a7 commit 3cbfc63
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -102,12 +102,19 @@ export function SirenAutoJoinHelperProvider(Private, Promise, es, kibiState) {
});
}

addNodesToTreeNormalLayout(tree, relations, compatibleSavedSearchesMap, compatibleDashboardsMap, btnCountEnabled) {
addNodesToTreeNormalLayout(tree, relations, compatibleSavedSearchesMap, compatibleDashboardsMap, btnCountEnabled, visibility) {
_.each(tree.nodes, node => {
if (node.type === TreeType.VIRTUAL_BUTTON) {
const relationsByDomain = _.filter(relations, rel => rel.domain.id === node.button.targetIndexPatternId);
_.each(relationsByDomain, relByDomain => {
if (relByDomain.range.id !== node.button.sourceIndexPatternId) {
const key = relByDomain.directLabel;
const relNodeId = 'tree-relation-' + key;

let relNode = node.findNode(relNodeId);

if (relByDomain.range.id !== node.button.sourceIndexPatternId
&& (!visibility || !visibility[node.id] || !visibility[node.id].relation
|| !visibility[node.id].relation[key] || !visibility[node.id].relation[key].toggle === false)) {
// filter the savedSearch with the same indexPattern
const compatibleSavedSearches = compatibleSavedSearchesMap[relByDomain.range.id];
_.each(compatibleSavedSearches, compatibleSavedSearch => {
Expand All @@ -123,10 +130,7 @@ export function SirenAutoJoinHelperProvider(Private, Promise, es, kibiState) {
if (btnCountEnabled) {
subButton.showSpinner = true;
}
const key = relByDomain.directLabel;
const relNodeId = 'tree-relation-' + key;

let relNode = node.findNode(relNodeId);
if (!relNode) {
relNode = new Node({
type: TreeType.RELATION,
Expand All @@ -140,17 +144,21 @@ export function SirenAutoJoinHelperProvider(Private, Promise, es, kibiState) {
node.addNode(relNode);
}

const buttonNode = new Node({
type: TreeType.BUTTON,
id: subButton.id,
label: subButton.label,
visible: false,
showChildren: false,
useAltNodes: false,
button: subButton
});
if (!visibility || !visibility[node.id] || !visibility[node.id].relation
|| !visibility[node.id].relation[key]
|| !visibility[node.id].relation[key].dashboard[compatibleDashboard.id] === false) {
const buttonNode = new Node({
type: TreeType.BUTTON,
id: subButton.id,
label: subButton.label,
visible: false,
showChildren: false,
useAltNodes: false,
button: subButton
});

relNode.addNode(buttonNode);
relNode.addNode(buttonNode);
}
});
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -525,7 +525,8 @@ function controller($scope, $rootScope, Private, kbnIndex, config, kibiState, ge
sirenAutoJoinHelper.addNodesToTreeNormalLayout(
tree, relations,
compatibleSavedSearchesMap, compatibleDashboardsMap,
$scope.btnCountsEnabled()
$scope.btnCountsEnabled(),
$scope.vis.params.visibility
);
treeHelper.addAlternativeNodesToTree(tree, $scope.btnCountsEnabled());
} else if ($scope.vis.params.layout === 'light') {
Expand Down

0 comments on commit 3cbfc63

Please sign in to comment.