Skip to content

Commit

Permalink
feat(*): move vcd api to module
Browse files Browse the repository at this point in the history
ref: MANAGER-15700

Signed-off-by: Nicolas Pierre-charles <[email protected]>
Signed-off-by: Paul Dickerson <[email protected]>
  • Loading branch information
Nicolas Pierre-charles committed Nov 13, 2024
1 parent e44af86 commit dfb4658
Show file tree
Hide file tree
Showing 49 changed files with 379 additions and 55 deletions.
1 change: 1 addition & 0 deletions .github/workflows/run-bdd-tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ jobs:
yarn exec turbo -- run build --filter="./packages/manager/core/*" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/manager-components/*" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/modules/order" --concurrency=5
yarn exec turbo -- run build --filter="./packages/manager/modules/vcd-api" --concurrency=5
# This task is for running the jest tests outside microApps
- name: Run tests Jest
run: yarn test:jest
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/veeam-backup/mocks/catalog.mock.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { order } from '../src/data';
import { order } from '@ovh-ux/manager-module-vcd-api';

export const veeamBackupCatalog = ({
catalogId: 7700,
Expand Down
2 changes: 1 addition & 1 deletion packages/manager/apps/veeam-backup/mocks/iam.mock.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { IamCheckResponse } from '@ovh-ux/manager-react-components';
import { backupList } from './veeam-backup.mock';
import { backupList } from '@ovh-ux/manager-module-vcd-api';
import { iamActions } from '../src/veeam-backup.config';

export const iamResponse: IamCheckResponse[] = [
Expand Down
2 changes: 0 additions & 2 deletions packages/manager/apps/veeam-backup/mocks/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
export * from './vcd-organization.handler';
export * from './veeam-backup.handler';
export * from './iam.handler';
export * from './catalog.handler';
7 changes: 4 additions & 3 deletions packages/manager/apps/veeam-backup/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
"@ovh-ux/manager-config": "^7.5.2",
"@ovh-ux/manager-core-api": "^0.8.2",
"@ovh-ux/manager-core-utils": "*",
"@ovh-ux/manager-module-order": "^0.6.3",
"@ovh-ux/manager-module-vcd-api": "^0.1.0",
"@ovh-ux/manager-react-components": "^1.40.0",
"@ovh-ux/manager-react-shell-client": "^0.7.7",
"@ovh-ux/manager-module-order": "^0.6.3",
"@ovh-ux/manager-tailwind-config": "*",
"@ovh-ux/request-tagger": "^0.3.2",
"@ovhcloud/ods-common-core": "17.2.2",
Expand All @@ -54,12 +55,12 @@
"@testing-library/react": "^16.0.1",
"@testing-library/user-event": "^14.5.2",
"@vitejs/plugin-react": "^4.3.0",
"@vitest/coverage-v8": "^1.6.0",
"@vitest/coverage-v8": "^2.1.4",
"element-internals-polyfill": "^1.3.11",
"msw": "2.1.7",
"typescript": "^4.3.2",
"vite": "^5.2.13",
"vitest": "^1.2.0"
"vitest": "^2.1.4"
},
"regions": [
"CA",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@ import { useTranslation } from 'react-i18next';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { OsdsChip } from '@ovhcloud/ods-components/react';
import { ODS_CHIP_SIZE } from '@ovhcloud/ods-components';
import { ResourceStatus, VeeamBackupWithIam } from '@/data';
import {
ResourceStatus,
VeeamBackupWithIam,
} from '@ovh-ux/manager-module-vcd-api';

export type BackupStatusBadgeProps = {
resourceStatus: ResourceStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,12 @@ import {
OdsBreadcrumbAttributeItem,
} from '@ovhcloud/ods-components';
import { ShellContext } from '@ovh-ux/manager-react-shell-client';
import {
getVeeamBackupDisplayName,
useVeeamBackup,
} from '@ovh-ux/manager-module-vcd-api';
import { urls } from '@/routes/routes.constant';
import { appName, productName } from '@/veeam-backup.config';
import { getVeeamBackupDisplayName, useVeeamBackup } from '@/data';

export type BreadcrumbItem = {
label: string | undefined;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ import {
import { OdsHTMLAnchorElementTarget } from '@ovhcloud/ods-common-core';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { useQueryClient } from '@tanstack/react-query';
import {
VeeamBackupWithIam,
veeamBackupListQueryKey,
} from '@ovh-ux/manager-module-vcd-api';
import { MessageData, MessagesContext } from './Messages.context';
import { VeeamBackupWithIam, veeamBackupListQueryKey } from '@/data';

export const SuccessMessage: React.FC<Partial<MessageData>> = ({
id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { useTranslation } from 'react-i18next';
import { OsdsMessage } from '@ovhcloud/ods-components/react';
import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { VCDOrganization } from '@/data';
import { VCDOrganization } from '@ovh-ux/manager-module-vcd-api';
import { VCDOrgInfoLink } from '../Links/VCDOrgInfoLink.component';

export type NoOrganizationMessageProps = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@ import {
Region,
} from '@ovh-ux/manager-react-components';
import { ODS_MESSAGE_TYPE, ODS_TEXT_SIZE } from '@ovhcloud/ods-components';
import { Breadcrumb } from '@/components/Breadcrumb/Breadcrumb';
import {
getRegionNameFromAzName,
getVeeamBackupDisplayName,
useVeeamBackup,
} from '@/data';
} from '@ovh-ux/manager-module-vcd-api';
import { Breadcrumb } from '@/components/Breadcrumb/Breadcrumb';
import { urls } from '@/routes/routes.constant';
import { SuccessMessages } from '@/components/Messages/SuccessMessage.component';
import { OrganizationCell } from '../listing/DatagridCell.component';
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import React from 'react';
import { OsdsButton, OsdsIcon } from '@ovhcloud/ods-components/react';
import { useNavigate } from 'react-router-dom';
import { Description, ManagerButton } from '@ovh-ux/manager-react-components';
import { Description } from '@ovh-ux/manager-react-components';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import {
ODS_ICON_NAME,
Expand All @@ -10,7 +10,10 @@ import {
ODS_BUTTON_VARIANT,
ODS_BUTTON_TYPE,
} from '@ovhcloud/ods-components';
import { VeeamBackupWithIam, getVeeamBackupDisplayName } from '@/data';
import {
VeeamBackupWithIam,
getVeeamBackupDisplayName,
} from '@ovh-ux/manager-module-vcd-api';
import { urls } from '@/routes/routes.constant';

export const DisplayNameWithEditButton = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
ODS_TEXT_LEVEL,
} from '@ovhcloud/ods-components';
import { useTranslation } from 'react-i18next';
import { VeeamBackupOffer } from '@/data';
import { VeeamBackupOffer } from '@ovh-ux/manager-module-vcd-api';

export const OfferProgress: React.FC<VeeamBackupOffer> = ({
name,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import {
useFormattedDate,
DateFormat,
} from '@ovh-ux/manager-react-components';
import { VeeamBackupWithIam } from '@/data';
import { VeeamBackupWithIam } from '@ovh-ux/manager-module-vcd-api';
import { urls } from '@/routes/routes.constant';
import { LoadingChip } from '@/components/Loading/Loading';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {
getButtonByIcon,
getButtonByLabel,
} from '@/test-helpers';
import { backupList } from '@/../mocks/veeam-backup.mock';
import { backupList } from '@ovh-ux/manager-module-vcd-api';

Check failure on line 11 in packages/manager/apps/veeam-backup/src/pages/dashboard/dashboard.spec.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

`@ovh-ux/manager-module-vcd-api` import should occur before import of `@/test-helpers`
import '@testing-library/jest-dom';
import { urls } from '@/routes/routes.constant';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,11 @@ import {
useOvhTracking,
} from '@ovh-ux/manager-react-shell-client';
import { DeleteServiceModal } from '@ovh-ux/manager-react-components';
import {
getVeeamBackupDisplayName,
useVeeamBackup,
} from '@ovh-ux/manager-module-vcd-api';
import { MessagesContext } from '@/components/Messages/Messages.context';
import { getVeeamBackupDisplayName, useVeeamBackup } from '@/data';
import { PageName } from '@/tracking.constant';

export const sharedTrackingParams: TrackingClickParams = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
changeInputValue,
getButtonByLabel,
} from '@/test-helpers';
import { backupList } from '@/../mocks/veeam-backup.mock';
import { backupList } from '@ovh-ux/manager-module-vcd-api';

Check failure on line 10 in packages/manager/apps/veeam-backup/src/pages/delete-veeam/delete-veeam.spec.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

`@ovh-ux/manager-module-vcd-api` import should occur before import of `@/test-helpers`
import { urls } from '@/routes/routes.constant';
import '@testing-library/jest-dom';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
veeamBackupListQueryKey,
veeamBackupQueryKey,
useVeeamBackup,
} from '@/data';
} from '@ovh-ux/manager-module-vcd-api';
import { PageName } from '@/tracking.constant';
import { MessagesContext } from '@/components/Messages/Messages.context';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {
changeInputValue,
getButtonByIcon,
} from '@/test-helpers';
import { backupList } from '@/../mocks/veeam-backup.mock';
import { backupList } from '@ovh-ux/manager-module-vcd-api';

Check failure on line 12 in packages/manager/apps/veeam-backup/src/pages/edit-name/edit-name.spec.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

`@ovh-ux/manager-module-vcd-api` import should occur before import of `@/test-helpers`
import { urls } from '@/routes/routes.constant';
import '@testing-library/jest-dom';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,5 @@
import React from 'react';
import {
OsdsChip,
OsdsLink,
OsdsSkeleton,
} from '@ovhcloud/ods-components/react';
import { OsdsLink, OsdsSkeleton } from '@ovhcloud/ods-components/react';
import { useNavigate } from 'react-router-dom';
import {
ActionMenu,
Expand All @@ -23,10 +19,9 @@ import {
getOrganizationDisplayName,
getOrganizationIdFromBackup,
useOrganization,
ResourceStatus,
getVeeamBackupDisplayName,
getRegionNameFromAzName,
} from '@/data';
} from '@ovh-ux/manager-module-vcd-api';
import { vcdOrganizationAppName } from '@/veeam-backup.config';
import { urls } from '@/routes/routes.constant';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,14 @@ import {
DatagridColumn,
RedirectionGuard,
} from '@ovh-ux/manager-react-components';
import {
VeeamBackupWithIam,
useVeeamBackupList,
} from '@ovh-ux/manager-module-vcd-api';
import ErrorBanner from '@/components/Error/Error';
import { Breadcrumb } from '@/components/Breadcrumb/Breadcrumb';
import { urls } from '@/routes/routes.constant';
import { SuccessMessages } from '@/components/Messages/SuccessMessage.component';
import { VeeamBackupWithIam, useVeeamBackupList } from '@/data';
import {
DisplayNameCell,
ActionCell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,12 @@ import { useNavigate } from 'react-router-dom';
import { OsdsMessage } from '@ovhcloud/ods-components/react';
import { ODS_MESSAGE_TYPE } from '@ovhcloud/ods-components';
import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import { useOrganizationList } from '@ovh-ux/manager-module-vcd-api';
import { useGuideUtils } from './useGuideUtils';
import onboardingImgSrc from '@/assets/veeamxOVHcloud.svg';
import { urls } from '@/routes/routes.constant';
import { useBillingUrl } from '@/components/Links/BillingLink.component';
import { productFullName } from '@/veeam-backup.config';
import { useOrganizationList } from '@/data';
import { NoOrganizationMessage } from '@/components/NoOrganizationMessage/NoOrganizationMessage.component';
import { Loading } from '@/components/Loading/Loading';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import { BillingLink } from '@/components/Links/BillingLink.component';
import { Breadcrumb } from '@/components/Breadcrumb/Breadcrumb';
import { OrderVeeamStep2 } from './OrderVeeamStep2.component';
import { productName } from '@/veeam-backup.config';
import { useVeeamBackupVmConsumptionPricing } from '@/data';
import { useVeeamBackupVmConsumptionPricing } from '@ovh-ux/manager-module-vcd-api';

Check failure on line 36 in packages/manager/apps/veeam-backup/src/pages/order-veeam/OrderVeeam.page.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

`@ovh-ux/manager-module-vcd-api` import should occur before import of `@/components/Links/BillingLink.component`
import { Loading } from '@/components/Loading/Loading';

export default function OrderVeeamPage() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,15 @@ import {
getVeeamBackupProductSettings,
useOrderURL,
} from '@ovh-ux/manager-module-order';
import { urls } from '@/routes/routes.constant';
import {
BackupStatus,
VCDOrganization,
VCDOrganizationWithBackupStatus,
getAvailabilityZone,
getOrganizationUuid,
useOrganizationWithBackupStatusList,
} from '@/data';
} from '@ovh-ux/manager-module-vcd-api';
import { urls } from '@/routes/routes.constant';
import { Loading } from '@/components/Loading/Loading';
import {
BackupStatusCell,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { ODS_THEME_COLOR_INTENT } from '@ovhcloud/ods-common-theming';
import {
VCDOrganizationWithBackupStatus,
getOrganizationDisplayName,
} from '@/data';
} from '@ovh-ux/manager-module-vcd-api';

const colorByStatus = {
active: ODS_THEME_COLOR_INTENT.success,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,14 +15,16 @@ import {
import { toMswHandlers } from '../../../../../../playwright-helpers';
import { getAuthenticationMocks } from '../../../../../../playwright-helpers/mocks/auth';
import {
getVeeamBackupMocks,
getOrganizationMocks,
GetOrganizationMocksParams,
GetVeeamBackupMocksParams,
getIamMocks,
getCatalogMocks,
GetCatalogMocksParams,
} from '../../mocks';
import {

Check failure on line 22 in packages/manager/apps/veeam-backup/src/test-helpers/render-test.tsx

View workflow job for this annotation

GitHub Actions / Lint Code Base

`@ovh-ux/manager-module-vcd-api` import should occur before import of `../../../../../../playwright-helpers`
getVeeamBackupMocks,
getOrganizationMocks,
GetOrganizationMocksParams,
GetVeeamBackupMocksParams,
} from '@ovh-ux/manager-module-vcd-api';
import { productName } from '../veeam-backup.config';
import { initTestI18n } from './test-i18n';
import { TestApp } from './TestApp';
Expand Down
1 change: 1 addition & 0 deletions packages/manager/modules/vcd-api/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
coverage
Empty file.
43 changes: 43 additions & 0 deletions packages/manager/modules/vcd-api/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
{
"name": "@ovh-ux/manager-module-vcd-api",
"version": "0.1.0",
"private": true,
"description": "OVHcloud manager module VCD API.",
"repository": {
"type": "git",
"url": "git+https://github.com/ovh/manager.git",
"directory": "packages/manager/modules/vcd-api"
},
"license": "BSD-3-Clause",
"author": "OVH SAS",
"sideEffects": false,
"main": "./dist/index.js",
"module": "./dist/index.js",
"types": "./dist/types/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "tsc",
"dev": "tsc",
"start:watch": "tsc -w",
"test": "vitest run",
"test:coverage": "vitest run --coverage"
},
"dependencies": {
"@ovh-ux/manager-core-api": "^0.9.0-alpha.0",
"@ovh-ux/manager-react-components": "^1.41.0-alpha.4"
},
"devDependencies": {
"@vitejs/plugin-react": "^4.3.3",
"@vitest/coverage-v8": "^2.1.4",
"msw": "2.1.7",
"typescript": "^5.1.6",
"vite": "^5.2.13",
"vitest": "^2.1.4"
},
"peerDependencies": {
"@tanstack/react-query": "5.x",
"react": "18.x"
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { backupList } from '../../../mocks/veeam-backup.mock';
import { backupList } from '../mocks/backup/veeam-backup.mock';
import {
getAvailabilityZone,
getBackupIdFromOrganization,
getOrganizationDisplayName,
getOrganizationIdFromBackup,
getOrganizationUuid,
} from './useOrganizations';
import { organizationList } from '../../../mocks/vcd-organization.mock';
import { organizationList } from '../mocks/organization/vcd-organization.mock';

describe('Managed VCD API utils', () => {
it('getAvailabilityZone returns the azName from the region', () => {
Expand Down Expand Up @@ -43,7 +43,7 @@ describe('Managed VCD API utils', () => {
...organizationList[0],
currentState: {
...organizationList[0].currentState,
fullName: null as string,
fullName: (null as unknown) as string,
},
};
expect(getOrganizationDisplayName(organizationWithoutDisplayName)).toBe(
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { backupList } from '../../../mocks/veeam-backup.mock';
import { backupList } from '../mocks';
import {
getRegionNameFromAzName,
getVeeamBackupDisplayName,
Expand All @@ -25,7 +25,7 @@ describe('Veeam-backup API utils', () => {
...backupList[0],
iam: {
...backupList[0].iam,
displayName: null as string,
displayName: (null as unknown) as string,
},
};
expect(getVeeamBackupDisplayName(backupWithoutDisplayName)).toBe(
Expand Down
Loading

0 comments on commit dfb4658

Please sign in to comment.