Instead of rewriting the API call, use ember to rewrite the URL
We now essentially do 2 redirects if you hit a `folder/` 1. If you visit `/ui/dc1/kv/folder/`, `consul` will redirect you to `/ui/dc1/kv/folder` 2. Once redirected to `/ui/dc1/kv/folder` via a 301, use ember/history API to redirect you back to `/ui/dc1/kv/folder/`. Bit long winded, but achieves what we want without having to get stuck into `consul` itself to remove the 301 for the UI
This commit is contained in:
parent
946bdd6d6e
commit
b8042c722e
|
@ -13,13 +13,17 @@ export default Route.extend(WithKvActions, {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
repo: service('kv'),
|
repo: service('kv'),
|
||||||
model: function(params) {
|
beforeModel: function() {
|
||||||
let key = params.key || '/';
|
|
||||||
// we are index or folder, so if the key doesn't have a trailing slash
|
// we are index or folder, so if the key doesn't have a trailing slash
|
||||||
// add one to force a fake findBySlug
|
// add one to force a fake findBySlug
|
||||||
|
const params = this.paramsFor(this.routeName);
|
||||||
|
const key = params.key || '/';
|
||||||
if (!isFolder(key)) {
|
if (!isFolder(key)) {
|
||||||
key = key + '/';
|
return this.replaceWith(this.routeName, key + '/');
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
model: function(params) {
|
||||||
|
let key = params.key || '/';
|
||||||
const dc = this.modelFor('dc').dc.Name;
|
const dc = this.modelFor('dc').dc.Name;
|
||||||
const repo = get(this, 'repo');
|
const repo = get(this, 'repo');
|
||||||
return hash({
|
return hash({
|
||||||
|
|
|
@ -8,7 +8,7 @@ Feature: dc / kvs / trailing slash
|
||||||
dc: datacenter
|
dc: datacenter
|
||||||
kv: foo/bar
|
kv: foo/bar
|
||||||
---
|
---
|
||||||
Then the url should be /datacenter/kv/foo/bar
|
Then the url should be /datacenter/kv/foo/bar/
|
||||||
And the last GET request was made to "/v1/kv/foo/bar/?keys&dc=datacenter&separator=%2F"
|
And the last GET request was made to "/v1/kv/foo/bar/?keys&dc=datacenter&separator=%2F"
|
||||||
When I visit the kvs page for yaml
|
When I visit the kvs page for yaml
|
||||||
---
|
---
|
||||||
|
|
Loading…
Reference in New Issue