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

Custom tooltip for Generated Token Policies form field on auth methods #15046

Merged
merged 13 commits into from
Apr 14, 2022

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Apr 14, 2022

This PR intercepts the model on the generatedItem component to replace the helpText for the auth form field "Generated Token's Policies"

Before the help text read: Comma-separated list of policies associated with the user.

However, this field (e.g form field = stringArray) does not accept comma separated lists. We instead want a user to add a row for each new policy. We cannot change the text here because that changes the CLI text which does accept a comma separated list. So instead, we interrupt the component, search for this field type and replace the helpText with the following: Add policies that will apply to the generated token for this user. One policy per row.

This now looks like this:
image

This change effects TLS Certificates, Userpass, and Kubernetes who have this field. The other auth methods have a different field or no policy field at all.

Will backport to 1.8

See GH issue here.

@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 17:26 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 17:28 Inactive
@Monkeychip Monkeychip added ui bug Used to indicate a potential bug labels Apr 14, 2022
@Monkeychip Monkeychip added this to the 1.11.0-rc1 milestone Apr 14, 2022
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 14, 2022 17:34 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 17:43 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 17:48 Inactive
@vercel vercel bot temporarily deployed to Preview – vault April 14, 2022 17:49 Inactive
@vercel vercel bot temporarily deployed to Preview – vault-storybook April 14, 2022 17:51 Inactive
Copy link
Contributor

@hashishaw hashishaw left a comment

Choose a reason for hiding this comment

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

Nice work tracking this down! Small change request, let me know if that doesn't work for some reason

// HelpText from the backend says add a comma separated list, which works on the CLI but not here on the UI.
// This effects TLS Certificates, Userpass, and Kubernetes. https://github.com/hashicorp/vault/issues/10346
if (element.Tokens) {
element.Tokens.forEach((attr) => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Instead of iterating over all of them can we do element.Tokens.find(attr => attr.name === 'tokenPolicies') and then update it if found? That way iteration will stop once the item is found, or have the same behavior as iterating over each if not found

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great idea. Amending.

@@ -69,6 +70,18 @@ module('Acceptance | auth backend list', function (hooks) {
await triggerKeyEvent('[data-test-input="username"]', 'keyup', 65);
await fillIn('[data-test-textarea]', user2);
await triggerKeyEvent('[data-test-textarea]', 'keyup', 65);
// test for modified helpText on generated token policies
await click('[data-test-toggle-group="Tokens"]');
Copy link
Contributor

Choose a reason for hiding this comment

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

👏

Copy link
Contributor

@hashishaw hashishaw left a comment

Choose a reason for hiding this comment

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

🚀

@Monkeychip Monkeychip merged commit c9ce3fd into main Apr 14, 2022
@Monkeychip Monkeychip deleted the ui/fix-tooltip branch April 15, 2022 16:42
kitography pushed a commit that referenced this pull request Apr 24, 2022
#15046)

* the conditional fix

* add test coverage

* changelog

* add possesive

* fix language

* fix

* fix

* change quotes

* fix

* replace with find
schultz-is pushed a commit that referenced this pull request Apr 27, 2022
#15046)

* the conditional fix

* add test coverage

* changelog

* add possesive

* fix language

* fix

* fix

* change quotes

* fix

* replace with find
schultz-is pushed a commit that referenced this pull request May 2, 2022
#15046)

* the conditional fix

* add test coverage

* changelog

* add possesive

* fix language

* fix

* fix

* change quotes

* fix

* replace with find
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Used to indicate a potential bug ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants