Skip to content

Commit cefe304

Browse files
committed
fix: enhance node card and details card to handle disabled state
1 parent 31633e1 commit cefe304

File tree

2 files changed

+20
-12
lines changed

2 files changed

+20
-12
lines changed

src/widgets/dashboard/nodes/node-card/node-card.widget.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ export const NodeCardWidget = memo((props: IProps) => {
6868
}, [node.trafficUsedBytes, node.trafficLimitBytes, node.isTrafficTrackingActive])
6969

7070
const isOnline = useMemo(() => {
71-
return node.isConnected && node.xrayUptime !== '0'
72-
}, [node.isConnected, node.xrayUptime])
71+
return node.isConnected && node.xrayUptime !== '0' && !node.isDisabled
72+
}, [node.isConnected, node.xrayUptime, node.isDisabled])
7373

7474
const getProgressColor = useCallback(() => {
7575
if (trafficData.fallbackProgress) return 'teal.6'
@@ -101,6 +101,14 @@ export const NodeCardWidget = memo((props: IProps) => {
101101
let borderColor = 'rgba(239, 68, 68, 0.3)'
102102
let boxShadow = 'rgba(239, 68, 68, 0.2)'
103103

104+
if (node.isDisabled) {
105+
backgroundColor = 'rgba(107, 114, 128, 0.15)'
106+
borderColor = 'rgba(107, 114, 128, 0.3)'
107+
boxShadow = 'rgba(107, 114, 128, 0.2)'
108+
109+
return { backgroundColor, borderColor, boxShadow }
110+
}
111+
104112
if (node.isConnected) {
105113
backgroundColor = 'rgba(45, 212, 191, 0.15)'
106114
borderColor = 'rgba(45, 212, 191, 0.3)'
@@ -109,10 +117,6 @@ export const NodeCardWidget = memo((props: IProps) => {
109117
backgroundColor = 'rgba(245, 158, 11, 0.15)'
110118
borderColor = 'rgba(245, 158, 11, 0.3)'
111119
boxShadow = 'rgba(245, 158, 11, 0.2)'
112-
} else if (node.isDisabled) {
113-
backgroundColor = 'rgba(107, 114, 128, 0.15)'
114-
borderColor = 'rgba(107, 114, 128, 0.3)'
115-
boxShadow = 'rgba(107, 114, 128, 0.2)'
116120
} else {
117121
backgroundColor = 'rgba(239, 68, 68, 0.15)'
118122
borderColor = 'rgba(239, 68, 68, 0.3)'

src/widgets/dashboard/nodes/node-details-card/node-details-card.widget.tsx

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,16 @@ export const NodeDetailsCardWidget = memo(({ node, fetchedNode }: IProps) => {
7373
return { icon, color, backgroundColor, borderColor, boxShadow }
7474
}
7575

76+
if (nodeData.isDisabled) {
77+
icon = <TbWifiOff size={18} style={{ color: 'var(--mantine-color-gray-6)' }} />
78+
color = 'gray'
79+
backgroundColor = 'rgba(107, 114, 128, 0.15)'
80+
borderColor = 'rgba(107, 114, 128, 0.3)'
81+
boxShadow = 'rgba(107, 114, 128, 0.2)'
82+
83+
return { icon, color, backgroundColor, borderColor, boxShadow }
84+
}
85+
7686
if (nodeData.isConnected) {
7787
icon = <TbWifi size={18} style={{ color: 'var(--mantine-color-teal-6)' }} />
7888
color = 'teal'
@@ -90,12 +100,6 @@ export const NodeDetailsCardWidget = memo(({ node, fetchedNode }: IProps) => {
90100
backgroundColor = 'rgba(245, 158, 11, 0.15)'
91101
borderColor = 'rgba(245, 158, 11, 0.3)'
92102
boxShadow = 'rgba(245, 158, 11, 0.2)'
93-
} else if (nodeData.isDisabled) {
94-
icon = <TbWifiOff size={18} style={{ color: 'var(--mantine-color-gray-6)' }} />
95-
color = 'gray'
96-
backgroundColor = 'rgba(107, 114, 128, 0.15)'
97-
borderColor = 'rgba(107, 114, 128, 0.3)'
98-
boxShadow = 'rgba(107, 114, 128, 0.2)'
99103
} else {
100104
icon = <PiWarningCircle size={18} style={{ color: 'var(--mantine-color-red-6)' }} />
101105
color = 'red'

0 commit comments

Comments
 (0)