chore: os image filter
This commit is contained in:
@@ -18,6 +18,7 @@ import FooterButtons from './components/footer-buttons';
|
|||||||
import ProviderCatalog from './components/provider-catalog';
|
import ProviderCatalog from './components/provider-catalog';
|
||||||
import { ProviderType, ProviderValueMap } from './config';
|
import { ProviderType, ProviderValueMap } from './config';
|
||||||
import providerList from './config/providers';
|
import providerList from './config/providers';
|
||||||
|
import { StepsContext } from './config/steps-context';
|
||||||
import { ClusterFormData } from './config/types';
|
import { ClusterFormData } from './config/types';
|
||||||
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';
|
||||||
@@ -89,6 +90,7 @@ const ClusterCreate = () => {
|
|||||||
}));
|
}));
|
||||||
}, [action, extraData.provider, stepList]);
|
}, [action, extraData.provider, stepList]);
|
||||||
|
|
||||||
|
// before moving to the next step, get all form values
|
||||||
const getFormFieldsValue = () => {
|
const getFormFieldsValue = () => {
|
||||||
setFormValues((prev) => {
|
setFormValues((prev) => {
|
||||||
const newFormValues = _.cloneDeep(prev);
|
const newFormValues = _.cloneDeep(prev);
|
||||||
@@ -206,7 +208,7 @@ const ClusterCreate = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* this function is used to render the modules in the current step
|
* this function is used to render the modules in the current step, they are not forms
|
||||||
* @returns
|
* @returns
|
||||||
*/
|
*/
|
||||||
const renderModules = () => {
|
const renderModules = () => {
|
||||||
@@ -304,10 +306,16 @@ const ClusterCreate = () => {
|
|||||||
current={extraData.provider}
|
current={extraData.provider}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
{renderModules()}
|
<StepsContext.Provider
|
||||||
<Container>
|
value={{
|
||||||
<Content>{renderForms()}</Content>
|
formValues: formValues
|
||||||
</Container>
|
}}
|
||||||
|
>
|
||||||
|
{renderModules()}
|
||||||
|
<Container>
|
||||||
|
<Content>{renderForms()}</Content>
|
||||||
|
</Container>
|
||||||
|
</StepsContext.Provider>
|
||||||
</div>
|
</div>
|
||||||
</PageContainerInner>
|
</PageContainerInner>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -24,10 +24,12 @@ import React, {
|
|||||||
forwardRef,
|
forwardRef,
|
||||||
useEffect,
|
useEffect,
|
||||||
useImperativeHandle,
|
useImperativeHandle,
|
||||||
|
useMemo,
|
||||||
useState
|
useState
|
||||||
} from 'react';
|
} from 'react';
|
||||||
import styled from 'styled-components';
|
import styled from 'styled-components';
|
||||||
import { ProviderType, instanceTypeFieldMap, vendorIconMap } from '../config';
|
import { ProviderType, instanceTypeFieldMap, vendorIconMap } from '../config';
|
||||||
|
import { useStepsContext } from '../config/steps-context';
|
||||||
import { NodePoolFormData as FormData } from '../config/types';
|
import { NodePoolFormData as FormData } from '../config/types';
|
||||||
import VolumesConfig from './volumes-config';
|
import VolumesConfig from './volumes-config';
|
||||||
|
|
||||||
@@ -85,15 +87,6 @@ const NotFoundContent = () => {
|
|||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
const NotFoundImageContent = () => {
|
|
||||||
const intl = useIntl();
|
|
||||||
return (
|
|
||||||
<NoContent>
|
|
||||||
{intl.formatMessage({ id: 'clusters.create.noImages' })}
|
|
||||||
</NoContent>
|
|
||||||
);
|
|
||||||
};
|
|
||||||
|
|
||||||
const RenderLabel = (data: {
|
const RenderLabel = (data: {
|
||||||
label: React.ReactNode;
|
label: React.ReactNode;
|
||||||
vendor: string;
|
vendor: string;
|
||||||
@@ -179,6 +172,7 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
currentData,
|
currentData,
|
||||||
collapseProps
|
collapseProps
|
||||||
} = props;
|
} = props;
|
||||||
|
const { formValues } = useStepsContext();
|
||||||
const [instanceTypeList] = useAtom(regionInstanceTypeListAtom);
|
const [instanceTypeList] = useAtom(regionInstanceTypeListAtom);
|
||||||
const [osImageList] = useAtom(regionOSImageListAtom);
|
const [osImageList] = useAtom(regionOSImageListAtom);
|
||||||
const { collapsible, onToggle, ...restCollapseProps } = collapseProps || {};
|
const { collapsible, onToggle, ...restCollapseProps } = collapseProps || {};
|
||||||
@@ -200,6 +194,13 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
}, [currentData]);
|
}, [currentData]);
|
||||||
|
|
||||||
|
const imageList = useMemo(() => {
|
||||||
|
if (instanceSpec.count === 8) {
|
||||||
|
return osImageList.filter((item) => item.value === 'gpu-h100x8-base');
|
||||||
|
}
|
||||||
|
return osImageList;
|
||||||
|
}, [osImageList, instanceSpec]);
|
||||||
|
|
||||||
const imageLabelRender = (data: {
|
const imageLabelRender = (data: {
|
||||||
label: React.ReactNode;
|
label: React.ReactNode;
|
||||||
value: string | number;
|
value: string | number;
|
||||||
@@ -250,14 +251,16 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
...option.specInfo,
|
...option.specInfo,
|
||||||
label: option.label,
|
label: option.label,
|
||||||
vendor: option.vendor,
|
vendor: option.vendor,
|
||||||
description: option.description
|
description: option.description,
|
||||||
|
count: option.count
|
||||||
});
|
});
|
||||||
form.setFieldsValue({
|
form.setFieldsValue({
|
||||||
instance_spec: {
|
instance_spec: {
|
||||||
...option.specInfo,
|
...option.specInfo,
|
||||||
label: option.label,
|
label: option.label,
|
||||||
vendor: option.vendor,
|
vendor: option.vendor,
|
||||||
description: option.description
|
description: option.description,
|
||||||
|
count: option.count
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
@@ -422,7 +425,7 @@ const PoolForm: React.FC<AddModalProps> = forwardRef((props, ref) => {
|
|||||||
}
|
}
|
||||||
labelRender={imageLabelRender}
|
labelRender={imageLabelRender}
|
||||||
placeholder={currentData?.image_name}
|
placeholder={currentData?.image_name}
|
||||||
options={osImageList}
|
options={imageList}
|
||||||
disabled={action === PageAction.EDIT}
|
disabled={action === PageAction.EDIT}
|
||||||
label={intl.formatMessage({
|
label={intl.formatMessage({
|
||||||
id: 'clusters.workerpool.osImage'
|
id: 'clusters.workerpool.osImage'
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
import { createContext, useContext } from 'react';
|
||||||
|
|
||||||
|
export interface StepsContextProps {
|
||||||
|
formValues: Record<string, any>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export const StepsContext = createContext<StepsContextProps>({
|
||||||
|
formValues: {}
|
||||||
|
});
|
||||||
|
|
||||||
|
export const useStepsContext = () => useContext(StepsContext);
|
||||||
@@ -126,6 +126,7 @@ export const useProviderRegions = () => {
|
|||||||
const label = formatLabel(item);
|
const label = formatLabel(item);
|
||||||
const description = `${label} ${item.gpu_info?.count}X`;
|
const description = `${label} ${item.gpu_info?.count}X`;
|
||||||
return {
|
return {
|
||||||
|
count: item.gpu_info?.count,
|
||||||
label: `${description} - ${formatSpec(specInfo)}`,
|
label: `${description} - ${formatSpec(specInfo)}`,
|
||||||
value: item.slug,
|
value: item.slug,
|
||||||
description: description,
|
description: description,
|
||||||
@@ -171,9 +172,12 @@ export const useProviderRegions = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
const updateOSImages = (region: string, allImages?: any[]) => {
|
const updateOSImages = (region: string, allImages?: any[]) => {
|
||||||
const list = (allImages || allOSImageList).filter((item) =>
|
const list = (allImages || allOSImageList).filter(
|
||||||
item.regions.includes(region)
|
(item) =>
|
||||||
|
item.regions.includes(region) &&
|
||||||
|
['debian', 'ubuntu'].includes(item.vendor)
|
||||||
);
|
);
|
||||||
|
console.log('osimagelist========', list);
|
||||||
setOSImageList(list);
|
setOSImageList(list);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -108,7 +108,6 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
}
|
}
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
console.log('gatherFormValues========', resultList);
|
|
||||||
return resultList.filter((item) => item);
|
return resultList.filter((item) => item);
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -135,7 +134,6 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
const newWorkerPools = worker_pools.map(
|
const newWorkerPools = worker_pools.map(
|
||||||
(poolData: NodePoolFormData, index: number) => [index, poolData]
|
(poolData: NodePoolFormData, index: number) => [index, poolData]
|
||||||
);
|
);
|
||||||
console.log('newWorkerPools========', newWorkerPools);
|
|
||||||
setWorkerPoolList(new Map(newWorkerPools));
|
setWorkerPoolList(new Map(newWorkerPools));
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -143,14 +141,12 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
const values = Object.values(formRefs.current).map((form) =>
|
const values = Object.values(formRefs.current).map((form) =>
|
||||||
form?.getFieldsValue()
|
form?.getFieldsValue()
|
||||||
);
|
);
|
||||||
console.log('getFieldsValue========', values);
|
|
||||||
return {
|
return {
|
||||||
worker_pools: values
|
worker_pools: values
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleOnToggle = (open: boolean, key: number) => {
|
const handleOnToggle = (open: boolean, key: number) => {
|
||||||
console.log('Active keys changed:', key);
|
|
||||||
if (open) {
|
if (open) {
|
||||||
setActiveKey((prev) => new Set([key]));
|
setActiveKey((prev) => new Set([key]));
|
||||||
} else {
|
} else {
|
||||||
@@ -170,7 +166,6 @@ const WorkerPoolsForm = forwardRef((props: WorkerPoolsFormProps, ref) => {
|
|||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
if (currentData) {
|
if (currentData) {
|
||||||
console.log('currentData===========1=', currentData);
|
|
||||||
setFieldsValue(currentData);
|
setFieldsValue(currentData);
|
||||||
}
|
}
|
||||||
}, [currentData]);
|
}, [currentData]);
|
||||||
|
|||||||
Reference in New Issue
Block a user