diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-catalog.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-catalog.mock.ts index 8d03032dd813..9ba13a3e03be 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-catalog.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-catalog.mock.ts @@ -1,6 +1,6 @@ -import { TVcdCatalog } from '../../src/types/vcd-catalog.interface'; +import { VCDCatalog } from '@ovh-ux/manager-module-vcd-api'; -export const catalogProductList: TVcdCatalog = [ +export const catalogProductList: VCDCatalog = [ { productName: 'pack-3264', mandatory: false, diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre-order.handler.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre-order.handler.ts index ac2af6c75a35..c56486c2c0ee 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre-order.handler.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre-order.handler.ts @@ -1,4 +1,4 @@ -import { IVdcOrderableResourceData } from '@/types/vcd-vdc-orderable-resource.interface'; +import { VCDOrderableResourceData } from '@ovh-ux/manager-module-vcd-api'; import { Handler } from '../../../../../../playwright-helpers'; import { catalogProductList } from './vcd-catalog.mock'; import { orderableResourceData } from './vdc-orderable-resource.mock'; @@ -16,7 +16,7 @@ export const getDatacentreOrderMocks = ({ isOrderableResourceKO, nbOrderableResource = Number.POSITIVE_INFINITY, }: GetDatacentreOrderMocksParams): Handler[] => { - const selectedOrderableResource: IVdcOrderableResourceData = { + const selectedOrderableResource: VCDOrderableResourceData = { compute: orderableResourceData.compute.slice(0, nbOrderableResource), storage: orderableResourceData.storage.slice(0, nbOrderableResource), }; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.mock.ts index 32446b83efd0..4ff1bf6ac519 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-datacentre.mock.ts @@ -1,6 +1,6 @@ -import IVcdDatacentre from '../../src/types/vcd-datacenter.interface'; +import { VCDDatacentre } from '@ovh-ux/manager-module-vcd-api'; -export const datacentreList: IVcdDatacentre[] = [ +export const datacentreList: VCDDatacentre[] = [ { id: 'vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf', resourceStatus: 'READY', diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-organization.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-organization.mock.ts index bb0f3dc62c8c..5f2b12888227 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-organization.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vcd-organization.mock.ts @@ -1,6 +1,6 @@ -import IVcdOrganization from '../../src/types/vcd-organization.interface'; +import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; -export const organizationList: IVcdOrganization[] = [ +export const organizationList: VCDOrganization[] = [ { currentState: { apiUrl: 'https://vcd.my.company', diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-compute.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-compute.mock.ts index a0a42ed9cfb2..38e24c6567a2 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-compute.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-compute.mock.ts @@ -1,6 +1,6 @@ -import IVcdCompute from '../../src/types/vcd-compute.interface'; +import { VCDCompute } from '@ovh-ux/manager-module-vcd-api'; -export const computeList: IVcdCompute[] = [ +export const computeList: VCDCompute[] = [ { id: 'f578c64f-ebec-4c19-a006-c96b1c7c1b95', resourceStatus: 'READY', diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-orderable-resource.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-orderable-resource.mock.ts index a62528086349..a8cd86708200 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-orderable-resource.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-orderable-resource.mock.ts @@ -1,6 +1,6 @@ -import { IVdcOrderableResourceData } from '../../src/types/vcd-vdc-orderable-resource.interface'; +import { VCDOrderableResourceData } from '@ovh-ux/manager-module-vcd-api'; -export const orderableResourceData: IVdcOrderableResourceData = { +export const orderableResourceData: VCDOrderableResourceData = { compute: [ { memoryQuota: 64, diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-storage.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-storage.mock.ts index e3538f33c932..f2bf3f048b47 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-storage.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/vcd-organization/vdc-storage.mock.ts @@ -1,6 +1,6 @@ -import IVcdStorage from '../../src/types/vcd-storage.interface'; +import { VCDStorage } from '@ovh-ux/manager-module-vcd-api'; -export const storageList: IVcdStorage[] = [ +export const storageList: VCDStorage[] = [ { id: 'fccce864-e1d5-4ab8-ad6a-79ecd295f420', resourceStatus: 'READY', diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/veeam-backup/veeam-backup.mock.ts b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/veeam-backup/veeam-backup.mock.ts index c3d4cf19fc8b..068ab60bd271 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/mocks/veeam-backup/veeam-backup.mock.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/mocks/veeam-backup/veeam-backup.mock.ts @@ -1,9 +1,7 @@ -import IVcdOrganizationBackup, { - BackupResourceStatus, -} from '../../src/types/vcd-organization-backup.interface'; +import { VCDOrganizationBackup } from '@ovh-ux/manager-module-vcd-api'; import { organizationList } from '../vcd-organization/vcd-organization.mock'; -export const backupList: IVcdOrganizationBackup[] = [ +export const backupList: VCDOrganizationBackup[] = [ { id: `${organizationList[0].id}-veeam-backup`, iam: { @@ -30,7 +28,7 @@ export const backupList: IVcdOrganizationBackup[] = [ }, updatedAt: '2024-06-14T09:21:21.943Z', createdAt: '2024-06-14T09:21:21.943Z', - resourceStatus: BackupResourceStatus.READY, + resourceStatus: 'READY', targetSpec: { offers: [ { diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/compute/ComputeOrderCells.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/compute/ComputeOrderCells.component.tsx index 839fddb6f188..c1f316106ac0 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/compute/ComputeOrderCells.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/compute/ComputeOrderCells.component.tsx @@ -7,11 +7,11 @@ import { import { OsdsRadio, OsdsRadioButton } from '@ovhcloud/ods-components/react'; import { ODS_RADIO_BUTTON_SIZE } from '@ovhcloud/ods-components'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; -import { IVdcOrderableVhostPriced } from '@/types/vcd-vdc-orderable-resource.interface'; +import { VCDOrderableVhostPriced } from '@ovh-ux/manager-module-vcd-api'; import { getVdcResourcePriceLabel } from '@/utils/getPricedOrderableResource'; import { useDatacentreOrderContext } from '@/context/DatacentreOrder.context'; -export const ComputeOrderSelectCell = (vHost: IVdcOrderableVhostPriced) => { +export const ComputeOrderSelectCell = (vHost: VCDOrderableVhostPriced) => { const { selectedResource, setSelectedResource } = useDatacentreOrderContext(); return ( @@ -30,11 +30,11 @@ export const ComputeOrderSelectCell = (vHost: IVdcOrderableVhostPriced) => { ); }; -export const ComputeOrderVhostCell = (vHost: IVdcOrderableVhostPriced) => ( +export const ComputeOrderVhostCell = (vHost: VCDOrderableVhostPriced) => ( {vHost.profile} ); -export const ComputeOrderCpuSpeedCell = (vHost: IVdcOrderableVhostPriced) => { +export const ComputeOrderCpuSpeedCell = (vHost: VCDOrderableVhostPriced) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres'); return ( @@ -43,7 +43,7 @@ export const ComputeOrderCpuSpeedCell = (vHost: IVdcOrderableVhostPriced) => { ); }; -export const ComputeOrderRamCell = (vHost: IVdcOrderableVhostPriced) => { +export const ComputeOrderRamCell = (vHost: VCDOrderableVhostPriced) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres/order'); return ( @@ -54,11 +54,11 @@ export const ComputeOrderRamCell = (vHost: IVdcOrderableVhostPriced) => { ); }; -export const ComputeOrderCpuCountCell = (vHost: IVdcOrderableVhostPriced) => ( +export const ComputeOrderCpuCountCell = (vHost: VCDOrderableVhostPriced) => ( {vHost.vCPUCount} ); -export const ComputeOrderPriceCell = (vHost: IVdcOrderableVhostPriced) => { +export const ComputeOrderPriceCell = (vHost: VCDOrderableVhostPriced) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres/order'); return ( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/container/DatagridContainer.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/container/DatagridContainer.component.tsx index afd8f9567d90..f5c6ea3b3c32 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/container/DatagridContainer.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/container/DatagridContainer.component.tsx @@ -8,6 +8,7 @@ import { import { OsdsDivider } from '@ovhcloud/ods-components/react'; import React, { useEffect, useState } from 'react'; import { useNavigate } from 'react-router-dom'; +import { icebergListingQueryKey } from '@ovh-ux/manager-module-vcd-api'; import Loading from '@/components/loading/Loading.component'; import TDatagridRoute from '@/types/datagrid-route.type'; import { useAutoRefetch } from '@/data/hooks/useAutoRefetch'; @@ -15,7 +16,6 @@ import { hasResourceUpdatingTargetSpec, UpdatableResource, } from '@/utils/refetchConditions'; -import { icebergListingQueryKey } from '@/utils/queryKeys'; export type TDatagridContainerProps = { route: TDatagridRoute; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/storage/StorageOrderCells.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/storage/StorageOrderCells.component.tsx index b94e76afee5b..63a87726ef0b 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/storage/StorageOrderCells.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/datagrid/storage/StorageOrderCells.component.tsx @@ -7,11 +7,11 @@ import { import { OsdsRadio, OsdsRadioButton } from '@ovhcloud/ods-components/react'; import { ODS_RADIO_BUTTON_SIZE } from '@ovhcloud/ods-components'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; -import { IVdcOrderableStoragePriced } from '@/types/vcd-vdc-orderable-resource.interface'; +import { VCDOrderableStoragePriced } from '@ovh-ux/manager-module-vcd-api'; import { getVdcResourcePriceLabel } from '@/utils/getPricedOrderableResource'; import { useDatacentreOrderContext } from '@/context/DatacentreOrder.context'; -export const StorageOrderSelectCell = (storage: IVdcOrderableStoragePriced) => { +export const StorageOrderSelectCell = (storage: VCDOrderableStoragePriced) => { const { selectedResource, setSelectedResource } = useDatacentreOrderContext(); return ( @@ -30,11 +30,11 @@ export const StorageOrderSelectCell = (storage: IVdcOrderableStoragePriced) => { ); }; -export const StorageOrderTypeCell = (storage: IVdcOrderableStoragePriced) => ( +export const StorageOrderTypeCell = (storage: VCDOrderableStoragePriced) => ( {storage.name} ); -export const StorageOrderPriceCell = (storage: IVdcOrderableStoragePriced) => { +export const StorageOrderPriceCell = (storage: VCDOrderableStoragePriced) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres/order'); return ( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/form/DatacentreOrder.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/form/DatacentreOrder.component.tsx index 85500ec03e87..b3ff0c76def1 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/form/DatacentreOrder.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/form/DatacentreOrder.component.tsx @@ -11,23 +11,23 @@ import { import { OsdsButton } from '@ovhcloud/ods-components/react'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; import { ODS_BUTTON_SIZE, ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; +import { + useVcdCatalog, + useVcdOrder, + useVdcOrderableResource, + VCDOrderableStoragePriced, + VCDOrderableVhostPriced, +} from '@ovh-ux/manager-module-vcd-api'; import { QuantitySelector } from './QuantitySelector.component'; import { useDatacentreOrderContext } from '@/context/DatacentreOrder.context'; -import { useVdcOrderableResource } from '@/data/hooks/useOrderableResource'; -import { useVcdCatalog } from '@/data/hooks/useVcdCatalog'; -import useVcdOrder from '@/data/hooks/useVcdOrder'; import { validateQuantity } from '@/utils/formValidation'; import { getPricedVdcResources } from '@/utils/getPricedOrderableResource'; import Loading from '../loading/Loading.component'; -import { - IVdcOrderableStoragePriced, - IVdcOrderableVhostPriced, -} from '@/types/vcd-vdc-orderable-resource.interface'; type OrderType = 'compute' | 'storage'; type OrderColumns = T extends 'compute' - ? DatagridColumn[] - : DatagridColumn[]; + ? DatagridColumn[] + : DatagridColumn[]; interface DatacentreOrderProps { orderType: T; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/modal/UpdateDetailModalHandler.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/modal/UpdateDetailModalHandler.tsx index de8a6f62f73e..f0dd835002dd 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/modal/UpdateDetailModalHandler.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/modal/UpdateDetailModalHandler.tsx @@ -1,9 +1,11 @@ import React from 'react'; import { useNavigate, useParams } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; -import useManagedVcdOrganization from '@/data/hooks/useManagedVcdOrganization'; -import { useUpdateVcdOrganizationDetails } from '@/data/hooks/useUpdateVcdOrganization'; -import { IVcdOrganizationState } from '@/types/vcd-organization.interface'; +import { + useVcdOrganization, + useUpdateVcdOrganizationDetails, + VCDOrganizationTargetSpec, +} from '@ovh-ux/manager-module-vcd-api'; import { validateDescription, validateOrganizationName, @@ -30,7 +32,7 @@ export const UpdateDetailModalHandler = ({ const closeModal = () => navigate('..'); const { addSuccess } = useMessageContext(); const { id } = useParams(); - const { data: vcdOrganization } = useManagedVcdOrganization({ id }); + const { data: vcdOrganization } = useVcdOrganization({ id }); const { updateDetails, error, isError } = useUpdateVcdOrganizationDetails({ id, onSuccess: () => { @@ -42,7 +44,8 @@ export const UpdateDetailModalHandler = ({ closeModal(); }, }); - const currentDetails: IVcdOrganizationState = vcdOrganization.data.targetSpec; + const currentDetails: VCDOrganizationTargetSpec = + vcdOrganization.data.targetSpec; const getOrganizationDetailKey = (key: OrganizationDetailName) => { const detailKeys: TOrganizationDetails = { diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-general-information-tile/DatacentreGeneralInformationTile.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-general-information-tile/DatacentreGeneralInformationTile.component.tsx index e93c9ac41745..345059cc1c7e 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-general-information-tile/DatacentreGeneralInformationTile.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-general-information-tile/DatacentreGeneralInformationTile.component.tsx @@ -9,16 +9,15 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core'; -import IVcdDatacentre from '@/types/vcd-datacenter.interface'; -import IVcdOrganization from '@/types/vcd-organization.interface'; +import { VCDDatacentre, VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; import { subRoutes } from '@/routes/routes.constant'; import { iamActions } from '@/utils/iam.constants'; import EditableTileItem from '../editable-tile-item/EditableTileItem.component'; import { capitalize } from '@/utils/capitalize'; type TTileProps = { - vcdDatacentre: IVcdDatacentre; - vcdOrganization: IVcdOrganization; + vcdDatacentre: VCDDatacentre; + vcdOrganization: VCDOrganization; }; export default function DatacentreGenerationInformationTile({ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-usage-tile/DatacentreUsageTile.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-usage-tile/DatacentreUsageTile.component.tsx index 9553b740cff3..9fc78faa7bc8 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-usage-tile/DatacentreUsageTile.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/datacentre-usage-tile/DatacentreUsageTile.component.tsx @@ -6,10 +6,10 @@ import { Description, } from '@ovh-ux/manager-react-components'; import { ODS_ICON_NAME } from '@ovhcloud/ods-components'; -import IVcdDatacentre from '@/types/vcd-datacenter.interface'; +import { VCDDatacentre } from '@ovh-ux/manager-module-vcd-api'; type TTileProps = { - vcdDatacentre: IVcdDatacentre; + vcdDatacentre: VCDDatacentre; }; export default function DatacentreUsageTile({ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.component.tsx index 4d227fcd0a1e..30d6b0320280 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.component.tsx @@ -4,15 +4,15 @@ import { DashboardTile } from '@ovh-ux/manager-react-components'; import { OsdsChip } from '@ovhcloud/ods-components/react'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; import { ODS_CHIP_SIZE } from '@ovhcloud/ods-components'; +import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; import { DATA_PROTECTION_BACKUP_TITLE, DATA_PROTECTION_RECOVERY_TITLE, } from '@/pages/dashboard/organization/OrganizationDashboard.constants'; import BackupTileItem from './backup-tile-item/BackupTileItem.component'; -import IVcdOrganization from '@/types/vcd-organization.interface'; type TTileProps = { - vcdOrganization: IVcdOrganization; + vcdOrganization: VCDOrganization; }; export default function DataProtectionTile({ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.spec.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.spec.tsx index 28611525d56a..eb8700c8fc78 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.spec.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/OrganizationDataProtectionTile.spec.tsx @@ -15,18 +15,20 @@ import { ShellContext, ShellContextType, } from '@ovh-ux/manager-react-shell-client'; +import { + ResourceStatus, + useVeeamBackup, + VeeamBackupWithIam, +} from '@ovh-ux/manager-module-vcd-api'; import OrganizationDataProtectionTile from './OrganizationDataProtectionTile.component'; -import { useManagedVcdOrganizationBackup } from '../../../data/hooks/useManagedVcdOrganization'; -import IVcdOrganizationBackup, { - BackupResourceStatus, -} from '../../../types/vcd-organization-backup.interface'; import { organizationList } from '../../../../mocks/vcd-organization/vcd-organization.mock'; -vi.mock('../../../data/hooks/useManagedVcdOrganization', () => ({ - useManagedVcdOrganizationBackup: vi.fn(), +vi.mock('@ovh-ux/manager-module-vcd-api', () => ({ + useVeeamBackup: vi.fn(), + getBackupIdFromOrganization: vi.fn(), })); -vi.mocked(useManagedVcdOrganizationBackup).mockReturnValue( - {} as UseQueryResult, ApiError>, +vi.mocked(useVeeamBackup).mockReturnValue( + {} as UseQueryResult, ApiError>, ); const shellContext = { @@ -88,9 +90,9 @@ describe('OrganizationDataProtectionTile component unit test suite', () => { describe('OrganizationDataProtectionTile query state-based behavior unit test suite', () => { it('should display backupLoading when query isLoading', async () => { - vi.mocked(useManagedVcdOrganizationBackup).mockReturnValue({ + vi.mocked(useVeeamBackup).mockReturnValue({ isLoading: true, - } as UseQueryResult, ApiError>); + } as UseQueryResult, ApiError>); // when await act(async () => renderComponent()); @@ -101,9 +103,9 @@ describe('OrganizationDataProtectionTile query state-based behavior unit test su }); it('should display backupError when query isError', async () => { - vi.mocked(useManagedVcdOrganizationBackup).mockReturnValue({ + vi.mocked(useVeeamBackup).mockReturnValue({ isError: true, - } as UseQueryResult, ApiError>); + } as UseQueryResult, ApiError>); // when await act(async () => renderComponent()); @@ -116,10 +118,10 @@ describe('OrganizationDataProtectionTile query state-based behavior unit test su }); it('should display noBackup when query isError 404', async () => { - vi.mocked(useManagedVcdOrganizationBackup).mockReturnValue({ + vi.mocked(useVeeamBackup).mockReturnValue({ isError: true, error: { response: { status: 404 } }, - } as UseQueryResult, ApiError>); + } as UseQueryResult, ApiError>); // when await act(async () => renderComponent()); @@ -130,11 +132,11 @@ describe('OrganizationDataProtectionTile query state-based behavior unit test su }); it('should display backupStatus when query isSuccess', async () => { - const testStatus = BackupResourceStatus.CREATING; - vi.mocked(useManagedVcdOrganizationBackup).mockReturnValue({ + const testStatus: ResourceStatus = 'READY'; + vi.mocked(useVeeamBackup).mockReturnValue({ isSuccess: true, data: { data: { resourceStatus: testStatus } }, - } as UseQueryResult, ApiError>); + } as UseQueryResult, ApiError>); // when await act(async () => renderComponent()); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/backup-tile-item/BackupTileItem.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/backup-tile-item/BackupTileItem.component.tsx index abb64b3ae58d..6201ed2644ae 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/backup-tile-item/BackupTileItem.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-data-tile/backup-tile-item/BackupTileItem.component.tsx @@ -4,17 +4,20 @@ import { ShellContext } from '@ovh-ux/manager-react-shell-client'; import { Links, LinkType } from '@ovh-ux/manager-react-components'; import { ODS_CHIP_SIZE } from '@ovhcloud/ods-components'; import { OsdsChip, OsdsSkeleton } from '@ovhcloud/ods-components/react'; +import { + getBackupIdFromOrganization, + useVeeamBackup, + VCDOrganization, +} from '@ovh-ux/manager-module-vcd-api'; import { veeamBackupAppName } from '@/routes/routes.constant'; -import { useManagedVcdOrganizationBackup } from '@/data/hooks/useManagedVcdOrganization'; import { BackupBadgeParams, getBackupBadgeParams, getBackupBadgeStatus, } from '@/utils/veeamBackupBadge'; -import IVcdOrganization from '@/types/vcd-organization.interface'; type TTileProps = { - vcdOrganization: IVcdOrganization; + vcdOrganization: VCDOrganization; }; export default function BackupTileItem({ @@ -22,8 +25,8 @@ export default function BackupTileItem({ }: Readonly) { const { t } = useTranslation('dashboard'); const { shell } = React.useContext(ShellContext); - const { data: vcdBackup, isLoading, error } = useManagedVcdOrganizationBackup( - vcdOrganization, + const { data: vcdBackup, isLoading, error } = useVeeamBackup( + getBackupIdFromOrganization(vcdOrganization), ); const [veeamHref, setVeeamHref] = React.useState(''); const badgeParams: BackupBadgeParams = getBackupBadgeParams( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/DatacentresCount.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/DatacentresCount.component.tsx index e40b52bcf946..d9accc6bcddb 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/DatacentresCount.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/DatacentresCount.component.tsx @@ -3,16 +3,13 @@ import { Description } from '@ovh-ux/manager-react-components'; import { useParams } from 'react-router-dom'; import { OsdsSkeleton, OsdsMessage } from '@ovhcloud/ods-components/react'; import { ODS_MESSAGE_TYPE, ODS_SKELETON_SIZE } from '@ovhcloud/ods-components'; -import useManagedVcdDatacentres from '@/data/hooks/useManagedVcdDatacentres'; +import { useVcdDatacentres } from '@ovh-ux/manager-module-vcd-api'; export const DatacentresCount: React.FC = () => { const { id } = useParams(); - const { - data: vDatacentres, - isError, - error, - isLoading, - } = useManagedVcdDatacentres(id); + const { data: vDatacentres, isError, error, isLoading } = useVcdDatacentres( + id, + ); if (isError) { return ( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/OrganizationGeneralInformationTile.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/OrganizationGeneralInformationTile.component.tsx index d49cbadb4482..8a471b5f86eb 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/OrganizationGeneralInformationTile.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-general-information-tile/OrganizationGeneralInformationTile.component.tsx @@ -17,14 +17,14 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate } from 'react-router-dom'; import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core'; -import IVcdOrganization from '@/types/vcd-organization.interface'; +import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; import { subRoutes } from '@/routes/routes.constant'; import { iamActions } from '@/utils/iam.constants'; import EditableTileItem from '../editable-tile-item/EditableTileItem.component'; import DatacentresCount from './DatacentresCount.component'; type TTileProps = { - vcdOrganization: IVcdOrganization; + vcdOrganization: VCDOrganization; }; export default function OrganizationGenerationInformationTile({ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-options-tile/OrganizationOptionsTile.component.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-options-tile/OrganizationOptionsTile.component.tsx index 2d60a54f917e..834004a12439 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-options-tile/OrganizationOptionsTile.component.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/components/tiles/organization-options-tile/OrganizationOptionsTile.component.tsx @@ -7,7 +7,7 @@ import { import { useTranslation } from 'react-i18next'; import { ODS_ICON_NAME } from '@ovhcloud/ods-components'; import { useParams } from 'react-router-dom'; -import useVcdOrder from '@/data/hooks/useVcdOrder'; +import { useVcdOrder } from '@ovh-ux/manager-module-vcd-api'; import { WINDOWS_LICENSE_PLANCODE } from '@/utils/planCode.constants'; export default function OrganizationOptionsTile({ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-cart.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-cart.ts deleted file mode 100644 index 9e8e6e190601..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-cart.ts +++ /dev/null @@ -1,9 +0,0 @@ -import apiClient, { ApiResponse } from '@ovh-ux/manager-core-api'; -import { TVcdCatalog } from '@/types/vcd-catalog.interface'; - -export const getVcdCatalog = async ( - serviceName: string, -): Promise> => - apiClient.v6.get( - `/order/cartServiceOption/vmwareCloudDirector/${serviceName}`, - ); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-datacentre.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-datacentre.ts deleted file mode 100644 index e47ec1cb7918..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-datacentre.ts +++ /dev/null @@ -1,58 +0,0 @@ -import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api'; -import IVcdDatacentre, { - IVcdDatacentreState, -} from '@/types/vcd-datacenter.interface'; -import { VCD_ORGANIZATION_ROUTE } from './hpc-vmware-managed-vcd.constants'; -import { IVdcOrderableResourceData } from '@/types/vcd-vdc-orderable-resource.interface'; - -export type UpdateVdcDetailsParams = { - id: string; - vdcId: string; - details: IVcdDatacentreState; -}; - -export const getVcdDatacentresRoute = (id: string) => { - return `${VCD_ORGANIZATION_ROUTE}/${id}/virtualDataCenter`; -}; - -export const getVcdDatacentreRoute = (id: string, vdcId: string) => { - return `${getVcdDatacentresRoute(id)}/${vdcId}`; -}; - -export const getVcdDatacentreComputeRoute = (id: string, vdcId: string) => { - return `${getVcdDatacentreRoute(id, vdcId)}/compute`; -}; - -export const getVcdDatacentreStorageRoute = (id: string, vdcId: string) => { - return `${getVcdDatacentreRoute(id, vdcId)}/storage`; -}; - -export const getVdcOrderableResourceRoute = (id: string, vdcId: string) => { - return `${getVcdDatacentreRoute(id, vdcId)}/orderableResource`; -}; - -export const getVcdDatacentre = async ( - id: string, - vdcId: string, -): Promise> => - apiClient.v2.get(getVcdDatacentreRoute(id, vdcId)); - -export const getVcdDatacentres = async ( - id: string, -): Promise> => - apiClient.v2.get(getVcdDatacentresRoute(id)); - -export const updateVdcDetails = async ({ - id, - vdcId, - details, -}: UpdateVdcDetailsParams) => - apiClient.v2.put(getVcdDatacentreRoute(id, vdcId), { - targetSpec: details, - }); - -export const getVdcOrderableResource = async ( - id: string, - vdcId: string, -): Promise> => - apiClient.v2.get(getVdcOrderableResourceRoute(id, vdcId)); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-reset-password.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-reset-password.ts deleted file mode 100644 index 724ad903b770..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd-reset-password.ts +++ /dev/null @@ -1,10 +0,0 @@ -import { apiClient, ApiResponse } from '@ovh-ux/manager-core-api'; -import { VCD_ORGANIZATION_ROUTE } from './hpc-vmware-managed-vcd.constants'; - -const getResetPasswordRoute = (id: string) => - `${VCD_ORGANIZATION_ROUTE}/${id}/password`; - -export const resetOrganizationPassword = ( - id: string, -): Promise> => - apiClient.v2.post(getResetPasswordRoute(id)); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.constants.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.constants.ts deleted file mode 100644 index 52f99990905f..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.constants.ts +++ /dev/null @@ -1 +0,0 @@ -export const VCD_ORGANIZATION_ROUTE = '/vmwareCloudDirector/organization'; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.ts deleted file mode 100644 index 722f8fb023b5..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/api/hpc-vmware-managed-vcd.ts +++ /dev/null @@ -1,42 +0,0 @@ -import { ApiResponse, apiClient } from '@ovh-ux/manager-core-api'; -import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; -import { IVcdOrganizationState } from '@/types/vcd-organization.interface'; -import { VCD_ORGANIZATION_ROUTE } from './hpc-vmware-managed-vcd.constants'; -import IVcdOrganizationBackup from '@/types/vcd-organization-backup.interface'; - -export type GetVcdOrganizationListParams = { - /** Filter resources on IAM tags */ - iamTags: any; -}; - -export type UpdateVcdOrganizationDetailsParams = { - id: string; - details: IVcdOrganizationState; -}; - -/** - * VMware on OVHcloud : Get VMware on OVHcloud - */ -export const getVcdOrganization = async ( - id: string, -): Promise> => - apiClient.v2.get(`${VCD_ORGANIZATION_ROUTE}/${id}`); - -/** - * Get VCD Backup - */ -export const getVcdOrganizationBackup = async ( - backupId: string, -): Promise> => - apiClient.v2.get(`/vmwareCloudDirector/backup/${backupId}`); - -/** - * Edit VCD Organization - */ -export const updateVcdOrganizationDetails = async ({ - id, - details, -}: UpdateVcdOrganizationDetailsParams): Promise> => - apiClient.v2.put(`${VCD_ORGANIZATION_ROUTE}/${id}`, { - targetSpec: details, - }); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdDatacentres.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdDatacentres.ts deleted file mode 100644 index 731f91d80b79..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdDatacentres.ts +++ /dev/null @@ -1,31 +0,0 @@ -import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; -import { keepPreviousData, useQuery } from '@tanstack/react-query'; -import { - getVcdDatacentre, - getVcdDatacentres, -} from '../api/hpc-vmware-managed-vcd-datacentre'; -import IVcdDatacentre from '@/types/vcd-datacenter.interface'; -import { - getVcdDatacentresQueryKey, - getVcdDatacentreQueryKey, -} from '@/utils/queryKeys'; - -const useManagedVcdDatacentres = (id: string) => { - return useQuery, ApiError>({ - queryKey: getVcdDatacentresQueryKey(id), - queryFn: () => getVcdDatacentres(id), - retry: false, - placeholderData: keepPreviousData, - }); -}; - -export const useManagedVcdDatacentre = (id: string, vdcId: string) => { - return useQuery, ApiError>({ - queryKey: getVcdDatacentreQueryKey(id, vdcId), - queryFn: () => getVcdDatacentre(id, vdcId), - retry: false, - placeholderData: keepPreviousData, - }); -}; - -export default useManagedVcdDatacentres; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdOrganization.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdOrganization.ts deleted file mode 100644 index 4e12d4df9cbb..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useManagedVcdOrganization.ts +++ /dev/null @@ -1,51 +0,0 @@ -import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; -import { - keepPreviousData, - useQuery, - UseQueryOptions, -} from '@tanstack/react-query'; -import { - getVcdOrganization, - getVcdOrganizationBackup, -} from '../api/hpc-vmware-managed-vcd'; -import IVcdOrganization from '@/types/vcd-organization.interface'; -import IVcdOrganizationBackup from '@/types/vcd-organization-backup.interface'; -import { - getVcdOrganizationQueryKey, - getVcdOrganizationBackupQueryKey, -} from '@/utils/queryKeys'; -import { getBackupIdFromOrganization } from '@/utils/veeamBackupId'; - -interface IUseManagedVcdOrganization - extends Pick { - id: string; -} - -const useManagedVcdOrganization = ({ - id, - refetchInterval, - refetchOnWindowFocus, -}: IUseManagedVcdOrganization) => { - return useQuery, ApiError>({ - queryKey: getVcdOrganizationQueryKey(id), - queryFn: () => getVcdOrganization(id), - retry: false, - refetchInterval, - refetchOnWindowFocus, - placeholderData: keepPreviousData, - }); -}; - -export const useManagedVcdOrganizationBackup = ( - vcdOrganization: IVcdOrganization, -) => { - return useQuery, ApiError>({ - queryKey: getVcdOrganizationBackupQueryKey(vcdOrganization.id), - queryFn: () => - getVcdOrganizationBackup(getBackupIdFromOrganization(vcdOrganization)), - retry: false, - placeholderData: keepPreviousData, - }); -}; - -export default useManagedVcdOrganization; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useOrderableResource.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useOrderableResource.ts deleted file mode 100644 index 5b885ff5902f..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useOrderableResource.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { ApiResponse, ApiError } from '@ovh-ux/manager-core-api'; -import { useQuery, keepPreviousData } from '@tanstack/react-query'; -import { IVdcOrderableResourceData } from '@/types/vcd-vdc-orderable-resource.interface'; -import { getVdcOrderableResource } from '../api/hpc-vmware-managed-vcd-datacentre'; -import { getVdcOrderableResourceQueryKey } from '@/utils/queryKeys'; - -export const useVdcOrderableResource = (id: string, vdcId: string) => { - return useQuery, ApiError>({ - queryKey: getVdcOrderableResourceQueryKey(vdcId), - queryFn: () => getVdcOrderableResource(id, vdcId), - placeholderData: keepPreviousData, - }); -}; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useResetPassword.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useResetPassword.ts deleted file mode 100644 index db118380b031..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useResetPassword.ts +++ /dev/null @@ -1,16 +0,0 @@ -import { useMutation, UseMutationOptions } from '@tanstack/react-query'; -import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; -import { resetOrganizationPassword } from '../api/hpc-vmware-managed-vcd-reset-password'; -import { getVcdOrganizationResetPasswordQueryKey } from '@/utils/queryKeys'; - -export const useResetPassword = ( - { id }: { id: string }, - options?: Partial< - UseMutationOptions, ApiError, void, unknown> - >, -) => - useMutation({ - mutationKey: getVcdOrganizationResetPasswordQueryKey(id), - mutationFn: () => resetOrganizationPassword(id), - ...options, - }); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdDatacentre.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdDatacentre.ts deleted file mode 100644 index 463e5fad9923..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdDatacentre.ts +++ /dev/null @@ -1,39 +0,0 @@ -import { ApiError } from '@ovh-ux/manager-core-api'; -import { useQueryClient, useMutation } from '@tanstack/react-query'; -import { - UpdateVdcDetailsParams, - updateVdcDetails, -} from '../api/hpc-vmware-managed-vcd-datacentre'; -import { - getVcdDatacentresQueryKey, - updateVdcDetailsMutationKey, -} from '@/utils/queryKeys'; - -export const useUpdateVdcDetails = ({ - id, - vdcId, - onSuccess, - onError, -}: { - id: string; - vdcId: string; - onSuccess?: () => void; - onError?: (result: ApiError) => void; -}) => { - const queryClient = useQueryClient(); - - const { mutateAsync: updateDetails, error, isError } = useMutation({ - mutationKey: updateVdcDetailsMutationKey(vdcId), - mutationFn: ({ details }: UpdateVdcDetailsParams) => - updateVdcDetails({ id, vdcId, details }), - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: getVcdDatacentresQueryKey(id), - }); - onSuccess?.(); - }, - onError: (result: ApiError) => onError?.(result), - }); - - return { updateDetails, error, isError }; -}; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdOrganization.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdOrganization.ts deleted file mode 100644 index 384bdfc37e61..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useUpdateVcdOrganization.ts +++ /dev/null @@ -1,44 +0,0 @@ -import { useMutation, useQueryClient } from '@tanstack/react-query'; -import { ApiError } from '@ovh-ux/manager-core-api'; -import { - updateVcdOrganizationDetails, - UpdateVcdOrganizationDetailsParams, -} from '../api/hpc-vmware-managed-vcd'; -import { - getVcdOrganizationsQueryKey, - getVcdOrganizationQueryKey, - icebergListingQueryKey, - updateVcdOrganizationDetailsMutationKey, -} from '@/utils/queryKeys'; - -export const useUpdateVcdOrganizationDetails = ({ - id, - onSuccess, - onError, -}: { - id: string; - onSuccess?: () => void; - onError?: (result: ApiError) => void; -}) => { - const queryClient = useQueryClient(); - - const { mutateAsync: updateDetails, error, isError } = useMutation({ - mutationKey: updateVcdOrganizationDetailsMutationKey(id), - mutationFn: ({ details }: UpdateVcdOrganizationDetailsParams) => - updateVcdOrganizationDetails({ id, details }), - onSuccess: () => { - queryClient.invalidateQueries({ - queryKey: getVcdOrganizationQueryKey(id), - exact: true, - }); - queryClient.invalidateQueries({ - queryKey: [...getVcdOrganizationsQueryKey(), icebergListingQueryKey], - exact: true, - }); - onSuccess?.(); - }, - onError: (result: ApiError) => onError?.(result), - }); - - return { updateDetails, error, isError }; -}; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdCatalog.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdCatalog.ts deleted file mode 100644 index fe7948c0a534..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdCatalog.ts +++ /dev/null @@ -1,13 +0,0 @@ -import { keepPreviousData, useQuery } from '@tanstack/react-query'; -import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; -import { getVcdCatalog } from '../api/hpc-vmware-managed-vcd-cart'; -import { TVcdCatalog } from '@/types/vcd-catalog.interface'; -import { getVcdCatalogQueryKey } from '@/utils/queryKeys'; - -export const useVcdCatalog = (serviceName: string) => { - return useQuery, ApiError>({ - queryKey: getVcdCatalogQueryKey(serviceName), - queryFn: () => getVcdCatalog(serviceName), - placeholderData: keepPreviousData, - }); -}; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdOrder.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdOrder.ts deleted file mode 100644 index 0998f4d2b675..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/data/hooks/useVcdOrder.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { - useOrderURL, - getVcdProductSettings, -} from '@ovh-ux/manager-module-order'; - -interface IVcdOrder { - serviceName: string; - planCode: string; - quantity?: number; - vdcOrgId?: string; -} - -const useVcdOrder = ({ - serviceName, - planCode, - quantity, - vdcOrgId, -}: IVcdOrder) => { - const orderBaseUrl = useOrderURL('express_review_base'); - const vcdProductSettings = getVcdProductSettings({ - serviceName, - planCode, - quantity, - vdcOrgId, - }); - const orderLink = `${orderBaseUrl}?products=~(${vcdProductSettings})`; - const redirectToOrder = () => { - window.open(orderLink, '_blank', 'noopener,noreferrer'); - }; - - return { orderLink, redirectToOrder }; -}; - -export default useVcdOrder; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/DatacentreDashboard.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/DatacentreDashboard.page.tsx index 33687d51b868..2ff1626855e2 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/DatacentreDashboard.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/DatacentreDashboard.page.tsx @@ -1,21 +1,23 @@ import React from 'react'; import { useNavigate, useParams, useResolvedPath } from 'react-router-dom'; import { useTranslation } from 'react-i18next'; +import { + useVcdOrganization, + useVcdDatacentre, + getVcdDatacentresQueryKey, +} from '@ovh-ux/manager-module-vcd-api'; import { BreadcrumbItem } from '@/hooks/breadcrumb/useBreadcrumb'; import VcdDashboardLayout from '@/components/dashboard/layout/VcdDashboardLayout.component'; -import { useManagedVcdDatacentre } from '@/data/hooks/useManagedVcdDatacentres'; -import useManagedVcdOrganization from '@/data/hooks/useManagedVcdOrganization'; import { COMPUTE_TITLE, STORAGE_TITLE } from './DatacentreDashboard.constant'; import { subRoutes, urls } from '@/routes/routes.constant'; import { useAutoRefetch } from '@/data/hooks/useAutoRefetch'; import { isUpdatingTargetSpec } from '@/utils/refetchConditions'; -import { getVcdDatacentresQueryKey } from '@/utils/queryKeys'; function DatacentreDashboardPage() { const { id, vdcId } = useParams(); const { t } = useTranslation('dashboard'); - const { data: vcdDatacentre } = useManagedVcdDatacentre(id, vdcId); - const { data: vcdOrganization } = useManagedVcdOrganization({ id }); + const { data: vcdDatacentre } = useVcdDatacentre(id, vdcId); + const { data: vcdOrganization } = useVcdOrganization({ id }); const navigate = useNavigate(); useAutoRefetch({ queryKey: getVcdDatacentresQueryKey(id), diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute-order/DatacentreComputeOrder.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute-order/DatacentreComputeOrder.page.tsx index a49f82bcbe33..c6ca658a603d 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute-order/DatacentreComputeOrder.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute-order/DatacentreComputeOrder.page.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { DatagridColumn } from '@ovh-ux/manager-react-components'; +import { VCDOrderableVhostPriced } from '@ovh-ux/manager-module-vcd-api'; import { DatacentreOrderProvider } from '@/context/DatacentreOrder.context'; -import { IVdcOrderableVhostPriced } from '@/types/vcd-vdc-orderable-resource.interface'; import { DatacentreOrder } from '@/components/form/DatacentreOrder.component'; import { ComputeOrderSelectCell, @@ -23,7 +23,7 @@ export default function ComputeOrderPage() { const { t: tCompute } = useTranslation( 'hpc-vmware-managed-vcd/datacentres/compute', ); - const columns: DatagridColumn[] = [ + const columns: DatagridColumn[] = [ { id: 'select', cell: ComputeOrderSelectCell, diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute/DatacentreCompute.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute/DatacentreCompute.page.tsx index 83e34db61f45..bc476a0edc67 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute/DatacentreCompute.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/compute/DatacentreCompute.page.tsx @@ -5,24 +5,26 @@ import { DataGridTextCell } from '@ovh-ux/manager-react-components'; import { OsdsButton } from '@ovhcloud/ods-components/react'; import { ODS_BUTTON_SIZE, ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; +import { + getVcdDatacentreComputeRoute, + getVdcComputeQueryKey, + VCDCompute, +} from '@ovh-ux/manager-module-vcd-api'; import { VHOSTS_TITLE } from './DatacentreCompute.constants'; import DatagridContainer from '@/components/datagrid/container/DatagridContainer.component'; -import IVcdCompute from '@/types/vcd-compute.interface'; -import { getVcdDatacentreComputeRoute } from '@/data/api/hpc-vmware-managed-vcd-datacentre'; import { subRoutes, urls } from '@/routes/routes.constant'; -import { getVdcComputeQueryKey } from '@/utils/queryKeys'; -const DatagridIdCell = (vcdCompute: IVcdCompute) => ( +const DatagridIdCell = (vcdCompute: VCDCompute) => ( {vcdCompute?.id} ); -const DatagridVHostProfilCell = (vcdCompute: IVcdCompute) => ( +const DatagridVHostProfilCell = (vcdCompute: VCDCompute) => ( {vcdCompute?.currentState?.profile} ); -const DatagridCpuCountCell = (vcdCompute: IVcdCompute) => ( +const DatagridCpuCountCell = (vcdCompute: VCDCompute) => ( {vcdCompute.currentState?.vCPUCount} ); -const DatagridBillingCell = (vcdCompute: IVcdCompute) => { +const DatagridBillingCell = (vcdCompute: VCDCompute) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres/compute'); return ( @@ -33,7 +35,7 @@ const DatagridBillingCell = (vcdCompute: IVcdCompute) => { ); }; -const DatagridRamCountCell = (vcdCompute: IVcdCompute) => { +const DatagridRamCountCell = (vcdCompute: VCDCompute) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres'); return ( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/DatacentreGeneralInformation.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/DatacentreGeneralInformation.page.tsx index 1e1e5b3ab7dc..925a0a937bf1 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/DatacentreGeneralInformation.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/DatacentreGeneralInformation.page.tsx @@ -1,8 +1,10 @@ import React from 'react'; import { Outlet, useParams } from 'react-router-dom'; +import { + useVcdDatacentre, + useVcdOrganization, +} from '@ovh-ux/manager-module-vcd-api'; import DatacentreGenerationInformationTile from '@/components/tiles/datacentre-general-information-tile/DatacentreGeneralInformationTile.component'; -import useManagedVcdOrganization from '@/data/hooks/useManagedVcdOrganization'; -import { useManagedVcdDatacentre } from '@/data/hooks/useManagedVcdDatacentres'; import Loading from '@/components/loading/Loading.component'; import Errors from '@/components/error/Error.component'; import DatacentreUsageTile from '@/components/tiles/datacentre-usage-tile/DatacentreUsageTile.component'; @@ -13,14 +15,14 @@ export default function DatacentresGeneralInformationPage() { data: vcdOrganization, isLoading: isLoadingVcd, error: vcdError, - } = useManagedVcdOrganization({ + } = useVcdOrganization({ id, }); const { data: vcdDatacentre, isLoading: isLoadingDatacentre, error: datacentreError, - } = useManagedVcdDatacentre(id, vdcId); + } = useVcdDatacentre(id, vdcId); if (vcdError || datacentreError) { return ; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/edit/EditVdcDescription.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/edit/EditVdcDescription.page.tsx index 7bc9b462e3a9..3800ffccd683 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/edit/EditVdcDescription.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/general-informations/edit/EditVdcDescription.page.tsx @@ -1,10 +1,12 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate, useParams } from 'react-router-dom'; -import { useManagedVcdDatacentre } from '@/data/hooks/useManagedVcdDatacentres'; -import { useUpdateVdcDetails } from '@/data/hooks/useUpdateVcdDatacentre'; +import { + useUpdateVdcDetails, + useVcdDatacentre, + VCDDatacentreTargetSpec, +} from '@ovh-ux/manager-module-vcd-api'; import { validateDescription } from '@/utils/formValidation'; -import { IVcdDatacentreState } from '@/types/vcd-datacenter.interface'; import { EditDetailModal } from '@/components/modal/EditDetailModal'; import { useMessageContext } from '@/context/Message.context'; import { subRoutes } from '@/routes/routes.constant'; @@ -15,7 +17,7 @@ export default function EditVdcDescription() { const closeModal = () => navigate('..'); const { addSuccess } = useMessageContext(); const { id, vdcId } = useParams(); - const { data: vcdDatacentre } = useManagedVcdDatacentre(id, vdcId); + const { data: vcdDatacentre } = useVcdDatacentre(id, vdcId); const { updateDetails, error, isError } = useUpdateVdcDetails({ id, vdcId, @@ -29,7 +31,8 @@ export default function EditVdcDescription() { }, }); - const currentVdcDetails: IVcdDatacentreState = vcdDatacentre.data.targetSpec; + const currentVdcDetails: VCDDatacentreTargetSpec = + vcdDatacentre.data.targetSpec; return ( [] = [ + const columns: DatagridColumn[] = [ { id: 'select', cell: StorageOrderSelectCell, diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/storage/DatacentreStorage.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/storage/DatacentreStorage.page.tsx index 98ebbbfebe12..2e83aa24ff15 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/storage/DatacentreStorage.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/datacentre/storage/DatacentreStorage.page.tsx @@ -5,29 +5,31 @@ import { useTranslation } from 'react-i18next'; import { OsdsButton } from '@ovhcloud/ods-components/react'; import { ODS_BUTTON_SIZE, ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; -import IVcdStorage from '@/types/vcd-storage.interface'; +import { + getVcdDatacentreStorageRoute, + getVdcStorageQueryKey, + VCDStorage, +} from '@ovh-ux/manager-module-vcd-api'; import DatagridContainer from '@/components/datagrid/container/DatagridContainer.component'; import { STORAGE_TITLE } from '../DatacentreDashboard.constant'; -import { getVcdDatacentreStorageRoute } from '@/data/api/hpc-vmware-managed-vcd-datacentre'; import { subRoutes, urls } from '@/routes/routes.constant'; -import { getVdcStorageQueryKey } from '@/utils/queryKeys'; import { capitalize } from '@/utils/capitalize'; -const DatagridIdCell = (vcdStorage: IVcdStorage) => ( +const DatagridIdCell = (vcdStorage: VCDStorage) => ( {vcdStorage?.id} ); -const DatagridNameCell = (vcdStorage: IVcdStorage) => ( +const DatagridNameCell = (vcdStorage: VCDStorage) => ( {vcdStorage?.currentState?.name} ); -const DatagridProfileCell = (vcdStorage: IVcdStorage) => ( +const DatagridProfileCell = (vcdStorage: VCDStorage) => ( {vcdStorage?.currentState?.profile} ); -const DatagridTypeCell = (vcdStorage: IVcdStorage) => ( +const DatagridTypeCell = (vcdStorage: VCDStorage) => ( {capitalize(vcdStorage?.currentState?.type)} ); -const DatagridCapacityCell = (vcdStorage: IVcdStorage) => { +const DatagridCapacityCell = (vcdStorage: VCDStorage) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres'); return ( @@ -37,7 +39,7 @@ const DatagridCapacityCell = (vcdStorage: IVcdStorage) => { ); }; -const DatagridBillingCell = (vcdStorage: IVcdStorage) => { +const DatagridBillingCell = (vcdStorage: VCDStorage) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres/compute'); return ( diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/OrganizationDashboard.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/OrganizationDashboard.page.tsx index f0cafe3cb654..735b1c2bc94e 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/OrganizationDashboard.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/OrganizationDashboard.page.tsx @@ -1,16 +1,15 @@ import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate, useParams, useResolvedPath } from 'react-router-dom'; - +import { useVcdOrganization } from '@ovh-ux/manager-module-vcd-api'; import VcdDashboardLayout from '@/components/dashboard/layout/VcdDashboardLayout.component'; -import useManagedVcdOrganization from '@/data/hooks/useManagedVcdOrganization'; import { BreadcrumbItem } from '@/hooks/breadcrumb/useBreadcrumb'; import { urls } from '@/routes/routes.constant'; export default function DashboardPage() { const { id } = useParams(); const { t } = useTranslation('dashboard'); - const { data: vcdOrganisation } = useManagedVcdOrganization({ id }); + const { data: vcdOrganisation } = useVcdOrganization({ id }); const navigate = useNavigate(); const tabsList = [ diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/OrganizationGeneralInformation.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/OrganizationGeneralInformation.page.tsx index 2ba67681d930..cd974cf6439b 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/OrganizationGeneralInformation.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/OrganizationGeneralInformation.page.tsx @@ -1,8 +1,8 @@ import React from 'react'; import { Outlet, useParams } from 'react-router-dom'; +import { useVcdOrganization } from '@ovh-ux/manager-module-vcd-api'; import Errors from '@/components/error/Error.component'; import Loading from '@/components/loading/Loading.component'; -import useManagedVcdOrganization from '@/data/hooks/useManagedVcdOrganization'; import OrganizationGenerationInformationTile from '@/components/tiles/organization-general-information-tile/OrganizationGeneralInformationTile.component'; import OrganizationOptionsTile from '@/components/tiles/organization-options-tile/OrganizationOptionsTile.component'; import OrganizationDataProtectionTile from '@/components/tiles/organization-data-tile/OrganizationDataProtectionTile.component'; @@ -16,9 +16,8 @@ export default function GeneralInformation() { isRefetchError, error, isLoading, - } = useManagedVcdOrganization({ + } = useVcdOrganization({ id, - refetchOnWindowFocus: true, refetchInterval: 60 * 1000, }); diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/edit/EditPassword.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/edit/EditPassword.page.tsx index 5426f12aa3b4..72b314303a72 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/edit/EditPassword.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/dashboard/organization/general-information/edit/EditPassword.page.tsx @@ -5,7 +5,7 @@ import { OsdsModal, OsdsButton } from '@ovhcloud/ods-components/react'; import { Description } from '@ovh-ux/manager-react-components'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; import { ODS_BUTTON_VARIANT } from '@ovhcloud/ods-components'; -import { useResetPassword } from '@/data/hooks/useResetPassword'; +import { useResetVcdPassword } from '@ovh-ux/manager-module-vcd-api'; import { useMessageContext } from '@/context/Message.context'; import { subRoutes } from '@/routes/routes.constant'; @@ -15,7 +15,7 @@ export default function EditPassword() { const closeModal = () => navigate('..'); const { id } = useParams(); const { addSuccess, addError } = useMessageContext(); - const { mutate: resetPassword } = useResetPassword( + const { mutate: resetPassword } = useResetVcdPassword( { id }, { onSettled: () => closeModal(), diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/datacentres/datacentres.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/datacentres/datacentres.page.tsx index fe2f8bb62a9d..6b84017eda4f 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/datacentres/datacentres.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/datacentres/datacentres.page.tsx @@ -2,17 +2,19 @@ import { DataGridTextCell, Links } from '@ovh-ux/manager-react-components'; import React from 'react'; import { useTranslation } from 'react-i18next'; import { useNavigate, useParams } from 'react-router-dom'; +import { + getVcdDatacentresQueryKey, + getVcdDatacentresRoute, + VCDDatacentre, +} from '@ovh-ux/manager-module-vcd-api'; import DatagridContainer, { TDatagridContainerProps, } from '@/components/datagrid/container/DatagridContainer.component'; import { subRoutes, urls } from '@/routes/routes.constant'; -import IVcdDatacentre from '@/types/vcd-datacenter.interface'; -import { getVcdDatacentresRoute } from '@/data/api/hpc-vmware-managed-vcd-datacentre'; -import { getVcdDatacentresQueryKey } from '@/utils/queryKeys'; import { capitalize } from '@/utils/capitalize'; /* ========= datagrid cells ========= */ -const DatagridIdCell = (vcdDatacentre: IVcdDatacentre) => { +const DatagridIdCell = (vcdDatacentre: VCDDatacentre) => { const navigate = useNavigate(); const { id } = useParams(); @@ -32,15 +34,15 @@ const DatagridIdCell = (vcdDatacentre: IVcdDatacentre) => { ); }; -const DatagridDescriptionCell = (vcdDatacentre: IVcdDatacentre) => ( +const DatagridDescriptionCell = (vcdDatacentre: VCDDatacentre) => ( {vcdDatacentre.currentState?.description} ); -const DatagridCpuCountCell = (vcdDatacentre: IVcdDatacentre) => ( +const DatagridCpuCountCell = (vcdDatacentre: VCDDatacentre) => ( {vcdDatacentre.currentState?.vCPUCount} ); -const DatagridCpuSpeedCell = (vcdDatacentre: IVcdDatacentre) => { +const DatagridCpuSpeedCell = (vcdDatacentre: VCDDatacentre) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres'); return ( @@ -52,7 +54,7 @@ const DatagridCpuSpeedCell = (vcdDatacentre: IVcdDatacentre) => { ); }; -const DatagridRamCountCell = (vcdDatacentre: IVcdDatacentre) => { +const DatagridRamCountCell = (vcdDatacentre: VCDDatacentre) => { const { t } = useTranslation('hpc-vmware-managed-vcd/datacentres'); return ( @@ -64,7 +66,7 @@ const DatagridRamCountCell = (vcdDatacentre: IVcdDatacentre) => { ); }; -const DatagridCommercialRange = (vcdDatacentre: IVcdDatacentre) => ( +const DatagridCommercialRange = (vcdDatacentre: VCDDatacentre) => ( {capitalize(vcdDatacentre.currentState?.commercialRange)} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/organizations/Organizations.page.tsx b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/organizations/Organizations.page.tsx index 3c120385cd19..3481535115c3 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/organizations/Organizations.page.tsx +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/pages/listing/organizations/Organizations.page.tsx @@ -9,15 +9,16 @@ import { Region, } from '@ovh-ux/manager-react-components'; import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core'; - +import { + getVcdOrganizationsQueryKey, + VCD_ORGANIZATION_ROUTE, + VCDOrganization, +} from '@ovh-ux/manager-module-vcd-api'; import DatagridContainer from '@/components/datagrid/container/DatagridContainer.component'; import { urls } from '@/routes/routes.constant'; -import IVcdOrganization from '@/types/vcd-organization.interface'; -import { VCD_ORGANIZATION_ROUTE } from '@/data/api/hpc-vmware-managed-vcd.constants'; -import { getVcdOrganizationsQueryKey } from '@/utils/queryKeys'; /* ========= datagrid cells ========== */ -const DatagridIdCell = (vdcOrg: IVcdOrganization) => { +const DatagridIdCell = (vdcOrg: VCDOrganization) => { const navigate = useNavigate(); return ( @@ -29,23 +30,23 @@ const DatagridIdCell = (vdcOrg: IVcdOrganization) => { ); }; -const DatagridLocationCell = (vdcOrg: IVcdOrganization) => ( +const DatagridLocationCell = (vdcOrg: VCDOrganization) => ( ); -const DatagridRegionCell = (vdcOrg: IVcdOrganization) => ( +const DatagridRegionCell = (vdcOrg: VCDOrganization) => ( {vdcOrg.currentState?.region?.toLowerCase()} ); -const DatagridDescriptionCell = (vdcOrg: IVcdOrganization) => ( +const DatagridDescriptionCell = (vdcOrg: VCDOrganization) => ( {vdcOrg.currentState?.description} ); -const DatagridWebInterfaceCell = (vdcOrg: IVcdOrganization) => ( +const DatagridWebInterfaceCell = (vdcOrg: VCDOrganization) => ( = T[keyof T]; - -const pricingCapacity = { - CONSUMPTION: 'consumption', - DETACH: 'detach', - DOWNGRADE: 'downgrade', - DYNAMIC: 'dynamic', - INSTALLATION: 'installation', - RENEW: 'renew', - UPGRADE: 'upgrade', -} as const; - -const productPricingType = { - CONSUMPTION: 'consumption', - PURCHASE: 'purchase', - RENTAL: 'rental', -} as const; - -const catalogProduct = { - CLOUD_SERVICE: 'cloud_service', - DELIVERY: 'delivery', - DEPOSIT: 'deposit', - DOMAIN: 'domain', - IMPLEMENTATION_SERVICES: 'implementation_servies', - SAAS_LICENSE: 'saas_license', - SHIPPING: 'shipping', - STORAGE: 'storage', -} as const; - -export interface IVcdCatalogProductPricing { - capacities: ObjectValues[]; - description: string; - duration: unknown; - interval: number; - minimumQuantity: number; - maximumQuantity: number | null; - minimumRepeat: number; - maximumRepeat: number | null; - price: Price; - priceInUcents: number; - pricingMode: string; - pricingType: ObjectValues; -} - -export interface IVcdCatalogProduct { - family: string; - planCode: string; - productName: string; - productType: ObjectValues; - prices: IVcdCatalogProductPricing[]; - exclusive: boolean; - mandatory: boolean; -} - -export type TVcdCatalog = IVcdCatalogProduct[]; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-compute.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-compute.interface.ts deleted file mode 100644 index d2749a60418a..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-compute.interface.ts +++ /dev/null @@ -1,14 +0,0 @@ -export interface IVcdComputeState { - vCPUCount: number; - billingType: string; - memoryQuota: number; - name: string; - profile: string; -} - -export default interface IVcdCompute { - id: string; - resourceStatus: string; - currentState: IVcdComputeState; - currentTasks?: any[]; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-datacenter.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-datacenter.interface.ts deleted file mode 100644 index f08cd1fdc29c..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-datacenter.interface.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { IamObject } from '@ovh-ux/manager-react-components'; - -export interface IVcdDatacentreState { - vCPUSpeed: number; - description: string; -} - -export interface IVcdDatacentreCurrentState extends IVcdDatacentreState { - commercialRange: string; - ipQuota: number; - storageQuota: number; - vCPUCount: number; - region: string; - memoryQuota: number; - name: string; -} - -export default interface IVcdDatacentre { - id: string; - resourceStatus: string; - currentState: IVcdDatacentreCurrentState; - targetSpec: IVcdDatacentreState; - currentTasks?: any[]; - iam: IamObject; - updatedAt: string; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization-backup.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization-backup.interface.ts deleted file mode 100644 index 4da774b4f2af..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization-backup.interface.ts +++ /dev/null @@ -1,48 +0,0 @@ -import { IamObject } from '@ovh-ux/manager-react-components/src/hooks/iam'; - -export enum BackupResourceStatus { - CREATING = 'CREATING', - DISABLED = 'DISABLED', - DISABLING = 'DISABLING', - READY = 'READY', - REMOVED = 'REMOVED', - UPDATING = 'UPDATING', -} - -interface IBackupOffer { - name: string; - quotaInTB: number; - status: string; - usedSpaceInGB: number; -} - -interface IVcdOrganizationBackupState { - offers: IBackupOffer[]; - region: string; -} - -interface IVcdOrganizationBackupSpecs { - offers: { - name: string; - quotaInTB: number; - status: string; - }[]; -} - -interface IVcdOrganizationBackupTask { - id: string; - link: string; - status: string | null; - type: string; -} - -export default interface IVcdOrganizationBackup { - id: string; - resourceStatus: BackupResourceStatus; - currentState: IVcdOrganizationBackupState; - targetSpec: IVcdOrganizationBackupSpecs; - currentTasks?: IVcdOrganizationBackupTask[]; - createdAt?: string; - updatedAt?: string; - iam: IamObject; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization.interface.ts deleted file mode 100644 index 0d470beaf099..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-organization.interface.ts +++ /dev/null @@ -1,25 +0,0 @@ -import { IamObject } from '@ovh-ux/manager-react-components'; - -export interface IVcdOrganizationState { - fullName: string; - description: string; -} - -export interface IVcdOrganizationCurrentState extends IVcdOrganizationState { - apiUrl?: string; - region: string; - name: string; - spla: boolean; - billingType: 'DEMO' | 'MONTHLY'; - webInterfaceUrl: string; -} - -export default interface IVcdOrganization { - id: string; - resourceStatus: string; - currentState: IVcdOrganizationCurrentState; - targetSpec: IVcdOrganizationState; - currentTasks?: any[]; - iam: IamObject; - updatedAt: string; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-storage.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-storage.interface.ts deleted file mode 100644 index 60bd8f4b5727..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-storage.interface.ts +++ /dev/null @@ -1,21 +0,0 @@ -export interface IVcdStorageState { - billingType: string; - capacity: number; - name: string; - profile: string; - type: string; -} - -interface IVcdStorageTask { - id: string; - link: string; - status: string; - type: string; -} - -export default interface IVcdStorage { - id: string; - resourceStatus: string; - currentState: IVcdStorageState; - currentTasks?: IVcdStorageTask[]; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-vdc-orderable-resource.interface.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-vdc-orderable-resource.interface.ts deleted file mode 100644 index 511a74134db3..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/types/vcd-vdc-orderable-resource.interface.ts +++ /dev/null @@ -1,26 +0,0 @@ -import { IVcdCatalogProductPricing } from './vcd-catalog.interface'; -import { IVcdComputeState } from './vcd-compute.interface'; -import { IVcdStorageState } from './vcd-storage.interface'; - -export interface IVdcOrderableVHost - extends Omit { - vCPUSpeed: number; -} -export interface IVdcOrderableVhostPriced extends IVdcOrderableVHost { - pricing: IVcdCatalogProductPricing; -} - -export type IVdcOrderableStorage = Omit; -export interface IVdcOrderableStoragePriced extends IVdcOrderableStorage { - pricing: IVcdCatalogProductPricing; -} - -export type IVdcOrderableResource = IVdcOrderableVHost | IVdcOrderableStorage; -export type IVdcOrderableResourcePriced = - | IVdcOrderableVhostPriced - | IVdcOrderableStoragePriced; - -export interface IVdcOrderableResourceData { - compute: IVdcOrderableVHost[]; - storage: IVdcOrderableStorage[]; -} diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/getPricedOrderableResource.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/getPricedOrderableResource.ts index f2c35bd7b6fd..73eb5ea92998 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/getPricedOrderableResource.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/getPricedOrderableResource.ts @@ -1,28 +1,28 @@ import { - IVdcOrderableResource, - IVdcOrderableResourcePriced, -} from '@/types/vcd-vdc-orderable-resource.interface'; -import { TVcdCatalog } from '@/types/vcd-catalog.interface'; + VCDCatalog, + VCDOrderableResource, + VCDOrderableResourcePriced, +} from '@ovh-ux/manager-module-vcd-api'; -export const getVdcResourcePrice = (resource: IVdcOrderableResourcePriced) => +export const getVdcResourcePrice = (resource: VCDOrderableResourcePriced) => resource.pricing?.priceInUcents; export const getVdcResourcePriceLabel = ( - resource: IVdcOrderableResourcePriced, + resource: VCDOrderableResourcePriced, ) => resource.pricing.price.text; export const getPricedVdcResources = ({ resources, catalog, }: { - resources: IVdcOrderableResource[]; - catalog: TVcdCatalog; -}): IVdcOrderableResourcePriced[] => { + resources: VCDOrderableResource[]; + catalog: VCDCatalog; +}): VCDOrderableResourcePriced[] => { if (!resources || !catalog) { return []; } return resources - .reduce((list: IVdcOrderableResourcePriced[], resource) => { + .reduce((list: VCDOrderableResourcePriced[], resource) => { const prices = catalog.find( ({ planCode }) => planCode === resource.profile, )?.prices; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/queryKeys.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/queryKeys.ts deleted file mode 100644 index 4386c620355c..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/queryKeys.ts +++ /dev/null @@ -1,60 +0,0 @@ -const vcdBaseKey = 'vmwareCloudDirector'; -const vdcBaseKey = 'virtualDataCenter'; -export const icebergListingQueryKey = 'servicesListingIceberg'; - -// VCD organizations -export const getVcdOrganizationsQueryKey = () => [vcdBaseKey, 'organizations']; -export const getVcdOrganizationQueryKey = (id: string) => [ - ...getVcdOrganizationsQueryKey(), - id, -]; -export const getVcdOrganizationBackupQueryKey = (id: string) => [ - ...getVcdOrganizationQueryKey(id), - 'backup', -]; -export const getVcdOrganizationResetPasswordQueryKey = (id: string) => [ - ...getVcdOrganizationQueryKey(id), - 'resetPassword', -]; -export const getVcdCatalogQueryKey = (serviceName: string) => [ - 'order', - 'cartServiceOption', - vcdBaseKey, - serviceName, -]; - -// VCD Organization virtualDataCenters -export const getVcdDatacentresQueryKey = (id: string) => [ - ...getVcdOrganizationQueryKey(id), - vdcBaseKey, -]; -export const getVcdDatacentreQueryKey = (id: string, vdcId: string) => [ - ...getVcdDatacentresQueryKey(id), - vdcId, -]; - -// VirtualDataCenter resources -const getVdcQueryKey = (vdcId: string) => [vdcBaseKey, vdcId]; - -export const getVdcComputeQueryKey = (vdcId: string) => [ - ...getVdcQueryKey(vdcId), - 'compute', -]; -export const getVdcStorageQueryKey = (vdcId: string) => [ - ...getVdcQueryKey(vdcId), - 'storage', -]; -export const getVdcOrderableResourceQueryKey = (vdcId: string) => [ - ...getVdcQueryKey(vdcId), - 'orderableResource', -]; - -// Mutation keys -export const updateVcdOrganizationDetailsMutationKey = (id: string) => [ - 'put', - ...getVcdOrganizationQueryKey(id), -]; -export const updateVdcDetailsMutationKey = (vdcId: string) => [ - 'put', - ...getVdcQueryKey(vdcId), -]; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/refetchConditions.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/refetchConditions.ts index a6accb3020c7..08d1b4372f9d 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/refetchConditions.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/refetchConditions.ts @@ -1,7 +1,6 @@ -import IVcdDatacentre from '@/types/vcd-datacenter.interface'; -import IVcdOrganization from '@/types/vcd-organization.interface'; +import { VCDDatacentre, VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; -export type UpdatableResource = IVcdOrganization | IVcdDatacentre; +export type UpdatableResource = VCDOrganization | VCDDatacentre; const targetSpecKey = 'configure-target-spec'; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupBadge.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupBadge.ts index 4d0e03eca207..1dcd337ff1d5 100644 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupBadge.ts +++ b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupBadge.ts @@ -1,7 +1,7 @@ +import { ResourceStatus } from '@ovh-ux/manager-module-vcd-api'; import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming'; -import { BackupResourceStatus } from '@/types/vcd-organization-backup.interface'; -type BadgeStatus = BackupResourceStatus | 'none' | 'error'; +type BadgeStatus = ResourceStatus | 'none' | 'error'; export type BackupBadgeParams = { color: ODS_THEME_COLOR_INTENT; translationKey: string; @@ -58,7 +58,7 @@ export const getBackupBadgeStatus = ({ backupStatus, }: { errorStatus: number; - backupStatus: BackupResourceStatus; + backupStatus: ResourceStatus; }): BadgeStatus => { if (backupStatus) return backupStatus; return errorStatus === 404 ? 'none' : 'error'; diff --git a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupId.ts b/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupId.ts deleted file mode 100644 index 9de7359dd19f..000000000000 --- a/packages/manager/apps/hpc-vmware-managed-vcd/src/utils/veeamBackupId.ts +++ /dev/null @@ -1,9 +0,0 @@ -import IVcdOrganization from '@/types/vcd-organization.interface'; - -const getOrganizationUuid = (organization: IVcdOrganization) => - organization.id.split( - `${organization.currentState.region.toLowerCase()}-`, - )[1]; - -export const getBackupIdFromOrganization = (organization: IVcdOrganization) => - `${getOrganizationUuid(organization)}-veeam-backup`; diff --git a/packages/manager/apps/veeam-backup/mocks/vcd-organization.mock.ts b/packages/manager/apps/veeam-backup/mocks/vcd-organization.mock.ts index 408d930d0b23..b91d70935dd4 100644 --- a/packages/manager/apps/veeam-backup/mocks/vcd-organization.mock.ts +++ b/packages/manager/apps/veeam-backup/mocks/vcd-organization.mock.ts @@ -1,6 +1,6 @@ -import { VCDOrganizationWithIam } from '@/data'; +import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api'; -export const organizationList: VCDOrganizationWithIam[] = [ +export const organizationList: VCDOrganization[] = [ { currentState: { apiUrl: 'https://vcd.my.company', diff --git a/packages/manager/modules/vcd-api/src/hook/useUpdateVcdDatacentre.ts b/packages/manager/modules/vcd-api/src/hook/useUpdateVcdDatacentre.ts index 75b040e27719..c4234f1a95ed 100644 --- a/packages/manager/modules/vcd-api/src/hook/useUpdateVcdDatacentre.ts +++ b/packages/manager/modules/vcd-api/src/hook/useUpdateVcdDatacentre.ts @@ -1,25 +1,36 @@ -import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; -import { keepPreviousData, useQuery } from '@tanstack/react-query'; -import { VCDDatacentre } from '../types'; -import { getVcdDatacentreQueryKey, getVcdDatacentresQueryKey } from '../utils'; -import { getVcdDatacentre, getVcdDatacentres } from '../api'; +import { ApiError } from '@ovh-ux/manager-core-api'; +import { useQueryClient, useMutation } from '@tanstack/react-query'; +import { updateVdcDetails, UpdateVdcDetailsParams } from '../api'; +import { + getVcdDatacentresQueryKey, + updateVdcDetailsMutationKey, +} from '../utils'; -const useManagedVcdDatacentres = (id: string) => { - return useQuery, ApiError>({ - queryKey: getVcdDatacentresQueryKey(id), - queryFn: () => getVcdDatacentres(id), - retry: false, - placeholderData: keepPreviousData, - }); -}; +export const useUpdateVdcDetails = ({ + id, + vdcId, + onSuccess, + onError, +}: { + id: string; + vdcId: string; + onSuccess?: () => void; + onError?: (result: ApiError) => void; +}) => { + const queryClient = useQueryClient(); -export const useManagedVcdDatacentre = (id: string, vdcId: string) => { - return useQuery, ApiError>({ - queryKey: getVcdDatacentreQueryKey(id, vdcId), - queryFn: () => getVcdDatacentre(id, vdcId), - retry: false, - placeholderData: keepPreviousData, + const { mutateAsync: updateDetails, error, isError } = useMutation({ + mutationKey: updateVdcDetailsMutationKey(vdcId), + mutationFn: ({ details }: UpdateVdcDetailsParams) => + updateVdcDetails({ id, vdcId, details }), + onSuccess: () => { + queryClient.invalidateQueries({ + queryKey: getVcdDatacentresQueryKey(id), + }); + onSuccess?.(); + }, + onError: (result: ApiError) => onError?.(result), }); -}; -export default useManagedVcdDatacentres; + return { updateDetails, error, isError }; +}; diff --git a/packages/manager/modules/vcd-api/src/hook/useVcdOrder.ts b/packages/manager/modules/vcd-api/src/hook/useVcdOrder.ts index 4b8d221b8409..410da249a539 100644 --- a/packages/manager/modules/vcd-api/src/hook/useVcdOrder.ts +++ b/packages/manager/modules/vcd-api/src/hook/useVcdOrder.ts @@ -4,7 +4,7 @@ import { } from '@ovh-ux/manager-module-order'; import { VCDOrder } from '../types'; -const useVcdOrder = ({ +export const useVcdOrder = ({ serviceName, planCode, quantity, @@ -24,5 +24,3 @@ const useVcdOrder = ({ return { orderLink, redirectToOrder }; }; - -export default useVcdOrder; diff --git a/packages/manager/modules/vcd-api/src/hook/useVcdOrganization.ts b/packages/manager/modules/vcd-api/src/hook/useVcdOrganization.ts index c22eb5b996ce..ea17aaef713b 100644 --- a/packages/manager/modules/vcd-api/src/hook/useVcdOrganization.ts +++ b/packages/manager/modules/vcd-api/src/hook/useVcdOrganization.ts @@ -1,4 +1,9 @@ -import { useQuery, useQueries } from '@tanstack/react-query'; +import { + useQuery, + useQueries, + UseQueryOptions, + keepPreviousData, +} from '@tanstack/react-query'; import { ApiError, ApiResponse } from '@ovh-ux/manager-core-api'; import { useResourcesIcebergV2 } from '@ovh-ux/manager-react-components'; import { getVcdOrganization, getVmwareCloudDirectorBackup } from '../api'; @@ -7,9 +12,18 @@ import { BackupStatus, VCDOrganization, VCDOrganizationWithBackupStatus, + VeeamBackup, VeeamBackupWithIam, } from '../types'; import { VCD_ORGANIZATION_ROUTE } from '../utils/apiRoutes'; +import { + getVcdOrganizationBackupQueryKey, + getVcdOrganizationQueryKey, +} from '../utils'; + +type UseVcdOrganization = Pick & { + id: string; +}; const backupSuffix = '-veeam-backup'; @@ -95,3 +109,28 @@ export const useOrganization = (organizationId: string) => queryKey: [VCD_ORGANIZATION_ROUTE, organizationId], queryFn: () => getVcdOrganization(organizationId), }); + +export const useVcdOrganization = ({ + id, + refetchInterval, +}: UseVcdOrganization) => { + return useQuery, ApiError>({ + queryKey: getVcdOrganizationQueryKey(id), + queryFn: () => getVcdOrganization(id), + retry: false, + refetchInterval, + placeholderData: keepPreviousData, + }); +}; + +export const useVcdOrganizationBackup = (vcdOrganization: VCDOrganization) => { + return useQuery, ApiError>({ + queryKey: getVcdOrganizationBackupQueryKey(vcdOrganization.id), + queryFn: () => + getVmwareCloudDirectorBackup( + getBackupIdFromOrganization(vcdOrganization), + ), + retry: false, + placeholderData: keepPreviousData, + }); +}; diff --git a/packages/manager/modules/vcd-api/src/mocks/vcd-datacentre/vcd-datacentre.mock.ts b/packages/manager/modules/vcd-api/src/mocks/vcd-datacentre/vcd-datacentre.mock.ts index eb35390b4ec1..44be4f657713 100644 --- a/packages/manager/modules/vcd-api/src/mocks/vcd-datacentre/vcd-datacentre.mock.ts +++ b/packages/manager/modules/vcd-api/src/mocks/vcd-datacentre/vcd-datacentre.mock.ts @@ -1,6 +1,6 @@ -import { VCDDatacentreWithIam } from '../../types'; +import { VCDDatacentre } from '../../types'; -export const datacentreList: VCDDatacentreWithIam[] = [ +export const datacentreList: VCDDatacentre[] = [ { id: 'vdc-eu-central-waw-adc311b5-0c0b-4071-b48f-b20813868bcf', resourceStatus: 'READY', diff --git a/packages/manager/modules/vcd-api/src/mocks/vcd-organization/vcd-organization.mock.ts b/packages/manager/modules/vcd-api/src/mocks/vcd-organization/vcd-organization.mock.ts index c46f3f9955fb..342e63a59d5e 100644 --- a/packages/manager/modules/vcd-api/src/mocks/vcd-organization/vcd-organization.mock.ts +++ b/packages/manager/modules/vcd-api/src/mocks/vcd-organization/vcd-organization.mock.ts @@ -1,6 +1,6 @@ -import { VCDOrganizationWithIam } from '../../types'; +import { VCDOrganization } from '../../types'; -export const organizationList: VCDOrganizationWithIam[] = [ +export const organizationList: VCDOrganization[] = [ { currentState: { apiUrl: 'https://vcd.my.company', diff --git a/packages/manager/modules/vcd-api/src/types/vcd-datacentre.type.ts b/packages/manager/modules/vcd-api/src/types/vcd-datacentre.type.ts index da898cac131e..8e837f97de30 100644 --- a/packages/manager/modules/vcd-api/src/types/vcd-datacentre.type.ts +++ b/packages/manager/modules/vcd-api/src/types/vcd-datacentre.type.ts @@ -1,4 +1,4 @@ -import { ResourceStatus, Task, WithIam } from './vcd-utility.type'; +import { ResourceStatus, Task, WithIam, WithoutIam } from './vcd-utility.type'; export type VCDDatacentreTargetSpec = { vCPUSpeed: number; @@ -15,13 +15,13 @@ export type VCDDatacentreState = VCDDatacentreTargetSpec & { name: string; }; -export type VCDDatacentre = { +export type VCDDatacentre = WithIam<{ id: string; resourceStatus: ResourceStatus; currentState: VCDDatacentreState; targetSpec: VCDDatacentreTargetSpec; currentTasks?: Task[]; updatedAt: string; -}; +}>; -export type VCDDatacentreWithIam = WithIam; +export type VCDDatacentreWithoutIam = WithoutIam; diff --git a/packages/manager/modules/vcd-api/src/types/vcd-organization.type.ts b/packages/manager/modules/vcd-api/src/types/vcd-organization.type.ts index 9a8c364d507c..afcd3e5f7ab3 100644 --- a/packages/manager/modules/vcd-api/src/types/vcd-organization.type.ts +++ b/packages/manager/modules/vcd-api/src/types/vcd-organization.type.ts @@ -1,5 +1,11 @@ -import { BillingType, ResourceStatus, Task, WithIam } from './vcd-utility.type'; -import { BackupStatus } from './vcd-backup.type'; +import { + BillingType, + ResourceStatus, + Task, + WithIam, + WithoutIam, +} from './vcd-utility.type'; +import { BackupStatus, VeeamBackupOffer } from './vcd-backup.type'; export type VCDRegion = | 'AP-SOUTH-MUM' @@ -30,17 +36,32 @@ export type VCDOrganizationState = VCDOrganizationTargetSpec & { webInterfaceUrl: string; }; -export type VCDOrganization = { +export type VCDOrganization = WithIam<{ id: string; resourceStatus: ResourceStatus; currentState: VCDOrganizationState; targetSpec: VCDOrganizationTargetSpec; currentTasks?: Task[]; updatedAt: string; -}; +}>; export type VCDOrganizationWithBackupStatus = VCDOrganization & { backupStatus?: BackupStatus; }; -export type VCDOrganizationWithIam = WithIam; +export type VCDOrganizationWithoutIam = WithoutIam; + +export type VCDOrganizationBackup = WithIam<{ + id: string; + resourceStatus: ResourceStatus; + currentState: { + offers: VeeamBackupOffer[]; + region: string; + }; + targetSpec: { + offers: Omit[]; + }; + currentTasks?: Task[]; + createdAt?: string; + updatedAt?: string; +}>; diff --git a/packages/manager/modules/vcd-api/src/types/vcd-utility.type.ts b/packages/manager/modules/vcd-api/src/types/vcd-utility.type.ts index 6c159b94de09..07a0e0078344 100644 --- a/packages/manager/modules/vcd-api/src/types/vcd-utility.type.ts +++ b/packages/manager/modules/vcd-api/src/types/vcd-utility.type.ts @@ -3,6 +3,7 @@ import { IamObject } from '@ovh-ux/manager-react-components'; export type ObjectValues = T[keyof T]; export type WithIam = T & { iam: IamObject }; +export type WithoutIam = Omit; export type BillingType = 'MONTHLY' | 'DEMO';