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 Nov 14, 2024
2 parents 524c42e + 163c5bf commit 3126f27
Show file tree
Hide file tree
Showing 18 changed files with 920 additions and 1,878 deletions.
468 changes: 195 additions & 273 deletions package-lock.json

Large diffs are not rendered by default.

24 changes: 12 additions & 12 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
{
"name": "xpanse-ui",
"version": "1.0.17",
"version": "1.0.18",
"private": true,
"type": "module",
"dependencies": {
"@ant-design/icons": "^5.5.1",
"@axa-fr/react-oidc": "^7.22.32",
"@tanstack/react-query": "^5.59.19",
"antd": "^5.21.6",
"@tanstack/react-query": "^5.59.20",
"antd": "^5.22.0",
"echarts": "5.5.1",
"echarts-for-react": "^3.0.2",
"rc-field-form": "^2.5.0",
"rc-menu": "^9.16.0",
"rc-tabs": "^15.4.0",
"react": "^18.2.0",
"react-dom": "^18.3.1",
"react-router-dom": "^6.27.0",
"react-router-dom": "^6.28.0",
"react-timer-hook": "^3.0.8",
"yaml": "^2.6.0",
"zustand": "^5.0.1"
Expand Down Expand Up @@ -100,18 +100,18 @@
},
"devDependencies": {
"@axa-fr/oidc-client": "^7.22.32",
"@hey-api/openapi-ts": "^0.54.2",
"@hey-api/openapi-ts": "^0.55.2",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@tanstack/eslint-plugin-query": "^5.59.7",
"@tanstack/eslint-plugin-query": "^5.60.1",
"@testing-library/jest-dom": "^6.6.3",
"@testing-library/react": "^16.0.1",
"@types/jest": "^29.5.14",
"@types/node": "^22.8.7",
"@types/node": "^22.9.0",
"@types/react": "^18.3.12",
"@types/react-dom": "^18.3.1",
"@types/uuid": "^10.0.0",
"@typescript-eslint/eslint-plugin": "^8.13.0",
"@typescript-eslint/parser": "^8.13.0",
"@typescript-eslint/eslint-plugin": "^8.14.0",
"@typescript-eslint/parser": "^8.14.0",
"@vitejs/plugin-react": "^4.3.3",
"env-cmd": "^10.1.0",
"eslint": "^8.57.1",
Expand All @@ -125,14 +125,14 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"knip": "^5.36.2",
"knip": "^5.36.7",
"prettier": "3.3.3",
"prettier-plugin-organize-imports": "^4.1.0",
"release-it": "^17.10.0",
"ts-jest": "^29.2.5",
"typescript": "5.6.3",
"uuid": "^11.0.2",
"vite": "^5.4.10"
"uuid": "^11.0.3",
"vite": "^5.4.11"
},
"overrides": {
"react-scripts": {
Expand Down
2 changes: 1 addition & 1 deletion public/OidcServiceWorker.js

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

Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: Huawei Inc.
*/

import { useQuery } from '@tanstack/react-query';
import {
getLatestServiceOrderStatus,
GetLatestServiceOrderStatusData,
taskStatus,
} from '../../../../xpanse-api/generated';
import { deploymentStatusPollingInterval } from '../../../utils/constants.tsx';

export function useLatestServiceOrderStatusQuery(
orderId: string | undefined,
isStartPolling: boolean,
refetchUntilStates: taskStatus[]
) {
return useQuery({
queryKey: ['getServiceDetailsById', orderId],
queryFn: () => {
const data: GetLatestServiceOrderStatusData = {
lastKnownServiceDeploymentState: undefined,
orderId: orderId ?? '',
};
return getLatestServiceOrderStatus(data);
},
refetchInterval: (query) =>
query.state.data && refetchUntilStates.includes(query.state.data.taskStatus as taskStatus)
? false
: deploymentStatusPollingInterval,
refetchIntervalInBackground: true,
refetchOnWindowFocus: false,
enabled: orderId !== undefined && isStartPolling,
gcTime: 0,
});
}
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ import {
import { sortVersionNum } from '../../../utils/Sort';
import { serviceIdQuery, serviceStateQuery } from '../../../utils/constants';
import { cspMap } from '../../common/csp/CspLogo';
import { useLatestServiceOrderStatusQuery } from '../../common/latestServiceOrderStatusQuery/useLatestServiceOrderStatusQuery.ts';
import { ContactDetailsShowType } from '../../common/ocl/ContactDetailsShowType';
import { ContactDetailsText } from '../../common/ocl/ContactDetailsText';
import { getExistingServiceParameters } from '../../order/common/utils/existingServiceParameters';
Expand All @@ -55,10 +56,7 @@ import { Locks } from '../../order/locks/Locks';
import { Migrate } from '../../order/migrate/Migrate';
import { Modify } from '../../order/modify/Modify';
import OrderSubmitStatusAlert from '../../order/orderStatus/OrderSubmitStatusAlert';
import {
useLatestServiceOrderStatusQuery,
useServiceDetailsByIdQuery,
} from '../../order/orderStatus/useServiceDetailsPollingQuery';
import { useServiceDetailsByIdQuery } from '../../order/orderStatus/useServiceDetailsPollingQuery';
import { PurgeServiceStatusAlert } from '../../order/purge/PurgeServiceStatusAlert';
import { usePurgeRequestStatusQuery } from '../../order/purge/usePurgeRequestStatusQuery';
import { usePurgeRequestSubmitQuery } from '../../order/purge/usePurgeRequestSubmitQuery';
Expand Down
8 changes: 3 additions & 5 deletions src/components/content/order/create/OrderSubmit.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,20 +13,18 @@ import serviceOrderStyles from '../../../../styles/service-order.module.css';
import tableStyles from '../../../../styles/table.module.css';
import { ApiError, DeployRequest, taskStatus } from '../../../../xpanse-api/generated';
import {
CUSTOMER_SERVICE_NAME_FIELD,
createServicePageRoute,
CUSTOMER_SERVICE_NAME_FIELD,
homePageRoute,
servicesSubPageRoute,
} from '../../../utils/constants';
import { ApiDoc } from '../../common/doc/ApiDoc';
import { useLatestServiceOrderStatusQuery } from '../../common/latestServiceOrderStatusQuery/useLatestServiceOrderStatusQuery.ts';
import { EulaInfo } from '../common/EulaInfo';
import { OrderItem } from '../common/utils/OrderItem';
import { OrderSubmitProps } from '../common/utils/OrderSubmitProps';
import OrderSubmitStatusAlert from '../orderStatus/OrderSubmitStatusAlert';
import {
useLatestServiceOrderStatusQuery,
useServiceDetailsByIdQuery,
} from '../orderStatus/useServiceDetailsPollingQuery';
import { useServiceDetailsByIdQuery } from '../orderStatus/useServiceDetailsPollingQuery';
import useRedeployFailedDeploymentQuery from '../retryDeployment/useRedeployFailedDeploymentQuery';
import { useOrderFormStore } from '../store/OrderFormStore';
import NavigateOrderSubmission from './NavigateOrderSubmission';
Expand Down
86 changes: 27 additions & 59 deletions src/components/content/order/migrate/MigrateServiceStatusAlert.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,70 +8,40 @@ import { useStopwatch } from 'react-timer-hook';
import {
ApiError,
DeployedServiceDetails,
migrationStatus,
GetLatestServiceOrderStatusResponse,
Response,
ServiceMigrationDetails,
ServiceOrder,
ServiceProviderContactDetails,
taskStatus,
VendorHostedDeployedServiceDetails,
} from '../../../../xpanse-api/generated';
import { convertStringArrayToUnorderedList } from '../../../utils/generateUnorderedList';
import { MigrationOrderSubmitResult } from './MigrationOrderSubmitResult';
import { MigrationProcessingStatus } from './MigrationProcessingStatus';
import { MigrationProcessingStatus } from './MigrationProcessingStatus.tsx';

function MigrateServiceStatusAlert({
migrateRequestError,
migrateRequestData,
deployedServiceDetails,
oldDeployedServiceDetails,
serviceProviderContactDetails,
isPollingError,
migrationDetails,
}: {
migrateRequestError: Error | null;
deployedServiceDetails: DeployedServiceDetails | undefined;
oldDeployedServiceDetails: DeployedServiceDetails | undefined;
migrateRequestData: ServiceOrder | undefined;
deployedServiceDetails: DeployedServiceDetails | VendorHostedDeployedServiceDetails | undefined;
oldDeployedServiceDetails: DeployedServiceDetails | VendorHostedDeployedServiceDetails | undefined;
serviceProviderContactDetails: ServiceProviderContactDetails | undefined;
isPollingError: boolean;
migrationDetails: ServiceMigrationDetails | undefined;
migrationDetails: GetLatestServiceOrderStatusResponse | undefined;
}): React.JSX.Element {
const stopWatch = useStopwatch({
autoStart: true,
});

const msg = useMemo(() => {
if (migrationDetails) {
if (
deployedServiceDetails &&
(migrationDetails.migrationStatus === migrationStatus.MIGRATION_COMPLETED ||
migrationDetails.migrationStatus === migrationStatus.DEPLOY_FAILED)
) {
return (
<MigrationProcessingStatus
response={deployedServiceDetails}
currentServiceHostingType={deployedServiceDetails.serviceHostingType}
/>
);
} else if (
oldDeployedServiceDetails &&
migrationDetails.migrationStatus === migrationStatus.DESTROY_FAILED
) {
return (
<MigrationProcessingStatus
response={oldDeployedServiceDetails}
currentServiceHostingType={oldDeployedServiceDetails.serviceHostingType}
/>
);
} else if (
migrationDetails.migrationStatus === migrationStatus.DATA_IMPORT_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DATA_EXPORT_FAILED
) {
return 'Data Migration Failed';
} else if (migrationDetails.migrationStatus === migrationStatus.DEPLOY_STARTED) {
return 'New Service Deployment In-progress';
} else if (migrationDetails.migrationStatus === migrationStatus.DESTROY_STARTED) {
return 'Old Service Destroy In-progress';
} else {
return 'Migrating... Please wait...';
}
} else if (migrateRequestError) {
if (migrateRequestError) {
if (
migrateRequestError instanceof ApiError &&
migrateRequestError.body &&
Expand All @@ -85,29 +55,34 @@ function MigrateServiceStatusAlert({
}
} else if (isPollingError) {
return 'Migration status polling failed. Please visit MyServices page to check the status of the request.';
} else if (migrationDetails) {
if (migrationDetails.isOrderCompleted) {
return (
<MigrationProcessingStatus
deployedResponse={deployedServiceDetails}
destroyedResponse={oldDeployedServiceDetails}
/>
);
} else {
return 'Migrating... Please wait...';
}
}
return 'Request submission in-progress';
return 'Migrate request submission in-progress';
}, [deployedServiceDetails, migrationDetails, isPollingError, migrateRequestError, oldDeployedServiceDetails]);

const alertType = useMemo(() => {
if (isPollingError || migrateRequestError) {
return 'error';
}
if (migrationDetails) {
if (
migrationDetails.migrationStatus === migrationStatus.MIGRATION_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DATA_EXPORT_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DATA_IMPORT_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DEPLOY_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DESTROY_FAILED
) {
if (migrationDetails.taskStatus === taskStatus.FAILED) {
return 'error';
}
}
return 'success';
}, [migrationDetails, isPollingError, migrateRequestError]);

if (isPollingError || migrateRequestError) {
if (isPollingError || migrateRequestError || migrationDetails?.isOrderCompleted) {
if (stopWatch.isRunning) {
stopWatch.pause();
}
Expand All @@ -123,14 +98,7 @@ function MigrateServiceStatusAlert({
}

if (migrationDetails) {
if (
migrationDetails.migrationStatus === migrationStatus.MIGRATION_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DATA_EXPORT_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DATA_IMPORT_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DEPLOY_FAILED ||
migrationDetails.migrationStatus === migrationStatus.DESTROY_FAILED ||
migrationDetails.migrationStatus === migrationStatus.MIGRATION_COMPLETED
) {
if (migrationDetails.taskStatus === taskStatus.FAILED) {
if (stopWatch.isRunning) {
stopWatch.pause();
}
Expand All @@ -140,7 +108,7 @@ function MigrateServiceStatusAlert({
return (
<MigrationOrderSubmitResult
msg={msg}
uuid={migrationDetails?.newServiceId ?? '-'}
uuid={migrateRequestData?.serviceId ?? '-'}
type={alertType}
stopWatch={stopWatch}
contactServiceDetails={alertType !== 'success' ? serviceProviderContactDetails : undefined}
Expand Down
Loading

0 comments on commit 3126f27

Please sign in to comment.