ui: [BUGFIX] Ensure in-folder KVs are created in the correct folder (#10569)

When clicking to create a KV within folder name, would would be viewing a form that was a form for creating a KV in the root, which when the user clicked to save, saved the KV in the root.

For the moment at least I've removed the code that strips double slashes, and whilst this isn't ideal, it looks like we've picked up one of those bugs that turns into a 'feature', and completely reworking KV to not rely on the double slashes is not really an option right now.
This commit is contained in:
John Cowen 2021-07-14 18:49:01 +01:00 committed by GitHub
parent ffb7e92aa7
commit 398db1339b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 5 deletions

3
.changelog/10569.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:bug
ui: Ensure in-folder KVs are created in the correct folder
```

View File

@ -54,7 +54,7 @@
<div> <div>
<div> <div>
{{#if authorized}} {{#if authorized}}
<nav aria-label="Breadcrumb"> <nav aria-label="Breadcrumb" data-test-breadcrumbs>
<YieldSlot @name="breadcrumbs"> <YieldSlot @name="breadcrumbs">
{{document-attrs class="with-breadcrumbs"}} {{document-attrs class="with-breadcrumbs"}}
{{yield}} {{yield}}

View File

@ -9,7 +9,9 @@ if (env('CONSUL_NSPACES_ENABLED')) {
} }
const trailingSlashRe = /\/$/; const trailingSlashRe = /\/$/;
const moreThan1SlashRe = /\/{2,}/g;
// see below re: ember double slashes
// const moreThan1SlashRe = /\/{2,}/g;
const _uuid = function() { const _uuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => { return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
@ -123,15 +125,16 @@ export default class FSMWithOptionalLocation {
} }
getURLFrom(url) { getURLFrom(url) {
// remove trailing slashes if they exists // remove trailing slashes if they exist
url = url || this.location.pathname; url = url || this.location.pathname;
this.rootURL = this.rootURL.replace(trailingSlashRe, ''); this.rootURL = this.rootURL.replace(trailingSlashRe, '');
this.baseURL = this.baseURL.replace(trailingSlashRe, ''); this.baseURL = this.baseURL.replace(trailingSlashRe, '');
// remove baseURL and rootURL from start of path // remove baseURL and rootURL from start of path
return url return url
.replace(new RegExp(`^${this.baseURL}(?=/|$)`), '') .replace(new RegExp(`^${this.baseURL}(?=/|$)`), '')
.replace(new RegExp(`^${this.rootURL}(?=/|$)`), '') .replace(new RegExp(`^${this.rootURL}(?=/|$)`), '');
.replace(moreThan1SlashRe, '/'); // remove extra slashes // ember default locations remove double slashes here e.g. '//'
// .replace(moreThan1SlashRe, '/'); // remove extra slashes
} }
getURLForTransition(url) { getURLForTransition(url) {

View File

@ -48,3 +48,4 @@ Feature: dc / kvs / create
And I click kv on the kvs And I click kv on the kvs
And I click create And I click create
And I see the text "New Key / Value" in "h1" And I see the text "New Key / Value" in "h1"
And I see the text "key-value" in "[data-test-breadcrumbs] li:nth-child(2) a"