@@ -3,17 +3,36 @@ import { deploymentStats } from "api/queries/deployment";
3
3
import { useAuthenticated } from "hooks" ;
4
4
import type { FC } from "react" ;
5
5
import { useQuery } from "react-query" ;
6
+ import { useLocation } from "react-router-dom" ;
6
7
import { DeploymentBannerView } from "./DeploymentBannerView" ;
7
8
9
+ const HIDE_DEPLOYMENT_BANNER_PATHS = [
10
+ // Hide the banner on workspace page because it already has a lot of
11
+ // information.
12
+ // - It adds names to the main groups that we're checking for, so it'll be a
13
+ // little more self-documenting
14
+ // - It redefines each group to only allow the characters A-Z (lowercase or
15
+ // uppercase), numbers, and hyphens
16
+ / ^ \/ @ (?< username > [ a - z A - Z 0 - 9 - ] + ) \/ (?< workspace_name > [ a - z A - Z 0 - 9 - ] + ) $ / ,
17
+ ] ;
18
+
8
19
export const DeploymentBanner : FC = ( ) => {
9
20
const { permissions } = useAuthenticated ( ) ;
10
21
const deploymentStatsQuery = useQuery ( deploymentStats ( ) ) ;
11
22
const healthQuery = useQuery ( {
12
23
...health ( ) ,
13
24
enabled : permissions . viewDeploymentConfig ,
14
25
} ) ;
26
+ const location = useLocation ( ) ;
27
+ const isHidden = HIDE_DEPLOYMENT_BANNER_PATHS . some ( ( regex ) =>
28
+ regex . test ( location . pathname ) ,
29
+ ) ;
15
30
16
- if ( ! permissions . viewDeploymentConfig || ! deploymentStatsQuery . data ) {
31
+ if (
32
+ isHidden ||
33
+ ! permissions . viewDeploymentConfig ||
34
+ ! deploymentStatsQuery . data
35
+ ) {
17
36
return null ;
18
37
}
19
38
0 commit comments