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

Icu 16534 refactor usage of tracked using this args #2711

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

lisbet-alvarez
Copy link
Collaborator

@lisbet-alvarez lisbet-alvarez commented Mar 7, 2025

🎟️ Jira ticket

Description

This refactor is in preparation for ember upgrade that will update eslint which comes with some new rules. One of them is disallowing usage of this.args with @tracked. Our usage was limited to initializing tracked variables so that was refactored to use getters instead to initialize.

How to Test

  1. Use vercel deployments or checkout branch locally
  2. Verify aws host catalog form(credential type radio buttons) work as expected.
  3. Verify aws storage bucket form work as expected.
  4. Verify worker filter generator toggle works as expected.

Checklist

  • I have added before and after screenshots for UI changes
  • I have added JSON response output for API changes
  • I have added steps to reproduce and test for bug fixes in the description
  • I have commented on my code, particularly in hard-to-understand areas
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works

Copy link

vercel bot commented Mar 7, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
boundary-ui ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 9:00pm
boundary-ui-desktop ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 11, 2025 9:00pm

@lisbet-alvarez lisbet-alvarez marked this pull request as ready for review March 10, 2025 18:09
@lisbet-alvarez lisbet-alvarez requested a review from a team as a code owner March 10, 2025 18:09
if (DYNAMIC_CREDENTIAL_FIELDS.some((field) => this[field])) {
this.#credentialType = TYPE_CREDENTIAL_DYNAMIC;
return TYPE_CREDENTIAL_DYNAMIC;
Copy link
Collaborator

Choose a reason for hiding this comment

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

None blocking comment:
The previous implementation checks if this.credentialType exists.
If it doesn't, it sets a value.
At the end, it always returns this.credentialType

The new implementation checks if this.credentialType exists.
If it doesnt', returns a value. BUT, and here is my questions, never sets the credentialType @Tracked property. I have nothing against, I would like to learn Why we change the approach on this?
If it does, returns the this.credentialType

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Great question, this getter shouldn't set the value of credentialType once it was changed to be tracked because we get this error. It also doesn't need to set the value for credentialType because the getter takes care of returning the correct type on initial load (when the private variable credentialType is undefined).

@calcaide
Copy link
Collaborator

Looking great so far!! left a couple of comments and will wait on other feedback too 😉

// If the role_arn is empty, then the credential type should be static
if (!storageBucket.role_arn) {
storageBucket.credentialType = TYPE_CREDENTIAL_STATIC;
}
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

if user has an existing storage bucket with static credential type and edits type to dynamic credential without entering a role_arn value then on save it will show type change to 'dynamic' even though its still static. So this change was added so that type stays as 'static'. We already do the same for host-catalogs.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch!

Copy link
Collaborator

@ZedLi ZedLi left a comment

Choose a reason for hiding this comment

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

Looks great!

// If the role_arn is empty, then the credential type should be static
if (!storageBucket.role_arn) {
storageBucket.credentialType = TYPE_CREDENTIAL_STATIC;
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Good catch!

Copy link
Collaborator

@DhariniJeeva DhariniJeeva left a comment

Choose a reason for hiding this comment

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

Thank you for the refactor! 🎉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants