-
Notifications
You must be signed in to change notification settings - Fork 2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move the namespace query param up the route hierarchy
This makes it active on all job routes
- Loading branch information
1 parent
2272e1d
commit f5bb57b
Showing
4 changed files
with
66 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import Ember from 'ember'; | ||
|
||
const { Controller, inject, observer } = Ember; | ||
|
||
export default Controller.extend({ | ||
system: inject.service(), | ||
|
||
queryParams: { | ||
jobNamespace: 'namespace', | ||
}, | ||
|
||
jobNamespace: 'default', | ||
|
||
// The namespace query param should act as an alias to the system active namespace. | ||
// But query param defaults can't be CPs: https://github.com/emberjs/ember.js/issues/9819 | ||
syncNamespaceService: observer('jobNamespace', function() { | ||
const newNamespace = this.get('jobNamespace'); | ||
const currentNamespace = this.get('system.activeNamespace.id'); | ||
const bothAreDefault = | ||
(currentNamespace == undefined || currentNamespace === 'default') && | ||
(newNamespace == undefined || newNamespace === 'default'); | ||
|
||
if (currentNamespace !== newNamespace && !bothAreDefault) { | ||
this.set('system.activeNamespace', newNamespace); | ||
this.send('refreshRoute'); | ||
} | ||
}), | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,11 @@ | ||
import Ember from 'ember'; | ||
|
||
const { Route, inject } = Ember; | ||
const { Route } = Ember; | ||
|
||
export default Route.extend({ | ||
system: inject.service(), | ||
|
||
setupController(controller) { | ||
this._super(...arguments); | ||
|
||
const namespace = this.get('system.activeNamespace.id'); | ||
if (namespace && namespace !== 'default') { | ||
controller.set('jobNamespace', namespace); | ||
} else { | ||
controller.set('jobNamespace', 'default'); | ||
} | ||
actions: { | ||
refreshRoute() { | ||
return true; | ||
}, | ||
}, | ||
}); |