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 Apr 23, 2024
2 parents 8c47ec0 + 6193b4d commit 4d4c437
Show file tree
Hide file tree
Showing 30 changed files with 1,517 additions and 705 deletions.
2 changes: 1 addition & 1 deletion docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileCopyrightText: Huawei Inc.
#
FROM nginx:1.25.4-alpine
FROM nginx:1.25.5-alpine
WORKDIR /usr/share/nginx/html
RUN apk add --no-cache bash envsubst
COPY docker/nginx-entrypoint.sh /
Expand Down
448 changes: 253 additions & 195 deletions package-lock.json

Large diffs are not rendered by default.

26 changes: 13 additions & 13 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
{
"name": "xpanse-ui",
"version": "1.0.8",
"version": "1.0.9",
"private": true,
"type": "module",
"dependencies": {
"@ant-design/icons": "^5.3.6",
"@axa-fr/react-oidc": "^7.22.0",
"@tanstack/react-query": "^5.29.0",
"antd": "^5.16.1",
"@axa-fr/react-oidc": "^7.22.3",
"@tanstack/react-query": "^5.29.2",
"antd": "^5.16.2",
"echarts": "5.5.0",
"echarts-for-react": "^3.0.2",
"rc-field-form": "^1.44.0",
"rc-field-form": "^2.0.0",
"rc-menu": "^9.12.2",
"rc-tabs": "^15.0.0",
"react": "^18.2.0",
Expand Down Expand Up @@ -82,18 +82,18 @@
]
},
"devDependencies": {
"@axa-fr/oidc-client": "^7.21.0",
"@axa-fr/oidc-client": "^7.22.2",
"@babel/plugin-proposal-private-property-in-object": "^7.21.11",
"@tanstack/eslint-plugin-query": "^5.28.11",
"@testing-library/jest-dom": "^6.4.2",
"@testing-library/react": "^15.0.0",
"@testing-library/react": "^15.0.2",
"@types/jest": "^29.5.12",
"@types/node": "^20.12.7",
"@types/react": "^18.2.75",
"@types/react-dom": "^18.2.24",
"@types/react": "^18.2.79",
"@types/react-dom": "^18.2.25",
"@types/uuid": "^9.0.8",
"@typescript-eslint/eslint-plugin": "^7.6.0",
"@typescript-eslint/parser": "^7.6.0",
"@typescript-eslint/eslint-plugin": "^7.7.0",
"@typescript-eslint/parser": "^7.7.0",
"env-cmd": "^10.1.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.0.0",
Expand All @@ -105,11 +105,11 @@
"identity-obj-proxy": "^3.0.0",
"jest": "^29.7.0",
"jest-environment-jsdom": "^29.7.0",
"knip": "^5.9.3",
"knip": "^5.9.4",
"openapi-typescript-codegen": "^0.29.0",
"prettier": "3.2.5",
"react-scripts": "5.0.1",
"release-it": "^17.1.1",
"release-it": "^17.2.0",
"ts-jest": "^29.1.2",
"typescript": "5.4.5",
"uuid": "^9.0.1"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,14 @@ function YamlSyntaxValidationResult({
validationResult: string;
yamlSyntaxValidationStatus: ValidationStatus;
}): React.JSX.Element {
const handleClick = (event: React.MouseEvent) => {
event.stopPropagation();
event.preventDefault();
};
if (yamlSyntaxValidationStatus === 'completed') {
return <Alert type={'info'} showIcon={true} message={validationResult} />;
return <Alert type={'info'} showIcon={true} message={validationResult} onClick={handleClick} />;
} else {
return <Alert type={'error'} showIcon={true} message={validationResult} />;
return <Alert type={'error'} showIcon={true} message={validationResult} onClick={handleClick} />;
}
}

Expand Down
96 changes: 0 additions & 96 deletions src/components/content/order/common/AvailabilityZoneInfo.tsx

This file was deleted.

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

import { AvailabilityZoneConfig } from '../../../../../xpanse-api/generated';
import { Alert, Flex, Radio } from 'antd';
import React from 'react';

export function AvailabilityZoneButton({
availabilityZoneConfig,
availabilityZones,
selectRegion,
onAvailabilityZoneChange,
selectAvailabilityZones,
}: {
availabilityZoneConfig: AvailabilityZoneConfig;
availabilityZones: string[] | undefined;
selectRegion: string;
onAvailabilityZoneChange: (varName: string, availabilityZone: string | undefined) => void;
selectAvailabilityZones: Record<string, string | undefined>;
}) {
const DEFAULT_OPTIONAL_AZ = 'Not Selected';
function onChange(varName: string, availabilityZone: string) {
onAvailabilityZoneChange(varName, availabilityZone !== DEFAULT_OPTIONAL_AZ ? availabilityZone : undefined);
}

return (
<>
<Flex vertical gap='middle'>
{availabilityZoneConfig.mandatory ? (
availabilityZones && availabilityZones.length > 0 ? (
<Radio.Group
buttonStyle='solid'
onChange={(e) => {
onChange(availabilityZoneConfig.varName, e.target.value as string);
}}
value={selectAvailabilityZones[availabilityZoneConfig.varName]}
>
{availabilityZones.map((availabilityZonesVariable) => (
<Radio.Button
name={availabilityZoneConfig.displayName}
key={availabilityZonesVariable}
value={availabilityZonesVariable}
>
{availabilityZonesVariable}
</Radio.Button>
))}
</Radio.Group>
) : (
<Alert
message={'No availability zones found for region ' + selectRegion}
description={'Mandatory field. Cannot proceed.'}
type={'error'}
closable={false}
/>
)
) : (
<Radio.Group
buttonStyle='solid'
onChange={(e) => {
onChange(availabilityZoneConfig.varName, e.target.value as string);
}}
value={selectAvailabilityZones[availabilityZoneConfig.varName] ?? DEFAULT_OPTIONAL_AZ}
>
{availabilityZones && availabilityZones.length > 0 ? (
<>
<Radio.Button name={availabilityZoneConfig.displayName} value={DEFAULT_OPTIONAL_AZ}>
{DEFAULT_OPTIONAL_AZ}
</Radio.Button>
{availabilityZones.map((availabilityZonesVariable) => (
<Radio.Button
name={availabilityZoneConfig.displayName}
key={availabilityZonesVariable}
value={availabilityZonesVariable}
>
{availabilityZonesVariable}
</Radio.Button>
))}
;
</>
) : (
<Alert
message={'No availability zones found for region ' + selectRegion}
description={'Optional field. Can proceed.'}
type={'success'}
closable={false}
/>
)}
</Radio.Group>
)}
</Flex>
</>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: Huawei Inc.
*/

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

export function AvailabilityZoneError({ error }: { error: Error }) {
if (error instanceof ApiError && error.body && 'details' in error.body) {
const response: Response = error.body as Response;
return (
<Alert
message={response.resultType.valueOf()}
description={convertStringArrayToUnorderedList(response.details)}
type={'error'}
closable={false}
/>
);
} else {
return (
<Alert
message='Fetching Availability Regions Failed'
description={error.message}
type={'error'}
closable={false}
/>
);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: Huawei Inc.
*/

import { AvailabilityZoneConfig, UserOrderableServiceVo } from '../../../../../xpanse-api/generated';
import { Form } from 'antd';
import React from 'react';
import { AvailabilityZoneButton } from './AvailabilityZoneButton';
import useGetAvailabilityZonesForRegionQuery from '../utils/useGetAvailabilityZonesForRegionQuery';
import { AvailabilityZoneLoading } from './AvailabilityZoneLoading';
import { AvailabilityZoneError } from './AvailabilityZoneError';

export function AvailabilityZoneFormItem({
availabilityZoneConfig,
selectRegion,
onAvailabilityZoneChange,
selectAvailabilityZones,
selectCsp,
}: {
availabilityZoneConfig: AvailabilityZoneConfig;
selectRegion: string;
onAvailabilityZoneChange: (varName: string, availabilityZone: string | undefined) => void;
selectAvailabilityZones: Record<string, string | undefined>;
selectCsp: UserOrderableServiceVo.csp;
}) {
const availabilityZonesVariableRequest = useGetAvailabilityZonesForRegionQuery(selectCsp, selectRegion);

function getFormContent() {
if (availabilityZonesVariableRequest.isLoading || availabilityZonesVariableRequest.isFetching) {
return <AvailabilityZoneLoading key={availabilityZoneConfig.varName} />;
}
if (availabilityZonesVariableRequest.isError) {
return (
<AvailabilityZoneError
error={availabilityZonesVariableRequest.error}
key={availabilityZoneConfig.varName}
/>
);
}
if (availabilityZonesVariableRequest.data) {
return (
<AvailabilityZoneButton
availabilityZoneConfig={availabilityZoneConfig}
selectRegion={selectRegion}
availabilityZones={availabilityZonesVariableRequest.data}
onAvailabilityZoneChange={onAvailabilityZoneChange}
selectAvailabilityZones={selectAvailabilityZones}
/>
);
}
return null;
}
return (
<Form.Item
key={availabilityZoneConfig.varName}
label={<p style={{ fontWeight: 'bold' }}>{availabilityZoneConfig.displayName}</p>}
required={availabilityZoneConfig.mandatory}
rules={[
{
required: availabilityZoneConfig.mandatory,
message: availabilityZoneConfig.displayName + 'is required',
},
{ type: 'string' },
]}
>
{getFormContent()}
</Form.Item>
);
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
/*
* SPDX-License-Identifier: Apache-2.0
* SPDX-FileCopyrightText: Huawei Inc.
*/

import { Skeleton } from 'antd';
import React from 'react';

export function AvailabilityZoneLoading() {
return <Skeleton active={true} loading={true} paragraph={{ rows: 1, width: ['20%'] }} />;
}
Loading

0 comments on commit 4d4c437

Please sign in to comment.