Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"ipBlockInformationTitle": "Informations du bloc d'IP",
"ipBlockInformationSubtitle": "Cette section vous permet de personnaliser les informations publiques sur votre bloc IP (informations présentes sur la base whois).",
"ipBlockInformationNetNameLabel": "Nom du réseau (Netname)",
"ipBlockInformationDescriptionLabel": "Description",
"ipBlockInformationOrganisationLabel": "Organisation",
"ipBlockInformationOrganisationOnGoingChange": "L'organisation du bloc d'IP est en cours de réaffectation. Veuillez patienter quelques minutes.",
"ipBlockInformationUpdateSuccessMessage": "Les informations du bloc d'IP {{ip}} ont été mises à jour.",
"ipBlockInformationUpdateErrorMessage": "Une erreur a eu lieu pendant la mise à jour des informations du bloc d'IP {{ip}}: {{error}}",
"ipBlockInformationOrgUpdateSuccessMessage": "Le bloc d'IP {{ip}} est en cours d'affectation à l'organisation {{organisation}}. Cette operation peut prendre quelques minutes",
"ipBlockInformationOrgUpdateErrorMessage": "Une erreur a eu lieu pendant l'affectation du bloc IP {{ip}} à l'organisation {{organisation}}: {{error}}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,7 @@
"listingActionEditDescription": "Editer la description",
"listingActionDeleteVirtualMac": "Supprimer la MAC virtuelle",
"listingActionByoipTerminate": "Résilier le service BYOIP",
"listingActionUpdateIpBlockInformation": "Voir / Modifier les informations sur le bloc IP",
"listingActionSlice": "Segmenter",
"listingActionAggregate": "Agréger",
"listingActionUnblockHackedIP": "Déblocage anti-hack",
Expand Down
1 change: 1 addition & 0 deletions packages/manager/apps/ips/src/data/api/get/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export * from './organisationsList';
export * from './organisationsDetails';
export * from './byoip';
export * from './productServices';
export * from './ipRipeInformation';
export * from './ipTask';
export * from './moveIp';
24 changes: 24 additions & 0 deletions packages/manager/apps/ips/src/data/api/get/ipRipeInformation.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';

export type IpRipeInformation = {
description: string;
netname: string;
};

export type GetIpRipeInformationParams = {
ip: string;
};

export const getIpRipeInformationQueryKey = (
params: GetIpRipeInformationParams,
) => [`get/ip/${encodeURIComponent(params.ip)}/ripe`];

/**
* Get IP Ripe Information
*/
export const getIpRipeInformation = async (
params: GetIpRipeInformationParams,
): Promise<ApiResponse<IpRipeInformation>> =>
apiClient.v6.get<IpRipeInformation>(
`/ip/${encodeURIComponent(params.ip)}/ripe`,
);
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';

export type ChangeIpOrganisationParams = {
ip: string;
organisation: string;
};

export const changeIpOrganisationQueryKey = (
params: ChangeIpOrganisationParams,
) => [`post/ip/${encodeURIComponent(params.ip)}/changeOrg`];

export const changeIpOrganisation = async (
params: ChangeIpOrganisationParams,
): Promise<ApiResponse<void>> => {
return apiClient.v6.post<void>(
`/ip/${encodeURIComponent(params.ip)}/changeOrg`,
{
organisation: params.organisation,
},
);
};
2 changes: 2 additions & 0 deletions packages/manager/apps/ips/src/data/api/postorput/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,5 @@ export * from './addIpToVirtualMac';
export * from './postMoveIp';
export * from './unblockAntiHackIp';
export * from './unblockAntiSpamIp';
export * from './upsertIpRipeInformation';
export * from './changeIpOrganisation';
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api';

export type UpsertIpRipeInformationParams = {
ip: string;
description: string;
netname: string;
};

export const upsertIpRipeInformationQueryKey = (
params: UpsertIpRipeInformationParams,
) => [`put/ip/${encodeURIComponent(params.ip)}/ripe`];

