-
Notifications
You must be signed in to change notification settings - Fork 21
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
Conversation
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.
done self-reviewing
watch: false, | ||
...getContext(__dirname), | ||
|
||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: "[name].js" | ||
filename: "[name].js", | ||
publicPath: "/" |
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.
Had to add this to get the dev server to work. Will need to check that this works for production server too. Full disclosure: webpack is black magic to me.
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.
😅 Really not sure why either. I guess this is telling webpack to insert /
at the beginning of every path?
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 guess we'll just need to keep an eye on this when we release and deploy
// const editButton = component.getByText("Edit"); | ||
// fireEvent.click(editButton); | ||
// expect(store.getState().environmentDetails.mode).toEqual("edit"); |
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.
TODO remove or fix
|
||
const onUpdateOrCreateEnv = ({ data }: IUpdateEnvironment) => { |
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 decided to get rid of this callback function because:
- Turning the child components into routed components means that the parent no longer imports the child components and so cannot pass properties directly to them (see line 47 on the right for how a route parent has to pass properties to route children)
- It seemed that having a centralized place in the app state for notifications is a good idea. PageLayout probably shouldn't own these functions.
- Keeping the
setRefreshEnvironment
behavior would be easy with the useEffect hook. However this will need to be changed in the future (I will add a TODO comment)
@@ -44,7 +43,8 @@ export const Environment = ({ | |||
/> | |||
</ListItemIcon> | |||
<Button | |||
onClick={onClick} | |||
component={Link} |
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.)
src/features/environmentCreate/components/EnvironmentCreate.tsx
Outdated
Show resolved
Hide resolved
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.
Tested locally, seems like it's working. I'm a big fan of putting state into the URL, so this seems like a really nice change. Thank you! 🎉
dispatch(modeChanged(EnvironmentDetailsModes.CREATE)); | ||
dispatch(openCreateNewEnvironmentTab(namespaceName)); |
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 🤷
dispatch(modeChanged(EnvironmentDetailsModes.READ)); | ||
dispatch(toggleNewEnvironmentView(false)); | ||
} | ||
}, [namespaceName, environmentName, foundNamespace, foundEnvironment]); |
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?
@@ -44,7 +43,8 @@ export const Environment = ({ | |||
/> | |||
</ListItemIcon> | |||
<Button | |||
onClick={onClick} | |||
component={Link} |
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?
const { palette } = useTheme(); | ||
|
||
const onCreateNewEnvironmentTab = ( |
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.
🎉
// This use of state to refetch the environment is an anti-pattern. We should | ||
// leverage RTK's cache invalidation features instead. | ||
useEffect(() => { |
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.
Instead of this comment, can you create an issue so we can track this work later on? That way we won't lose track of it after we merge this PR.
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.
watch: false, | ||
...getContext(__dirname), | ||
|
||
output: { | ||
path: path.resolve(__dirname, "dist"), | ||
filename: "[name].js" | ||
filename: "[name].js", | ||
publicPath: "/" |
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.
😅 Really not sure why either. I guess this is telling webpack to insert /
at the beginning of every path?
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.
Thanks @peytondmurray for your review!
dispatch(modeChanged(EnvironmentDetailsModes.CREATE)); | ||
dispatch(openCreateNewEnvironmentTab(namespaceName)); |
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.)
@@ -44,7 +43,8 @@ export const Environment = ({ | |||
/> | |||
</ListItemIcon> | |||
<Button | |||
onClick={onClick} | |||
component={Link} |
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.)
dispatch(modeChanged(EnvironmentDetailsModes.READ)); | ||
dispatch(toggleNewEnvironmentView(false)); | ||
} | ||
}, [namespaceName, environmentName, foundNamespace, foundEnvironment]); |
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.
// This use of state to refetch the environment is an anti-pattern. We should | ||
// leverage RTK's cache invalidation features instead. | ||
useEffect(() => { |
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.
Closes #386
Testing
The automatic tests should give some confidence that this PR does not horribly break anything. That said, a manual run-through should be done before approving and merging.
Types of website actions affected by this PR that should be tested manually in various combinations: