Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ui: Fixup KV folder creation then further creation within that folder #12081

Merged
merged 5 commits into from
Jan 19, 2022

Conversation

johncowen
Copy link
Contributor

Fixes #12073

See ^ for details.

The KV edit/form flow is one of our oldest form flows and it is currently a little bit of a mash up of mostly one of our old ways of doing forms with a tiny bit of cross over into our newer way of doing forms (the idea is soon to most entirely to new style forms the same as our namespace and partitions forms).

The fix here is two fold:

  1. We shouldn't be providing the DataSource (which loads the data) with an id when we are creating from within a folder (in the buggy code we are providing the parentKey of the new KV you are creating)
  2. Being able to provide an empty id to the DataSource/KV repository and that repository responding with a newly created object is more towards the "new way of doing forms", therefore the corresponding code to return a newly created ember-data object. As we changed the actual bug in point 1 here, we need to make sure the repository responds with an empty object when the request id is empty.

John Cowen added 4 commits January 14, 2022 12:39
Passing '' should load a brand new `isNew` model which is what we need
here
...to return a brand new model, therefore isNew will be set
@johncowen johncowen added theme/ui Anything related to the UI backport/1.11 labels Jan 14, 2022
@johncowen johncowen changed the title UI/bugfix/in folder creates ui: Fixup KV folder creation then further creation within that folder Jan 14, 2022
Copy link
Contributor Author

@johncowen johncowen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Notes:

@@ -16,7 +16,7 @@ as |parentKey|}}
partition=route.params.partition
nspace=route.params.nspace
dc=route.params.dc
key=(if (string-ends-with routeName 'create') parentKey route.params.key)
key=(if (string-ends-with routeName 'create') '' route.params.key)
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was the actual bug

});
} else {
item = await super.findBySlug(...arguments);
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This bit makes the "pass an empty id to get a new ember-data object" work

And I click "[data-test-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"
And I see the "[data-test-kv-key]" element
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Test was mainly copy/pasted from the above (not visible unless you view the entire file). We were already testing: "creating a folder" and "clicking create from within a folder" but not "creating a folder and then immediately clicking create form within that folder".

I also noticed that we weren't asserting for existence of the input field in the "clicking create from within a folder" test that already existed. Whilst this test wasn't failing even with the extra assertion, I thought it would be a good idea to add here to helper prevent any possible regression in the future (line 52)

@johncowen johncowen requested review from jgwhite, a user, amyrlam and natmegs January 14, 2022 13:36
@vercel vercel bot temporarily deployed to Preview – consul-ui-staging January 14, 2022 17:42 Inactive
@vercel vercel bot temporarily deployed to Preview – consul January 14, 2022 17:42 Inactive
@jkirschner-hashicorp
Copy link
Contributor

This is just a QA test; someone else needs to conduct the front-end engineering review

As far as I can tell, this fix does address the bug.

I ran this against a locally running Consul client agent (v1.11.x) via:

~/go/src/github.com/hashicorp/consul/ui/packages/consul-ui$ CONSUL_HTTP_ADDR=http://localhost:8500 make start-consul

With that setup, I can no longer reproduce the bug with the steps described above.

Copy link

@amyrlam amyrlam left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code 👍

@johncowen
Copy link
Contributor Author

Thanks for checking that for me @jkirschner-hashicorp, also super glad you found it easy to test the reproduction.

~/go/src/github.com/hashicorp/consul/ui/packages/consul-ui$ CONSUL_HTTP_ADDR=http://localhost:8500 make start-consul

FYI (and anyone else who may read this) you can just do also:

~/go/src/github.com/hashicorp/consul/ui/packages/consul-ui$ make start-consul

As localhost:8500 is fairly common I made it so it will just use that by default if you don't set it.

@johncowen johncowen merged commit cdb8a35 into main Jan 19, 2022
@johncowen johncowen deleted the ui/bugfix/in-folder-creates branch January 19, 2022 10:09
@hc-github-team-consul-core
Copy link
Collaborator

🍒 If backport labels were added before merging, cherry-picking will start automatically.

To retroactively trigger a backport after merging, add backport labels and re-run https://circleci.com/gh/hashicorp/consul/557877.

@hc-github-team-consul-core
Copy link
Collaborator

🍒✅ Cherry pick of commit cdb8a35 onto release/1.11.x succeeded!

hc-github-team-consul-core pushed a commit that referenced this pull request Jan 19, 2022
…#12081)

The fix here is two fold:

- We shouldn't be providing the DataSource (which loads the data) with an id when we are creating from within a folder (in the buggy code we are providing the parentKey of the new KV you are creating)
- Being able to provide an empty id to the DataSource/KV repository and that repository responding with a newly created object is more towards the "new way of doing forms", therefore the corresponding code to return a newly created ember-data object. As we changed the actual bug in point 1 here, we need to make sure the repository responds with an empty object when the request id is empty.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
theme/ui Anything related to the UI
Projects
None yet
Development

Successfully merging this pull request may close these issues.

In GUI, unable to create keys within a KV folder (Consul 1.11.x)
4 participants