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 17, 2024
2 parents 372cb30 + ac128a0 commit fd49405
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,9 @@
*/

import { ApiError, Response } from '../../../../../xpanse-api/generated';
import { Alert } from 'antd';
import { Alert, Button } from 'antd';
import { convertStringArrayToUnorderedList } from '../../../../utils/generateUnorderedList';
import React from 'react';

export function AvailabilityZoneError({ error }: { error: Error }): React.JSX.Element {
export function AvailabilityZoneError({ retryRequest, error }: { retryRequest: () => void; error: Error }) {
if (error instanceof ApiError && error.body && 'details' in error.body) {
const response: Response = error.body as Response;
return (
Expand All @@ -17,6 +15,17 @@ export function AvailabilityZoneError({ error }: { error: Error }): React.JSX.El
description={convertStringArrayToUnorderedList(response.details)}
type={'error'}
closable={false}
action={
<Button
className={'try-again-btn-class'}
size='small'
type='primary'
onClick={retryRequest}
danger={true}
>
Retry Request
</Button>
}
/>
);
} else {
Expand All @@ -26,6 +35,17 @@ export function AvailabilityZoneError({ error }: { error: Error }): React.JSX.El
description={error.message}
type={'error'}
closable={false}
action={
<Button
className={'try-again-btn-class'}
size='small'
type='primary'
onClick={retryRequest}
danger={true}
>
Retry Request
</Button>
}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,19 @@ export function AvailabilityZoneFormItem({
selectCsp: UserOrderableServiceVo.csp;
}): React.JSX.Element {
const availabilityZonesVariableRequest = useGetAvailabilityZonesForRegionQuery(selectCsp, selectRegion);

const retryRequest = () => {
if (availabilityZonesVariableRequest.isError) {
void availabilityZonesVariableRequest.refetch();
}
};
function getFormContent() {
if (availabilityZonesVariableRequest.isLoading || availabilityZonesVariableRequest.isFetching) {
return <AvailabilityZoneLoading key={availabilityZoneConfig.varName} />;
}
if (availabilityZonesVariableRequest.isError) {
return (
<AvailabilityZoneError
retryRequest={retryRequest}
error={availabilityZonesVariableRequest.error}
key={availabilityZoneConfig.varName}
/>
Expand Down
16 changes: 14 additions & 2 deletions src/components/content/order/migrate/SelectDestination.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import CspSelect from '../formElements/CspSelect';
import { AvailabilityZoneConfig, MigrateRequest, UserOrderableServiceVo } from '../../../../xpanse-api/generated';
import { Button, Form, Space, StepProps, Tabs } from 'antd';
import { Tab } from 'rc-tabs/lib/interface';
import React, { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { Dispatch, SetStateAction, useEffect, useState } from 'react';
import { Flavor } from '../types/Flavor';
import { getAvailableServiceHostingTypes } from '../formDataHelpers/serviceHostingTypeHelper';
import { convertAreasToTabs } from '../formDataHelpers/areaHelper';
Expand Down Expand Up @@ -247,6 +247,10 @@ export const SelectDestination = ({
}
}

function isAvailabilityZoneRequired(): boolean {
return availabilityZoneConfigs.filter((availabilityZoneConfig) => availabilityZoneConfig.mandatory).length > 0;
}

return (
<Form
form={form}
Expand Down Expand Up @@ -317,7 +321,15 @@ export const SelectDestination = ({
>
Previous
</Button>
<Button type='primary' className={'migrate-steps-operation-button-clas'} htmlType='submit'>
<Button
type='primary'
disabled={
getAvailabilityZonesForRegionQuery.isError ||
(isAvailabilityZoneRequired() && getAvailabilityZonesForRegionQuery.data?.length === 0)
}
className={'migrate-steps-operation-button-clas'}
htmlType='submit'
>
Next
</Button>
</Space>
Expand Down

0 comments on commit fd49405

Please sign in to comment.