fix(domain-manager): correct domain URL reference and filter logic (#12074)

Updated URL reference from getFrontUrl to getBaseUrl to ensure correct
hostname handling. Adjusted record filtering logic to exclude successful
records, preventing unnecessary rendering in the UI.
This commit is contained in:
Antoine Moreaux
2025-05-15 19:35:55 +02:00
committed by GitHub
parent 09d92c9113
commit 1570ad955e
4 changed files with 41 additions and 37 deletions
@@ -92,18 +92,20 @@ export const SettingsCustomDomain = () => {
Icon={IconTrash}
variant="primary"
onClick={deleteCustomDomain}
type="button"
/>
</StyledButtonGroup>
</StyledDomainFormWrapper>
{currentWorkspace?.customDomain && (
<StyledRecordsWrapper>
<SettingsCustomDomainRecordsStatus />
{customDomainRecords && (
<SettingsCustomDomainRecords
records={customDomainRecords.records}
/>
)}
{customDomainRecords &&
customDomainRecords.records.some(
(record) => record.status !== 'success',
) && (
<SettingsCustomDomainRecords
records={customDomainRecords.records}
/>
)}
</StyledRecordsWrapper>
)}
</Section>
@@ -70,33 +70,35 @@ export const SettingsCustomDomainRecords = ({
<TableHeader>Value</TableHeader>
</TableRow>
<TableBody>
{records.map((record) => (
<TableRow gridAutoColumns="30% 16% auto" key={record.key}>
<StyledTableCell>
<StyledButton
title={record.key}
onClick={() => copyToClipboardDebounced(record.key)}
type="button"
/>
</StyledTableCell>
<StyledTableCell>
<StyledButton
title={record.type.toUpperCase()}
onClick={() =>
copyToClipboardDebounced(record.type.toUpperCase())
}
type="button"
/>
</StyledTableCell>
<StyledTableCell>
<StyledButton
title={record.value}
onClick={() => copyToClipboardDebounced(record.value)}
type="button"
/>
</StyledTableCell>
</TableRow>
))}
{records
.filter((record) => record.status !== 'success')
.map((record) => (
<TableRow gridAutoColumns="30% 16% auto" key={record.key}>
<StyledTableCell>
<StyledButton
title={record.key}
onClick={() => copyToClipboardDebounced(record.key)}
type="button"
/>
</StyledTableCell>
<StyledTableCell>
<StyledButton
title={record.type.toUpperCase()}
onClick={() =>
copyToClipboardDebounced(record.type.toUpperCase())
}
type="button"
/>
</StyledTableCell>
<StyledTableCell>
<StyledButton
title={record.value}
onClick={() => copyToClipboardDebounced(record.value)}
type="button"
/>
</StyledTableCell>
</TableRow>
))}
</TableBody>
</StyledTable>
);
@@ -36,7 +36,7 @@ describe('CustomDomainService', () => {
{
provide: DomainManagerService,
useValue: {
getFrontUrl: jest.fn(),
getBaseUrl: jest.fn(),
},
},
],
@@ -148,7 +148,7 @@ describe('CustomDomainService', () => {
jest.spyOn(twentyConfigService, 'get').mockReturnValue('test-zone-id');
jest
.spyOn(domainManagerService, 'getFrontUrl')
.spyOn(domainManagerService, 'getBaseUrl')
.mockReturnValue(new URL('https://front.domain'));
(customDomainService as any).cloudflareClient = cloudflareMock;
@@ -185,7 +185,7 @@ describe('CustomDomainService', () => {
jest.spyOn(twentyConfigService, 'get').mockReturnValue('test-zone-id');
jest
.spyOn(domainManagerService, 'getFrontUrl')
.spyOn(domainManagerService, 'getBaseUrl')
.mockReturnValue(new URL('https://front.domain'));
(customDomainService as any).cloudflareClient = cloudflareMock;
@@ -133,7 +133,7 @@ export class CustomDomainService {
? 'error'
: 'success',
key: response.result[0].hostname,
value: this.domainManagerService.getFrontUrl().hostname,
value: this.domainManagerService.getBaseUrl().hostname,
},
]),
};