feat: add env field in deploy form
This commit is contained in:
@@ -33,7 +33,6 @@ const LabelSelector: React.FC<LabelSelectorProps> = ({
|
||||
});
|
||||
setLabelList(list);
|
||||
}
|
||||
console.log('labelsData=========', labelsData);
|
||||
}, [labels]);
|
||||
|
||||
const handleLabelListChange = useCallback(
|
||||
|
||||
@@ -26,6 +26,7 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
||||
}) => {
|
||||
const intl = useIntl();
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
const boxRef = useRef<HTMLDivElement>(null);
|
||||
|
||||
const updateLabels = (list: { key: string; value: string }[]) => {
|
||||
const newLabels = _.reduce(
|
||||
@@ -57,11 +58,6 @@ const Inner: React.FC<LabelSelectorProps> = ({
|
||||
];
|
||||
onLabelListChange(newLabelList);
|
||||
updateLabels(newLabelList);
|
||||
|
||||
setTimeout(() => {
|
||||
// button scroll to view
|
||||
buttonRef.current?.scrollIntoView?.({ behavior: 'smooth' });
|
||||
}, 100);
|
||||
};
|
||||
|
||||
const handleOnDelete = (index: string) => {
|
||||
|
||||
@@ -51,9 +51,9 @@ const ListInput: React.FC<ListInputProps> = (props) => {
|
||||
uid: countRef.current
|
||||
});
|
||||
setList(values);
|
||||
setTimeout(() => {
|
||||
buttonRef.current?.scrollIntoView?.({ behavior: 'smooth' });
|
||||
}, 100);
|
||||
// setTimeout(() => {
|
||||
// buttonRef.current?.scrollIntoView?.({ behavior: 'smooth' });
|
||||
// }, 100);
|
||||
};
|
||||
|
||||
React.useEffect(() => {
|
||||
|
||||
@@ -213,9 +213,11 @@ export default {
|
||||
'common.title.stop.confirm': 'Confirm stop',
|
||||
'common.title.start.confirm': 'Confirm start',
|
||||
'common.title.recreate.confirm': 'Confirm recreate',
|
||||
'common.button.addLabel': 'Add Labels',
|
||||
'common.button.addSelector': 'Add Selectors',
|
||||
'common.button.addLabel': 'Add Label',
|
||||
'common.button.addSelector': 'Add Selector',
|
||||
'common.button.addParams': 'Add Parameter',
|
||||
'common.button.vars': 'Add Variable',
|
||||
'common.text.variable': 'Variable',
|
||||
'common.text.here': 'here',
|
||||
'common.text.latest': 'Latest',
|
||||
'common.text.new': 'New',
|
||||
|
||||
@@ -10,6 +10,7 @@ export default {
|
||||
'models.form.filename': 'File Name',
|
||||
'models.form.replicas': 'Replicas',
|
||||
'models.form.selector': 'Selector',
|
||||
'models.form.env': 'Environment Variables',
|
||||
'models.form.configurations': 'Configurations',
|
||||
'models.form.s3address': 'S3 Address',
|
||||
'models.form.partialoffload.tips':
|
||||
|
||||
@@ -209,6 +209,8 @@ export default {
|
||||
'common.button.addLabel': '添加标签',
|
||||
'common.button.addSelector': '添加选择器',
|
||||
'common.button.addParams': '添加参数',
|
||||
'common.button.vars': '添加变量',
|
||||
'common.text.variable': '变量',
|
||||
'common.text.here': '这里',
|
||||
'common.text.latest': '最新',
|
||||
'common.text.new': '新',
|
||||
|
||||
@@ -10,6 +10,7 @@ export default {
|
||||
'models.form.filename': '文件名',
|
||||
'models.form.replicas': '副本数',
|
||||
'models.form.selector': '选择器',
|
||||
'models.form.env': '环境变量',
|
||||
'models.form.configurations': '配置',
|
||||
'models.form.s3address': 'S3 地址',
|
||||
'models.form.partialoffload.tips':
|
||||
|
||||
@@ -43,6 +43,7 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
|
||||
const intl = useIntl();
|
||||
const wokerSelector = Form.useWatch('worker_selector', form);
|
||||
const EnviromentVars = Form.useWatch('env', form);
|
||||
const scheduleType = Form.useWatch('scheduleType', form);
|
||||
const backend = Form.useWatch('backend', form);
|
||||
const backend_parameters = Form.useWatch('backend_parameters', form);
|
||||
@@ -118,6 +119,12 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
},
|
||||
[]
|
||||
);
|
||||
const handleEnviromentVarsChange = useCallback(
|
||||
(labels: Record<string, any>) => {
|
||||
form.setFieldValue('env', labels);
|
||||
},
|
||||
[]
|
||||
);
|
||||
|
||||
const handleBackendParametersChange = useCallback((list: string[]) => {
|
||||
form.setFieldValue('backend_parameters', list);
|
||||
@@ -201,6 +208,41 @@ const AdvanceConfig: React.FC<AdvanceConfigProps> = (props) => {
|
||||
}
|
||||
></SealSelect>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="env"
|
||||
rules={[
|
||||
() => ({
|
||||
validator(rule, value) {
|
||||
if (_.keys(value).length > 0) {
|
||||
if (_.some(_.keys(value), (k: string) => !value[k])) {
|
||||
return Promise.reject(
|
||||
intl.formatMessage(
|
||||
{
|
||||
id: 'common.validate.value'
|
||||
},
|
||||
{
|
||||
name: intl.formatMessage({
|
||||
id: 'common.text.variable'
|
||||
})
|
||||
}
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
return Promise.resolve();
|
||||
}
|
||||
})
|
||||
]}
|
||||
>
|
||||
<LabelSelector
|
||||
label={intl.formatMessage({
|
||||
id: 'models.form.env'
|
||||
})}
|
||||
labels={EnviromentVars}
|
||||
btnText="common.button.vars"
|
||||
onChange={handleEnviromentVarsChange}
|
||||
></LabelSelector>
|
||||
</Form.Item>
|
||||
<Form.Item<FormData>
|
||||
name="worker_selector"
|
||||
rules={[
|
||||
|
||||
@@ -31,6 +31,7 @@ export interface ListItem {
|
||||
|
||||
export interface FormData {
|
||||
backend: string;
|
||||
env?: Record<string, any>;
|
||||
size?: number;
|
||||
quantization?: number;
|
||||
categories?: string[];
|
||||
|
||||
Reference in New Issue
Block a user