-
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
52cdc63
commit 11b0066
Showing
16 changed files
with
334 additions
and
101 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
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.
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
77 changes: 77 additions & 0 deletions
77
packages/manager/apps/pci-block-storage/src/pages/new/components/DeploymentModeStep.tsx
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,77 @@ | ||
import { useParams } from 'react-router-dom'; | ||
import { | ||
OsdsChip, | ||
OsdsSpinner, | ||
OsdsText, | ||
} from '@ovhcloud/ods-components/react'; | ||
import { useTranslation } from 'react-i18next'; | ||
import { ODS_CHIP_SIZE, ODS_SPINNER_SIZE } from '@ovhcloud/ods-components'; | ||
import { useMemo, useState } from 'react'; | ||
import { TilesInputComponent } from '@ovh-ux/manager-react-components'; | ||
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; | ||
import { mapPricesToGroups, TRegionGroup } from '@/api/data/catalog'; | ||
import { useVolumeCatalog } from '@/api/hooks/useCatalog'; | ||
|
||
export const DeploymentModeStep = () => { | ||
const { t } = useTranslation(['add', 'common']); | ||
const { projectId } = useParams(); | ||
|
||
const { data, isPending } = useVolumeCatalog(projectId); | ||
|
||
const mappedGroups = useMemo( | ||
() => | ||
data | ||
? mapPricesToGroups(data.regionsGroups, data.regions, data.models) | ||
: [], | ||
[data], | ||
); | ||
|
||
const [selectedRegionGroup, setSelectedRegionGroup] = useState< | ||
null | ReturnType<typeof mapPricesToGroups>[number] | ||
>(null); | ||
|
||
// if (isPending) return <OsdsSkeleton />; | ||
return <OsdsSpinner inline size={ODS_SPINNER_SIZE.md} />; | ||
|
||
return ( | ||
<div> | ||
<TilesInputComponent<ReturnType<typeof mapPricesToGroups>[number]> | ||
items={mappedGroups} | ||
value={selectedRegionGroup} | ||
onInput={setSelectedRegionGroup} | ||
label={(group) => ( | ||
<div className="w-full"> | ||
<div className="border-solid border-0 border-b border-b-[#85d9fd] py-3 d-flex"> | ||
<OsdsText> | ||
{t( | ||
`pci_projects_project_storages_blocks_add_deployment_mode_title_${group.name}`, | ||
)} | ||
</OsdsText> | ||
</div> | ||
<div className="py-3"> | ||
{group.tags.includes('is_new') ? ( | ||
<div> | ||
<OsdsChip | ||
className="ms-3" | ||
color={ODS_THEME_COLOR_INTENT.success} | ||
size={ODS_CHIP_SIZE.sm} | ||
inline | ||
> | ||
{t('common:pci_projects_project_storages_blocks_new')} | ||
</OsdsChip> | ||
Gratuit | ||
</div> | ||
) : ( | ||
group.leastPrice !== null && | ||
t( | ||
'pci_projects_project_storages_blocks_add_deployment_mode_price_from', | ||
{ price: group.leastPrice }, | ||
) | ||
)} | ||
</div> | ||
</div> | ||
)} | ||
/> | ||
</div> | ||
); | ||
}; |
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
Oops, something went wrong.