-
Notifications
You must be signed in to change notification settings - Fork 899
chore: simplify workspace routing #17981
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,19 +1,39 @@ | ||
import { health } from "api/queries/debug"; | ||
import { deploymentStats } from "api/queries/deployment"; | ||
import { useAuthenticated } from "hooks"; | ||
import type { FC } from "react"; | ||
import { type FC, useEffect, useState } from "react"; | ||
import { useQuery } from "react-query"; | ||
import { useLocation } from "react-router-dom"; | ||
import { DeploymentBannerView } from "./DeploymentBannerView"; | ||
|
||
const HIDE_DEPLOYMENT_BANNER_PATHS = [ | ||
// Workspace page. | ||
// Hide the banner on workspace page because it already has a lot of information. | ||
/^\/@[^\/]+\/[^\/]+$/, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What types of paths are we trying to catch with this? My gut feeling is that the current regex might be a little too loose in some ways, and a little too strict in others Like, right now, we're exclusively matching patterns that go like There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this wasn't what you wanted, you can let me know what you were going for, and I can try to whip up a regex for it There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is exactly what we want. It is to catch the workspace page route, but I'm open in case you have a better regex idea or a way to match the path. Since the route path def is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In that case, try
I just checked what characters we allow for usernames and workspace names, and those seemed to be the only characters we support right now There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is a good one 👍 |
||
]; | ||
|
||
export const DeploymentBanner: FC = () => { | ||
const { permissions } = useAuthenticated(); | ||
const deploymentStatsQuery = useQuery(deploymentStats()); | ||
const healthQuery = useQuery({ | ||
...health(), | ||
enabled: permissions.viewDeploymentConfig, | ||
}); | ||
const location = useLocation(); | ||
const [visible, setVisible] = useState(true); | ||
|
||
useEffect(() => { | ||
const isHidden = HIDE_DEPLOYMENT_BANNER_PATHS.some((regex) => | ||
regex.test(location.pathname), | ||
); | ||
setVisible(!isHidden); | ||
}, [location.pathname]); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this doesn't need to be an effect, you're pulling state from a hook. just use a There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 100%!!! Idk why I did that 🤦 |
||
|
||
if (!permissions.viewDeploymentConfig || !deploymentStatsQuery.data) { | ||
if ( | ||
!visible || | ||
!permissions.viewDeploymentConfig || | ||
!deploymentStatsQuery.data | ||
) { | ||
return null; | ||
} | ||
|
||
|
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'm worried that we missed something in the conversion here:
Was that intentional?
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.
Yeap. I did some storybook reviews and QA around and I didn't find anything broken. Maybe it was a leftover? I would appreciate you helping me with some QA 🙏