Skip to content

Commit

Permalink
Merge branch 'eclipse-xpanse:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
WangLiNaruto authored May 9, 2024
2 parents 5314004 + 5ac5ecd commit 64fab36
Show file tree
Hide file tree
Showing 30 changed files with 1,387 additions and 388 deletions.
40 changes: 20 additions & 20 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"antd": "^5.17.0",
"echarts": "5.5.0",
"echarts-for-react": "^3.0.2",
"rc-field-form": "^2.0.0",
"rc-field-form": "^2.0.1",
"rc-menu": "^9.12.2",
"rc-tabs": "^15.0.0",
"react": "^18.2.0",
Expand Down Expand Up @@ -87,9 +87,9 @@
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@tanstack/eslint-plugin-query": "^5.32.1",
"@testing-library/jest-dom": "^6.4.5",
"@testing-library/react": "^15.0.6",
"@testing-library/react": "^15.0.7",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.10",
"@types/node": "^20.12.11",
"@types/react": "^18.3.1",
"@types/react-dom": "^18.3.0",
"@types/uuid": "^9.0.8",
Expand All @@ -106,7 +106,7 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"knip": "^5.12.3",
"knip": "^5.13.0",
"openapi-typescript-codegen": "^0.29.0",
"prettier": "3.2.5",
"react-scripts": "5.0.1",
Expand Down
4 changes: 2 additions & 2 deletions src/components/content/order/common/RegionInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import React from 'react';
import { Form, Select, Space } from 'antd';
import '../../../../styles/service_order.css';
import { Region } from '../types/Region';
import { RegionDropDownInfo } from '../types/RegionDropDownInfo';

