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

refactor: [M3-9211] - Refactor Linode Rebuild Dialog #11629

Conversation

bnussman-akamai
Copy link
Member

Description 📝

  • Refactors the Linode Rebuild Dialog to use react-hook-form 🧹
    • Makes some small UI tweaks, but should be feature parity (or better)
    • This form is quite complex, so help me make sure it works correctly!
  • Remove unused code as a result of the refactor 🗑️
    • Removes lots of legacy StackScript code
    • Should help us remove a good bit of recompose
  • I am so sorry for the size of the diff 😥 I should have broken this up and saved the clean up for later
    • I wanted to add some more cypress testing, but I don't want to make the diff any crazier. I will follow up this PR with more testing. For now, this flow should continue to pass existing rebuild tests

Preview 📷

Before After
Screenshot 2025-02-06 at 7 10 39 PM Screenshot 2025-02-06 at 7 11 02 PM

How to test 🧪

  • Test all aspects of the Linode Rebuild dialog
    • Verify you can rebuild from an Image
    • Verify you can rebuild from a StackScript
    • Verify you can rebuild with Metadata
    • Verify you can rebuild with StackScript User Defined Fields
    • Verify form validation works as expected
    • Verify type to confirm works as expected
    • Verify you can rebuild with and without Disk Encryption
Author Checklists

As an Author, to speed up the review process, I considered 🤔

👀 Doing a self review
❔ Our contribution guidelines
🤏 Splitting feature into small PRs
➕ Adding a changeset
🧪 Providing/improving test coverage
🔐 Removing all sensitive information from the code and PR description
🚩 Using a feature flag to protect the release
👣 Providing comprehensive reproduction steps
📑 Providing or updating our documentation
🕛 Scheduling a pair reviewing session
📱 Providing mobile support
♿ Providing accessibility support


  • I have read and considered all applicable items listed above.

As an Author, before moving this PR from Draft to Open, I confirmed ✅

  • All unit tests are passing
  • TypeScript compilation succeeded without errors
  • Code passes all linting rules

@bnussman-akamai bnussman-akamai self-assigned this Feb 7, 2025
@bnussman-akamai bnussman-akamai requested review from a team as code owners February 7, 2025 00:19
@bnussman-akamai bnussman-akamai requested review from dmcintyr-akamai and removed request for a team February 7, 2025 00:19
Copy link
Member Author

Choose a reason for hiding this comment

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

This is not really new code, it is just extracted from AccessPanel, which is now deleted 🗑️

@@ -107,12 +109,14 @@ export const Security = () => {
? DISK_ENCRYPTION_DEFAULT_DISTRIBUTED_INSTANCES
: DISK_ENCRYPTION_UNAVAILABLE_IN_REGION_COPY
}
isEncryptEntityChecked={
isDistributedRegion || field.value === 'enabled'
Copy link
Member Author

Choose a reason for hiding this comment

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

Local disk encryption is on by default for Compute Instances in distributed regions, and can't be turned off.

Comment on lines +43 to +46
const error = (
// @ts-expect-error UDFs don't abide by the form's error type. This is an api-v4 bug.
formState.errors?.[userDefinedField.name] ?? fieldState.error
)?.message?.replace('the UDF', '');
Copy link
Member Author

Choose a reason for hiding this comment

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

The POST /v4/linode/instances endpoint breaks normal error handling patterns. This is why a // @ts-expect-error is here. I updated this to support correct error shape so that client side errors also surface.

This change was necessary because the Linode Rebuild form does client side validation on UDF fields. This is something I'll probably circle back to and add to Linode Create

<ImageSelect
disabled={disabled}
errorText={imageFieldError}
onChange={onImageChange}
value={selectedImage}
variant="all"
/>
<StyledAccessPanel
Copy link
Member Author

@bnussman-akamai bnussman-akamai Feb 7, 2025

Choose a reason for hiding this comment

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

I went ahead an made this change so I could delete AccessPanel.

AccessPanel was an abstraction that was getting out of hand. Now we just use PasswordInput and UserSSHKeyPanel, etc... directly

Copy link
Member Author

Choose a reason for hiding this comment

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

I was confused as to why ImageAndPassword.tsx implemented restricted user support, but this whole form didn't. (This form uses ImageAndPassword)

I went ahead and moved the restricted user code up one level so that it now lives here instead of inside of ImageAndPassword.

Ultimately, I don't think it matters because I don't think restricted users can even open this drawer.

image: string().required('An image is required.'),
root_pass: string().required('Password is required.'),
authorized_keys: array().of(SSHKeySchema),
Copy link
Member Author

Choose a reason for hiding this comment

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

Unless there is an undocumented API easter egg I don't know about, this was wrong.

https://techdocs.akamai.com/linode-api/reference/post-rebuild-linode-instance

Copy link

github-actions bot commented Feb 7, 2025

Coverage Report:
Base Coverage: 78.94%
Current Coverage: 78.87%

@linode-gh-bot
Copy link
Collaborator

Cloud Manager UI test results

🔺 6 failing tests on test run #3 ↗︎

❌ Failing✅ Passing↪️ Skipped🕐 Duration
6 Failing494 Passing2 Skipped121m 40s

Details

Failing Tests
SpecTest
smoke-linode-landing-table.spec.tslinode landing checks » checks label and region sorting behavior for linode table
smoke-linode-landing-table.spec.tslinode landing checks » checks group by tag for linde table
smoke-linode-landing-table.spec.tslinode landing checks » checks summary view for linode table
smoke-linode-landing-table.spec.tslinode landing checks for non-empty state with restricted user » checks restricted user with read access has no access to create linode and can see existing linodes
backup-linode.spec.ts"Enable Linode Backups" banner » shows "Enable Linode Backups" banner
backup-linode.spec.ts"Enable Linode Backups" banner » can enable Linode backups via "Enable Linode Backups" notice

Troubleshooting

Use this command to re-run the failing tests:

yarn cy:run -s "cypress/e2e/core/linodes/smoke-linode-landing-table.spec.ts,cypress/e2e/core/linodes/backup-linode.spec.ts"

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.

3 participants