Skip to content

Commit 5f52059

Browse files
Update IDL to latest and fix errors (#1048)
* Update IDLs to cadence-workflow/cadence-idl@792058c * Rewrite logic for isActiveActiveDomain to check for new active-active fields * Update fixtures for active-active domains * Remove logic to find default active cluster for UI, now that activeClusterName will be set for active-active domains as well * Remove activeClusterSelectionPolicy from Workflow Summary for the time being * Remove failover version table for the time being (will be added in a follow-up PR) Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
1 parent 852f0a1 commit 5f52059

25 files changed

+54
-409
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "cadence-web",
33
"private": true,
44
"config": {
5-
"cadence_idl_version": "0e56e57909d9fa738eaa8d7a9561ea16acdf51e4"
5+
"cadence_idl_version": "792058c9dbad5787cf8444c5d4bef0763a311b0c"
66
},
77
"scripts": {
88
"dev": "next dev -p ${CADENCE_WEB_PORT:-8088} -H ${CADENCE_WEB_HOSTNAME:-0.0.0.0} | pino-pretty --messageKey message",

src/utils/data-formatters/schema/history-event-schema.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,20 @@ const cronOverlapPolicySchema = z.enum([
141141
CronOverlapPolicy.CRON_OVERLAP_POLICY_BUFFER_ONE,
142142
]);
143143

144+
const clusterAttributeSchema = z.object({
145+
scope: z.string(),
146+
name: z.string(),
147+
});
148+
149+
// TODO @adhitya.mamallan - this needs to be removed as part of active-active's redesign
144150
const activeClusterSelectionStrategySchema = z.enum([
145151
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_INVALID,
146152
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_REGION_STICKY,
147153
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_EXTERNAL_ENTITY,
148154
]);
149155

156+
// TODO @adhitya.mamallan - this needs to be modified as part of active-active's redesign,
157+
// so that we only check for clusterAttributes
150158
const activeClusterSelectionPolicySchema = z.discriminatedUnion(
151159
'strategyConfig',
152160
[
@@ -157,6 +165,7 @@ const activeClusterSelectionPolicySchema = z.discriminatedUnion(
157165
stickyRegion: z.string(),
158166
}),
159167
activeClusterExternalEntityConfig: z.nullable(z.undefined()),
168+
clusterAttribute: clusterAttributeSchema.nullable(),
160169
}),
161170
z.object({
162171
strategy: activeClusterSelectionStrategySchema,
@@ -166,6 +175,7 @@ const activeClusterSelectionPolicySchema = z.discriminatedUnion(
166175
externalEntityType: z.string(),
167176
externalEntityKey: z.string(),
168177
}),
178+
clusterAttribute: clusterAttributeSchema.nullable(),
169179
}),
170180
]
171181
);

src/views/domain-page/domain-page-metadata-clusters/__tests__/domain-page-metadata-clusters.test.tsx

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,9 @@ import {
44
mockDomainDescription,
55
mockDomainDescriptionSingleCluster,
66
} from '../../__fixtures__/domain-description';
7-
import * as isActiveClusterModule from '../../helpers/is-active-cluster';
87
import DomainPageMetadataClusters from '../domain-page-metadata-clusters';
98

10-
jest.mock('../../helpers/is-active-cluster', () => ({
11-
__esModule: true,
12-
default: jest.fn().mockReturnValue(false),
13-
}));
14-
159
describe(DomainPageMetadataClusters.name, () => {
16-
beforeEach(() => {
17-
jest.clearAllMocks();
18-
});
19-
2010
it('renders plain text for single cluster', async () => {
2111
render(
2212
<DomainPageMetadataClusters {...mockDomainDescriptionSingleCluster} />
@@ -27,11 +17,6 @@ describe(DomainPageMetadataClusters.name, () => {
2717
});
2818

2919
it('renders active/passive labels and links for multiple clusters', () => {
30-
jest
31-
.spyOn(isActiveClusterModule, 'default')
32-
.mockReturnValueOnce(true) // cluster_1 is active
33-
.mockReturnValueOnce(false); // cluster_2 is passive
34-
3520
const { container } = render(
3621
<DomainPageMetadataClusters {...mockDomainDescription} />
3722
);

src/views/domain-page/domain-page-metadata-clusters/domain-page-metadata-clusters.tsx

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import React from 'react';
33
import Link from '@/components/link/link';
44

55
import { type DomainDescription } from '../domain-page.types';
6-
import isActiveCluster from '../helpers/is-active-cluster';
76

87
import { styled } from './domain-page-metadata-clusters.styles';
98

@@ -18,12 +17,10 @@ export default function DomainPageMetadataClusters(
1817
return (
1918
<styled.ClusterTextContainer>
2019
{domainDescription.clusters.map((cluster, index) => {
21-
const replicationStatusLabel = isActiveCluster(
22-
domainDescription,
23-
cluster.clusterName
24-
)
25-
? 'active'
26-
: 'passive';
20+
const replicationStatusLabel =
21+
cluster.clusterName === domainDescription.activeClusterName
22+
? 'active'
23+
: 'passive';
2724

2825
return (
2926
<React.Fragment key={cluster.clusterName}>
Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,10 @@
11
import { render, screen } from '@/test-utils/rtl';
22

3-
import { type Props as SublistTableProps } from '@/components/list-table-nested/sublist-table/sublist-table.types';
43
import { mockActiveActiveDomain } from '@/views/shared/active-active/__fixtures__/active-active-domain';
54

65
import { mockDomainDescription } from '../../__fixtures__/domain-description';
76
import DomainPageMetadataFailoverVersion from '../domain-page-metadata-failover-version';
87

9-
jest.mock('@/components/list-table-nested/sublist-table/sublist-table', () =>
10-
jest.fn(({ items }: SublistTableProps) => (
11-
<div data-testid="mock-sublist-table">{JSON.stringify(items)}</div>
12-
))
13-
);
14-
158
jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');
169

1710
describe(DomainPageMetadataFailoverVersion.name, () => {
@@ -23,19 +16,12 @@ describe(DomainPageMetadataFailoverVersion.name, () => {
2316
render(<DomainPageMetadataFailoverVersion {...mockDomainDescription} />);
2417

2518
expect(screen.getByText('123456')).toBeInTheDocument();
26-
expect(screen.queryByTestId('mock-sublist-table')).not.toBeInTheDocument();
2719
});
2820

29-
it('renders SublistTable for active-active domains', () => {
21+
// TODO @adhitya.mamallan: add special rendering for failover versions for different cluster attributes
22+
it('temp: renders failover version as text for active-active domains', () => {
3023
render(<DomainPageMetadataFailoverVersion {...mockActiveActiveDomain} />);
3124

32-
const sublistTable = screen.getByTestId('mock-sublist-table');
33-
expect(sublistTable).toBeInTheDocument();
34-
expect(sublistTable).toHaveTextContent(
35-
/{"key":"cluster0","label":"cluster0","value":"0"}/
36-
);
37-
expect(sublistTable).toHaveTextContent(
38-
/{"key":"cluster1","label":"cluster1","value":"2"}/
39-
);
25+
expect(screen.getByText('2')).toBeInTheDocument();
4026
});
4127
});

src/views/domain-page/domain-page-metadata-failover-version/domain-page-metadata-failover-version.tsx

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import SublistTable from '@/components/list-table-nested/sublist-table/sublist-table';
21
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';
32

43
import { type DomainDescription } from '../domain-page.types';
@@ -7,22 +6,8 @@ export default function DomainPageMetadataFailoverVersion(
76
domainDescription: DomainDescription
87
) {
98
if (isActiveActiveDomain(domainDescription)) {
10-
return (
11-
<SublistTable
12-
items={Object.values(domainDescription.activeClusters.regionToCluster)
13-
.sort(
14-
(
15-
{ activeClusterName: clusterA },
16-
{ activeClusterName: clusterB }
17-
) => (clusterA > clusterB ? 1 : -1)
18-
)
19-
.map(({ activeClusterName, failoverVersion }) => ({
20-
key: activeClusterName,
21-
label: activeClusterName,
22-
value: failoverVersion,
23-
}))}
24-
/>
25-
);
9+
// TODO @adhitya.mamallan: add special rendering for failover versions for different cluster attributes
10+
return domainDescription.failoverVersion;
2611
}
2712

2813
return domainDescription.failoverVersion;

src/views/domain-page/helpers/__tests__/is-active-cluster.test.ts

Lines changed: 0 additions & 50 deletions
This file was deleted.

src/views/domain-page/helpers/is-active-cluster.ts

Lines changed: 0 additions & 18 deletions
This file was deleted.

src/views/domains-page/domains-table-domain-name-cell/__tests__/domains-table-domain-name-cell.test.tsx

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,8 @@ jest.mock('@/views/shared/domain-status-tag/domain-status-tag', () =>
1414
);
1515

1616
jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');
17-
jest.mock(
18-
'@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain'
19-
);
2017

21-
describe('DomainTableClusterCell', () => {
18+
describe(DomainsTableDomainNameCell.name, () => {
2219
it('should render link for domain if domain using the active cluster', async () => {
2320
render(<DomainsTableDomainNameCell {...globalDomain} />);
2421
const clusterLinks = await screen.findAllByRole('link');

src/views/domains-page/domains-table-domain-name-cell/domains-table-domain-name-cell.tsx

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,19 @@ import cadenceIcon from '@/assets/cadence-logo.svg';
77
import Link from '@/components/link/link';
88
import useStyletronClasses from '@/hooks/use-styletron-classes';
99
import type { DomainData } from '@/views/domains-page/domains-page.types';
10-
import getDefaultClusterForActiveActiveDomain from '@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain';
11-
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';
1210
import DomainStatusTag from '@/views/shared/domain-status-tag/domain-status-tag';
1311

1412
import { cssStyles } from './domains-table-domain-name-cell.styles';
1513

1614
function DomainsTableDomainNameCell(props: DomainData) {
1715
const { cls } = useStyletronClasses(cssStyles);
1816

19-
const clusterName = isActiveActiveDomain(props)
20-
? getDefaultClusterForActiveActiveDomain(props)
21-
: props.activeClusterName;
22-
2317
return (
2418
<div className={cls.domainNameCell}>
2519
<Image width={16} height={16} alt="Cadence Icon" src={cadenceIcon} />
26-
<Link href={`/domains/${props.name}/${clusterName}`}>{props.name}</Link>
20+
<Link href={`/domains/${props.name}/${props.activeClusterName}`}>
21+
{props.name}
22+
</Link>
2723
{props.status !== 'DOMAIN_STATUS_REGISTERED' && (
2824
<DomainStatusTag status={props.status} />
2925
)}

0 commit comments

Comments
 (0)