Skip to content

Commit ff4f053

Browse files
Change global/local field to Cluster Operation Mode (#1000)
Change global/local field to Cluster Operation Mode, with three possible values: Active-Active, Active-Passive (formerly Global), and Local
1 parent bab4502 commit ff4f053

File tree

4 files changed

+64
-9
lines changed

4 files changed

+64
-9
lines changed

src/views/domain-page/config/domain-page-metadata-extended-table.config.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ import { createElement } from 'react';
22

33
import DomainPageMetadataClusters from '../domain-page-metadata-clusters/domain-page-metadata-clusters';
44
import DomainPageMetadataDescription from '../domain-page-metadata-description/domain-page-metadata-description';
5+
import DomainPageMetadataMode from '../domain-page-metadata-mode/domain-page-metadata-mode';
56
import { type MetadataItem } from '../domain-page-metadata-table/domain-page-metadata-table.types';
67
import DomainPageMetadataViewJson from '../domain-page-metadata-view-json/domain-page-metadata-view-json';
78

@@ -40,13 +41,12 @@ const domainPageMetadataExtendedTableConfig = [
4041
createElement(DomainPageMetadataClusters, domainDescription),
4142
},
4243
{
43-
key: 'globalOrLocal',
44-
label: 'Global/Local',
45-
description:
46-
'Whether the domain is global (operates in multiple clusters) or not',
44+
key: 'mode',
45+
label: 'Mode',
46+
description: 'Domain operation mode in multi-cluster setup',
4747
kind: 'simple',
4848
getValue: ({ domainDescription }) =>
49-
domainDescription.isGlobalDomain ? 'Global' : 'Local',
49+
createElement(DomainPageMetadataMode, domainDescription),
5050
},
5151
{
5252
key: 'failoverVersion',

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import type { ListTableItem } from '@/components/list-table/list-table.types';
22

33
import DomainPageMetadataClusters from '../domain-page-metadata-clusters/domain-page-metadata-clusters';
4+
import DomainPageMetadataMode from '../domain-page-metadata-mode/domain-page-metadata-mode';
45
import { type DomainDescription } from '../domain-page.types';
56

67
const domainPageMetadataTableConfig: Array<ListTableItem<DomainDescription>> = [
@@ -21,10 +22,9 @@ const domainPageMetadataTableConfig: Array<ListTableItem<DomainDescription>> = [
2122
renderValue: DomainPageMetadataClusters,
2223
},
2324
{
24-
key: 'globalOrLocal',
25-
label: 'Global/Local',
26-
renderValue: (domainDescription: DomainDescription) =>
27-
domainDescription.isGlobalDomain ? 'Global' : 'Local',
25+
key: 'mode',
26+
label: 'Mode',
27+
renderValue: DomainPageMetadataMode,
2828
},
2929
{
3030
key: 'failoverVersion',
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
import { render, screen } from '@/test-utils/rtl';
2+
3+
import { mockActiveActiveDomain } from '@/views/shared/active-active/__fixtures__/active-active-domain';
4+
5+
import {
6+
mockDomainDescription,
7+
mockDomainDescriptionSingleCluster,
8+
} from '../../__fixtures__/domain-description';
9+
import DomainPageMetadataMode from '../domain-page-metadata-mode';
10+
11+
jest.mock('@/views/shared/active-active/helpers/is-active-active-domain');
12+
13+
describe(DomainPageMetadataMode.name, () => {
14+
it('renders Active-Active when domain is active-active', () => {
15+
render(<DomainPageMetadataMode {...mockActiveActiveDomain} />);
16+
17+
expect(screen.getByText('Active-Active')).toBeInTheDocument();
18+
});
19+
20+
it('renders Active-Passive when domain is global but not active-active', () => {
21+
render(<DomainPageMetadataMode {...mockDomainDescription} />);
22+
23+
expect(screen.getByText('Active-Passive')).toBeInTheDocument();
24+
});
25+
26+
it('renders Local when domain is not global', () => {
27+
render(
28+
<DomainPageMetadataMode
29+
{...{
30+
...mockDomainDescriptionSingleCluster,
31+
isGlobalDomain: false,
32+
}}
33+
/>
34+
);
35+
36+
expect(screen.getByText('Local')).toBeInTheDocument();
37+
});
38+
});
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import isActiveActiveDomain from '@/views/shared/active-active/helpers/is-active-active-domain';
2+
3+
import { type DomainDescription } from '../domain-page.types';
4+
5+
export default function DomainPageMetadataMode(
6+
domainDescription: DomainDescription
7+
) {
8+
if (isActiveActiveDomain(domainDescription)) {
9+
return 'Active-Active';
10+
}
11+
12+
if (domainDescription.isGlobalDomain) {
13+
return 'Active-Passive';
14+
}
15+
16+
return 'Local';
17+
}

0 commit comments

Comments
 (0)