Skip to content

Commit

Permalink
fix(core/cluster): Use redirectTo hook to switch to pipelines when …
Browse files Browse the repository at this point in the history
…serverGroups is disabled (#3643)
  • Loading branch information
christopherthielen committed May 5, 2017
1 parent 8f22a27 commit 69c7e3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
6 changes: 0 additions & 6 deletions app/scripts/modules/core/cluster/allClusters.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@ module.exports = angular.module('spinnaker.core.cluster.allClusters.controller',
])
.controller('AllClustersCtrl', function($scope, app, $uibModal, $timeout, providerSelectionService, clusterFilterService, $state,
ClusterFilterModel, MultiselectModel, InsightFilterStateModel, serverGroupCommandBuilder, cloudProviderRegistry) {

if (app.serverGroups.disabled) {
$state.go('^.^' + app.dataSources.find(ds => ds.sref && !ds.disabled).sref, {}, {location: 'replace'});
return;
}

this.application = app;
ClusterFilterModel.activate();
this.initialized = false;
Expand Down
13 changes: 13 additions & 0 deletions app/scripts/modules/core/serverGroup/serverGroup.states.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,19 @@ module(SERVER_GROUP_STATES, [
// and deal with the exception in the AllClustersCtrl
ready: (app: Application) => app.getDataSource('serverGroups').ready().catch(() => null),
},
redirectTo: (transition) => {
return transition.injector().getAsync('app').then((app: Application) => {
if (app.serverGroups.disabled) {
const relativeSref = app.dataSources.find(ds => ds.sref && !ds.disabled).sref;
const params = transition.params();
// Target the state relative to the `clusters` state
const options = { relative: transition.to().name };
// Up two state levels first
return transition.router.stateService.target('^.^' + relativeSref, params, options);
}
return null;
});
},
params: stateConfigProvider.buildDynamicParams(filterModelConfig),
data: {
pageTitleSection: {
Expand Down

0 comments on commit 69c7e3e

Please sign in to comment.