Skip to content

Commit 1b1e257

Browse files
committed
#RI-3477 - add colors to the overview table
1 parent bbda5ad commit 1b1e257

File tree

3 files changed

+30
-5
lines changed

3 files changed

+30
-5
lines changed

redisinsight/ui/src/pages/clusterDetails/components/cluser-nodes-table/ClusterNodesTable.spec.tsx

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import React from 'react'
22
import { ModifiedClusterNodes } from 'uiSrc/pages/clusterDetails/ClusterDetailsPage'
33
import { getLetterByIndex } from 'uiSrc/utils'
4+
import { rgb } from 'uiSrc/utils/colors'
45
import { render, screen } from 'uiSrc/utils/test-utils'
56

67
import ClusterNodesTable from './ClusterNodesTable'
@@ -107,4 +108,11 @@ describe('ClusterNodesTable', () => {
107108
render(<ClusterNodesTable nodes={mockNodes} loading={false} />)
108109
expect(screen.queryByTestId('opsPerSecond-value-max')).not.toBeInTheDocument()
109110
})
111+
112+
it('should render background color for each node', () => {
113+
render(<ClusterNodesTable nodes={mockNodes} loading={false} />)
114+
mockNodes.forEach(({ letter, color }) => {
115+
expect(screen.getByTestId(`node-color-${letter}`)).toHaveStyle({ 'background-color': rgb(color) })
116+
})
117+
})
110118
})

redisinsight/ui/src/pages/clusterDetails/components/cluser-nodes-table/ClusterNodesTable.tsx

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import {
2020
} from 'uiSrc/components/database-overview/components/icons'
2121
import { ModifiedClusterNodes } from 'uiSrc/pages/clusterDetails/ClusterDetailsPage'
2222
import { formatBytes, Nullable } from 'uiSrc/utils'
23+
import { rgb } from 'uiSrc/utils/colors'
2324
import { numberWithSpaces } from 'uiSrc/utils/numbers'
2425

2526
import styles from './styles.module.scss'
@@ -49,11 +50,18 @@ const ClusterNodesTable = ({ nodes, loading }: { nodes: Nullable<ModifiedCluster
4950
field: 'host',
5051
dataType: 'string',
5152
sortable: ({ index }) => index,
52-
render: (value: number, { letter, port }) => (
53-
<div className={styles.hostPort}>
54-
<span className={styles.nodeName} data-testid="node-letter">{letter}</span>
55-
<span>{value}:{port}</span>
56-
</div>
53+
render: (value: number, { letter, port, color }) => (
54+
<>
55+
<div
56+
className={styles.nodeColor}
57+
data-testid={`node-color-${letter}`}
58+
style={{ backgroundColor: rgb(color) }}
59+
/>
60+
<div className={styles.hostPort}>
61+
<span className={styles.nodeName} data-testid="node-letter">{letter}</span>
62+
<span>{value}:{port}</span>
63+
</div>
64+
</>
5765
)
5866
},
5967
{

redisinsight/ui/src/pages/clusterDetails/components/cluser-nodes-table/styles.module.scss

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ $breakpoint-table: 1232px;
9595
}
9696

9797
.euiTableCellContent {
98+
position: relative;
9899
padding: 12px 12px 12px 24px;
99100
font: normal normal 500 16px/18px Inconsolata;
100101

@@ -171,4 +172,12 @@ $breakpoint-table: 1232px;
171172
display: inline-flex;
172173
font: normal normal normal 13px/18px Graphik, sans-serif !important;
173174
}
175+
176+
.nodeColor {
177+
position: absolute;
178+
left: 0;
179+
top: 1px;
180+
bottom: 1px;
181+
width: 3px;
182+
}
174183
}

0 commit comments

Comments
 (0)