export const RegionInfo = ({
selectRegion,
Expand All @@ -16,7 +16,7 @@ export const RegionInfo = ({
}: {
selectRegion: string;
onChangeRegion?: (newRegion: string) => void;
regionList?: Region[];
regionList?: RegionDropDownInfo[];
disabled?: boolean;
}): React.JSX.Element => {
return (
Expand Down
4 changes: 2 additions & 2 deletions src/components/content/order/create/SelectServiceForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import {
UserOrderableServiceVo,
} from '../../../../xpanse-api/generated';
import { Tab } from 'rc-tabs/lib/interface';
import { Region } from '../types/Region';
import { RegionDropDownInfo } from '../types/RegionDropDownInfo';
import { Flavor } from '../types/Flavor';
import { getSortedVersionList } from '../formDataHelpers/versionHelper';
import { getCspListForVersion } from '../formDataHelpers/cspHelper';
Expand Down Expand Up @@ -89,7 +89,7 @@ export function SelectServiceForm({ services }: { services: UserOrderableService
);
let areaList: Tab[] = convertAreasToTabs(selectCsp, selectServiceHostType, versionToServicesMap.get(selectVersion));
const [selectArea, setSelectArea] = useState<string>(serviceInfo ? serviceInfo.area : areaList[0].key);
let regionList: Region[] = getRegionDropDownValues(
let regionList: RegionDropDownInfo[] = getRegionDropDownValues(
selectCsp,
selectServiceHostType,
selectArea,
Expand Down
21 changes: 0 additions & 21 deletions src/components/content/order/formDataHelpers/areaHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -71,24 +71,3 @@ export function convertAreasToTabs(
}
return areaTabs;
}

export function getAreaForRegion(
selectCsp: UserOrderableServiceVo.csp,
selectServiceHostingType: UserOrderableServiceVo.serviceHostingType,
userOrderableServices: UserOrderableServiceVo[],
inputRegion: string
) {
const areaList: Area[] = getAreasForSelectedVersionHostingTypeAndCsp(
selectCsp,
selectServiceHostingType,
userOrderableServices
);
for (const area of areaList) {
for (const region of area.regions) {
if (region === inputRegion) {
return area.name;
}
}
}
return '';
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function getBilling(
): Billing {
let billing: Billing = {
// TODO Will be fixed in #1591 or #1592
billingModes: ['monthly'],
billingModes: ['fixed'],
};
if (versionMapper) {
versionMapper.forEach((userOrderableServiceVo) => {
Expand Down
3 changes: 2 additions & 1 deletion src/components/content/order/formDataHelpers/flavorHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,8 @@ export function getFlavorList(
const flavors: Flavor[] = [];
if (flavorList.length > 0) {
for (const flavor of flavorList) {
const flavorItem = { value: flavor.name, label: flavor.name, price: flavor.fixedPrice.toString() };
// TODO will be fixed after #1597 is fixed
const flavorItem = { value: flavor.name, label: flavor.name, price: (20).toString() };
flavors.push(flavorItem);
}
}
Expand Down
7 changes: 3 additions & 4 deletions src/components/content/order/formDataHelpers/regionHelper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,23 +3,22 @@
* SPDX-FileCopyrightText: Huawei Inc.
*/

import { Region } from '../types/Region';
import { RegionDropDownInfo } from '../types/RegionDropDownInfo';
import { UserOrderableServiceVo } from '../../../../xpanse-api/generated';
import { Area } from '../types/Area';
import { getAreasForSelectedVersionHostingTypeAndCsp } from './areaHelper';

export function getRegionDropDownValues(
selectCsp: UserOrderableServiceVo.csp,
selectServiceHostingType: UserOrderableServiceVo.serviceHostingType,
selectArea: string,
userOrderableServices: UserOrderableServiceVo[] | undefined
): Region[] {
): RegionDropDownInfo[] {
const areaList: Area[] = getAreasForSelectedVersionHostingTypeAndCsp(
selectCsp,
selectServiceHostingType,
userOrderableServices
);
let regions: Region[] = [];
let regions: RegionDropDownInfo[] = [];
if (areaList.length > 0) {
regions = areaList
.filter((v) => v.name === selectArea)
Expand Down
2 changes: 1 addition & 1 deletion src/components/content/order/migrate/ExportServiceData.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const ExportServiceData = ({

const next = () => {
stepItem.status = 'finish';
setCurrentMigrationStep(MigrationSteps.SelectADestination);
setCurrentMigrationStep(MigrationSteps.SelectMigrateTarget);
};

return (
Expand Down
66 changes: 55 additions & 11 deletions src/components/content/order/migrate/Migrate.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import React, { useMemo, useState } from 'react';
import {
DeployedServiceDetails,
DeployRequest,
Region,
ServiceCatalogService,
UserOrderableServiceVo,
VendorHostedDeployedServiceDetails,
Expand All @@ -18,20 +17,35 @@ import { StepProps, Steps } from 'antd';
import { MigrateServiceSubmit } from './MigrateServiceSubmit';
import { ExportServiceData } from './ExportServiceData';
import { ImportServiceData } from './ImportServiceData';
import { SelectMigrationTarget } from './SelectMigrationTarget';
import { useQuery } from '@tanstack/react-query';
import { MigrationSteps } from '../types/MigrationSteps';
import { Tab } from 'rc-tabs/lib/interface';
import { RegionDropDownInfo } from '../types/RegionDropDownInfo';

export const Migrate = ({
currentSelectedService,
}: {
currentSelectedService: DeployedServiceDetails | VendorHostedDeployedServiceDetails;
}): React.JSX.Element => {
const [currentMigrationStep, setCurrentMigrationStep] = useState<MigrationSteps>(MigrationSteps.ExportServiceData);

const [target, setTarget] = useState<string | undefined>(undefined);

const [cspList, setCspList] = useState<UserOrderableServiceVo.csp[]>([]);
const [selectCsp, setSelectCsp] = useState<UserOrderableServiceVo.csp>(currentSelectedService.csp);

const [serviceHostTypes, setServiceHostTypes] = useState<UserOrderableServiceVo.serviceHostingType[]>([]);
const [selectServiceHostingType, setSelectServiceHostingType] = useState<UserOrderableServiceVo.serviceHostingType>(
currentSelectedService.serviceHostingType
);
const [selectRegion, setSelectRegion] = useState<Region>(currentSelectedService.deployRequest.region);

const [areaList, setAreaList] = useState<Tab[]>([]);
const [selectArea, setSelectArea] = useState<string>(currentSelectedService.deployRequest.region.area);

const [regionList, setRegionList] = useState<RegionDropDownInfo[]>([]);
const [selectRegion, setSelectRegion] = useState<string>(currentSelectedService.deployRequest.region.name);

const [selectAvailabilityZones, setSelectAvailabilityZones] = useState<Record<string, string>>(
currentSelectedService.deployRequest.availabilityZones ?? {}
);
Expand Down Expand Up @@ -65,10 +79,7 @@ export const Migrate = ({
selectedServiceHostingType: UserOrderableServiceVo.serviceHostingType
) => {
setSelectCsp(selectedCsp);
setSelectRegion({
name: selectRegionName,
area: selectAreaName,
});
setSelectRegion(selectRegionName);
setSelectAvailabilityZones(selectAvailabilityZonesName);
setSelectFlavor(selectedFlavor);
setSelectServiceHostingType(selectedServiceHostingType);
Expand All @@ -80,6 +91,11 @@ export const Migrate = ({
title: 'Export data',
description: 'Export service data.',
},
{
title: 'Select a migrate target',
description:
'Select between migrating between different regions within the same cloud or migrating between different clouds',
},
{
title: 'Select a destination',
description: 'Select a destination for migrating the existing deployment.',
Expand Down Expand Up @@ -120,17 +136,45 @@ export const Migrate = ({
stepItem={items[MigrationSteps.ExportServiceData]}
/>
);
case MigrationSteps.SelectMigrateTarget:
return (
<SelectMigrationTarget
target={target}
setTarget={setTarget}
currentSelectedService={currentSelectedService}
userOrderableServiceVoList={listOrderableServices.data ?? []}
setCspList={setCspList}
setSelectCsp={setSelectCsp}
setServiceHostTypes={setServiceHostTypes}
setSelectServiceHostingType={setSelectServiceHostingType}
setAreaList={setAreaList}
setSelectArea={setSelectArea}
setRegionList={setRegionList}
setSelectRegion={setSelectRegion}
setCurrentMigrationStep={setCurrentMigrationStep}
stepItem={items[MigrationSteps.SelectMigrateTarget]}
/>
);
case MigrationSteps.SelectADestination:
return (
<SelectDestination
userOrderableServiceVoList={listOrderableServices.data ?? []}
updateSelectedParameters={updateSelectedParameters}
currentCsp={selectCsp}
currentRegion={selectRegion.name}
cspList={cspList}
selectCsp={selectCsp}
setSelectCsp={setSelectCsp}
serviceHostTypes={serviceHostTypes}
selectServiceHostType={selectServiceHostingType}
setSelectServiceHostingType={setSelectServiceHostingType}
areaList={areaList}
selectArea={selectArea}
setSelectArea={setSelectArea}
regionList={regionList}
selectRegion={selectRegion}
setSelectRegion={setSelectRegion}
selectAvailabilityZones={selectAvailabilityZones}
setSelectAvailabilityZones={setSelectAvailabilityZones}
currentFlavor={selectFlavor}
currentServiceHostingType={selectServiceHostingType}
setCurrentMigrationStep={setCurrentMigrationStep}
stepItem={items[MigrationSteps.SelectADestination]}
/>
Expand All @@ -148,7 +192,7 @@ export const Migrate = ({
userOrderableServiceVoList={listOrderableServices.data ?? []}
selectCsp={selectCsp}
selectServiceHostingType={selectServiceHostingType}
region={selectRegion}
region={{ name: selectRegion, area: selectArea }}
availabilityZones={selectAvailabilityZones}
selectFlavor={selectFlavor}
isEulaAccepted={isEulaAccepted}
Expand All @@ -163,7 +207,7 @@ export const Migrate = ({
<MigrateServiceSubmit
userOrderableServiceVoList={listOrderableServices.data ?? []}
selectCsp={selectCsp}
region={selectRegion}
region={{ name: selectRegion, area: selectArea }}
availabilityZones={selectAvailabilityZones}
selectFlavor={selectFlavor}
selectServiceHostingType={selectServiceHostingType}
Expand Down
Loading

0 comments on commit 64fab36

Please sign in to comment.