diff --git a/packages/manager/apps/pci-block-storage/ovh-ux-manager-pci-common-v0.14.5-3az.tgz b/packages/manager/apps/pci-block-storage/ovh-ux-manager-pci-common-v0.14.5-3az.tgz new file mode 100644 index 000000000000..58891b21013b Binary files /dev/null and b/packages/manager/apps/pci-block-storage/ovh-ux-manager-pci-common-v0.14.5-3az.tgz differ diff --git a/packages/manager/apps/pci-block-storage/package.json b/packages/manager/apps/pci-block-storage/package.json index 5417ce8209c7..f94b0cf1fcf5 100644 --- a/packages/manager/apps/pci-block-storage/package.json +++ b/packages/manager/apps/pci-block-storage/package.json @@ -17,7 +17,7 @@ "dependencies": { "@ovh-ux/manager-config": "^8.0.2", "@ovh-ux/manager-core-api": "^0.9.0", - "@ovh-ux/manager-pci-common": "^0.14.2", + "@ovh-ux/manager-pci-common": "file:./ovh-ux-manager-pci-common-v0.14.5-3az.tgz", "@ovh-ux/manager-react-components": "^1.43.0", "@ovh-ux/manager-react-core-application": "^0.11.5", "@ovh-ux/manager-react-shell-client": "^0.8.5", diff --git a/packages/manager/apps/pci-block-storage/src/api/data/availableVolumes.ts b/packages/manager/apps/pci-block-storage/src/api/data/availableVolumes.ts index a65a21d030e3..bae1be8ff819 100644 --- a/packages/manager/apps/pci-block-storage/src/api/data/availableVolumes.ts +++ b/packages/manager/apps/pci-block-storage/src/api/data/availableVolumes.ts @@ -7,6 +7,7 @@ export type TAvailableVolumesResponse = { regions: { name: string; enabled: boolean; + type: string; }[]; }[]; }; @@ -22,7 +23,7 @@ export const getProjectsAvailableVolumes = async ( return data; }; -export function isRegionWith3AZ(region: TLocalisation) { +export function isRegionWith3AZ(region: Pick) { return region.type === 'region-3-az'; } diff --git a/packages/manager/apps/pci-block-storage/src/pages/new/components/LocationStep.component.tsx b/packages/manager/apps/pci-block-storage/src/pages/new/components/LocationStep.component.tsx index ddca42059db0..eeecacc71618 100644 --- a/packages/manager/apps/pci-block-storage/src/pages/new/components/LocationStep.component.tsx +++ b/packages/manager/apps/pci-block-storage/src/pages/new/components/LocationStep.component.tsx @@ -8,9 +8,13 @@ import { useProject, RegionSelector, RegionSummary, + usePCICommonContextFactory, + PCICommonContext, } from '@ovh-ux/manager-pci-common'; import { TLocalisation } from '@/api/hooks/useRegions'; import { StepState } from '@/pages/new/hooks/useStep'; +import { useProjectsAvailableVolumes } from '@/api/hooks/useProjectsAvailableVolumes'; +import { isRegionWith3AZ } from '@/api/data/availableVolumes'; interface LocationProps { projectId: string; @@ -18,6 +22,19 @@ interface LocationProps { onSubmit: (region: TLocalisation) => void; } +const useHas3AZRegion = (projectId: string) => { + const { data: availableVolumes, isPending } = useProjectsAvailableVolumes( + projectId, + ); + + return { + has3AZ: + availableVolumes?.plans.some((p) => p.regions.some(isRegionWith3AZ)) || + false, + isPending, + }; +}; + export function LocationStep({ projectId, step, @@ -28,8 +45,12 @@ export function LocationStep({ const { data: project } = useProject(); const isDiscovery = isDiscoveryProject(project); const hasRegion = !!region; + + const { has3AZ } = useHas3AZRegion(projectId); + const pciCommonProperties = usePCICommonContextFactory({ has3AZ }); + return ( - <> + {hasRegion && step.isLocked && } {(!step.isLocked || isDiscovery) && ( r.isMacro || - r.services.some((s) => s.name === 'volume' && s.status === 'UP') + r.services.some((s) => s.name === 'volume' && s.status === 'UP') || + r.type === 'region-3-az' } /> )} @@ -51,6 +73,6 @@ export function LocationStep({ {tStepper('common_stepper_next_button_label')} )} - + ); }