Skip to content

Commit 55ebfc5

Browse files
fix: Various fixes for Domain Failover History (#1117)
* Remove "Type" column from failovers table * Allow rendering cluster failovers if either from/to is missing (this occurs when new cluster attributes are created) * Rename "primary" to "default" * Add top spacing to table when rendering without filter component (active-passive domain) Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com> Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
1 parent d9d63bc commit 55ebfc5

18 files changed

+73
-64
lines changed

src/views/domain-page/config/domain-page-failovers-table-active-active.config.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ import DomainPageFailoverActiveActive from '../domain-page-failover-active-activ
77
import domainPageFailoversTableConfig from './domain-page-failovers-table.config';
88

99
const domainPageFailoversTableActiveActiveConfig = [
10-
...domainPageFailoversTableConfig.slice(0, 3),
10+
...domainPageFailoversTableConfig.slice(0, 2),
1111
{
12-
...domainPageFailoversTableConfig[3],
12+
...domainPageFailoversTableConfig[2],
1313
renderCell: (event: FailoverEvent) =>
1414
createElement(DomainPageFailoverActiveActive, { failoverEvent: event }),
1515
},

src/views/domain-page/config/domain-page-failovers-table.config.ts

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import { type FailoverEvent } from '@/route-handlers/list-failover-history/list-
66
import parseGrpcTimestamp from '@/utils/datetime/parse-grpc-timestamp';
77

88
import DomainPageFailoverSingleCluster from '../domain-page-failover-single-cluster/domain-page-failover-single-cluster';
9-
import { FAILOVER_TYPE_LABEL_MAP } from '../domain-page-failovers/domain-page-failovers.constants';
109

1110
const domainPageFailoversTableConfig = [
1211
{
@@ -26,17 +25,10 @@ const domainPageFailoversTableConfig = [
2625
: null,
2726
}),
2827
},
29-
{
30-
name: 'Type',
31-
id: 'type',
32-
width: '10%',
33-
renderCell: (event: FailoverEvent) =>
34-
FAILOVER_TYPE_LABEL_MAP[event.failoverType],
35-
},
3628
{
3729
name: 'Failover Information',
3830
id: 'failoverInfo',
39-
width: '40%',
31+
width: '50%',
4032
renderCell: (event: FailoverEvent) =>
4133
createElement(DomainPageFailoverSingleCluster, {
4234
fromCluster: event.clusterFailovers[0]?.fromCluster?.activeClusterName,

src/views/domain-page/domain-page-failover-active-active/__tests__/domain-page-failover-active-active.test.tsx

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import { render, screen } from '@/test-utils/rtl';
33
import * as usePageQueryParamsModule from '@/hooks/use-page-query-params/use-page-query-params';
44
import { type FailoverEvent } from '@/route-handlers/list-failover-history/list-failover-history.types';
55
import { mockDomainPageQueryParamsValues } from '@/views/domain-page/__fixtures__/domain-page-query-params';
6-
import { PRIMARY_CLUSTER_SCOPE } from '@/views/domain-page/domain-page-failovers/domain-page-failovers.constants';
6+
import { DEFAULT_CLUSTER_SCOPE } from '@/views/domain-page/domain-page-failovers/domain-page-failovers.constants';
77

88
import DomainPageFailoverActiveActive from '../domain-page-failover-active-active';
99

@@ -31,7 +31,7 @@ describe(DomainPageFailoverActiveActive.name, () => {
3131
jest.clearAllMocks();
3232
});
3333

34-
it('renders cluster failover when matching primary cluster failover is found', () => {
34+
it('renders cluster failover when matching default cluster failover is found', () => {
3535
const failoverEvent: FailoverEvent = {
3636
id: 'failover-1',
3737
createdTime: {
@@ -56,10 +56,10 @@ describe(DomainPageFailoverActiveActive.name, () => {
5656

5757
setup({
5858
failoverEvent,
59-
clusterAttributeScope: PRIMARY_CLUSTER_SCOPE,
59+
clusterAttributeScope: DEFAULT_CLUSTER_SCOPE,
6060
});
6161

62-
expect(screen.getByText('Primary:')).toBeInTheDocument();
62+
expect(screen.getByText('Default:')).toBeInTheDocument();
6363
expect(
6464
screen.getByTestId('mock-single-cluster-failover')
6565
).toBeInTheDocument();
@@ -68,7 +68,7 @@ describe(DomainPageFailoverActiveActive.name, () => {
6868
expect(screen.getByTestId('mock-failover-modal')).toBeInTheDocument();
6969
});
7070

71-
it('renders cluster failover when matching non-primary cluster failover is found', () => {
71+
it('renders cluster failover when matching non-default cluster failover is found', () => {
7272
const failoverEvent: FailoverEvent = {
7373
id: 'failover-1',
7474
createdTime: {
@@ -109,7 +109,7 @@ describe(DomainPageFailoverActiveActive.name, () => {
109109
expect(screen.getByTestId('mock-failover-modal')).toBeInTheDocument();
110110
});
111111

112-
it('does not render cluster failover section when clusterAttributeScope is set but clusterAttributeValue is undefined for non-primary scope', () => {
112+
it('does not render cluster failover section when clusterAttributeScope is set but clusterAttributeValue is undefined for non-default scope', () => {
113113
const failoverEvent: FailoverEvent = {
114114
id: 'failover-1',
115115
createdTime: {
@@ -235,7 +235,7 @@ describe(DomainPageFailoverActiveActive.name, () => {
235235

236236
setup({
237237
failoverEvent,
238-
clusterAttributeScope: PRIMARY_CLUSTER_SCOPE,
238+
clusterAttributeScope: DEFAULT_CLUSTER_SCOPE,
239239
});
240240

241241
expect(

src/views/domain-page/domain-page-failover-active-active/domain-page-failover-active-active.tsx

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,10 @@ import usePageQueryParams from '@/hooks/use-page-query-params/use-page-query-par
88
import domainPageQueryParamsConfig from '../config/domain-page-query-params.config';
99
import DomainPageFailoverModal from '../domain-page-failover-modal/domain-page-failover-modal';
1010
import DomainPageFailoverSingleCluster from '../domain-page-failover-single-cluster/domain-page-failover-single-cluster';
11-
import { PRIMARY_CLUSTER_SCOPE } from '../domain-page-failovers/domain-page-failovers.constants';
11+
import {
12+
DEFAULT_CLUSTER_SCOPE,
13+
DEFAULT_CLUSTER_SCOPE_LABEL,
14+
} from '../domain-page-failovers/domain-page-failovers.constants';
1215
import clusterFailoverMatchesAttribute from '../helpers/cluster-failover-matches-attribute';
1316

1417
import { styled } from './domain-page-failover-active-active.styles';
@@ -25,7 +28,7 @@ export default function DomainPageFailoverActiveActive({
2528
const clusterFailoverForMaybeSelectedAttribute = useMemo(() => {
2629
if (
2730
!clusterAttributeScope ||
28-
(clusterAttributeScope !== PRIMARY_CLUSTER_SCOPE &&
31+
(clusterAttributeScope !== DEFAULT_CLUSTER_SCOPE &&
2932
!clusterAttributeValue)
3033
)
3134
return undefined;
@@ -49,8 +52,8 @@ export default function DomainPageFailoverActiveActive({
4952
{clusterFailoverForMaybeSelectedAttribute && (
5053
<styled.ClusterFailoverContainer>
5154
<styled.ClusterAttributeLabel>
52-
{clusterAttributeScope === PRIMARY_CLUSTER_SCOPE
53-
? 'Primary:'
55+
{clusterAttributeScope === DEFAULT_CLUSTER_SCOPE
56+
? `${DEFAULT_CLUSTER_SCOPE_LABEL}:`
5457
: `${clusterAttributeScope} (${clusterAttributeValue}):`}
5558
</styled.ClusterAttributeLabel>
5659
<DomainPageFailoverSingleCluster

src/views/domain-page/domain-page-failover-modal/__tests__/domain-page-failover-modal.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ describe(DomainPageFailoverModal.name, () => {
149149
expect(screen.getByText('Scope')).toBeInTheDocument();
150150
expect(screen.getByText('Attribute')).toBeInTheDocument();
151151
expect(screen.getByText('Clusters')).toBeInTheDocument();
152-
expect(screen.getByText('Primary')).toBeInTheDocument();
152+
expect(screen.getByText('Default')).toBeInTheDocument();
153153
expect(screen.getByText('-')).toBeInTheDocument();
154154
expect(
155155
screen.getByTestId('mock-single-cluster-failover')
@@ -174,7 +174,7 @@ describe(DomainPageFailoverModal.name, () => {
174174
expect(screen.queryByText('Clusters')).not.toBeInTheDocument();
175175
});
176176

177-
it('displays Primary scope and dash for attribute when clusterAttribute is null', () => {
177+
it('displays Default scope and dash for attribute when clusterAttribute is null', () => {
178178
const failoverEvent: FailoverEvent = {
179179
id: 'failover-1',
180180
createdTime: {
@@ -199,7 +199,7 @@ describe(DomainPageFailoverModal.name, () => {
199199

200200
setup({ failoverEvent, isOpen: true });
201201

202-
expect(screen.getByText('Primary')).toBeInTheDocument();
202+
expect(screen.getByText('Default')).toBeInTheDocument();
203203
expect(screen.getByText('-')).toBeInTheDocument();
204204
});
205205

@@ -274,7 +274,7 @@ describe(DomainPageFailoverModal.name, () => {
274274

275275
setup({ failoverEvent, isOpen: true });
276276

277-
expect(screen.getByText('Primary')).toBeInTheDocument();
277+
expect(screen.getByText('Default')).toBeInTheDocument();
278278
expect(screen.getByText('region')).toBeInTheDocument();
279279
expect(screen.getByText('us-east')).toBeInTheDocument();
280280
const clusterComponents = screen.getAllByTestId(

src/views/domain-page/domain-page-failover-modal/domain-page-failover-modal.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
'use client';
21
import { useMemo } from 'react';
32

43
import { Modal, ModalBody, ModalButton } from 'baseui/modal';
@@ -31,7 +30,7 @@ export default function DomainPageFailoverModal({
3130
const attribute = clusterFailover.clusterAttribute;
3231
if (attribute === null) {
3332
return {
34-
scope: 'Primary',
33+
scope: 'Default',
3534
attribute: '-',
3635
clusters,
3736
};

src/views/domain-page/domain-page-failover-single-cluster/__tests__/domain-page-failover-single-cluster.test.tsx

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,24 @@ describe(DomainPageFailoverSingleCluster.name, () => {
1010
expect(screen.getByText(/cluster-2/)).toBeInTheDocument();
1111
});
1212

13-
it('returns null when fromCluster is missing', () => {
13+
it('renders a placeholder when fromCluster is missing', () => {
1414
setup({ toCluster: 'cluster-2' });
1515

16-
expect(screen.queryByText(/cluster-2/)).not.toBeInTheDocument();
16+
expect(screen.getByText('None')).toBeInTheDocument();
17+
expect(screen.getByText(/cluster-2/)).toBeInTheDocument();
1718
});
1819

19-
it('returns null when toCluster is missing', () => {
20+
it('renders a placeholder when toCluster is missing', () => {
2021
setup({ fromCluster: 'cluster-1' });
2122

22-
expect(screen.queryByText(/cluster-1/)).not.toBeInTheDocument();
23+
expect(screen.getByText(/cluster-1/)).toBeInTheDocument();
24+
expect(screen.getByText('None')).toBeInTheDocument();
25+
});
26+
27+
it('renders null (and not the None placeholders) when both clusters are missing', () => {
28+
setup({});
29+
30+
expect(screen.queryByText('None')).not.toBeInTheDocument();
2331
});
2432
});
2533

src/views/domain-page/domain-page-failover-single-cluster/domain-page-failover-single-cluster.styles.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,9 @@ const cssStylesObj = {
1111
gap: theme.sizing.scale400,
1212
alignItems: 'center',
1313
}),
14+
noClusterContainer: (theme: Theme) => ({
15+
color: theme.colors.contentSecondary,
16+
}),
1417
} satisfies StyletronCSSObject;
1518

1619
export const cssStyles: StyletronCSSObjectOf<typeof cssStylesObj> =

src/views/domain-page/domain-page-failover-single-cluster/domain-page-failover-single-cluster.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,13 @@ export default function DomainPageFailoverSingleCluster({
1111
}: Props) {
1212
const { cls, theme } = useStyletronClasses(cssStyles);
1313

14-
if (!fromCluster || !toCluster) return null;
14+
if (!fromCluster && !toCluster) return null;
1515

1616
return (
1717
<div className={cls.failoverContainer}>
18-
{fromCluster}
18+
{fromCluster ?? <div className={cls.noClusterContainer}>None</div>}
1919
<MdArrowForward color={theme.colors.contentSecondary} />
20-
{toCluster}
20+
{toCluster ?? <div className={cls.noClusterContainer}>None</div>}
2121
</div>
2222
);
2323
}

src/views/domain-page/domain-page-failovers-filters/__tests__/domain-page-failovers-filters.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import type domainPageQueryParamsConfig from '@/views/domain-page/config/domain-
66
import { mockActiveActiveDomain } from '@/views/shared/active-active/__fixtures__/active-active-domain';
77
import { type ActiveActiveDomain } from '@/views/shared/active-active/active-active.types';
88

9-
import { PRIMARY_CLUSTER_SCOPE } from '../../domain-page-failovers/domain-page-failovers.constants';
9+
import { DEFAULT_CLUSTER_SCOPE } from '../../domain-page-failovers/domain-page-failovers.constants';
1010
import DomainPageFailoversFilters from '../domain-page-failovers-filters';
1111

1212
describe(DomainPageFailoversFilters.name, () => {
@@ -26,14 +26,14 @@ describe(DomainPageFailoversFilters.name, () => {
2626
);
2727
await user.click(scopeCombobox);
2828

29-
expect(screen.getByText(PRIMARY_CLUSTER_SCOPE)).toBeInTheDocument();
29+
expect(screen.getByText(DEFAULT_CLUSTER_SCOPE)).toBeInTheDocument();
3030
expect(screen.getByText('region')).toBeInTheDocument();
3131
});
3232

33-
it('disables cluster attribute value combobox when scope is primary', () => {
33+
it('disables cluster attribute value combobox when scope is default', () => {
3434
setup({
3535
queryParamsOverrides: {
36-
clusterAttributeScope: PRIMARY_CLUSTER_SCOPE,
36+
clusterAttributeScope: DEFAULT_CLUSTER_SCOPE,
3737
},
3838
});
3939

0 commit comments

Comments
 (0)