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

Create sections for Secrets sync destination fields for create/edit view #27538

Merged
merged 18 commits into from
Jun 27, 2024

Conversation

Monkeychip
Copy link
Contributor

@Monkeychip Monkeychip commented Jun 19, 2024

Description

Creates a separate section for updating sensitive creds on Secrets sync create/edit form.

  • enterprise test pass

Designs:
image

Implementation create:
image

Implementation edit:
image

@Monkeychip Monkeychip added the ui label Jun 19, 2024
@Monkeychip Monkeychip added this to the 1.18.0-rc milestone Jun 19, 2024
@github-actions github-actions bot added the hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed label Jun 19, 2024
Copy link

github-actions bot commented Jun 19, 2024

CI Results:
All Go tests succeeded! ✅

@Monkeychip Monkeychip changed the title WIP: update Secrets sync destination fields for create/edit view Create sections for Secrets sync destination fields for create/edit view Jun 20, 2024
@Monkeychip Monkeychip marked this pull request as ready for review June 20, 2024 15:34
@Monkeychip Monkeychip requested a review from a team as a code owner June 20, 2024 15:34
Copy link

Build Results:
All builds succeeded! ✅

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

A couple of questions! Could you include a screenshot of the edit view as well?

@Monkeychip Monkeychip requested a review from hellobontempo June 21, 2024 15:31
Comment on lines 20 to 23
Connection credentials are sensitive information
{{#if @destination.isNew}} used to authenticate with the destination. {{else}}
and the value cannot be read. Enable the input to update.
{{/if}}
Copy link
Contributor

@hellobontempo hellobontempo Jun 21, 2024

Choose a reason for hiding this comment

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

There is a lot more logic now that relies on whether a model isNew or not. Could we add test coverage for this logic?

Copy link
Contributor Author

@Monkeychip Monkeychip Jun 26, 2024

Choose a reason for hiding this comment

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

Done and dusted. Note the maskedInput vs wrapped maskedInputs by the enableInput component on create vs edit are covered in the create-and-edit test. They're a little hard to see. I added one for create in this PR. And the edit masked check is done by calling enableInput on the test here. If those values were not wrapped by the correct component, you couldn't find this value.

this.model = this.generateModel();

await this.renderFormComponent();
assert.dom(PAGE.breadcrumbs).hasText('Secrets Sync Destinations Destination Edit Destination');
assert.dom('h2').hasText('Credentials', 'renders credentials section on edit');
assert
Copy link
Contributor Author

Choose a reason for hiding this comment

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

moved this into a subtext specific test

@Monkeychip Monkeychip requested a review from hellobontempo June 27, 2024 14:20
class="has-bottom-margin-m"
data-test-destination-subText={{group}}
>
{{(this.groupSubtext group @destination.isNew)}}
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
{{(this.groupSubtext group @destination.isNew)}}
{{this.groupSubtext group @destination.isNew}}

class="has-bottom-margin-m"
data-test-destination-subText={{group}}
>
{{(this.groupSubtext group @destination.isNew)}}
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 passing in isNew here can we just access this.args.destination.isNew in the component helper?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that and then realized I was hitting issues because this is within an each iteration, so it's easier to access the destination by passing it in like this.

Comment on lines +59 to +62
groupSubtext(group: string, isNew: boolean) {
const dynamicText = isNew
? 'used to authenticate with the destination'
: 'and the value cannot be read. Enable the input to update';
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
groupSubtext(group: string, isNew: boolean) {
const dynamicText = isNew
? 'used to authenticate with the destination'
: 'and the value cannot be read. Enable the input to update';
groupSubtext(group: string) {
const dynamicText = this.args.destination.isNew
? 'used to authenticate with the destination'
: 'and the value cannot be read. Enable the input to update';

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I went this exact same route, but it fails to read the args. It might be because I'm iterating over via a each and then each-in and then an each again, but passing in via the template solved the problem
image

Copy link
Contributor

Choose a reason for hiding this comment

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

strange! it must be how the template helper functions compile 🤔

Comment on lines 88 to 89
const { type } = SYNC_DESTINATIONS[0];
this.model = this.store.createRecord(`sync/destinations/${type}`, { type });
Copy link
Contributor

Choose a reason for hiding this comment

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

If you look at the test above, this needs to be updated to the following to accurately render the edit view

Suggested change
const { type } = SYNC_DESTINATIONS[0];
this.model = this.store.createRecord(`sync/destinations/${type}`, { type });
const { type } = SYNC_DESTINATIONS[0];
this.model = this.generateModel()

Copy link
Contributor

Choose a reason for hiding this comment

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

Also since these are "it renders" related tests, the assertions below could also just move into the test above. I don't think separate subtext tests are needed since the existing "edit: it renders" and "create: it renders" are so small already

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Good catch re: 1st comment.

Re 2nd comment: I broke these up because I wanted to isolate the isNew functionality from the transition and breadcrumbs. However, let me clear up the tests a bit to make that more evident.

Copy link
Contributor

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

Just one assertion update then this is good to go!

@Monkeychip Monkeychip requested a review from hellobontempo June 27, 2024 17:36
@@ -56,13 +56,18 @@ module('Integration | Component | sync | Secrets::Page::Destinations::CreateAndE
assert.true(transition, 'transitions to vault.cluster.sync.secrets.destinations.create on cancel');
});

test('create: it renders fieldGroups subtext', async function (assert) {
assert.expect(2);
test('create: it renders headers and fieldGroups subtext', async function (assert) {
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

@hellobontempo hellobontempo left a comment

Choose a reason for hiding this comment

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

Thanks for addressing that final cleanup! Looks great! 🚀

@Monkeychip Monkeychip merged commit 84aeec0 into main Jun 27, 2024
31 checks passed
@Monkeychip Monkeychip deleted the ui/VAULT-28051-add-gh-destination branch June 27, 2024 18:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hashicorp-contributed-pr If the PR is HashiCorp (i.e. not-community) contributed ui
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants