From d9e09f994445a0ebce0015105cd4df9ebf7be0b7 Mon Sep 17 00:00:00 2001 From: Tristan WAGNER Date: Wed, 27 Nov 2024 16:46:08 +0100 Subject: [PATCH] feat(zimbra): intialize diagnostics page ref: MANAGER-16089 Signed-off-by: Tristan WAGNER --- .../translations/domains/Messages_fr_FR.json | 3 +- .../domains/diagnostic/Messages_fr_FR.json | 72 +++++----- .../layout-helpers/Dashboard/Dashboard.tsx | 5 +- .../apps/zimbra/src/hooks/useDomain.ts | 25 +++- .../Domains/ActionButtonDomain.component.tsx | 17 +++ .../dashboard/Domains/Diagnostics.page.tsx | 133 ++++++++++++++++++ .../src/pages/dashboard/Domains/Domains.tsx | 48 +------ .../ModalDiagnosticDnsRecord.component.tsx | 2 +- .../Domains/ModalEditDomain.component.tsx | 6 +- .../ModalsDiagnosticDNSRecord.spec.tsx | 71 ---------- .../zimbra/src/routes/routes.constants.ts | 5 +- .../manager/apps/zimbra/src/routes/routes.tsx | 40 ++++++ .../zimbra/src/utils/iamAction.constants.ts | 1 + 13 files changed, 265 insertions(+), 163 deletions(-) create mode 100644 packages/manager/apps/zimbra/src/pages/dashboard/Domains/Diagnostics.page.tsx delete mode 100644 packages/manager/apps/zimbra/src/pages/dashboard/Domains/__test__/ModalsDiagnosticDNSRecord.spec.tsx diff --git a/packages/manager/apps/zimbra/public/translations/domains/Messages_fr_FR.json b/packages/manager/apps/zimbra/public/translations/domains/Messages_fr_FR.json index 67aa9374151e..9045052a5b91 100644 --- a/packages/manager/apps/zimbra/public/translations/domains/Messages_fr_FR.json +++ b/packages/manager/apps/zimbra/public/translations/domains/Messages_fr_FR.json @@ -1,14 +1,13 @@ { "zimbra_domains_add_domain_title": "Ajouter un domaine", "zimbra_domains_datagrid_account_label": "Nombre de comptes", - "zimbra_domains_datagrid_diagnostic_label": "Diagnostique", "zimbra_domains_datagrid_diagnostic_configuration_ok": "Configuration OK", - "zimbra_domains_datagrid_diagnostic_tooltip_title": "Diagnostic {{ diagType }}", "zimbra_domains_datagrid_domain_label": "Domaine", "zimbra_domains_datagrid_organization_label": "Organisation", "zimbra_domains_datagrid_status_label": "Statut", "zimbra_domains_datagrid_account_number": "Nombre de comptes", "zimbra_domains_tooltip_configure": "Configurer", "zimbra_domains_tooltip_delete": "Supprimer", + "zimbra_domains_tooltip_diagnostics": "Diagnostiques", "zimbra_domains_tooltip_need_organization": "Veuillez d'abord configurer une organisation" } diff --git a/packages/manager/apps/zimbra/public/translations/domains/diagnostic/Messages_fr_FR.json b/packages/manager/apps/zimbra/public/translations/domains/diagnostic/Messages_fr_FR.json index ded8a920ff98..334aa9f84b5c 100644 --- a/packages/manager/apps/zimbra/public/translations/domains/diagnostic/Messages_fr_FR.json +++ b/packages/manager/apps/zimbra/public/translations/domains/diagnostic/Messages_fr_FR.json @@ -1,37 +1,39 @@ { - "zimbra_domain_modal_diagnostic_guide": "guide", - "zimbra_domain_modal_diagnostic_srv_title": "Diagnostique SRV", - "zimbra_domain_modal_diagnostic_srv_content_header": "Pour faciliter la configuration des boites mails sur vos terminaux, veuillez ajouter cette configuration à votre DNS (consulter notre )", - "zimbra_domain_modal_diagnostic_srv_content_header_ovh_hosted_domain_part1": "La configuration SRV permet la configuration automatique de vos boites mails sur vos clients de messagerie.", - "zimbra_domain_modal_diagnostic_srv_content_header_ovh_hosted_domain_part2": "Votre domaine est hébergé chez OVH Cloud, nous allons procéder à la configuration de votre champ SRV.", - "zimbra_domain_modal_diagnostic_srv_domain": "Domaine", - "zimbra_domain_modal_diagnostic_fields": "Champs", - "zimbra_domain_modal_diagnostic_srv_action_validate": "Valider", - "zimbra_domain_modal_diagnostic_srv_action_cancel": "Annuler", - "zimbra_domain_modal_diagnostic_srv_action_close": "Fermer", - "zimbra_domain_modal_diagnostic_field_subdomain": "Sous domaine :", - "zimbra_domain_modal_diagnostic_field_priority": "Priorité :", - "zimbra_domain_modal_diagnostic_field_weight": "Poids :", - "zimbra_domain_modal_diagnostic_field_port": "Port :", - "zimbra_domain_modal_diagnostic_field_target": "Cible :", - "zimbra_domain_modal_diagnostic_mx_title": "Diagnostique MX", - "zimbra_domain_modal_diagnostic_mx_content_header_part1": "La configuration de l'enregistrement MX permet de recevoir vos emails dans vos boites mail.", - "zimbra_domain_modal_diagnostic_mx_content_header_part2": "Votre domaine n'étant pas géré par OVH Cloud, cette action doit être effectuée manuellement.", - "zimbra_domain_modal_diagnostic_mx_content_header_part3": "Veuillez créer les champs MX sur ce domaine en donnant les mêmes informations que ci-dessous.", - "zimbra_domain_modal_diagnostic_mx_content_header_ovh_hosted_domain_part1": "La configuration de l'enregistrement MX permet de recevoir vos emails dans vos boites mail.", - "zimbra_domain_modal_diagnostic_mx_content_header_ovh_hosted_domain_part2": "Votre domaine étant hébergé chez OVH Cloud, nous allons effectuer la configuration pour vous.", - "zimbra_domain_modal_diagnostic_mx_content_header_ovh_hosted_domain_part3": "Souhaitez-vous commencer à recevoir les mails du domaine {{domain}} sur ce service ?", - "zimbra_domain_modal_diagnostic_mx_content_footer": "En cas de problème, consultez la documentation de votre fournisseur de domaine.", - "zimbra_domain_modal_diagnostic_mx_action_validate": "Confirmer", - "zimbra_domain_modal_diagnostic_mx_action_test": "Tester", - "zimbra_domain_modal_diagnostic_mx_action_cancel": "Annuler", - "zimbra_domain_modal_diagnostic_mx_action_close": "Fermer", - "zimbra_domain_modal_diagnostic_spf_title": "Diagnostique SPF", - "zimbra_domain_modal_diagnostic_spf_content_header": "Si le domaine n'est pas géré par le même identifiant client que le service Exchange ou si votre domaine n'est pas hébergé chez OVHcloud, la configuration automatique n'est pas possible. Veuillez créer le champ SPF sur ce domaine manuellement en donnant les mêmes informations que ci-dessous.", - "zimbra_domain_modal_diagnostic_spf_content_header_ovh_hosted_domain_part1": "SPF permet de valider qu'OVHCloud est un émetteur légitime de mails avec votre nom de domaine.", - "zimbra_domain_modal_diagnostic_spf_content_header_ovh_hosted_domain_part2": "Votre domaine étant hébergé chez OVHCloud, nous pouvons procéder à la configuration automatique.", - "zimbra_domain_modal_diagnostic_spf_content_header_ovh_hosted_domain_part3": "Souhaitez-vous effectuer la configuration ?", - "zimbra_domain_modal_diagnostic_spf_action_cancel": "Annuler", - "zimbra_domain_modal_diagnostic_spf_action_close": "Fermer", - "zimbra_domain_modal_diagnostic_spf_action_validate": "Ok" + "zimbra_domain_diagnostic_cta_back": "Retour aux domaines", + "zimbra_domain_diagnostic_guide": "guide", + "zimbra_domain_diagnostic_subtitle": "Diagnostiques du domaine {{domain}}", + "zimbra_domain_diagnostic_srv_title": "Diagnostique SRV", + "zimbra_domain_diagnostic_srv_content_header": "Pour faciliter la configuration des boites mails sur vos terminaux, veuillez ajouter cette configuration à votre DNS (consulter notre )", + "zimbra_domain_diagnostic_srv_content_header_ovh_hosted_domain_part1": "La configuration SRV permet la configuration automatique de vos boites mails sur vos clients de messagerie.", + "zimbra_domain_diagnostic_srv_content_header_ovh_hosted_domain_part2": "Votre domaine est hébergé chez OVH Cloud, nous allons procéder à la configuration de votre champ SRV.", + "zimbra_domain_diagnostic_srv_domain": "Domaine", + "zimbra_domain_diagnostic_fields": "Champs", + "zimbra_domain_diagnostic_srv_action_validate": "Valider", + "zimbra_domain_diagnostic_srv_action_cancel": "Annuler", + "zimbra_domain_diagnostic_srv_action_close": "Fermer", + "zimbra_domain_diagnostic_field_subdomain": "Sous domaine :", + "zimbra_domain_diagnostic_field_priority": "Priorité :", + "zimbra_domain_diagnostic_field_weight": "Poids :", + "zimbra_domain_diagnostic_field_port": "Port :", + "zimbra_domain_diagnostic_field_target": "Cible :", + "zimbra_domain_diagnostic_mx_title": "Diagnostique MX", + "zimbra_domain_diagnostic_mx_content_header_part1": "La configuration de l'enregistrement MX permet de recevoir vos emails dans vos boites mail.", + "zimbra_domain_diagnostic_mx_content_header_part2": "Votre domaine n'étant pas géré par OVH Cloud, cette action doit être effectuée manuellement.", + "zimbra_domain_diagnostic_mx_content_header_part3": "Veuillez créer les champs MX sur ce domaine en donnant les mêmes informations que ci-dessous.", + "zimbra_domain_diagnostic_mx_content_header_ovh_hosted_domain_part1": "La configuration de l'enregistrement MX permet de recevoir vos emails dans vos boites mail.", + "zimbra_domain_diagnostic_mx_content_header_ovh_hosted_domain_part2": "Votre domaine étant hébergé chez OVH Cloud, nous allons effectuer la configuration pour vous.", + "zimbra_domain_diagnostic_mx_content_header_ovh_hosted_domain_part3": "Souhaitez-vous commencer à recevoir les mails du domaine {{domain}} sur ce service ?", + "zimbra_domain_diagnostic_mx_content_footer": "En cas de problème, consultez la documentation de votre fournisseur de domaine.", + "zimbra_domain_diagnostic_mx_action_validate": "Confirmer", + "zimbra_domain_diagnostic_mx_action_test": "Tester", + "zimbra_domain_diagnostic_mx_action_cancel": "Annuler", + "zimbra_domain_diagnostic_mx_action_close": "Fermer", + "zimbra_domain_diagnostic_spf_title": "Diagnostique SPF", + "zimbra_domain_diagnostic_spf_content_header": "Si le domaine n'est pas géré par le même identifiant client que le service Exchange ou si votre domaine n'est pas hébergé chez OVHcloud, la configuration automatique n'est pas possible. Veuillez créer le champ SPF sur ce domaine manuellement en donnant les mêmes informations que ci-dessous.", + "zimbra_domain_diagnostic_spf_content_header_ovh_hosted_domain_part1": "SPF permet de valider qu'OVHCloud est un émetteur légitime de mails avec votre nom de domaine.", + "zimbra_domain_diagnostic_spf_content_header_ovh_hosted_domain_part2": "Votre domaine étant hébergé chez OVHCloud, nous pouvons procéder à la configuration automatique.", + "zimbra_domain_diagnostic_spf_content_header_ovh_hosted_domain_part3": "Souhaitez-vous effectuer la configuration ?", + "zimbra_domain_diagnostic_spf_action_cancel": "Annuler", + "zimbra_domain_diagnostic_spf_action_close": "Fermer", + "zimbra_domain_diagnostic_spf_action_validate": "Ok" } diff --git a/packages/manager/apps/zimbra/src/components/layout-helpers/Dashboard/Dashboard.tsx b/packages/manager/apps/zimbra/src/components/layout-helpers/Dashboard/Dashboard.tsx index 34245279f673..8ac7cbe2dfb9 100644 --- a/packages/manager/apps/zimbra/src/components/layout-helpers/Dashboard/Dashboard.tsx +++ b/packages/manager/apps/zimbra/src/components/layout-helpers/Dashboard/Dashboard.tsx @@ -89,7 +89,10 @@ export const Dashboard: React.FC = () => { urls.domains, urls.domainsEdit, urls.domainsDelete, - urls.domains_diagnostic, + urls.domains_diagnostic_mx, + urls.domains_diagnostic_spf, + urls.domains_diagnostic_srv, + urls.domains_diagnostic_dkim, ], platformId, ), diff --git a/packages/manager/apps/zimbra/src/hooks/useDomain.ts b/packages/manager/apps/zimbra/src/hooks/useDomain.ts index b94ffe06f7b5..32ba6ead19d4 100644 --- a/packages/manager/apps/zimbra/src/hooks/useDomain.ts +++ b/packages/manager/apps/zimbra/src/hooks/useDomain.ts @@ -1,18 +1,33 @@ -import { useQuery } from '@tanstack/react-query'; +import { + useQuery, + UseQueryOptions, + UseQueryResult, +} from '@tanstack/react-query'; import { usePlatform } from '@/hooks'; import { + DomainType, getZimbraPlatformDomainDetail, getZimbraPlatformDomainQueryKey, } from '@/api/domain'; -export const useDomain = (domainId: string, noCache?: boolean) => { +type UseDomainParams = Omit & { + domainId: string; +}; + +export const useDomain = (params: UseDomainParams) => { + const { domainId, ...options } = params; const { platformId } = usePlatform(); return useQuery({ queryKey: getZimbraPlatformDomainQueryKey(platformId, domainId), queryFn: () => getZimbraPlatformDomainDetail(platformId, domainId), - enabled: !!platformId && !!domainId, - gcTime: noCache ? 0 : 5000, - }); + enabled: (query) => + (typeof options.enabled === 'function' + ? options.enabled(query) + : typeof options.enabled !== 'boolean' || options.enabled) && + !!platformId && + !!domainId, + ...options, + }) as UseQueryResult; }; diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ActionButtonDomain.component.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ActionButtonDomain.component.tsx index c71eb5bd0c53..33ccd3f006a4 100644 --- a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ActionButtonDomain.component.tsx +++ b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ActionButtonDomain.component.tsx @@ -7,6 +7,7 @@ import { DomainsItem } from './Domains'; import { useGenerateUrl, usePlatform } from '@/hooks'; import { IAM_ACTIONS } from '@/utils/iamAction.constants'; import { ResourceStatus } from '@/api/api.type'; +import { FEATURE_FLAGS } from '@/utils'; interface ActionButtonDomainProps { domainItem: DomainsItem; @@ -34,6 +35,14 @@ const ActionButtonDomain: React.FC = ({ navigate(hrefEditDomain); }; + const hrefDiagnosticsDomain = useGenerateUrl('./diagnostics/mx', 'path', { + domainId: domainItem.id, + }); + + const handleDiagnosticsDomainClick = () => { + navigate(hrefDiagnosticsDomain); + }; + const actionItems = [ { id: 1, @@ -44,6 +53,14 @@ const ActionButtonDomain: React.FC = ({ }, { id: 2, + onclick: handleDiagnosticsDomainClick, + label: t('zimbra_domains_tooltip_diagnostics'), + urn: platformUrn, + iamActions: [IAM_ACTIONS.domain.edit /* TODO diagnose */], + hidden: !FEATURE_FLAGS.DOMAIN_DIAGNOSTICS, + }, + { + id: 3, onclick: handleDeleteDomainClick, label: t('zimbra_domains_tooltip_delete'), urn: platformUrn, diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Diagnostics.page.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Diagnostics.page.tsx new file mode 100644 index 000000000000..b4e106b947b2 --- /dev/null +++ b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Diagnostics.page.tsx @@ -0,0 +1,133 @@ +import React, { useEffect, useState } from 'react'; +import { + LinkType, + Links, + IconLinkAlignmentType, + Subtitle, +} from '@ovh-ux/manager-react-components'; + +import { useTranslation } from 'react-i18next'; +import { useLocation, useNavigate, useSearchParams } from 'react-router-dom'; +import { ODS_LINK_COLOR } from '@ovhcloud/ods-components'; +import { useGenerateUrl, useDomain, usePlatform } from '@/hooks'; +import Loading from '@/components/Loading/Loading'; +import TabsPanel, { + activatedTabs, + computePathMatchers, + TabItemProps, +} from '@/components/layout-helpers/Dashboard/TabsPanel'; +import { urls } from '@/routes/routes.constants'; + +export default function DomainDiagnostics() { + const { t } = useTranslation('domains/diagnostic'); + const { platformId } = usePlatform(); + const location = useLocation(); + const [searchParams] = useSearchParams(); + const params = Object.fromEntries(searchParams.entries()); + const domainId = searchParams.get('domainId'); + const navigate = useNavigate(); + const goBackUrl = useGenerateUrl('../..', 'href'); + // const onClose = () => navigate(goBackUrl); + + const { data: domain, isLoading } = useDomain({ + domainId, + }); + + const pathMatcherMXTab = computePathMatchers( + [urls.domains_diagnostic_mx], + platformId, + ); + + const pathMatcherSRVTab = computePathMatchers( + [urls.domains_diagnostic_srv], + platformId, + ); + + const pathMatcherSPFTab = computePathMatchers( + [urls.domains_diagnostic_spf], + platformId, + ); + + const pathMatcherDKIMTab = computePathMatchers( + [urls.domains_diagnostic_dkim], + platformId, + ); + + const [isMXTab, setIsMXTab] = useState( + activatedTabs(pathMatcherMXTab, location), + ); + const [isSRVTab, setIsSRVTab] = useState( + activatedTabs(pathMatcherSRVTab, location), + ); + const [isSPFTab, setIsSPFTab] = useState( + activatedTabs(pathMatcherSPFTab, location), + ); + const [isDKIMTab, setIsDKIMTab] = useState( + activatedTabs(pathMatcherDKIMTab, location), + ); + + const tabsList: TabItemProps[] = [ + { + name: 'mx', + title: 'MX', + to: useGenerateUrl('../diagnostics/mx', 'path', params), + pathMatchers: pathMatcherMXTab, + }, + { + name: 'srv', + title: 'SRV', + to: useGenerateUrl('../diagnostics/srv', 'path', params), + pathMatchers: pathMatcherSRVTab, + }, + { + name: 'spf', + title: 'SPF', + to: useGenerateUrl('../diagnostics/spf', 'path', params), + pathMatchers: pathMatcherSPFTab, + }, + { + name: 'dkim', + title: 'DKIM', + to: useGenerateUrl('../diagnostics/dkim', 'path', params), + pathMatchers: pathMatcherDKIMTab, + }, + ]; + + useEffect(() => { + setIsMXTab(activatedTabs(pathMatcherMXTab, location)); + setIsSRVTab(activatedTabs(pathMatcherSRVTab, location)); + setIsSPFTab(activatedTabs(pathMatcherSPFTab, location)); + setIsDKIMTab(activatedTabs(pathMatcherDKIMTab, location)); + }, [location, isLoading]); + + if (isLoading) { + return ; + } + + return ( +
+ + + {t('zimbra_domain_diagnostic_subtitle', { + domain: domain?.currentState.name, + })} + +
+ +
+ {isMXTab &&
MX
} + {isSRVTab &&
SRV
} + {isSPFTab &&
SPF
} + {isDKIMTab &&
DKIM
} +
+ ); +} diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Domains.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Domains.tsx index c46061b71c2f..41dbce3937b4 100644 --- a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Domains.tsx +++ b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/Domains.tsx @@ -27,11 +27,9 @@ import { IAM_ACTIONS } from '@/utils/iamAction.constants'; import { DATAGRID_REFRESH_INTERVAL, DATAGRID_REFRESH_ON_MOUNT, - DnsRecordType, FEATURE_FLAGS, } from '@/utils'; import Loading from '@/components/Loading/Loading'; -import { DiagnosticBadge } from '@/components/DiagnosticBadge'; import { DomainType } from '@/api/domain/type'; import { AccountStatistics, ResourceStatus } from '@/api/api.type'; import { BadgeStatus } from '@/components/BadgeStatus'; @@ -67,36 +65,6 @@ const columns: DatagridColumn[] = [ ), label: 'zimbra_domains_datagrid_account_number', }, - { - id: 'diagnostic', - cell: (item) => { - return ( -
- - - - -
- ); - }, - label: 'zimbra_domains_datagrid_diagnostic_label', - }, { id: 'status', cell: (item) => , @@ -191,18 +159,10 @@ export default function Domains() { ) : ( <> - !( - !FEATURE_FLAGS.DOMAIN_DIAGNOSTICS && - c.id === 'diagnostic' - ), - ) - .map((column) => ({ - ...column, - label: t(column.label), - }))} + columns={columns.map((column) => ({ + ...column, + label: t(column.label), + }))} items={items} totalItems={items.length} hasNextPage={!isFetchingNextPage && hasNextPage} diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalDiagnosticDnsRecord.component.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalDiagnosticDnsRecord.component.tsx index 92c6f4d1849f..23bd62dc4723 100644 --- a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalDiagnosticDnsRecord.component.tsx +++ b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalDiagnosticDnsRecord.component.tsx @@ -80,7 +80,7 @@ export default function ModalDiagnosticDnsRecord( ); const [domain, setDomain] = useState(); - const { data, isLoading } = useDomain(domainId); + const { data, isLoading } = useDomain({ domainId }); useEffect(() => { setDomain(data); diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalEditDomain.component.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalEditDomain.component.tsx index 9aefa63b7ea4..b6a8e11f61cc 100644 --- a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalEditDomain.component.tsx +++ b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/ModalEditDomain.component.tsx @@ -40,9 +40,9 @@ export default function ModalEditDomain() { const { platformId } = usePlatform(); - const { data: detailDomain, isLoading: isLoadingDomain } = useDomain( - editDomainId, - ); + const { data: detailDomain, isLoading: isLoadingDomain } = useDomain({ + domainId: editDomainId, + }); const { data: organizationsList, isLoading: isLoadingOrganizations, diff --git a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/__test__/ModalsDiagnosticDNSRecord.spec.tsx b/packages/manager/apps/zimbra/src/pages/dashboard/Domains/__test__/ModalsDiagnosticDNSRecord.spec.tsx deleted file mode 100644 index 0aba630ae253..000000000000 --- a/packages/manager/apps/zimbra/src/pages/dashboard/Domains/__test__/ModalsDiagnosticDNSRecord.spec.tsx +++ /dev/null @@ -1,71 +0,0 @@ -import React from 'react'; -import 'element-internals-polyfill'; -import '@testing-library/jest-dom'; -import { vi, describe, expect } from 'vitest'; -import { useSearchParams } from 'react-router-dom'; -import { render } from '@/utils/test.provider'; -import { DnsRecordType } from '@/utils'; -import { domainDetailMock } from '@/api/_mock_'; -import ModalDiagnosticDnsRecord from '../ModalDiagnosticDnsRecord.component'; -import domainDiagnosticTranslation from '@/public/translations/domains/diagnostic/Messages_fr_FR.json'; - -vi.mocked(useSearchParams).mockReturnValue([ - new URLSearchParams({ - domainId: domainDetailMock.id, - }), - vi.fn(), -]); - -describe('Domain diagnostic modalc ', () => { - it('should display diagnostic modal', async () => { - const { findByText, getByTestId } = render( - , - ); - - expect( - await findByText( - domainDiagnosticTranslation.zimbra_domain_modal_diagnostic_srv_title, - ), - ).toBeVisible(); - - expect( - getByTestId('diagnostic-srv-modal-secondary-btn'), - ).toBeInTheDocument(); - }); -}); - -describe('Domain diagnostic modal MX', () => { - it('should display diagnostic modal', async () => { - const { findByText, getByTestId } = render( - , - ); - - expect( - await findByText( - domainDiagnosticTranslation.zimbra_domain_modal_diagnostic_mx_title, - ), - ).toBeVisible(); - - expect( - getByTestId('diagnostic-mx-modal-secondary-btn'), - ).toBeInTheDocument(); - }); -}); - -describe('Domain diagnostic modal SPF', () => { - it('should display diagnostic modal', async () => { - const { findByText, getByTestId } = render( - , - ); - - expect( - await findByText( - domainDiagnosticTranslation.zimbra_domain_modal_diagnostic_spf_title, - ), - ).toBeVisible(); - - expect( - getByTestId('diagnostic-spf-modal-secondary-btn'), - ).toBeInTheDocument(); - }); -}); diff --git a/packages/manager/apps/zimbra/src/routes/routes.constants.ts b/packages/manager/apps/zimbra/src/routes/routes.constants.ts index 336e40dadef8..eedbc22dfb28 100644 --- a/packages/manager/apps/zimbra/src/routes/routes.constants.ts +++ b/packages/manager/apps/zimbra/src/routes/routes.constants.ts @@ -8,7 +8,10 @@ export const urls = { domains: '/:serviceName/domains', domainsEdit: '/:serviceName/domains/edit', domainsDelete: '/:serviceName/domains/delete', - domains_diagnostic: '/:serviceName/domains/diagnostic', + domains_diagnostic_mx: '/:serviceName/domains/diagnostics/mx', + domains_diagnostic_srv: '/:serviceName/domains/diagnostics/srv', + domains_diagnostic_spf: '/:serviceName/domains/diagnostics/spf', + domains_diagnostic_dkim: '/:serviceName/domains/diagnostics/dkim', email_accounts: '/:serviceName/email_accounts', email_accounts_add: '/:serviceName/email_accounts/add', email_accounts_edit: '/:serviceName/email_accounts/settings', diff --git a/packages/manager/apps/zimbra/src/routes/routes.tsx b/packages/manager/apps/zimbra/src/routes/routes.tsx index 89880b6aea43..8511b341631b 100644 --- a/packages/manager/apps/zimbra/src/routes/routes.tsx +++ b/packages/manager/apps/zimbra/src/routes/routes.tsx @@ -118,6 +118,46 @@ export const Routes: any = [ breadcrumbLabel: 'zimbra_dashboard_domains_delete', }, }, + { + path: 'diagnostics/mx', + ...lazyRouteConfig(() => + import('@/pages/dashboard/Domains/Diagnostics.page'), + ), + handle: { + isOverridePage: true, + breadcrumbLabel: 'zimbra_dashboard_domains_diagnostics_mx', + }, + }, + { + path: 'diagnostics/srv', + ...lazyRouteConfig(() => + import('@/pages/dashboard/Domains/Diagnostics.page'), + ), + handle: { + isOverridePage: true, + breadcrumbLabel: 'zimbra_dashboard_domains_diagnostics_srv', + }, + }, + { + path: 'diagnostics/spf', + ...lazyRouteConfig(() => + import('@/pages/dashboard/Domains/Diagnostics.page'), + ), + handle: { + isOverridePage: true, + breadcrumbLabel: 'zimbra_dashboard_domains_diagnostics_spf', + }, + }, + { + path: 'diagnostics/dkim', + ...lazyRouteConfig(() => + import('@/pages/dashboard/Domains/Diagnostics.page'), + ), + handle: { + isOverridePage: true, + breadcrumbLabel: 'zimbra_dashboard_domains_diagnostics_dkim', + }, + }, ], }, { diff --git a/packages/manager/apps/zimbra/src/utils/iamAction.constants.ts b/packages/manager/apps/zimbra/src/utils/iamAction.constants.ts index c31fc82f84e1..d43513fb05d1 100644 --- a/packages/manager/apps/zimbra/src/utils/iamAction.constants.ts +++ b/packages/manager/apps/zimbra/src/utils/iamAction.constants.ts @@ -20,6 +20,7 @@ export const IAM_ACTIONS = { create: `${IAM_ACTIONS_PREFIX}domain/create`, delete: `${IAM_ACTIONS_PREFIX}domain/delete`, edit: `${IAM_ACTIONS_PREFIX}domain/edit`, + diagnose: `${IAM_ACTIONS_PREFIX}domain/diagnose`, }, mailingList: { create: `${IAM_ACTIONS_PREFIX}mailingList/create`,