Skip to content

Commit 07acd55

Browse files
feat: add env vars and checks
1 parent b68314d commit 07acd55

File tree

5 files changed

+20
-22
lines changed

5 files changed

+20
-22
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,4 @@ DEFAULT_CI_TRIGGER_TYPE_MANUAL=false
3737
ANNOUNCEMENT_BANNER_MSG=
3838
LOGIN_PAGE_IMAGE=
3939
LOGIN_PAGE_IMAGE_BG=
40+
SHOW_DEFAULT_CLUSTER=false

src/components/ClusterNodes/ClusterSelectionList.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ export default function ClusterSelectionList({
2121
isSuperAdmin,
2222
clusterListLoader,
2323
refreshData,
24-
initTabsBasedOnRole
24+
initTabsBasedOnRole,
2525
}: ClusterSelectionType) {
2626
const location = useLocation()
2727
const history = useHistory()
@@ -121,6 +121,7 @@ export default function ClusterSelectionList({
121121

122122
const renderClusterRow = (clusterData: ClusterDetail): JSX.Element => {
123123
const errorCount = clusterData.nodeErrors ? Object.keys(clusterData.nodeErrors).length : 0
124+
if (!window._env_.SHOW_DEFAULT_CLUSTER && clusterData.name === 'default_cluster') return <></>
124125
return (
125126
<div
126127
key={`cluster-${clusterData.id}`}

src/components/ResourceBrowser/ResourceList/ClusterSelector.tsx

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ interface ClusterSelectorType {
1818
}
1919

2020
export default function ClusterSelector({ onChange, clusterList, clusterId }: ClusterSelectorType) {
21+
if (!window._env_.SHOW_DEFAULT_CLUSTER) {
22+
clusterList = clusterList.filter((item) => item.label !== 'default_cluster')
23+
}
2124
const defaultOption = clusterList.find((item) => item.value == clusterId)
2225

2326
return (

src/components/ResourceBrowser/ResourceList/ResourceList.tsx

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -62,20 +62,9 @@ import {
6262
sortEventListData,
6363
} from '../Utils'
6464
import '../ResourceBrowser.scss'
65-
import {
66-
ClusterCapacityType,
67-
ClusterDetail,
68-
ClusterErrorType,
69-
ClusterImageList,
70-
ERROR_TYPE,
71-
} from '../../ClusterNodes/types'
65+
import { ClusterCapacityType, ClusterDetail, ClusterImageList } from '../../ClusterNodes/types'
7266
import { getHostURLConfiguration } from '../../../services/service'
73-
import {
74-
clusterNamespaceList,
75-
getClusterCapacity,
76-
getClusterList,
77-
getClusterListMin,
78-
} from '../../ClusterNodes/clusterNodes.service'
67+
import { clusterNamespaceList, getClusterList, getClusterListMin } from '../../ClusterNodes/clusterNodes.service'
7968
import ClusterSelectionList from '../../ClusterNodes/ClusterSelectionList'
8069
import ClusterSelector from './ClusterSelector'
8170
import ClusterOverview from '../../ClusterNodes/ClusterOverview'
@@ -698,6 +687,12 @@ export default function ResourceList() {
698687
setSelectedCluster(selected)
699688
getNamespaceList(selected.value)
700689

690+
if (selected.value === 1 && !window._env_.SHOW_DEFAULT_CLUSTER) {
691+
replace({
692+
pathname: URLS.RESOURCE_BROWSER,
693+
})
694+
return
695+
}
701696
if (!skipRedirection) {
702697
const path = `${URLS.RESOURCE_BROWSER}/${selected.value}/${
703698
ALL_NAMESPACE_OPTION.value

src/index.tsx

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ interface customEnv {
4747
ANNOUNCEMENT_BANNER_MSG?: string
4848
LOGIN_PAGE_IMAGE?: string
4949
LOGIN_PAGE_IMAGE_BG?: string
50+
SHOW_DEFAULT_CLUSTER?: boolean
5051
}
5152
declare global {
5253
interface Window {
@@ -58,11 +59,7 @@ declare global {
5859
}
5960

6061
const root = document.getElementById('root')
61-
if (
62-
process.env.NODE_ENV === 'production' &&
63-
window._env_ &&
64-
(window._env_.SENTRY_ERROR_ENABLED)
65-
) {
62+
if (process.env.NODE_ENV === 'production' && window._env_ && window._env_.SENTRY_ERROR_ENABLED) {
6663
const integrationArr = []
6764
integrationArr.push(new CaptureConsole({ levels: ['error'] }))
6865
if (window._env_.SENTRY_PERFORMANCE_ENABLED) {
@@ -145,13 +142,14 @@ if (!window || !window._env_) {
145142
ENABLE_CHART_SEARCH_IN_HELM_DEPLOY: false,
146143
HIDE_EXCLUDE_INCLUDE_GIT_COMMITS: true,
147144
ENABLE_BUILD_CONTEXT: false,
148-
CLAIR_TOOL_VERSION:'V4',
145+
CLAIR_TOOL_VERSION: 'V4',
149146
ENABLE_RESTART_WORKLOAD: false,
150147
ENABLE_SCOPED_VARIABLES: false,
151148
DEFAULT_CI_TRIGGER_TYPE_MANUAL: false,
152149
ANNOUNCEMENT_BANNER_MSG: '',
153150
LOGIN_PAGE_IMAGE: '',
154-
LOGIN_PAGE_IMAGE_BG: ''
151+
LOGIN_PAGE_IMAGE_BG: '',
152+
SHOW_DEFAULT_CLUSTER: false,
155153
}
156154
}
157155

@@ -167,5 +165,5 @@ ReactDOM.render(
167165
)
168166

169167
if (process.env.NODE_ENV === 'development') {
170-
(module as any).hot.accept()
168+
;(module as any).hot.accept()
171169
}

0 commit comments

Comments
 (0)