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-6258] - React Query for SSH Keys #8892

Merged

Conversation

bnussman-akamai
Copy link
Member

@bnussman-akamai bnussman-akamai commented Mar 17, 2023

Description 📝

  • Uses React Query for SSH Keys
  • API paginates http://localhost:3000/profile/keys
  • Adds ability for users to edit the label of their ssh keys
    • The API has had this functionality, we just didn't implement it
  • This was a lot more difficult than expected because SSH keys are used on Linode creation flows

How to test 🧪

  • Test all actions possible on http://localhost:3000/profile/keys
  • Test the following with at least one SSH Key on your account and please perform these actions as *both a normal user and as a restricted user
    • Test Creating a Linode with an SSH Key
    • Test rebuilding a Linode from an Image with an SSH Key
    • Test rebuilding a Linode from a Stackscript with an SSH Key

@bnussman-akamai bnussman-akamai added Work in Progress React Query Relating to the transition to use React Query labels Mar 17, 2023
@bnussman-akamai bnussman-akamai self-assigned this Mar 17, 2023
@bnussman-akamai bnussman-akamai marked this pull request as ready for review March 17, 2023 20:25
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Going to take a deeper look later today or sometime tomorrow but left a couple of small comments

packages/manager/src/queries/profile.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

  • I tried rebuilding with an Image & SSH key and with a StackScript & SSH key but ran into a Service unavailable [1.10] API error earlier, so I will circle back around to testing that.

  • If you edit an SSH key, clear out the label, and click "Save", the error persists if you close the drawer and go back to edit it. It also persists across different SSH keys (i.e., if you get up to the error on one, then you exit that drawer and go to edit another key, the error will show up there too)

packages/manager/src/utilities/stringUtils.test.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@cpathipa cpathipa left a comment

Choose a reason for hiding this comment

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

Not able to run the app locally.
image

@@ -0,0 +1,75 @@
import * as React from 'react';
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for adding test coverage!

Comment on lines +29 to +47
actions={
<ActionsPanel>
<Button
buttonType="secondary"
onClick={onClose}
data-qa-cancel-delete
>
Cancel
</Button>
<Button
buttonType="primary"
onClick={onDelete}
loading={isLoading}
data-qa-confirm-delete
>
Delete
</Button>
</ActionsPanel>
}
Copy link
Contributor

Choose a reason for hiding this comment

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

nit-picky: We could decouple this ActionsPanel and define it upper level.
Note: For naming convention, we could follow existing pattern.

  const Actions = (
    <ActionsPanel>
      <Button buttonType="secondary" onClick={onClose} data-qa-cancel-delete>
        Cancel
      </Button>
      <Button
        buttonType="primary"
        onClick={onDelete}
        loading={isLoading}
        data-qa-confirm-delete
      >
        Delete
      </Button>
    </ActionsPanel>
  );

  return (
    <ConfirmationDialog
      open={open}
      onClose={onClose}
      title="Delete SSH Key"
      error={error?.[0].reason}
      actions={Actions}
    >
      <Typography>Are you sure you want to delete SSH key {label}?</Typography>
    </ConfirmationDialog>
  );
};

@bnussman-akamai
Copy link
Member Author

@cpathipa You may need to run rm -rf node_modules/.vite from the repo's root to clear the vite cache. The app runs fine for me.

@cpathipa cpathipa added Add'tl Approval Needed Waiting on another approval! and removed Under Review labels Mar 24, 2023
@cpathipa
Copy link
Contributor

@bnussman-akamai FYI - A few files have conflicts that should be resolved.

Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

The edit --> empty label interaction is still a bit off from what I'd expect; in this clip, I clear the label, try to save, get the error, and close the drawer. But when I re-open the drawer, although the error is cleared, the label field itself is still empty (instead of having the current label):

Edit "Label" field interaction
Screen.Recording.2023-03-24.at.3.12.55.PM.mov

Aside from that, looks like something odd is going on for restricted users in the "SSH Keys" table in the Linode Create and Rebuild flows?

Screenshot 2023-03-22 at 12 26 32 PM

@hkhalil-akamai
Copy link
Contributor

Only seeing one minor regression...
Screen Shot 2023-03-24 at 3 43 00 PM

Copy link
Contributor

@hkhalil-akamai hkhalil-akamai left a comment

Choose a reason for hiding this comment

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

Really great clean-up/refactoring; unit tests are a plus

@bnussman-akamai
Copy link
Member Author

Very helpful feedback, thank you @dwiley-akamai. Should all be addressed in 5d25bf3

@cpathipa cpathipa added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Mar 28, 2023
Copy link
Contributor

@dwiley-akamai dwiley-akamai left a comment

Choose a reason for hiding this comment

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

Looks good, thanks for addressing that feedback! 🚀

@bnussman-akamai bnussman-akamai merged commit 850aa63 into linode:develop Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Approved Multiple approvals and ready to merge! React Query Relating to the transition to use React Query Ready for Review
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants