github.com/cockroachdb/cockroach@v20.2.0-alpha.1+incompatible/pkg/ui/ccl/src/views/clusterviz/containers/map/layout.ts (about) 1 // Copyright 2017 The Cockroach Authors. 2 // 3 // Licensed as a CockroachDB Enterprise file under the Cockroach Community 4 // License (the "License"); you may not use this file except in compliance with 5 // the License. You may obtain a copy of the License at 6 // 7 // https://github.com/cockroachdb/cockroach/blob/master/licenses/CCL.txt 8 9 import _ from "lodash"; 10 11 import { LocalityTree } from "src/redux/localities"; 12 import { LocationTree } from "src/redux/locations"; 13 import { getChildLocalities } from "src/util/localities"; 14 import { findOrCalculateLocation } from "src/util/locations"; 15 16 export function renderAsMap(locationTree: LocationTree, localityTree: LocalityTree) { 17 // If there are any nodes directly under this locality, don't show a map. 18 if (!_.isEmpty(localityTree.nodes)) { 19 return false; 20 } 21 22 // Otherwise, show a map as long as we're able to find or calculate a location 23 // for every child locality. 24 const children = getChildLocalities(localityTree); 25 return _.every( 26 children, 27 (child) => !_.isNil(findOrCalculateLocation(locationTree, child)), 28 ); 29 }