mirror of
https://github.com/weaveworks/scope.git
synced 2026-03-03 02:00:43 +00:00
Merge pull request #1823 from weaveworks/1809-make-services-initial-topo
Makes services the initial topology if available
This commit is contained in:
@@ -7,8 +7,8 @@ import ActionTypes from '../constants/action-types';
|
||||
import { EDGE_ID_SEPARATOR } from '../constants/naming';
|
||||
import { applyPinnedSearches, updateNodeMatches } from '../utils/search-utils';
|
||||
import { getNetworkNodes, getAvailableNetworks } from '../utils/network-view-utils';
|
||||
import { findTopologyById, getAdjacentNodes, setTopologyUrlsById,
|
||||
updateTopologyIds, filterHiddenTopologies, addTopologyFullname } from '../utils/topology-utils';
|
||||
import { findTopologyById, getAdjacentNodes, setTopologyUrlsById, updateTopologyIds,
|
||||
filterHiddenTopologies, addTopologyFullname, getDefaultTopology } from '../utils/topology-utils';
|
||||
|
||||
const log = debug('scope:app-store');
|
||||
const error = debug('scope:error');
|
||||
@@ -25,7 +25,7 @@ export const initialState = makeMap({
|
||||
controlPipes: makeOrderedMap(), // pipeId -> controlPipe
|
||||
controlStatus: makeMap(),
|
||||
currentTopology: null,
|
||||
currentTopologyId: 'containers',
|
||||
currentTopologyId: null,
|
||||
errorUrl: null,
|
||||
forceRelayout: false,
|
||||
gridMode: false,
|
||||
@@ -606,6 +606,10 @@ export function rootReducer(state = initialState, action) {
|
||||
state = state.set('errorUrl', null);
|
||||
state = state.update('topologyUrlsById', topologyUrlsById => topologyUrlsById.clear());
|
||||
state = processTopologies(state, action.topologies);
|
||||
if (!state.get('currentTopologyId')) {
|
||||
state = state.set('currentTopologyId', getDefaultTopology(state.get('topologies')));
|
||||
log(`Set currentTopologyId to ${state.get('currentTopologyId')}`);
|
||||
}
|
||||
state = setTopology(state, state.get('currentTopologyId'));
|
||||
// only set on first load, if options are not already set via route
|
||||
if (!state.get('topologiesLoaded') && state.get('topologyOptions').size === 0) {
|
||||
|
||||
@@ -1,5 +1,31 @@
|
||||
import _ from 'lodash';
|
||||
import { is as isDeepEqual, Map as makeMap, Set as makeSet } from 'immutable';
|
||||
import { is as isDeepEqual, Map as makeMap, Set as makeSet, List as makeList } from 'immutable';
|
||||
|
||||
|
||||
//
|
||||
// top priority first
|
||||
//
|
||||
const TOPOLOGY_DISPLAY_PRIORITY = [
|
||||
'services',
|
||||
'deployments',
|
||||
'replica-sets',
|
||||
'pods',
|
||||
'containers',
|
||||
];
|
||||
|
||||
|
||||
export function getDefaultTopology(topologies) {
|
||||
const flatTopologies = topologies
|
||||
.flatMap(t => makeList([t]).concat(t.get('sub_topologies', makeList())));
|
||||
|
||||
return flatTopologies
|
||||
.sortBy(t => {
|
||||
const index = TOPOLOGY_DISPLAY_PRIORITY.indexOf(t.get('id'));
|
||||
return index === -1 ? Infinity : index;
|
||||
})
|
||||
.getIn([0, 'id']);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Returns a cache ID based on the topologyId and optionsQuery
|
||||
|
||||
Reference in New Issue
Block a user