Skip to content

Commit e2318ec

Browse files
committed
feat(ips): adding a modal to edit ip block information
ref: #MANAGER-20142 Signed-off-by: aderghamov <[email protected]>
1 parent 73e1f41 commit e2318ec

File tree

18 files changed

+485
-0
lines changed

18 files changed

+485
-0
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
"ipBlockInformationTitle": "Informations du bloc d'IP",
3+
"ipBlockInformationSubtitle": "Cette section vous permet de personnaliser les informations publiques sur votre bloc IP (informations présentes sur la base whois).",
4+
"ipBlockInformationNetNameLabel": "Nom du réseau (Netname)",
5+
"ipBlockInformationDescriptionLabel": "Description",
6+
"ipBlockInformationOrganisationLabel": "Organisation",
7+
"ipBlockInformationUpdateSuccessMessage": "Les informations du bloc d'IP {{ip}} ont été mises à jour.",
8+
"ipBlockInformationUpdateErrorMessage": "Une erreur a eu lieu pendant la mise à jour des informations du bloc d'IP {{ip}}: {{error}}",
9+
"ipBlockInformationOrgUpdateSuccessMessage": "Le bloc d'IP {{ip}} est en cours d'affectation à l'organisation {{organisation}}. Cette operation peut prendre quelques minutes",
10+
"ipBlockInformationOrgUpdateErrorMessage": "Une erreur a eu lieu pendant l'affectation du bloc IP {{ip}} à l'organisation {{organisation}}: {{error}}"
11+
}

packages/manager/apps/ips/public/translations/listing/Messages_fr_FR.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@
7676
"listingActionEditDescription": "Editer la description",
7777
"listingActionDeleteVirtualMac": "Supprimer la MAC virtuelle",
7878
"listingActionByoipTerminate": "Résilier le service BYOIP",
79+
"listingActionUpdateIpBlockInformation": "Voir / Modifier les informations sur le bloc IP",
7980
"listingActionSlice": "Segmenter",
8081
"listingActionAggregate": "Agréger",
8182
"listingActionUnblockHackedIP": "Déblocage anti-hack",

packages/manager/apps/ips/src/data/api/get/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,5 +14,6 @@ export * from './organisationsList';
1414
export * from './organisationsDetails';
1515
export * from './byoip';
1616
export * from './productServices';
17+
export * from './ipRipeInformation';
1718
export * from './ipTask';
1819
export * from './moveIp';
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';
2+
3+
export type IpRipeInformation = {
4+
description: string;
5+
netname: string;
6+
};
7+
8+
export type GetIpRipeInformationParams = {
9+
ip: string;
10+
};
11+
12+
export const getIpRipeInformationQueryKey = (
13+
params: GetIpRipeInformationParams,
14+
) => [`get/ip/${encodeURIComponent(params.ip)}/ripe`];
15+
16+
/**
17+
* Get IP Ripe Information
18+
*/
19+
export const getIpRipeInformation = async (
20+
params: GetIpRipeInformationParams,
21+
): Promise<ApiResponse<IpRipeInformation>> =>
22+
apiClient.v6.get<IpRipeInformation>(
23+
`/ip/${encodeURIComponent(params.ip)}/ripe`,
24+
);
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';
2+
3+
export type ChangeIpOrganisationParams = {
4+
ip: string;
5+
organisation: string;
6+
};
7+
8+
export const changeIpOrganisationQueryKey = (
9+
params: ChangeIpOrganisationParams,
10+
) => [`post/ip/${encodeURIComponent(params.ip)}/changeOrg`];
11+
12+
export const changeIpOrganisation = async (
13+
params: ChangeIpOrganisationParams,
14+
): Promise<ApiResponse<void>> => {
15+
return apiClient.v6.post<void>(
16+
`/ip/${encodeURIComponent(params.ip)}/changeOrg`,
17+
{
18+
organisation: params.organisation,
19+
},
20+
);
21+
};

packages/manager/apps/ips/src/data/api/postorput/index.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,3 +7,5 @@ export * from './addIpToVirtualMac';
77
export * from './postMoveIp';
88
export * from './unblockAntiHackIp';
99
export * from './unblockAntiSpamIp';
10+
export * from './upsertIpRipeInformation';
11+
export * from './changeIpOrganisation';
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';
2+
3+
export type UpsertIpRipeInformationParams = {
4+
ip: string;
5+
description: string;
6+
netname: string;
7+
};
8+
9+
export const upsertIpRipeInformationQueryKey = (
10+
params: UpsertIpRipeInformationParams,
11+
) => [`put/ip/${encodeURIComponent(params.ip)}/ripe`];
12+
13+
export const upsertIpRipeInformation = async (
14+
params: UpsertIpRipeInformationParams,
15+
): Promise<ApiResponse<void>> => {
16+
return apiClient.v6.put<void>(`/ip/${encodeURIComponent(params.ip)}/ripe`, {
17+
description: params.description,
18+
netname: params.netname,
19+
});
20+
};

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
export * from './ip';
2+
export * from './organisation';
23
export * from './useGetTokens';
34
export * from './useIpv6Availability';
45
export * from './useGetProductService';

packages/manager/apps/ips/src/data/hooks/ip/index.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ export * from './useGetIpVmacDetails';
66
export * from './useGetIpVmacWithIp';
77
export * from './useGetIpMitigation';
88
export * from './useGetIpGameFirewall';
9+
export * from './useGetIpOrganisation';
910
export * from './useIpHasAlerts';
1011
export * from './useGetIpAntihack';
1112
export * from './useGetIpSpam';
@@ -24,3 +25,6 @@ export * from './useMoveIpService';
2425
export * from './useGetDedicatedServerTasks';
2526
export * from './useByoipActions';
2627
export * from './edge-firewall';
28+
export * from './useChangeIpOrganisation';
29+
export * from './useGetIpRipeInformation';
30+
export * from './useUpsertIpRipeInformation';
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
import { useMutation } from '@tanstack/react-query';
2+
import { ApiError } from '@ovh-ux/manager-core-api';
3+
import { changeIpOrganisation } from '@/data/api/postorput/changeIpOrganisation';
4+
5+
export type UseChangeIpOrganisationParams = {
6+
ip: string;
7+
organisation: string;
8+
onSuccess: () => void;
9+
onError: (error: ApiError) => void;
10+
};
11+
12+
export const useChangeIpOrganisation = ({
13+
ip,
14+
organisation,
15+
onSuccess,
16+
onError,
17+
}: UseChangeIpOrganisationParams) => {
18+
return useMutation({
19+
mutationFn: async () => {
20+
const { data } = await changeIpOrganisation({ ip, organisation });
21+
return data;
22+
},
23+
onSuccess,
24+
onError,
25+
});
26+
};

0 commit comments

Comments
 (0)