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-6934] MUI v5 Migration - SRC > Features > Linodes pt 1 #9445

Merged
merged 25 commits into from
Aug 1, 2023

Conversation

coliu-akamai
Copy link
Contributor

@coliu-akamai coliu-akamai commented Jul 24, 2023

Description 📝

Part of migrating SRC > Features > Firewalls from MUI v4 to v5 -- breaking this PR up since there will be a lot of files. This specific pr is for styling changes: running the codemod, and then converting styles to styled components / sx if possible.

There will be a later PR for fixing up imports/exports, etc later

Major Changes 🔄

  • removes any imports from MUI v4
  • switch to styled components or use sx prop for styling

Preview 📷

How to test 🧪

  1. Go to the /linodes section locally and test to make sure that all functionality and styling works and looks as expected

@@ -290,16 +266,11 @@ export const RebuildFromStackScript = (props: Props) => {
resetSelectedStackScript={resetStackScript}
selectedId={ss.id}
selectedUsername={ss.username}
updateFor={[classes, ss.id, errors]}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since classes was just a Record<classes from the makeStyles, string> after the tss codemod (and just a ClassNameMap before), I think removing them from here should be ok? Seems like it was being checked in the renderGuard hoc

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes that's fine

return (
<TableRow
ariaLabel={label}
className={classes.bodyRow}
data-qa-linode={label}
data-qa-loading
key={id}
onMouseEnter={handleMouseEnter}
onMouseLeave={handleMouseLeave}
Copy link
Contributor

Choose a reason for hiding this comment

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

Just giving some context on why I made this change: Instead of having the parent component control the state of it's child using very specific css selectors (see LinodeRow.style.ts), I believe the component itself should be responsible for it's own state changes. By passing down an isHovered prop, the child component can toggle the copy icon itself.

className={`${classes.row} ${showAll && classes.multipleAddresses}`}
key={key}
<StyledRenderIPDiv
{...handlers}
Copy link
Contributor

Choose a reason for hiding this comment

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

Same goes for this, see my comment here. In this case, we're conditionally applying the handlers since we only need them if showTooltipOnIpHover is true

@@ -0,0 +1,14 @@
import Grid from '@mui/material/Unstable_Grid2';
Copy link
Contributor Author

Choose a reason for hiding this comment

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

saw that a lot of files had the same styling for a component, so I created a separate 'common' styling file for the package -- would this be fine? or is there another approach?

Copy link
Contributor

Choose a reason for hiding this comment

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

@coliu-akamai Yes! We need to do this

Comment on lines 148 to 149
sx={{ tooltip: { maxWidth: 300 } }} // ???
// classes={{ tooltip: classes.maintenanceTooltip }}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

is this feasible? unsure if this is the correct way to get the same behavior

@@ -200,12 +209,12 @@ export const RenderFlag: React.FC<{
* or if it has a pending mutation available. Mutations take
* precedent over notifications
*/
const { classes, linodeNotifications, mutationAvailable } = props;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed classes from the RenderFlag props, as it seemed it wasn't being used anyway (classes.flag was not a thing in the linode row styles anyway)

@@ -158,6 +127,8 @@ const LinodeNetworking = () => {
};

const renderIPRow = (ipDisplay: IPDisplay) => {
// TODO: in order to fully get rid of makeStyles for this file, may need to convert this to a functional component
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Tried converting to styled componets/sx for components with classes.row and classes.copy, but this led to some styling behavior at first being lost. Possible solution to fully get rid of makestyles would likely be very similar to the stuff done in IPAddress.tsx/LinodeRow.tsx

Copy link
Contributor

@jaalah-akamai jaalah-akamai left a comment

Choose a reason for hiding this comment

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

Nice improvements and updates

@bnussman-akamai bnussman-akamai added the Add'tl Approval Needed Waiting on another approval! label Aug 1, 2023
Copy link
Member

@bnussman-akamai bnussman-akamai left a comment

Choose a reason for hiding this comment

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

Styles look good to me! 🎨

@bnussman-akamai bnussman-akamai added Approved Multiple approvals and ready to merge! and removed Add'tl Approval Needed Waiting on another approval! labels Aug 1, 2023
@coliu-akamai coliu-akamai merged commit 5011b48 into linode:develop Aug 1, 2023
jaalah-akamai pushed a commit that referenced this pull request Aug 7, 2023
#9445)

* refactor [m3-6272] begin using codemod

* refactor [m3-6272] continue switching to tss react

* codemod to LinodesDetail

* refactor [m3-6272] migrate linode create styles

* IPAddress test difficulties

* fix some styling

* some more ip styling but some weird things going on

* narrowing down a source of styling pain

* need to look into this IP test

* testing ip address

* converting to styled components or sx

* more style conversions

* Improve linode ip address tooltip

* Fix focus

* rest of styling

* it was not the rest of styling

* cleanup of styling

* fix up styling

* Added changeset: MUI v5 Migration > SRC > Features > Linodes Pt 1

* all styles converted(except one file, see pr comment), for real this time

---------

Co-authored-by: Jaalah Ramos <[email protected]>
jaalah-akamai pushed a commit that referenced this pull request Aug 7, 2023
#9445)

* refactor [m3-6272] begin using codemod

* refactor [m3-6272] continue switching to tss react

* codemod to LinodesDetail

* refactor [m3-6272] migrate linode create styles

* IPAddress test difficulties

* fix some styling

* some more ip styling but some weird things going on

* narrowing down a source of styling pain

* need to look into this IP test

* testing ip address

* converting to styled components or sx

* more style conversions

* Improve linode ip address tooltip

* Fix focus

* rest of styling

* it was not the rest of styling

* cleanup of styling

* fix up styling

* Added changeset: MUI v5 Migration > SRC > Features > Linodes Pt 1

* all styles converted(except one file, see pr comment), for real this time

---------

Co-authored-by: Jaalah Ramos <[email protected]>
jaalah-akamai pushed a commit that referenced this pull request Aug 8, 2023
#9445)

* refactor [m3-6272] begin using codemod

* refactor [m3-6272] continue switching to tss react

* codemod to LinodesDetail

* refactor [m3-6272] migrate linode create styles

* IPAddress test difficulties

* fix some styling

* some more ip styling but some weird things going on

* narrowing down a source of styling pain

* need to look into this IP test

* testing ip address

* converting to styled components or sx

* more style conversions

* Improve linode ip address tooltip

* Fix focus

* rest of styling

* it was not the rest of styling

* cleanup of styling

* fix up styling

* Added changeset: MUI v5 Migration > SRC > Features > Linodes Pt 1

* all styles converted(except one file, see pr comment), for real this time

---------

Co-authored-by: Jaalah Ramos <[email protected]>
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!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants