Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "cadence-web",
"private": true,
"config": {
"cadence_idl_version": "0e56e57909d9fa738eaa8d7a9561ea16acdf51e4"
"cadence_idl_version": "792058c9dbad5787cf8444c5d4bef0763a311b0c"
},
"scripts": {
"dev": "next dev -p ${CADENCE_WEB_PORT:-8088} -H ${CADENCE_WEB_HOSTNAME:-0.0.0.0} | pino-pretty --messageKey message",
Expand Down
10 changes: 10 additions & 0 deletions src/utils/data-formatters/schema/history-event-schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,20 @@ const cronOverlapPolicySchema = z.enum([
CronOverlapPolicy.CRON_OVERLAP_POLICY_BUFFER_ONE,
]);

const clusterAttributeSchema = z.object({
scope: z.string(),
name: z.string(),
});

// TODO @adhitya.mamallan - this needs to be removed as part of active-active's redesign
const activeClusterSelectionStrategySchema = z.enum([
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_INVALID,
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_REGION_STICKY,
ActiveClusterSelectionStrategy.ACTIVE_CLUSTER_SELECTION_STRATEGY_EXTERNAL_ENTITY,
]);

// TODO @adhitya.mamallan - this needs to be modified as part of active-active's redesign,
// so that we only check for clusterAttributes
const activeClusterSelectionPolicySchema = z.discriminatedUnion(
'strategyConfig',
[
Expand All @@ -157,6 +165,7 @@ const activeClusterSelectionPolicySchema = z.discriminatedUnion(
stickyRegion: z.string(),
}),
activeClusterExternalEntityConfig: z.nullable(z.undefined()),
clusterAttribute: clusterAttributeSchema.nullable(),
}),
z.object({
strategy: activeClusterSelectionStrategySchema,
Expand All @@ -166,6 +175,7 @@ const activeClusterSelectionPolicySchema = z.discriminatedUnion(
externalEntityType: z.string(),
externalEntityKey: z.string(),
}),
clusterAttribute: clusterAttributeSchema.nullable(),
}),
]
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,9 @@ import {
mockDomainDescription,
mockDomainDescriptionSingleCluster,
} from '../../__fixtures__/domain-description';
import * as isActiveClusterModule from '../../helpers/is-active-cluster';
import DomainPageMetadataClusters from '../domain-page-metadata-clusters';

jest.mock('../../helpers/is-active-cluster', () => ({
__esModule: true,
default: jest.fn().mockReturnValue(false),
}));

describe(DomainPageMetadataClusters.name, () => {
beforeEach(() => {
jest.clearAllMocks();
});

it('renders plain text for single cluster', async () => {
render(
<DomainPageMetadataClusters {...mockDomainDescriptionSingleCluster} />
Expand All @@ -27,11 +17,6 @@ describe(DomainPageMetadataClusters.name, () => {
});

it('renders active/passive labels and links for multiple clusters', () => {
jest
.spyOn(isActiveClusterModule, 'default')
.mockReturnValueOnce(true) // cluster_1 is active
.mockReturnValueOnce(false); // cluster_2 is passive

const { container } = render(
<DomainPageMetadataClusters {...mockDomainDescription} />
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ import React from 'react';
import Link from '@/components/link/link';

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

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

Expand All @@ -18,12 +17,10 @@ export default function DomainPageMetadataClusters(
return (
<styled.ClusterTextContainer>
{domainDescription.clusters.map((cluster, index) => {
const replicationStatusLabel = isActiveCluster(
domainDescription,
cluster.clusterName
)
? 'active'
: 'passive';
const replicationStatusLabel =
cluster.clusterName === domainDescription.activeClusterName
? 'active'
: 'passive';

return (
<React.Fragment key={cluster.clusterName}>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,10 @@
import { render, screen } from '@/test-utils/rtl';

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

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

jest.mock('@/components/list-table-nested/sublist-table/sublist-table', () =>
jest.fn(({ items }: SublistTableProps) => (
<div data-testid="mock-sublist-table">{JSON.stringify(items)}</div>
))
);

jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');

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

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

it('renders SublistTable for active-active domains', () => {
// TODO @adhitya.mamallan: add special rendering for failover versions for different cluster attributes
it('temp: renders failover version as text for active-active domains', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: Don't see much value from adding temp: to the test case name. We track todos in different ways and the name can keep describing what it tests only.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I completely delete the file in #1052 anyway 😅

render(<DomainPageMetadataFailoverVersion {...mockActiveActiveDomain} />);

const sublistTable = screen.getByTestId('mock-sublist-table');
expect(sublistTable).toBeInTheDocument();
expect(sublistTable).toHaveTextContent(
/{"key":"cluster0","label":"cluster0","value":"0"}/
);
expect(sublistTable).toHaveTextContent(
/{"key":"cluster1","label":"cluster1","value":"2"}/
);
expect(screen.getByText('2')).toBeInTheDocument();
});
});
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import SublistTable from '@/components/list-table-nested/sublist-table/sublist-table';
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';

import { type DomainDescription } from '../domain-page.types';
Expand All @@ -7,22 +6,8 @@ export default function DomainPageMetadataFailoverVersion(
domainDescription: DomainDescription
) {
if (isActiveActiveDomain(domainDescription)) {
return (
<SublistTable
items={Object.values(domainDescription.activeClusters.regionToCluster)
.sort(
(
{ activeClusterName: clusterA },
{ activeClusterName: clusterB }
) => (clusterA > clusterB ? 1 : -1)
)
.map(({ activeClusterName, failoverVersion }) => ({
key: activeClusterName,
label: activeClusterName,
value: failoverVersion,
}))}
/>
);
// TODO @adhitya.mamallan: add special rendering for failover versions for different cluster attributes
return domainDescription.failoverVersion;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This one is still under discussion but part of the planned changes correct?

Copy link
Member Author

@adhityamamallan adhityamamallan Oct 27, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, I've raised a follow-up for it already (#1052)

}

return domainDescription.failoverVersion;
Expand Down
50 changes: 0 additions & 50 deletions src/views/domain-page/helpers/__tests__/is-active-cluster.test.ts

This file was deleted.

18 changes: 0 additions & 18 deletions src/views/domain-page/helpers/is-active-cluster.ts

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,8 @@ jest.mock('@/views/shared/domain-status-tag/domain-status-tag', () =>
);

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

describe('DomainTableClusterCell', () => {
describe(DomainsTableDomainNameCell.name, () => {
it('should render link for domain if domain using the active cluster', async () => {
render(<DomainsTableDomainNameCell {...globalDomain} />);
const clusterLinks = await screen.findAllByRole('link');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,19 @@ import cadenceIcon from '@/assets/cadence-logo.svg';
import Link from '@/components/link/link';
import useStyletronClasses from '@/hooks/use-styletron-classes';
import type { DomainData } from '@/views/domains-page/domains-page.types';
import getDefaultClusterForActiveActiveDomain from '@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain';
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';
import DomainStatusTag from '@/views/shared/domain-status-tag/domain-status-tag';

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

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

const clusterName = isActiveActiveDomain(props)
? getDefaultClusterForActiveActiveDomain(props)
: props.activeClusterName;

return (
<div className={cls.domainNameCell}>
<Image width={16} height={16} alt="Cadence Icon" src={cadenceIcon} />
<Link href={`/domains/${props.name}/${clusterName}`}>{props.name}</Link>
<Link href={`/domains/${props.name}/${props.activeClusterName}`}>
{props.name}
</Link>
{props.status !== 'DOMAIN_STATUS_REGISTERED' && (
<DomainStatusTag status={props.status} />
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import getUniqueDomains from '../get-unique-domains';

jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');

jest.mock(
'@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain'
);

describe('getUniqueDomains', () => {
it('should return unique domains based on id-name-activeClusterName', () => {
const domains: DomainData[] = [
Expand Down
12 changes: 3 additions & 9 deletions src/views/domains-page/helpers/get-unique-domains.ts
Original file line number Diff line number Diff line change
@@ -1,18 +1,12 @@
import getDefaultClusterForActiveActiveDomain from '@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain';
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';

import { type DomainData } from '../domains-page.types';

export default function getUniqueDomains(domains: DomainData[]) {
const allUniqueDomains: Record<string, boolean> = {};
return domains.filter((d: DomainData) => {
const defaultCluster = isActiveActiveDomain(d)
? getDefaultClusterForActiveActiveDomain(d)
: d.activeClusterName;

if (allUniqueDomains[`${d.id}-${d.name}-${defaultCluster}`]) return false;
if (allUniqueDomains[`${d.id}-${d.name}-${d.activeClusterName}`])
return false;

allUniqueDomains[`${d.id}-${d.name}-${defaultCluster}`] = true;
allUniqueDomains[`${d.id}-${d.name}-${d.activeClusterName}`] = true;
return true;
});
}
6 changes: 1 addition & 5 deletions src/views/redirect-domain/__tests__/redirect-domain.node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@ import RedirectDomain from '../redirect-domain';

jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');

jest.mock(
'@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain'
);

const MOCK_ALL_DOMAINS: Array<DomainData> = [
getDomainObj({
name: 'mock-domain-unique',
Expand Down Expand Up @@ -78,7 +74,7 @@ describe(RedirectDomain.name, () => {
expectedRedirect: '/domains/mock-domain-unique/mock-cluster-1',
},
{
name: 'should redirect to domain page of default UI cluster for an active-active domain',
name: 'should redirect to domain page of active cluster for an active-active domain',
urlParams: ['mock-domain-active-active'],
expectedRedirect: '/domains/mock-domain-active-active/cluster0',
},
Expand Down
8 changes: 1 addition & 7 deletions src/views/redirect-domain/redirect-domain.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
import { notFound, redirect } from 'next/navigation';
import queryString from 'query-string';

import getDefaultClusterForActiveActiveDomain from '@/views/shared/active-active/helpers/get-default-cluster-for-active-active-domain';
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';

import { getCachedAllDomains } from '../domains-page/helpers/get-all-domains';

import { type Props } from './redirect-domain.types';
Expand Down Expand Up @@ -36,11 +33,8 @@ export default async function RedirectDomain(props: Props) {
})
);
}
const clusterToRedirectTo = isActiveActiveDomain(domainDetails)
? getDefaultClusterForActiveActiveDomain(domainDetails)
: domainDetails.activeClusterName;

const baseUrl = `/domains/${encodeURIComponent(domain)}/${encodeURIComponent(clusterToRedirectTo)}`;
const baseUrl = `/domains/${encodeURIComponent(domain)}/${encodeURIComponent(domainDetails.activeClusterName)}`;

redirect(
queryString.stringifyUrl({
Expand Down
Loading
Loading