ui: Enable recovery from a unreachable datacenter (500 error)
For URL maintenance reasons we store the last visited DC in localStorage incase you come back to a page (for example settings) that doesn't have a dc in the URL. A problem arises here if the last DC you tried to visit is unreachable. The first fix here clears out the last visited DC from localStorage if the API has errored out. Secondly, our `href-mut` helper which mutates the current current and replaces 'parts' in the URL rather than the whole thing functioned by detecting the current route/URL you are on an 'mutating' that. A problem arose here as even though you might be on the `/ui/dc-1/services` URL the actual route is the 'error' route which does not have a URL that can be changed properly. The second fix here changes the arguments that href-mut accepts to `{{href-mut fallbackRouteName, hashOfThingsToReplace}}`. If the route is the error route it will use the fallbackRouteName. Although it seems strange we decided to put the fallbackRoute as the first argument so it looks similar to the normal `{{href-to}}` helper. Acceptance tests included here to replicate the original bug report.
Showing
- ui-v2/app/helpers/href-mut.js 9 additions, 1 deletionui-v2/app/helpers/href-mut.js
- ui-v2/app/routes/application.js 2 additions, 1 deletionui-v2/app/routes/application.js
- ui-v2/app/services/repository/dc.js 3 additions, 0 deletionsui-v2/app/services/repository/dc.js
- ui-v2/app/templates/components/hashicorp-consul.hbs 2 additions, 2 deletionsui-v2/app/templates/components/hashicorp-consul.hbs
- ui-v2/app/templates/error.hbs 1 addition, 1 deletionui-v2/app/templates/error.hbs
- ui-v2/tests/acceptance/dc/error.feature 26 additions, 0 deletionsui-v2/tests/acceptance/dc/error.feature
- ui-v2/tests/acceptance/steps/dc/error-steps.js 10 additions, 0 deletionsui-v2/tests/acceptance/steps/dc/error-steps.js
- ui-v2/tests/pages/dc/services/index.js 1 addition, 0 deletionsui-v2/tests/pages/dc/services/index.js
Please register or sign in to comment