fix: edit worker pool miss data
This commit is contained in:
@@ -20,6 +20,7 @@ import { ProviderType, ProviderValueMap } from './config';
|
|||||||
import providerList from './config/providers';
|
import providerList from './config/providers';
|
||||||
import { StepsContext } from './config/steps-context';
|
import { StepsContext } from './config/steps-context';
|
||||||
import { ClusterFormData } from './config/types';
|
import { ClusterFormData } from './config/types';
|
||||||
|
import useSystemConfig from './services/use-system-config';
|
||||||
import { moduleMap, moduleRegistry } from './step-forms/module-registry';
|
import { moduleMap, moduleRegistry } from './step-forms/module-registry';
|
||||||
import useStepList from './step-forms/use-step-list';
|
import useStepList from './step-forms/use-step-list';
|
||||||
|
|
||||||
@@ -38,6 +39,7 @@ const ClusterCreate = () => {
|
|||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const startStep = 0;
|
const startStep = 0;
|
||||||
const stepList = useStepList();
|
const stepList = useStepList();
|
||||||
|
const { systemConfig } = useSystemConfig();
|
||||||
const [searchParams] = useSearchParams();
|
const [searchParams] = useSearchParams();
|
||||||
const action =
|
const action =
|
||||||
(searchParams.get('action') as PageActionType) || PageAction.CREATE;
|
(searchParams.get('action') as PageActionType) || PageAction.CREATE;
|
||||||
@@ -308,7 +310,8 @@ const ClusterCreate = () => {
|
|||||||
)}
|
)}
|
||||||
<StepsContext.Provider
|
<StepsContext.Provider
|
||||||
value={{
|
value={{
|
||||||
formValues: formValues
|
formValues: formValues,
|
||||||
|
systemConfig: systemConfig
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
{renderModules()}
|
{renderModules()}
|
||||||
|
|||||||
@@ -10,9 +10,9 @@ import { useAtom } from 'jotai';
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import React, { useEffect } from 'react';
|
import React, { useEffect } from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
|
import { useStepsContext } from '../config/steps-context';
|
||||||
import { ClusterFormData as FormData } from '../config/types';
|
import { ClusterFormData as FormData } from '../config/types';
|
||||||
import { useProviderRegions } from '../hooks/use-provider-regions';
|
import { useProviderRegions } from '../hooks/use-provider-regions';
|
||||||
import useSystemConfig from '../services/use-system-config';
|
|
||||||
|
|
||||||
const OptionItem = styled.div`
|
const OptionItem = styled.div`
|
||||||
display: flex;
|
display: flex;
|
||||||
@@ -47,7 +47,6 @@ const NotFoundCredentialContent: React.FC = () => {
|
|||||||
const [, setFromClusterCreation] = useAtom(fromClusterCreationAtom);
|
const [, setFromClusterCreation] = useAtom(fromClusterCreationAtom);
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const handleOnClick = () => {
|
const handleOnClick = () => {
|
||||||
console.log('click add credential');
|
|
||||||
setFromClusterCreation(true);
|
setFromClusterCreation(true);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -76,7 +75,7 @@ const optionRender = (option: any): React.ReactNode => {
|
|||||||
const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
const CloudProvider: React.FC<CloudProviderProps> = (props) => {
|
||||||
const { credentialList, action, credentialID } = props;
|
const { credentialList, action, credentialID } = props;
|
||||||
const intl = useIntl();
|
const intl = useIntl();
|
||||||
const { systemConfig } = useSystemConfig();
|
const { systemConfig } = useStepsContext();
|
||||||
const form = Form.useFormInstance<FormData>();
|
const form = Form.useFormInstance<FormData>();
|
||||||
|
|
||||||
const {
|
const {
|
||||||
|
|||||||
@@ -184,25 +184,36 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentData) {
|
if (currentData) {
|
||||||
// when change the region, shoudle check the instance type and the os Image.
|
if (action === PageAction.CREATE) {
|
||||||
const selectOSImage = osImageList.find(
|
// when change the region, shoudle check the instance type and the os Image.
|
||||||
(item) => item.os_image === currentData.os_image
|
const selectOSImage = osImageList.find(
|
||||||
);
|
(item) => item.os_image === currentData.os_image
|
||||||
const selectInstanceType = instanceTypeList.find(
|
);
|
||||||
(item) => item.value === currentData.instance_type
|
const selectInstanceType = instanceTypeList.find(
|
||||||
);
|
(item) => item.value === currentData.instance_type
|
||||||
form.setFieldsValue({
|
);
|
||||||
...currentData,
|
|
||||||
instance_type: selectInstanceType?.value || '',
|
|
||||||
os_image: selectOSImage?.os_image || '',
|
|
||||||
image_name: selectOSImage?.value || ''
|
|
||||||
});
|
|
||||||
|
|
||||||
setInstanceSpec(() => {
|
form.setFieldsValue({
|
||||||
return selectInstanceType ? currentData.instance_spec : {};
|
...currentData,
|
||||||
});
|
instance_type: selectInstanceType?.value || '',
|
||||||
|
os_image: selectOSImage?.os_image || '',
|
||||||
|
image_name: selectOSImage?.value || ''
|
||||||
|
});
|
||||||
|
|
||||||
|
setInstanceSpec(() => {
|
||||||
|
return selectInstanceType ? currentData.instance_spec : {};
|
||||||
|
});
|
||||||
|
} else if (action === PageAction.EDIT) {
|
||||||
|
form.setFieldsValue({
|
||||||
|
...currentData
|
||||||
|
});
|
||||||
|
|
||||||
|
setInstanceSpec(() => {
|
||||||
|
return currentData.instance_spec || {};
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}, [currentData, instanceTypeList, osImageList]);
|
}, [currentData, instanceTypeList, osImageList, action]);
|
||||||
|
|
||||||
const updateImageList = useMemoizedFn((instanceSpec: Record<string, any>) => {
|
const updateImageList = useMemoizedFn((instanceSpec: Record<string, any>) => {
|
||||||
if (instanceSpec.count === 8) {
|
if (instanceSpec.count === 8) {
|
||||||
|
|||||||
@@ -2,10 +2,12 @@ import { createContext, useContext } from 'react';
|
|||||||
|
|
||||||
export interface StepsContextProps {
|
export interface StepsContextProps {
|
||||||
formValues: Record<string, any>;
|
formValues: Record<string, any>;
|
||||||
|
systemConfig?: Record<string, any>;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const StepsContext = createContext<StepsContextProps>({
|
export const StepsContext = createContext<StepsContextProps>({
|
||||||
formValues: {}
|
formValues: {},
|
||||||
|
systemConfig: {}
|
||||||
});
|
});
|
||||||
|
|
||||||
export const useStepsContext = () => useContext(StepsContext);
|
export const useStepsContext = () => useContext(StepsContext);
|
||||||
|
|||||||
Reference in New Issue
Block a user