Skip to content

Commit

Permalink
ui: [BUGFIX] Ensure in-folder KVs are created in the correct folder (#…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
johncowen authored and John Cowen committed Jul 15, 2021
1 parent 70f29c2 commit 244cd15
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 5 deletions.
3 changes: 3 additions & 0 deletions .changelog/10569.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
```release-note:bug
ui: Ensure in-folder KVs are created in the correct folder
```
2 changes: 1 addition & 1 deletion ui/packages/consul-ui/app/components/app-view/index.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
<div>
<div>
{{#if authorized}}
<nav aria-label="Breadcrumb">
<nav aria-label="Breadcrumb" data-test-breadcrumbs>
<YieldSlot @name="breadcrumbs">
{{document-attrs class="with-breadcrumbs"}}
{{yield}}
Expand Down
11 changes: 7 additions & 4 deletions ui/packages/consul-ui/app/locations/fsm-with-optional.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,9 @@ if (env('CONSUL_NSPACES_ENABLED')) {
}

const trailingSlashRe = /\/$/;
const moreThan1SlashRe = /\/{2,}/g;

// see below re: ember double slashes
// const moreThan1SlashRe = /\/{2,}/g;

const _uuid = function() {
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, c => {
Expand Down Expand Up @@ -123,15 +125,16 @@ export default class FSMWithOptionalLocation {
}

getURLFrom(url) {
// remove trailing slashes if they exists
// remove trailing slashes if they exist
url = url || this.location.pathname;
this.rootURL = this.rootURL.replace(trailingSlashRe, '');
this.baseURL = this.baseURL.replace(trailingSlashRe, '');
// remove baseURL and rootURL from start of path
return url
.replace(new RegExp(`^${this.baseURL}(?=/|$)`), '')
.replace(new RegExp(`^${this.rootURL}(?=/|$)`), '')
.replace(moreThan1SlashRe, '/'); // remove extra slashes
.replace(new RegExp(`^${this.rootURL}(?=/|$)`), '');
// ember default locations remove double slashes here e.g. '//'
// .replace(moreThan1SlashRe, '/'); // remove extra slashes
}

getURLForTransition(url) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,3 +48,4 @@ Feature: dc / kvs / create
And I click kv on the kvs
And I click create
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"

0 comments on commit 244cd15

Please sign in to comment.