Skip to content

Commit

Permalink
Merge pull request #701 from easyops-cn/alex/CMDB_INSTANCE-2129
Browse files Browse the repository at this point in the history
feat(): cmdb实例编辑支持手动验证
  • Loading branch information
willc001 authored Dec 17, 2024
2 parents 0b0ca6f + 386a83a commit e5e78db
Showing 1 changed file with 31 additions and 13 deletions.
44 changes: 31 additions & 13 deletions libs/cmdb-instances/src/model-attribute-form/ModelAttributeForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ interface ModelAttributeFormProps extends FormComponentProps {
};
isResetInstanceNameWhenSaveAndContinueToAddInstance?: boolean;
uploadConfig?: UploadConfig;
useManualVerification?: boolean;
ref?: any;
}

export type attributesFieldsByTag = [string, ModifiedModelObjectField[]];
Expand Down Expand Up @@ -399,8 +401,12 @@ export class ModelAttributeForm extends Component<
}
};
/* istanbul ignore next */
handleSubmit = (e: FormEvent, type?: string) => {
e.preventDefault();
public handleSubmit = (e?: FormEvent, type?: string) => {
// 允许不传入 event 参数
if (e) {
e.preventDefault();
}

this.props.scrollToFirstError
? this.props.form.validateFieldsAndScroll(
{
Expand Down Expand Up @@ -655,16 +661,17 @@ export class ModelAttributeForm extends Component<
label={
<span>
<span>{attribute.name}</span>
{attribute.description && attribute.description !== "" && (
<Tooltip title={attribute.description}>
<ExclamationCircleFilled
style={{
padding: "0 2px",
color: "var(--color-secondary-text)",
}}
/>
</Tooltip>
)}
{attribute.description &&
attribute.description !== "" && (
<Tooltip title={attribute.description}>
<ExclamationCircleFilled
style={{
padding: "0 2px",
color: "var(--color-secondary-text)",
}}
/>
</Tooltip>
)}
</span>
}
key={attribute.name}
Expand Down Expand Up @@ -827,11 +834,22 @@ export class ModelAttributeForm extends Component<
return (
<Form>
{collapse}
{submitContainer}
{!this.props.useManualVerification && submitContainer}
</Form>
);
}
}

export const InstanceModelAttributeForm =
Form.create<ModelAttributeFormProps>()(ModelAttributeForm);

export const InstanceModelAttributeFormRef = React.forwardRef<
ModelAttributeForm,
ModelAttributeFormProps
>((props, ref) => {
const WrappedForm = Form.create<ModelAttributeFormProps & { ref: any }>()(
ModelAttributeForm
) as any;
return <WrappedForm {...props} wrappedComponentRef={ref} />;
});
InstanceModelAttributeFormRef.displayName = "InstanceModelAttributeFormRef";

0 comments on commit e5e78db

Please sign in to comment.