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

feat: show and hide environments #9323

Merged
merged 7 commits into from
Feb 19, 2025
Merged

feat: show and hide environments #9323

merged 7 commits into from
Feb 19, 2025

Conversation

Tymek
Copy link
Member

@Tymek Tymek commented Feb 18, 2025

About the changes

  • Button to show and hide environments
  • Refactored hook storing state of hidden environments
  • Changed the way flag is triggered for feature overview
  • Visual updates for new page look

Copy link

vercel bot commented Feb 18, 2025

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

Name Status Preview Comments Updated (UTC)
unleash-monorepo-frontend ✅ Ready (Inspect) Visit Preview 💬 Add feedback Feb 19, 2025 9:47am
1 Skipped Deployment
Name Status Preview Comments Updated (UTC)
unleash-docs ⬜️ Ignored (Inspect) Visit Preview Feb 19, 2025 9:47am

Copy link
Contributor

github-actions bot commented Feb 18, 2025

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

OpenSSF Scorecard

PackageVersionScoreDetails

Scanned Files

Copy link
Member Author

Choose a reason for hiding this comment

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

Copy for keeping a new version behind a flag

Copy link
Contributor

@thomasheartman thomasheartman left a comment

Choose a reason for hiding this comment

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

Got a fair few comments and questions, but nothing blocking. Some things will have to be checked/addressed before we start rolling it out (a11y stuff, babyyyyy), but I'm happy to put it in behind the flag.

Nice work!

Comment on lines 9 to 11
environments: Pick<FeatureEnvironmentSchema, 'name'>[];
hiddenEnvironments: FeatureEnvironmentSchema['name'][];
onChange: (name: FeatureEnvironmentSchema['name']) => void;
Copy link
Contributor

Choose a reason for hiding this comment

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

These are all strings or simple objects, right? Is there a particular benefit to depending on the openapi types for them? I don't see how they'll ever change, and these types stand out a lot more than just string or {name: string}.

Just thinking that if you're not that familiar with the schemas, you might need to go and look them up and everything, and I don't see what it adds here aside from ... more text.

I don't mind particularly, but I'd maybe stick with simpler types here instead. Especially for when the type is just string. I think there's a better case for using the Pick type.

Suggested change
environments: Pick<FeatureEnvironmentSchema, 'name'>[];
hiddenEnvironments: FeatureEnvironmentSchema['name'][];
onChange: (name: FeatureEnvironmentSchema['name']) => void;
environments: {name: string}[];
hiddenEnvironments: string[];
onChange: (name: string) => void;

But anyway: up to you 🤷🏼

Comment on lines +60 to +63
<Checkbox
onChange={() => onChange(name)}
checked={!hiddenEnvironments?.includes(name)}
/>
Copy link
Contributor

Choose a reason for hiding this comment

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

Again: I'm not sure how Menu works, but there's a couple things here that we might wanna change:

All form controls (that includes checkboxes), should have labels (according to MUI's accessibility notes for this component). In this case, you'd probably want to label it with the name of the env (so probably wrap the name of the env in a label and mark it as being for this checkbox).

But I'm not even sure we should have the checkbox here. How does it work with keyboard focus? Does it give you multiple tab stops within it? It looks like it's designed to be navigated by arrow keys and that tab takes you to the next item in the document flow, but I'm not sure whether adding an input field here messes with that or not. Regardless, I can imagine it being confusing for screen readers.

But based on how MUI uses the menu in their docs, maybe it's better to just use an icon instead of a form control? 💁🏼

Comment on lines +169 to +175
{onEnvironmentVisibilityChange ? (
<EnvironmentVisibilityMenu
environments={feature.environments || []}
hiddenEnvironments={hiddenEnvironments || []}
onChange={onEnvironmentVisibilityChange}
/>
) : null}
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is the onEnvironmentVisibilityChange function optional? Are there cases where we don't want you to do that?

Copy link
Member Author

Choose a reason for hiding this comment

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

For tests that. We have some "parent flag" tests that don't pass environments.

Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm. I'm not sure I want the tests to determine whether something should be required or not. And in this case, seems like we fall back to an empty list of environments anyway? Optionally, you could keep the function optional but give it a default impl that does nothing?

Comment on lines +8 to +10
/**
* @deprecated use tested `useLocalStorageState` hook instead
*/
Copy link
Contributor

Choose a reason for hiding this comment

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

How many places do we use this today? I migrating off it going to be hard? Also, why are we deprecating it? I don't remember any conversation about that.

Copy link
Member Author

Choose a reason for hiding this comment

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

Just this place. I didn't find it anywhere else. We already got rid of this for favorites

Copy link
Contributor

Choose a reason for hiding this comment

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

Safe. Shouldn't be a problem, then. But I still don't understand why we're deprecating it? Does it do something we've moved away from? Does it not work?

Tymek and others added 2 commits February 19, 2025 10:43
…tureOverviewMetaData/EnvironmentVisibilityMenu/hooks/useEnvironmentVisibility.ts

Co-authored-by: Thomas Heartman <[email protected]>
@Tymek Tymek enabled auto-merge (squash) February 19, 2025 09:44
@Tymek Tymek merged commit 2a6487e into main Feb 19, 2025
10 of 11 checks passed
@Tymek Tymek deleted the 1-3378 branch February 19, 2025 09:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

2 participants