Skip to content

Commit f449ad3

Browse files
committed
feat(zimbra): add redirections tab
ref: #PRDCOL-113 Signed-off-by: Atef ZAAFOURI <[email protected]>
1 parent e2f20f7 commit f449ad3

File tree

26 files changed

+413
-118
lines changed

26 files changed

+413
-118
lines changed

packages/manager/apps/zimbra/public/translations/common/Messages_fr_FR.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929
"add_domain": "Ajouter un domaine",
3030
"edit_domain": "Configuration du domaine",
3131
"delete_domain": "Supprimer le domaine",
32-
"redirection": "Redirection",
32+
"redirections": "Redirections",
3333
"delete_redirection": "Supprimer la redirection",
3434
"add_redirection": "Créer une redirection",
3535
"edit_redirection": "Modifier la redirection",

packages/manager/apps/zimbra/public/translations/redirections/Messages_fr_FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"zimbra_redirections_from": "De",
33
"zimbra_redirections_to": "Vers",
44
"zimbra_redirections_account_title": "Gestion des redirections",
5+
"zimbra_redirections_account_quota": "Quota de redirection",
56
"zimbra_redirections_delete_modal_content": "Souhaitez-vous supprimer la redirection ?",
67
"zimbra_redirections_add_header": "Merci de compléter les informations pour la redirection.",
78
"zimbra_redirections_add_form_input_from": "De l'adresse",

packages/manager/apps/zimbra/src/constants.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,5 @@ export const ZimbraEmailsLink: Record<string, string> = {
2121
TN: `${OVH_WEBSITE_ROOT_URL}/fr-tn/emails/zimbra-emails/`,
2222
SN: `${OVH_WEBSITE_ROOT_URL}/fr-sn/emails/zimbra-emails/`,
2323
};
24+
25+
export const MAX_REDIRECTIONS_QUOTA = 1000;

packages/manager/apps/zimbra/src/data/api/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,3 +10,4 @@ export * from './service';
1010
export * from './task';
1111
export * from './type';
1212
export * from './utils';
13+
export * from './redirection';
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import { fetchIcebergV2, v2 } from '@ovh-ux/manager-core-api';
2+
3+
import { getApiPath } from '@/data/api';
4+
import { APIV2_DEFAULT_PAGESIZE } from '@/utils';
5+
6+
import { RedirectionBodyParamsType, RedirectionType } from './type';
7+
8+
// GET
9+
10+
export const getZimbraPlatformRedirections = ({
11+
platformId,
12+
searchParams,
13+
pageParam,
14+
pageSize = APIV2_DEFAULT_PAGESIZE,
15+
disableCache,
16+
}: {
17+
platformId: string;
18+
searchParams?: string;
19+
pageParam?: unknown;
20+
pageSize?: number;
21+
disableCache?: boolean;
22+
}) =>
23+
fetchIcebergV2<RedirectionType[]>({
24+
route: `${getApiPath(platformId)}redirection${searchParams}`,
25+
pageSize,
26+
cursor: pageParam as string,
27+
disableCache,
28+
});
29+
30+
export const getZimbraPlatformRedirection = async (platformId: string, id: string) => {
31+
const { data } = await v2.get<RedirectionType>(`${getApiPath(platformId)}redirection/${id}`);
32+
return data;
33+
};
34+
35+
// POST
36+
37+
export const postZimbraPlatformRedirection = async (
38+
platformId: string,
39+
params: RedirectionBodyParamsType,
40+
) => {
41+
const { data } = await v2.post(`${getApiPath(platformId)}redirection`, {
42+
targetSpec: params,
43+
});
44+
return data;
45+
};
46+
47+
// DELETE
48+
49+
export const deleteZimbraPlatformRedirection = async (
50+
platformId: string,
51+
redirectionId: string,
52+
) => {
53+
const { data } = await v2.delete(`${getApiPath(platformId)}redirection/${redirectionId}`);
54+
return data;
55+
};
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
export * from './api';
2+
export * from './key';
3+
export * from './type';
4+
export * from './mocks';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
export const getZimbraPlatformRedirectionsQueryKey = (
2+
platformId: string,
3+
searchParams?: string,
4+
shouldFetchAll?: boolean,
5+
) => {
6+
return [
7+
'get',
8+
'zimbra',
9+
'platform',
10+
platformId,
11+
'redirections',
12+
searchParams,
13+
shouldFetchAll ? 'all' : '',
14+
].filter(Boolean);
15+
};
16+
17+
export const getZimbraPlatformRedirectionQueryKey = (
18+
platformId: string,
19+
RedirectionId?: string,
20+
) => ['get', 'zimbra', 'platform', platformId, 'Redirection', RedirectionId];
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { RedirectionType } from './type';
2+
3+
export const redirectionsMock: RedirectionType[] = [
4+
{
5+
id: 'bf333af7-585d-4fb3-b81c-06be10df4828',
6+
resourceStatus: 'READY',
7+
checksum: '',
8+
targetSpec: {
9+
source: '[email protected]',
10+
destination: '[email protected]',
11+
},
12+
currentState: {
13+
source: '[email protected]',
14+
destination: '[email protected]',
15+
createdAt: '2025-10-23T12:51:45.619Z',
16+
domainId: '19a11201-1530-4000-81ee-86fb8d5a3e01',
17+
organizationId: '19a11201-1530-4000-80cc-5574700d8b01',
18+
updatedAt: '2025-10-23T12:51:45.619Z',
19+
},
20+
currentTasks: [],
21+
},
22+
];
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import { ResourceStatus } from '@/data/api';
2+
3+
export type RedirectionBodyParamsType = {
4+
source: string;
5+
destination: string;
6+
};
7+
8+
export type RedirectionType = {
9+
checksum: string;
10+
currentState: RedirectionBodyParamsType & {
11+
createdAt: string;
12+
domainId: string;
13+
organizationId: string;
14+
updatedAt: string;
15+
};
16+
currentTasks: {
17+
id: string;
18+
link: string;
19+
status: string;
20+
type: string;
21+
}[];
22+
id: string;
23+
resourceStatus: keyof typeof ResourceStatus;
24+
targetSpec: RedirectionBodyParamsType;
25+
};

packages/manager/apps/zimbra/src/data/hooks/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,5 @@ export * from './slot/useSlot';
1818
export * from './services/useSlotServices';
1919
export * from './services/useSlotService';
2020
export * from './task/useTasks';
21+
export * from './redirection/useRedirection';
22+
export * from './redirection/useRedirections';

0 commit comments

Comments
 (0)