Skip to content

Commit 5d3e81b

Browse files
authored
Merge pull request #830 from devtron-labs/feat/cluster-map
feat: add cluster map from fe-lib
2 parents 9e45261 + b64abf5 commit 5d3e81b

File tree

18 files changed

+193
-23
lines changed

18 files changed

+193
-23
lines changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@devtron-labs/devtron-fe-common-lib",
3-
"version": "1.18.0-pre-0",
3+
"version": "1.18.0-pre-1",
44
"description": "Supporting common component library",
55
"type": "module",
66
"main": "dist/index.js",
Lines changed: 4 additions & 4 deletions
Loading

src/Common/Modals/Modal.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import { noop } from '@Common/Helper'
2626
export const Modal = ({
2727
style = {},
2828
children,
29-
modal = false,
3029
rootClassName = '',
3130
onClick = null,
3231
callbackRef = null,
@@ -63,7 +62,7 @@ export const Modal = ({
6362
}, [])
6463

6564
return (
66-
<Backdrop onEscape={noop} onClick={handleClick}>
65+
<Backdrop onEscape={noop} onClick={handleClick} hasClearBackground={noBackDrop}>
6766
<div
6867
tabIndex={0}
6968
onClick={handleClick}
@@ -75,7 +74,7 @@ export const Modal = ({
7574
innerRef.current = el
7675
}}
7776
id="popup"
78-
className={`${rootClassName} ${POP_UP_MENU_MODAL_ID} ${modal ? 'modal' : ''} ${noBackDrop ? 'no-back-drop' : ''}`}
77+
className={`${rootClassName} ${POP_UP_MENU_MODAL_ID}`}
7978
style={{ ...style }}
8079
>
8180
{children}

src/Common/Modals/VisibleModal.tsx

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ import React, { SyntheticEvent } from 'react'
1919
import { DTFocusTrapType } from '@Shared/Components/DTFocusTrap'
2020

2121
import { Backdrop, POP_UP_MENU_MODAL_ID } from '../../Shared'
22+
import { stopPropagation } from '@Common/Helper'
2223

2324
export class VisibleModal extends React.Component<{
2425
className?: string
@@ -57,7 +58,7 @@ export class VisibleModal extends React.Component<{
5758
onClick={this.handleBodyClick}
5859
initialFocus={this.props.initialFocus ?? undefined}
5960
>
60-
<div className={this.props.parentClassName}>
61+
<div className={this.props.parentClassName} onClick={stopPropagation}>
6162
<div className={`visible-modal__body ${this.props.className || ''}`}>{this.props.children}</div>
6263
</div>
6364
</Backdrop>

src/Common/Modals/VisibleModal2.tsx

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import React, { SyntheticEvent } from 'react'
1818
import { Backdrop } from '@Shared/Components'
1919
import { DTFocusTrapType } from '@Shared/Components/DTFocusTrap'
20+
import { stopPropagation } from '@Common/Helper'
2021

2122
export class VisibleModal2 extends React.Component<{
2223
className?: string
@@ -39,7 +40,9 @@ export class VisibleModal2 extends React.Component<{
3940
onClick={this.handleBodyClick}
4041
initialFocus={this.props.initialFocus ?? undefined}
4142
>
42-
<div className={`visible-modal__body ${this.props.className || ''}`}>{this.props.children}</div>
43+
<div className={`visible-modal__body ${this.props.className || ''}`} onClick={stopPropagation}>
44+
{this.props.children}
45+
</div>
4346
</Backdrop>
4447
)
4548
}

src/Common/Types.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,6 @@ export interface PopupMenuBodyType {
321321
export interface ModalType {
322322
style?: React.CSSProperties
323323
children?: ReactNode
324-
modal?: boolean
325324
rootClassName?: string
326325
onClick?: any
327326
callbackRef?: (element?: any) => any
Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
import { SegmentedBarChart } from '@Common/SegmentedBarChart'
6+
7+
import { ClusterMapProps } from './types'
8+
import { getEntities } from './utils'
9+
10+
export const ClusterMap = ({ filteredList, isLoading }: ClusterMapProps) => {
11+
if (!filteredList?.length) {
12+
return null
13+
}
14+
15+
const { statusEntities, deploymentEntities } = getEntities(filteredList)
16+
17+
return (
18+
<div className="pb-16 px-20">
19+
<div className="dc__grid-half shadow__card--20 w-100 dc__border br-8 dc__grid dc__align-items-center">
20+
<SegmentedBarChart
21+
entities={statusEntities}
22+
rootClassName="p-16 fs-13 dc__border-right-n1 cn-9"
23+
countClassName="fw-6 fs-20 lh-1-5"
24+
labelClassName="lh-20"
25+
isProportional
26+
showAnimationOnBar
27+
isLoading={isLoading}
28+
/>
29+
30+
<SegmentedBarChart
31+
entities={deploymentEntities}
32+
rootClassName="p-16 fs-13 cn-9"
33+
countClassName="fw-6 fs-20 lh-1-5"
34+
labelClassName="lh-20"
35+
isProportional
36+
showAnimationOnBar
37+
isLoading={isLoading}
38+
/>
39+
</div>
40+
</div>
41+
)
42+
}
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
export * from './ClusterMap'
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
/*
2+
* Copyright (c) 2024. Devtron Inc.
3+
*/
4+
5+
import { ClusterStatusType } from '../types'
6+
7+
export interface ClusterStatusAndType {
8+
isProd: boolean
9+
status: ClusterStatusType
10+
}
11+
12+
export interface ClusterMapProps {
13+
isLoading?: boolean
14+
filteredList: ClusterStatusAndType[]
15+
}
16+
17+
export interface StatusCountEnum {
18+
healthyCount: number
19+
unhealthyCount: number
20+
connectionFailedCount: number
21+
prodCount: number
22+
}
23+
24+
export interface StatusEntity {
25+
value: number
26+
label: string
27+
color: string
28+
proportionalValue: string
29+
}
30+
31+
export interface ClusterEntitiesTypes {
32+
statusEntities: StatusEntity[]
33+
deploymentEntities: StatusEntity[]
34+
}

0 commit comments

Comments
 (0)