Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix:The selected cluster exception display zone #346

Merged
merged 11 commits into from
Apr 29, 2024
2 changes: 1 addition & 1 deletion ui/src/pages/Tenant/New/BasicInfo.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default function BasicInfo({
const clusterOptions = clusterList
.filter((cluster) => cluster.status !== 'failed')
.map((cluster) => ({
value: cluster.clusterId,
value: cluster.id,
label: cluster.name,
status: cluster.status,
}));
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/Tenant/New/ResourcePools.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { findMinParameter, modifyZoneCheckedStatus } from '../helper';
import styles from './index.less';

interface ResourcePoolsProps {
selectClusterId?: number;
selectClusterId?: string;
clusterList: API.SimpleClusterList;
form: FormInstance<API.NewTenantForm>;
setClusterList: React.Dispatch<React.SetStateAction<API.SimpleClusterList>>;
Expand Down Expand Up @@ -45,7 +45,7 @@ export default function ResourcePools({
);
};
const targetZoneList = clusterList
.filter((cluster) => cluster.clusterId === selectClusterId)[0]
.filter((cluster) => cluster.id === selectClusterId)[0]
?.topology.map((zone) => ({ zone: zone.zone, checked: zone.checked }));

useEffect(() => {
Expand Down
10 changes: 5 additions & 5 deletions ui/src/pages/Tenant/New/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export default function New() {
const publicKey = usePublicKey();
const [form] = Form.useForm<API.NewTenantForm>();
const [passwordVal, setPasswordVal] = useState('');
const [selectClusterId, setSelectClusterId] = useState<number>();
const [selectClusterId, setSelectClusterId] = useState<string>();
const [clusterList, setClusterList] = useState<API.SimpleClusterList>([]);
useRequest(getSimpleClusterList, {
onSuccess: ({ successful, data }) => {
Expand All @@ -43,7 +43,7 @@ export default function New() {
});
//Selected cluster's resource name and namespace
const { name: clusterName, namespace: ns } =
clusterList.filter((cluster) => cluster.clusterId === selectClusterId)[0] ||
clusterList.filter((cluster) => cluster.id === selectClusterId)[0] ||
{};
const essentialParameter = essentialParameterRes?.data;

Expand All @@ -64,7 +64,7 @@ export default function New() {
}

const ns = clusterList.filter(
(cluster) => cluster.clusterId === selectClusterId,
(cluster) => cluster.id === selectClusterId,
)[0]?.namespace;
const res = await createTenantReportWrap({
namespace: ns,
Expand All @@ -89,7 +89,7 @@ export default function New() {

useUpdateEffect(() => {
const { name, namespace } = clusterList.find(
(cluster) => cluster.clusterId === selectClusterId,
(cluster) => cluster.id === selectClusterId,
) || {};
if (name && namespace) {
getEssentialParameters({
Expand All @@ -102,7 +102,7 @@ export default function New() {
useEffect(() => {
if (clusterList) {
const cluster = clusterList.find(
(cluster) => cluster.clusterId === selectClusterId,
(cluster) => cluster.id === selectClusterId,
);
cluster?.topology.forEach((zone) => {
form.setFieldValue(['pools', zone.zone, 'checked'], zone.checked);
Expand Down
4 changes: 2 additions & 2 deletions ui/src/pages/Tenant/helper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,13 @@ export const modifyZoneCheckedStatus = (
zone: string,
checked: boolean,
target: {
id?: number;
id?: string;
name?: string;
},
) => {
const _clusterList = cloneDeep(clusterList);
for (const cluster of _clusterList) {
if (cluster.clusterId === target.id || cluster.name === target.name) {
if (cluster.id === target.id || cluster.name === target.name) {
cluster.topology.forEach((zoneItem) => {
if (zoneItem.zone === zone) {
zoneItem.checked = checked;
Expand Down
18 changes: 9 additions & 9 deletions ui/src/services/index.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { formatTopoData } from '@/components/TopoComponent/helper';
import { formatClusterData } from '@/pages/Cluster/Detail/Overview/helper';
import { formatStatisticData } from '@/utils/helper';
import { floorToTwoDecimalPlaces,formatStatisticData } from '@/utils/helper';
import { intl } from '@/utils/intl';
import { request } from '@umijs/max';
import { floorToTwoDecimalPlaces } from '@/utils/helper';
import _ from 'lodash';
import moment from 'moment';

Expand Down Expand Up @@ -155,18 +154,19 @@ export async function getSimpleClusterList(): Promise<API.SimpleClusterListRespo
method: 'GET',
});
if (r.successful) {
return{
return {
...r,
data:r.data.map((clusterDetail) => ({
clusterId: clusterDetail.clusterId,
data: r.data.map((clusterDetail) => ({
clusterId: clusterDetail.clusterId, // clusterId is not unique
id: `${clusterDetail.namespace}:${clusterDetail.name}`,
name: clusterDetail.name,
namespace: clusterDetail.namespace,
topology: clusterDetail.topology,
clusterName: clusterDetail.clusterName,
status: clusterDetail.status
}))
}
};
status: clusterDetail.status,
})),
};
}
return r;
}

Expand Down
1 change: 1 addition & 0 deletions ui/src/type/typings.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,7 @@ declare namespace API {
namespace: string;
topology: Topology[];
status: string;
id: string;
};

type SimpleClusterList = SimpleCluster[];
Expand Down