From c2ac5f6134b1c6b30b4293fda44667ce2b09f7e0 Mon Sep 17 00:00:00 2001 From: Simon Howe Date: Tue, 23 Aug 2016 14:13:54 +0200 Subject: [PATCH] Check for all k8s topos before defaulting to container topo - Show something from k8s by default if its around. --- client/app/scripts/utils/topology-utils.js | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/client/app/scripts/utils/topology-utils.js b/client/app/scripts/utils/topology-utils.js index c2955bbb19..ae22afaba9 100644 --- a/client/app/scripts/utils/topology-utils.js +++ b/client/app/scripts/utils/topology-utils.js @@ -2,10 +2,16 @@ import _ from 'lodash'; import { is as isDeepEqual, Map as makeMap, Set as makeSet, List as makeList } from 'immutable'; -const TOPOLOGY_DISPLAY_PRIORITY = { - services: 1, - containers: 2, -}; +// +// top priority first +// +const TOPOLOGY_DISPLAY_PRIORITY = [ + 'services', + 'deployments', + 'replica-sets', + 'pods', + 'containers', +]; export function getDefaultTopology(topologies) { @@ -13,7 +19,10 @@ export function getDefaultTopology(topologies) { .flatMap(t => makeList([t]).concat(t.get('sub_topologies', makeList()))); return flatTopologies - .sortBy(t => TOPOLOGY_DISPLAY_PRIORITY[t.get('id')] || Infinity) + .sortBy(t => { + const index = TOPOLOGY_DISPLAY_PRIORITY.indexOf(t.get('id')); + return index === -1 ? Infinity : index; + }) .getIn([0, 'id']); }