-
Notifications
You must be signed in to change notification settings - Fork 98
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(pci-block-storage): add deploy zone
ref: TAPC-2112 Signed-off-by: Simon Chaumet <[email protected]>
- Loading branch information
1 parent
e571211
commit fd842c0
Showing
33 changed files
with
674 additions
and
505 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
packages/manager/apps/pci-block-storage/src/api/data/availableVolumes.ts
This file was deleted.
Oops, something went wrong.
68 changes: 41 additions & 27 deletions
68
packages/manager/apps/pci-block-storage/src/api/data/catalog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,28 +1,42 @@ | ||
export type TPricing = { | ||
capacities: string[]; | ||
mode: string; | ||
phase: number; | ||
commitment: number; | ||
description: string; | ||
price: { | ||
currencyCode: string; | ||
text: string; | ||
value: number; | ||
}; | ||
tax: number; | ||
interval: number; | ||
intervalUnit: string; | ||
quantity: { | ||
max?: number; | ||
min?: number; | ||
}; | ||
repeat: { | ||
max?: number; | ||
min?: number; | ||
}; | ||
strategy: string; | ||
mustBeCompleted: boolean; | ||
type: string; | ||
promotions: unknown[]; | ||
engagementConfiguration?: unknown; | ||
import { TAddon } from '@ovh-ux/manager-pci-common'; | ||
import { v6 } from '@ovh-ux/manager-core-api'; | ||
import { TRegion } from '@/api/data/regions'; | ||
|
||
export type TCatalogGroup = { | ||
name: string; | ||
tags: string[]; | ||
}; | ||
|
||
export type TVolumePricing = Pick<TAddon['pricings'][number], 'price'> & { | ||
regions: TRegion['name'][]; | ||
showAvailabilityZones: boolean; | ||
interval: 'day' | 'hour' | 'month' | 'none'; | ||
specs: TAddon['blobs']['technical']; | ||
}; | ||
|
||
export type TVolumeCatalogFilter = { | ||
[key in 'deployment' | 'region']: TCatalogGroup[]; | ||
}; | ||
|
||
export type TVolumeCatalogElementFilter = { | ||
[Property in keyof TVolumeCatalogFilter]?: TVolumeCatalogFilter[Property][number]['name'][]; | ||
}; | ||
|
||
export type TVolumeAddon = { | ||
name: string; | ||
tags: string[]; | ||
filters: TVolumeCatalogElementFilter; | ||
pricings: TVolumePricing[]; | ||
}; | ||
|
||
export type TVolumeCatalog = { | ||
filters: TVolumeCatalogFilter; | ||
regions: TRegion[]; | ||
models: TVolumeAddon[]; | ||
}; | ||
|
||
export const getVolumeCatalog = async ( | ||
projectId: string, | ||
): Promise<TVolumeCatalog> => | ||
(await v6.get<TVolumeCatalog>(`/cloud/project/${projectId}/catalog/volume`)) | ||
.data; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 8 additions & 19 deletions
27
packages/manager/apps/pci-block-storage/src/api/data/regions.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,12 @@ | ||
import { fetchIcebergV6 } from '@ovh-ux/manager-core-api'; | ||
import { TVolumeCatalogElementFilter } from '@/api/data/catalog'; | ||
|
||
export type TRegion = { | ||
name: string; | ||
type: string; | ||
status: string; | ||
continentCode: string; | ||
services: { | ||
name: string; | ||
status: string; | ||
endpoint: string; | ||
}[]; | ||
datacenterLocation: string; | ||
}; | ||
|
||
export const getProjectRegions = async ( | ||
projectId: string, | ||
): Promise<TRegion[]> => { | ||
const { data } = await fetchIcebergV6<TRegion>({ | ||
route: `/cloud/project/${projectId}/region`, | ||
}); | ||
return data; | ||
type: 'region-3-az' | 'region' | 'localzone'; | ||
availabilityZones: string[]; | ||
isInMaintenance: boolean; | ||
isActivated: boolean; | ||
country: string; | ||
filters: TVolumeCatalogElementFilter; | ||
datacenter: string; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 10 additions & 0 deletions
10
packages/manager/apps/pci-block-storage/src/api/hooks/useCatalog.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,26 @@ | ||
import { useQuery } from '@tanstack/react-query'; | ||
import { useMe } from '@ovh-ux/manager-react-components'; | ||
import { getCatalog } from '@ovh-ux/manager-pci-common'; | ||
import { getVolumeCatalog } from '@/api/data/catalog'; | ||
|
||
export const getCatalogQuery = (ovhSubsidiary: string) => ({ | ||
queryKey: ['catalog'], | ||
queryFn: () => getCatalog(ovhSubsidiary), | ||
}); | ||
|
||
/** | ||
* @deprecated use {@link useVolumeCatalog} instead | ||
*/ | ||
export const useCatalog = () => { | ||
const { me } = useMe(); | ||
return useQuery({ | ||
...getCatalogQuery(me?.ovhSubsidiary), | ||
enabled: !!me, | ||
}); | ||
}; | ||
|
||
export const useVolumeCatalog = (projectId: string) => | ||
useQuery({ | ||
queryKey: ['projects', projectId, 'catalog', 'volume'], | ||
queryFn: () => getVolumeCatalog(projectId), | ||
}); |
47 changes: 0 additions & 47 deletions
47
packages/manager/apps/pci-block-storage/src/api/hooks/useConsumptionVolumesAddon.ts
This file was deleted.
Oops, something went wrong.
12 changes: 12 additions & 0 deletions
12
packages/manager/apps/pci-block-storage/src/api/hooks/useHas3AZRegion.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { useVolumeCatalog } from '@/api/hooks/useCatalog'; | ||
|
||
export const useHas3AZRegion = (projectId: string) => { | ||
const { data: volumeCatalog, isPending } = useVolumeCatalog(projectId); | ||
|
||
return { | ||
has3AZ: | ||
volumeCatalog?.filters.deployment.some((d) => d.name === 'region-3-az') || | ||
false, | ||
isPending, | ||
}; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
19 changes: 0 additions & 19 deletions
19
packages/manager/apps/pci-block-storage/src/api/hooks/useProjectsAvailableVolumes.ts
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.