Skip to content

Commit 75e92c3

Browse files
authored
feat: add isBeingPromoted field to piles (#2719)
1 parent a4b737b commit 75e92c3

File tree

5 files changed

+42
-3
lines changed

5 files changed

+42
-3
lines changed

src/containers/Cluster/ClusterOverview/components/BridgeInfoTable.tsx

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,12 +46,33 @@ const BridgePileCard = React.memo(function BridgePileCard({pile}: BridgePileCard
4646
return <Label theme={theme}>{pile.State}</Label>;
4747
}, [pile.State]);
4848

49+
const renderBeingPromotedStatus = React.useCallback(() => {
50+
const isBeingPromoted = pile.IsBeingPromoted;
51+
const icon = isBeingPromoted ? CircleCheckFill : CircleXmarkFill;
52+
const text = isBeingPromoted ? i18n('value_yes') : i18n('value_no');
53+
54+
return (
55+
<Flex gap={1} alignItems="center">
56+
<Icon
57+
data={icon}
58+
size={16}
59+
className={b('status-icon', {primary: isBeingPromoted})}
60+
/>
61+
<Text color="secondary">{text}</Text>
62+
</Flex>
63+
);
64+
}, [pile.IsBeingPromoted]);
65+
4966
const info = React.useMemo(
5067
() => [
5168
{
5269
name: i18n('field_primary'),
5370
content: renderPrimaryStatus(),
5471
},
72+
{
73+
name: i18n('field_being-promoted'),
74+
content: renderBeingPromotedStatus(),
75+
},
5576
{
5677
name: i18n('field_state'),
5778
content: renderStateStatus(),
@@ -62,7 +83,7 @@ const BridgePileCard = React.memo(function BridgePileCard({pile}: BridgePileCard
6283
pile.Nodes === undefined ? EMPTY_DATA_PLACEHOLDER : formatNumber(pile.Nodes),
6384
},
6485
],
65-
[renderPrimaryStatus, renderStateStatus, pile.Nodes],
86+
[renderPrimaryStatus, renderBeingPromotedStatus, renderStateStatus, pile.Nodes],
6687
);
6788

6889
return (

src/containers/Cluster/i18n/en.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
"label_load": "Load",
2323
"field_name": "Name",
2424
"field_primary": "Primary",
25+
"field_being-promoted": "Being Promoted",
2526
"field_state": "State",
2627
"field_nodes": "Nodes",
2728
"value_yes": "Yes",

src/types/api/cluster.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@ export interface TBridgePile {
106106
State?: string;
107107
/** whether this pile is primary */
108108
IsPrimary?: boolean;
109+
/** whether this pile is being promoted to primary */
110+
IsBeingPromoted?: boolean;
109111
/** number of nodes in the pile */
110112
Nodes?: number;
111113
}

tests/suites/bridge/bridge.test.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ test.describe('Bridge mode - Cluster Overview', () => {
120120
const firstPileContent = await clusterPage.getFirstPileContent();
121121
expect(firstPileContent).toContain('r1');
122122
expect(firstPileContent).toContain('Yes'); // Primary status
123+
expect(firstPileContent).toContain('No'); // Being Promoted status (false for first pile)
123124
expect(firstPileContent).toContain('SYNCHRONIZED');
124125
expect(firstPileContent).toContain('16'); // Nodes count
125126
});

tests/suites/bridge/mocks.ts

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,22 @@ export const mockClusterWithBridgePiles = (page: Page) => {
131131
NetworkWriteThroughput: '1445752',
132132
BridgeInfo: {
133133
Piles: [
134-
{PileId: 1, Name: 'r1', State: 'SYNCHRONIZED', IsPrimary: true, Nodes: 16},
135-
{PileId: 2, Name: 'r2', State: 'READY', IsPrimary: false, Nodes: 12},
134+
{
135+
PileId: 1,
136+
Name: 'r1',
137+
State: 'SYNCHRONIZED',
138+
IsPrimary: true,
139+
IsBeingPromoted: false,
140+
Nodes: 16,
141+
},
142+
{
143+
PileId: 2,
144+
Name: 'r2',
145+
State: 'READY',
146+
IsPrimary: false,
147+
IsBeingPromoted: true,
148+
Nodes: 12,
149+
},
136150
],
137151
},
138152
}),

0 commit comments

Comments
 (0)