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