diff --git a/ui/app/routes/application.js b/ui/app/routes/application.js index 6119eb4ce..477d30c49 100644 --- a/ui/app/routes/application.js +++ b/ui/app/routes/application.js @@ -46,14 +46,15 @@ export default Route.extend({ ); }, - // setupController doesn't refire when the model hook refires as part of - // a query param change - afterModel(model, transition) { - const queryParam = transition.queryParams.region; - const controller = this.controllerFor('application'); + // Model is being used as a way to transfer the provided region + // query param to update the controller state. + model(params) { + return params.region; + }, + + setupController(controller, model) { + const queryParam = model; - // The default region shouldn't show up as a query param since - // it's superfluous. if (queryParam === this.get('system.defaultRegion.region')) { next(() => { controller.set('region', null); diff --git a/ui/tests/acceptance/regions-test.js b/ui/tests/acceptance/regions-test.js index 9fae4d6a3..2a392eed1 100644 --- a/ui/tests/acceptance/regions-test.js +++ b/ui/tests/acceptance/regions-test.js @@ -137,7 +137,7 @@ test('switching regions to the default region, unsets the region query param', f selectChoose('[data-test-region-switcher]', defaultRegion); andThen(() => { - assert.equal(currentURL(), '/jobs', 'No region query param for the default region'); + assert.notOk(currentURL().includes('region='), 'No region query param for the default region'); assert.equal( window.localStorage.nomadActiveRegion, defaultRegion,