diff --git a/ui-v2/app/helpers/href-mut.js b/ui-v2/app/helpers/href-mut.js index 6ad337df1..6353d4406 100644 --- a/ui-v2/app/helpers/href-mut.js +++ b/ui-v2/app/helpers/href-mut.js @@ -22,7 +22,7 @@ export default Helper.extend({ atts = atts.concat(getRouteParams(parent, params)); current = parent; } - let route = this.router.currentRouteName; + let route = this.router.currentRoute.name; // TODO: this is specific to consul/nspaces // 'ideally' we could try and do this elsewhere // not super important though. diff --git a/ui-v2/app/routes/application.js b/ui-v2/app/routes/application.js index d815090bb..c66cf4bf7 100644 --- a/ui-v2/app/routes/application.js +++ b/ui-v2/app/routes/application.js @@ -51,6 +51,8 @@ export default Route.extend(WithBlockingActions, { error = e.errors[0]; error.message = error.title || error.detail || 'Error'; } + // Try and get the currently attempted dc, whereever that may be + const model = this.modelFor('dc') || this.modelFor('nspace.dc'); // TODO: Unfortunately ember will not maintain the correct URL // for you i.e. when this happens the URL in your browser location bar // will be the URL where you clicked on the link to come here @@ -62,7 +64,6 @@ export default Route.extend(WithBlockingActions, { // 403 page // To note: Consul only gives you back a 403 if a non-existent token has been sent in the header // if a token has not been sent at all, it just gives you a 200 with an empty dataset - const model = this.modelFor('dc'); if (error.status === '403') { return this.feedback.execute(() => { return this.settings.delete('token').then(() => { @@ -85,7 +86,8 @@ export default Route.extend(WithBlockingActions, { : { Name: 'Error' }, dcs: model && model.dcs ? model.dcs : [], }) - .then(model => { + .then(model => Promise.all([model, this.repo.clearActive()])) + .then(([model]) => { removeLoading($root); model.nspaces = [model.nspace]; // we can't use setupController as we received an error diff --git a/ui-v2/app/services/repository/dc.js b/ui-v2/app/services/repository/dc.js index 09654c768..76d0957ab 100644 --- a/ui-v2/app/services/repository/dc.js +++ b/ui-v2/app/services/repository/dc.js @@ -43,4 +43,7 @@ export default RepositoryService.extend({ } ); }, + clearActive: function() { + return this.settings.delete('dc'); + }, }); diff --git a/ui-v2/app/templates/error.hbs b/ui-v2/app/templates/error.hbs index cc1244d5c..bcf13457f 100644 --- a/ui-v2/app/templates/error.hbs +++ b/ui-v2/app/templates/error.hbs @@ -15,7 +15,7 @@ You may have visited a URL that is loading an unknown resource, so you can try going back to the root or try re-submitting your ACL Token/SecretID by going back to ACLs.
Try looking in our documentation

- Go back to root + Go back to root {{/block-slot}} {{/app-view}} {{/hashicorp-consul}} diff --git a/ui-v2/tests/acceptance/dc/error.feature b/ui-v2/tests/acceptance/dc/error.feature new file mode 100644 index 000000000..7cb465ae7 --- /dev/null +++ b/ui-v2/tests/acceptance/dc/error.feature @@ -0,0 +1,26 @@ +@setupApplicationTest +Feature: dc / error: Recovering from a dc 500 error + Background: + Given 2 datacenter models from yaml + --- + - dc-1 + - dc-500 + --- + And 3 service models + And the url "/v1/internal/ui/services" responds with a 500 status + When I visit the services page for yaml + --- + dc: dc-500 + --- + Then the url should be /dc-500/services + And the title should be "Consul" + Then I see the text "500 (The backend responded with an error)" in "[data-test-error]" + Scenario: Clicking the back to root button + Given the url "/v1/internal/ui/services" responds with a 200 status + When I click home + Then I see 3 service models + Scenario: Choosing a different dc from the dc menu + Given the url "/v1/internal/ui/services" responds with a 200 status + When I click dc on the navigation + And I click dcs.0.name + Then I see 3 service models diff --git a/ui-v2/tests/acceptance/steps/dc/error-steps.js b/ui-v2/tests/acceptance/steps/dc/error-steps.js new file mode 100644 index 000000000..3c9a76f69 --- /dev/null +++ b/ui-v2/tests/acceptance/steps/dc/error-steps.js @@ -0,0 +1,10 @@ +import steps from '../steps'; + +// step definitions that are shared between features should be moved to the +// tests/acceptance/steps/steps.js file + +export default function(assert) { + return steps(assert).then('I should find a file', function() { + assert.ok(true, this.step); + }); +} diff --git a/ui-v2/tests/pages/dc/services/index.js b/ui-v2/tests/pages/dc/services/index.js index 3ecab2a87..7b43e3618 100644 --- a/ui-v2/tests/pages/dc/services/index.js +++ b/ui-v2/tests/pages/dc/services/index.js @@ -11,5 +11,6 @@ export default function(visitable, clickable, attribute, collection, page, filte }), navigation: page.navigation, filter: filter, + home: clickable('[data-test-home]'), }; }