Skip to content

Commit 7e6c0d9

Browse files
committed
Merge branch 'main' of https://github.com/devtron-labs/dashboard into feat/external-link-strategy
2 parents 6d89476 + a85f262 commit 7e6c0d9

File tree

14 files changed

+113
-70
lines changed

14 files changed

+113
-70
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,3 +71,4 @@ FEATURE_AI_INTEGRATION_ENABLE=false
7171
LOGIN_PAGE_IMAGE=
7272
FEATURE_MANAGE_TRAFFIC_ENABLE=false
7373
FEATURE_REDFISH_NODE_ENABLE=false
74+
FEATURE_INFRA_PROVISION_INFO_BLOCK_HIDE=false

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"private": true,
55
"homepage": "/dashboard",
66
"dependencies": {
7-
"@devtron-labs/devtron-fe-common-lib": "1.15.0",
7+
"@devtron-labs/devtron-fe-common-lib": "1.15.2",
88
"@esbuild-plugins/node-globals-polyfill": "0.2.3",
99
"@rjsf/core": "^5.13.3",
1010
"@rjsf/utils": "^5.13.3",

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/CreateCluster.component.tsx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const CreateClusterForm = importComponentFromFELibrary(
2828
'CreateClusterForm',
2929
() => (
3030
<EnterpriseTrialDialog
31-
featureTitle="EKS Cluster"
32-
featureDescription="With Devtron, you can effortlessly create an Amazon EKS cluster."
31+
featureTitle="Create Kubernetes Cluster"
32+
featureDescription="Use Devtron to easily create Kubernetes clusters on popular cloud providers. Simplify cluster
33+
provisioning and management with a guided, user-friendly interface."
3334
/>
3435
),
3536
'function',
@@ -74,7 +75,7 @@ const CreateCluster = ({ handleReloadClusterList, handleRedirectOnModalClose }:
7475
FooterComponent={FooterComponent}
7576
/>
7677
)
77-
case CreateClusterTypeEnum.CREATE_EKS_CLUSTER:
78+
case CreateClusterTypeEnum.CREATE_CLUSTER:
7879
return (
7980
<CreateClusterForm
8081
apiCallInProgress={apiCallInProgress}

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/constants.tsx

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,18 +12,15 @@ export const SIDEBAR_CONFIG: SidebarConfigType = {
1212
</p>
1313
),
1414
},
15-
[CreateClusterTypeEnum.CREATE_EKS_CLUSTER]: {
16-
title: 'Create EKS Cluster',
17-
iconName: 'ic-cluster',
18-
dataTestId: 'create-eks-cluster-tab',
15+
[CreateClusterTypeEnum.CREATE_CLUSTER]: {
16+
title: 'Create Kubernetes Cluster',
17+
iconName: 'ic-new',
18+
dataTestId: 'create-cluster-tab',
1919
body: (
20-
<>
21-
<p className="m-0">With Devtron, you can effortlessly create an Amazon EKS cluster.</p>
22-
<p className="m-0">
23-
Amazon Elastic Kubernetes Service (Amazon EKS) is a fully managed Kubernetes service that enables
24-
you to run Kubernetes seamlessly in both AWS Cloud and on-premises data centers.
25-
</p>
26-
</>
20+
<p className="m-0">
21+
Use Devtron to easily create Kubernetes clusters on popular cloud providers. Simplify cluster
22+
provisioning and management with a guided, user-friendly interface.
23+
</p>
2724
),
2825
isEnterprise: true,
2926
},

src/Pages/GlobalConfigurations/ClustersAndEnvironments/CreateCluster/types.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { IconName } from '@devtron-labs/devtron-fe-common-lib'
22

33
export enum CreateClusterTypeEnum {
44
CONNECT_CLUSTER = 'connect-cluster',
5-
CREATE_EKS_CLUSTER = 'create-eks-cluster',
5+
CREATE_CLUSTER = 'create-cluster',
66
ADD_ISOLATED_CLUSTER = 'add-isolated-cluster',
77
}
88

src/components/ResourceBrowser/ResourceList/ClusterSelector.tsx

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -116,25 +116,27 @@ const ClusterSelector: React.FC<ClusterSelectorType> = ({
116116

117117
{defaultOption?.isProd && <span className="px-6 py-2 br-4 bcb-1 cb-7 fs-12 lh-16 fw-5">Production</span>}
118118

119-
<PopupMenu autoClose>
120-
<PopupMenu.Button rootClassName="flex ml-auto p-4 border__secondary" isKebab>
121-
<MenuDots className="icon-dim-16 fcn-7" data-testid="popup-menu-button" />
122-
</PopupMenu.Button>
123-
124-
<PopupMenu.Body rootClassName="dc__border p-4">
125-
<div className="w-150 flexbox-col">
126-
<button
127-
type="button"
128-
className="dc__outline-none flexbox dc__gap-8 dc__transparent dc__hover-n50 px-12 py-6 dc__align-items-center"
129-
onClick={handleOpenDeleteModal}
130-
data-testid="delete_cluster_button"
131-
>
132-
<Icon name="ic-delete" color="R500" />
133-
<span className="fs-14 lh-1-5 cr-5">Delete</span>
134-
</button>
135-
</div>
136-
</PopupMenu.Body>
137-
</PopupMenu>
119+
{defaultOption?.value !== String(DEFAULT_CLUSTER_ID) && (
120+
<PopupMenu autoClose>
121+
<PopupMenu.Button rootClassName="flex ml-auto p-4 border__secondary" isKebab>
122+
<MenuDots className="icon-dim-16 fcn-7" data-testid="popup-menu-button" />
123+
</PopupMenu.Button>
124+
125+
<PopupMenu.Body rootClassName="dc__border p-4">
126+
<div className="w-150 flexbox-col">
127+
<button
128+
type="button"
129+
className="dc__outline-none flexbox dc__gap-8 dc__transparent dc__hover-n50 px-12 py-6 dc__align-items-center"
130+
onClick={handleOpenDeleteModal}
131+
data-testid="delete_cluster_button"
132+
>
133+
<Icon name="ic-delete" color="R500" />
134+
<span className="fs-14 lh-1-5 cr-5">Delete</span>
135+
</button>
136+
</div>
137+
</PopupMenu.Body>
138+
</PopupMenu>
139+
)}
138140

139141
{openDeleteClusterModal && (
140142
<DeleteClusterConfirmationModal

src/components/common/hooks/constants.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,4 +33,4 @@ export const FILE_READING_FAILED_STATUS = {
3333
}
3434

3535
export const ONLINE_BANNER_TIMEOUT = 3000
36-
export const INTERNET_CONNECTIVITY_INTERVAL = 10000
36+
export const INTERNET_CONNECTIVITY_INTERVAL = 30000
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { Routes } from '@Config/constants'
2+
3+
import { INTERNET_CONNECTIVITY_INTERVAL } from '../constants'
4+
import { CheckConnectivityParamsType, FetchConnectivityParamsType } from './types'
5+
6+
const fetchWithTimeout = ({ url, options, controller }: FetchConnectivityParamsType): Promise<any> => {
7+
const timeoutId = setTimeout(() => controller.abort(), INTERNET_CONNECTIVITY_INTERVAL)
8+
9+
return fetch(url, { ...options, signal: controller.signal }).finally(() => {
10+
clearTimeout(timeoutId)
11+
})
12+
}
13+
14+
export const getFallbackInternetConnectivity = ({ controller }: CheckConnectivityParamsType): Promise<any> =>
15+
fetchWithTimeout({
16+
url: 'https://www.google.com/favicon.ico',
17+
options: {
18+
method: 'HEAD',
19+
mode: 'no-cors',
20+
},
21+
controller,
22+
})
23+
24+
export const getInternetConnectivity = ({ controller }: CheckConnectivityParamsType): Promise<any> => {
25+
const baseUrl = window._env_?.CENTRAL_API_ENDPOINT ?? 'https://api.devtron.ai'
26+
const url = `${baseUrl}/${Routes.HEALTH}`
27+
28+
return fetchWithTimeout({ url, options: {}, controller })
29+
}
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
export interface FetchConnectivityParamsType {
2+
url: string
3+
options: RequestInit
4+
controller: AbortController
5+
}
6+
7+
export interface CheckConnectivityParamsType extends Pick<FetchConnectivityParamsType, 'controller'> {}

src/components/common/hooks/useOnline/useOnline.ts

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
import { useEffect, useRef, useState } from 'react'
22

3-
import { getIsRequestAborted, noop, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
4-
5-
import { getInternetConnectivity } from '@Services/service'
3+
import { noop, useMainContext } from '@devtron-labs/devtron-fe-common-lib'
64

75
import { INTERNET_CONNECTIVITY_INTERVAL } from '../constants'
6+
import { getFallbackInternetConnectivity, getInternetConnectivity } from './service'
87

98
export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
109
const [online, setOnline] = useState(structuredClone(navigator.onLine))
@@ -19,6 +18,14 @@ export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
1918
abortControllerRef.current.abort()
2019
}
2120

21+
const onConnectivitySuccess = (checkConnectivity) => {
22+
setOnline((prev) => {
23+
if (!prev) onOnline()
24+
return true
25+
})
26+
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
27+
}
28+
2229
const checkConnectivity = async () => {
2330
if (isAirgapped) return
2431

@@ -27,21 +34,34 @@ export const useOnline = ({ onOnline = noop }: { onOnline?: () => void }) => {
2734
abortControllerRef.current = controller
2835

2936
try {
30-
await getInternetConnectivity(abortControllerRef.current)
31-
setOnline((prev) => {
32-
if (!prev) {
33-
onOnline()
34-
}
35-
return true
37+
await getFallbackInternetConnectivity({
38+
controller: abortControllerRef.current,
3639
})
37-
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
38-
} catch (error) {
39-
setOnline(false)
40-
if (!getIsRequestAborted(error)) {
41-
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
40+
onConnectivitySuccess(checkConnectivity)
41+
} catch {
42+
if (abortControllerRef.current.signal.aborted) {
43+
if (timeoutRef.current) {
44+
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
45+
}
46+
return
47+
}
48+
const fallbackController = new AbortController()
49+
abortControllerRef.current = fallbackController
50+
try {
51+
await getInternetConnectivity({
52+
controller: abortControllerRef.current,
53+
})
54+
onConnectivitySuccess(checkConnectivity)
55+
} catch {
56+
if (!abortControllerRef.current.signal.aborted) {
57+
setOnline(false)
58+
} else if (timeoutRef.current) {
59+
timeoutRef.current = setTimeout(checkConnectivity, INTERNET_CONNECTIVITY_INTERVAL)
60+
}
4261
}
4362
}
4463
}
64+
4565
const handleOffline = () => {
4666
handleClearTimeout()
4767
setOnline(false)

0 commit comments

Comments
 (0)