Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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
Bye tabs, hi URLs #389
Bye tabs, hi URLs #389
Changes from 2 commits
db3d2c4
11eb62d
7a736af
d47a430
e46eccc
f5a9fd9
0c3e0c8
8116d1d
2fda414
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
Check failure on line 18 in src/App.tsx
GitHub Actions / Build Package
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These dispatch calls used to happen when the user clicked the button. Now we need to dispatch these actions when the user navigates to the URL. I put these dispatch calls in a useEffect hook so that they don't cause infinite re-renders (by caching on the value of namespaceName on line 48 below).
I don't really love using useEffect this way but I couldn't think of a better cost-benefit way to do it.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I'm not even sure how else you'd do it other than a useEffect hook unless you mean something really hacky with URLSearchParams or something. So this seems good 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, I could put some bit of code that runs as soon as the the Redux-related functions are available, checks the URL, and dispatches these actions. Or I could probably figure out some way to leverage the React Router's
loader
function.But so long as this seems good to you, I'll keep it for now. (Again, it's a question of effort versus reward, and I'm not sure more effort is worth the reward, not yet.)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These actions used to be dispatched on click when the user clicked on an environment, but now they need to happen when the user navigates to an environment's web page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's probably not clear what I'm doing here. I'll need to add a comment or something.
I want this React hook to run whenever the namespace and environment name changes, but I also need it to re-run when an environment or namespace have been found.
Previously this component (EnvironmentDetails) was only rendered once the environment details had been fetched from the server (see the old version of PageLayout in the files changed).
Now the component renders before the data has been fetched from the server. So this hook will run once but nothing will happen because namespace and environment are undefined. Then once those are fetched, the hook will run again.
Most of the changes to this component (including passing the Redux toolkit skip token, checking for current build id, and the check for selected environment) have to do with it now being rendered before all the data has arrived.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you're right that a comment here would help clear this up. I guess this means the UI will now have an "intermediate" state where this hook has run once but not twice, right?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think I overcomplicated this. I'm going to push a commit that should simplify this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wanted to change the Button component directly to a Link, but it was causing styling issues. The reason why is that the MUI button component renders with several classes attached to it and those same classes get applied whether the HTML element used is
button
or (now)a
. This should probably be cleaned up at some point but it's low priority in my mind.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yah, this doesn't seem like a big deal unless I'm missing something accessibility related or something?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, it's just not very hygienic. Because you end up with an
<a>
tag that has button classes applied to it. (But yes, not a big deal.)