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-8720] - One ImageSelect to rule them all #11058

Merged
merged 16 commits into from
Oct 29, 2024

Conversation

abailly-akamai
Copy link
Contributor

@abailly-akamai abailly-akamai commented Oct 8, 2024

Description 📝

This PR consolidates the three different ImageSelect we had in the codebase.

  1. src/components/ImageSelectV2
  2. src/components/ImageSelect (legacy)
  3. src/features/Images/ImageSelect (used in StackscriptCreate for instance)

It unifies the experience for every feature where an image picker is featured and cleans up the codebase accordingly from unnecessary utils.

Changes 🔄

  • Consolidate ImageSelect to include treatment, styling and interfaces of all ImageSelect components, including the "All/Any" and multiple options
  • Fix sorting of groups and options
    • Groups are sorted alphabetically, with the exception of private images ("My Images") being first
    • Within groups, options are sorted by the created property (latests release first)
  • Get rid of console warnings for
    • ImageSelect
    • Dialog (unrelated but caught while testing)
  • e2e updates to look for the new Autocomplete
  • unit coverage updates and improvements
  • cleanup

Target release date 🗓️

Before (stackscript create, for instance) After
Screenshot 2024-10-22 at 14 01 03 Screenshot 2024-10-22 at 14 00 40

How to test 🧪

Prerequisites

Verification steps

Verify the behavior and content of the following UIs while comparing to their production equivalent:

  • /linode/create (no changes)
  • /linodes/create?type=Images (no changes)
  • /linodes > Action menu > Rebuild
    • rebuild from image (no changes)
    • rebuild from stackscript (no changes)
  • linode/{id}/storage (linode must be powered down) > Add Disk > Create from Image (old grouping replaced)
  • stackscripts/create (old grouping replaced)

As an Author I have considered 🤔

Check all that apply

  • 👀 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

@abailly-akamai abailly-akamai self-assigned this Oct 8, 2024
@abailly-akamai abailly-akamai force-pushed the M3-8720 branch 7 times, most recently from e883123 to 4585ec3 Compare October 17, 2024 15:54
@abailly-akamai abailly-akamai force-pushed the M3-8720 branch 3 times, most recently from 68d5676 to ba20dbb Compare October 22, 2024 13:55
@abailly-akamai abailly-akamai changed the title refactor: [M3-8720] - Fully deprecate ImageSelect v1 refactor: [M3-8720] - One ImageSelect to rule them all Oct 22, 2024
...rest
} = props;
export const Dialog = React.forwardRef(
(props: DialogProps, ref: React.Ref<HTMLDivElement>) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unrelated to ImageSelect changes but why not fixing here 🧹

The only change here (the rest is indenting) is to forward to ref to avoid console errors such as in /linodes
Should silence quite a bunch of warnings.

Screenshot 2024-10-22 at 13 33 26

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The diff looks weird here cause it looks like we are modifying the whole component, but it is because ImageOptionV2 is being renamed to ImageOption which was our legacy component (now deleted)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Same comment about the diff size

<EnhancedSelect
onChange={(selected: Item<MODES>) => {
setMode(selected.value);
<Autocomplete
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Taking this opportunity to replace this old deprecated Select with our new Autocomplete. one more down!

const { data: regionsData, isLoading: isLoadingRegions } = useRegionsQuery();
const isLoading = isLoadingPreferences || isLoadingImages || isLoadingRegions;
const isLoading = isLoadingPreferences || isLoadingRegions;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We're not fetching images from the parent anymore

errorText={imageFieldError}
onChange={onImageChange}
value={selectedImage}
variant="all"
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 am requiring the variant property now, forces to make a decision since it affects API filtering

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changes to the stackscript create is due to removing fetching from the class component, which in turns allows us to fully get rid of the withImages HOC 🎉

@abailly-akamai abailly-akamai marked this pull request as ready for review October 22, 2024 18:20
@abailly-akamai abailly-akamai requested review from a team as code owners October 22, 2024 18:20
@abailly-akamai abailly-akamai requested review from jdamore-linode, hana-akamai and cpathipa and removed request for a team October 22, 2024 18:20
Copy link

github-actions bot commented Oct 22, 2024

Coverage Report:
Base Coverage: 87.05%
Current Coverage: 87.15%

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.

Looking solid on my initial pass!

I'm noticing that re-opening the ImageSelect does not scroll the currently selected Image into view like it use to

Screen.Recording.2024-10-22.at.4.50.43.PM.mov

@abailly-akamai
Copy link
Contributor Author

@bnussman-akamai Yeah great catch, one has to be careful when overriding with renderGroup - turns out it wasn't needed since it was to remedy the deepMerge style deprecation which is now fixed 👍

@bnussman-akamai
Copy link
Member

Heads up: I think there is a crash on the multi-select. I was seeing it on the StackScript create page

@abailly-akamai
Copy link
Contributor Author

@bnussman-akamai yes thank you, rebase gone wrong - fixed (this will also fix the e2e)

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.

Looks great!

Didn't spot any regressions on the flows I checked, only improvements! The consistancy across all of the flows is great

So glad to finally have only one ImageSelect 🎉 🙏

@hana-akamai
Copy link
Contributor

Nice work, no regressions noticed! 🧹 Looks like there's some merge conflicts to resolve

Copy link
Contributor

@coliu-akamai coliu-akamai left a comment

Choose a reason for hiding this comment

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

✅ confirmed tests pass
✅ confirmed flows listed in verification steps

this is awesome and so much nicer and consistent - thanks Alban!! 🚀 🎉

@abailly-akamai abailly-akamai merged commit 0cbb976 into linode:develop Oct 29, 2024
23 checks passed
Copy link

cypress bot commented Oct 29, 2024

Cloud Manager E2E    Run #6754

Run Properties:  status check passed Passed #6754  •  git commit 0cbb976196: refactor: [M3-8720] - One `ImageSelect` to rule them all (#11058)
Project Cloud Manager E2E
Branch Review develop
Run status status check passed Passed #6754
Run duration 25m 43s
Commit git commit 0cbb976196: refactor: [M3-8720] - One `ImageSelect` to rule them all (#11058)
Committer Alban Bailly
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 1
Tests that did not run due to a developer annotating a test with .skip  Pending 2
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 445
View all changes introduced in this branch ↗︎

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

Successfully merging this pull request may close these issues.

4 participants