Skip to content

Commit

Permalink
feat(zimbra): intialize diagnostics page
Browse files Browse the repository at this point in the history
ref: MANAGER-16089

Signed-off-by: Tristan WAGNER <[email protected]>
  • Loading branch information
tristanwagner committed Nov 28, 2024
1 parent 5095aa4 commit 50349c5
Show file tree
Hide file tree
Showing 12 changed files with 268 additions and 80 deletions.
Original file line number Diff line number Diff line change
@@ -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"
}
Original file line number Diff line number Diff line change
@@ -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 <guide/>)",
"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 <strong>{{domain}}</strong> 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 <guide/>)",
"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 <strong>{{domain}}</strong> 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"
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
),
Expand Down
25 changes: 20 additions & 5 deletions packages/manager/apps/zimbra/src/hooks/useDomain.ts
Original file line number Diff line number Diff line change
@@ -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<UseQueryOptions, 'queryKey' | 'queryFn'> & {
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<DomainType>;
};
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@ const ActionButtonDomain: React.FC<ActionButtonDomainProps> = ({
navigate(hrefEditDomain);
};

const hrefDiagnosticsDomain = useGenerateUrl('./diagnostics/mx', 'path', {
domainId: domainItem.id,
});

const handleDiagnosticsDomainClick = () => {
navigate(hrefDiagnosticsDomain);
};

const actionItems = [
{
id: 1,
Expand All @@ -44,6 +52,13 @@ const ActionButtonDomain: React.FC<ActionButtonDomainProps> = ({
},
{
id: 2,
onclick: handleDiagnosticsDomainClick,
label: t('zimbra_domains_tooltip_diagnostics'),
urn: platformUrn,
iamActions: [IAM_ACTIONS.domain.edit /* TODO diagnose */],
},
{
id: 3,
onclick: handleDeleteDomainClick,
label: t('zimbra_domains_tooltip_delete'),
urn: platformUrn,
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
import React, { useEffect, useState } from 'react';
import {
LinkType,
Links,
IconLinkAlignmentType,
Subtitle,
} from '@ovh-ux/manager-react-components';

import { useTranslation } from 'react-i18next';
import {
useLocation,
useMatches,
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 navigate = useNavigate();
const goBackUrl = useGenerateUrl('../..', 'href');
const onClose = () => navigate(goBackUrl);

const matches = useMatches();

console.log(matches);
const domainId = searchParams.get('domainId');
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));
console.log(isMXTab, isSRVTab, isSPFTab, isDKIMTab);
}, [location, isLoading]);

if (isLoading) {
return <Loading />;
}

return (
<div
className="flex flex-col w-full gap-4 mb-5"
data-testid="domain-diagnostic-page"
>
<Links
iconAlignment={IconLinkAlignmentType.left}
type={LinkType.back}
href={goBackUrl}
color={ODS_LINK_COLOR.primary}
label={t('zimbra_domain_diagnostic_cta_back')}
/>
<Subtitle>
{t('zimbra_domain_diagnostic_subtitle', {
domain: domain?.currentState.name,
})}
</Subtitle>
<div className="mt-5 mb-8">
<TabsPanel tabs={tabsList} />
</div>
{isMXTab && <div>MX</div>}
{isSRVTab && <div>SRV</div>}
{isSPFTab && <div>SPF</div>}
{isDKIMTab && <div>DKIM</div>}
</div>
);
}
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -67,36 +65,6 @@ const columns: DatagridColumn<DomainsItem>[] = [
),
label: 'zimbra_domains_datagrid_account_number',
},
{
id: 'diagnostic',
cell: (item) => {
return (
<div className="flex gap-4">
<DiagnosticBadge
diagType={DnsRecordType.MX}
domainId={item.id}
status={ODS_BADGE_COLOR.critical}
/>
<DiagnosticBadge
diagType={DnsRecordType.SRV}
domainId={item.id}
status={ODS_BADGE_COLOR.critical}
/>
<DiagnosticBadge
diagType={DnsRecordType.SPF}
domainId={item.id}
status={ODS_BADGE_COLOR.critical}
/>
<DiagnosticBadge
diagType={DnsRecordType.DKIM}
domainId={item.id}
status={ODS_BADGE_COLOR.success}
/>
</div>
);
},
label: 'zimbra_domains_datagrid_diagnostic_label',
},
{
id: 'status',
cell: (item) => <BadgeStatus itemStatus={item.status}></BadgeStatus>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ export default function ModalDiagnosticDnsRecord(
);

const [domain, setDomain] = useState<DomainType>();
const { data, isLoading } = useDomain(domainId);
const { data, isLoading } = useDomain({ domainId });

useEffect(() => {
setDomain(data);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
5 changes: 4 additions & 1 deletion packages/manager/apps/zimbra/src/routes/routes.constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down
Loading

0 comments on commit 50349c5

Please sign in to comment.