export const upsertIpRipeInformation = async (
params: UpsertIpRipeInformationParams,
): Promise<ApiResponse<void>> => {
return apiClient.v6.put<void>(`/ip/${encodeURIComponent(params.ip)}/ripe`, {
description: params.description,
netname: params.netname,
});
};
1 change: 1 addition & 0 deletions packages/manager/apps/ips/src/data/hooks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
export * from './ip';
export * from './organisation';
export * from './useGetTokens';
export * from './useIpv6Availability';
export * from './useGetProductService';
Expand Down
2 changes: 2 additions & 0 deletions packages/manager/apps/ips/src/data/hooks/ip/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export * from './useGetIpVmacDetails';
export * from './useGetIpVmacWithIp';
export * from './useGetIpMitigation';
export * from './useGetIpGameFirewall';
export * from './useGetIpOrganisation';
export * from './useIpHasAlerts';
export * from './useGetIpAntihack';
export * from './useGetIpSpam';
Expand All @@ -24,3 +25,4 @@ export * from './useMoveIpService';
export * from './useGetDedicatedServerTasks';
export * from './useByoipActions';
export * from './edge-firewall';
export * from './useGetIpRipeInformation';
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
import { useQuery, useQueries } from '@tanstack/react-query';
import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api';
import {
IpDetails,
getIpDetailsQueryKey,
getIpDetails,
getIpTaskQueryKey,
getIpTaskList,
} from '@/data/api';
import { IpTaskFunction, IpTaskStatus } from '@/types';

export type UseGetIpOrganisationParams = {
ip: string;
enabled?: boolean;
};

export const useGetIpOrganisation = ({
ip,
enabled = true,
}: UseGetIpOrganisationParams) => {
const taskQueries = useQueries({
queries: [IpTaskStatus.init, IpTaskStatus.todo, IpTaskStatus.doing].map(
(status) => ({
queryKey: getIpTaskQueryKey({
ip,
status,
fn: IpTaskFunction.changeRipeOrg,
}),
queryFn: () =>
getIpTaskList({
ip,
status,
fn: IpTaskFunction.changeRipeOrg,
}),
staleTime: 0,
}),
),
});

const isTasksLoading = taskQueries.some((query) => query.isLoading);
const taskError = taskQueries.find((query) => query.isError)?.error;
const hasOnGoingChangeRipeOrgTask = taskQueries.some(
(query) => query.data?.data && query.data.data.length > 0,
);

const { data: ipDetailsResponse, isLoading, isError, error } = useQuery<
ApiResponse<IpDetails>,
ApiError
>({
queryKey: getIpDetailsQueryKey({ ip }),
queryFn: () => getIpDetails({ ip }),
enabled:
enabled && !isTasksLoading && !taskError && !hasOnGoingChangeRipeOrgTask,
staleTime: Number.POSITIVE_INFINITY,
retry: false,
});

return {
organisationId: ipDetailsResponse?.data.organisationId,
rirForOrganisation: ipDetailsResponse?.data.rir,
hasOnGoingChangeRipeOrgTask,
isLoading: isLoading || isTasksLoading,
isError: isError || !!taskError,
error: error ?? taskError,
};
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import { useQuery } from '@tanstack/react-query';
import {
getIpRipeInformation,
getIpRipeInformationQueryKey,
} from '@/data/api/get/ipRipeInformation';

export type UseGetIpRipeInformationParams = {
ip: string;
};

export type IpRipeInformation = {
description: string;
netname: string;
};

export const useGetIpRipeInformation = ({
ip,
}: UseGetIpRipeInformationParams) => {
const { data: ipRipeInfo, isLoading, isError, error } = useQuery<
IpRipeInformation
>({
queryKey: getIpRipeInformationQueryKey({ ip }),
queryFn: () =>
getIpRipeInformation({ ip }).then((response) => response.data),
retry: false,
staleTime: Number.POSITIVE_INFINITY,
});

return { ipRipeInfo, isLoading, isError, error };
};
Loading
Loading