From 279e095fbd584d589bbc379f4d5da1f7a28cadc9 Mon Sep 17 00:00:00 2001 From: noneAuth Date: Mon, 25 Mar 2024 15:28:20 +0800 Subject: [PATCH 1/5] fix: adding edges without restricting primary keys --- .../graph-construct/add-nodes-edges/index.tsx | 30 ++++++++++++------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx b/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx index b591e305..9e0e0d59 100644 --- a/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx +++ b/client/src/components/studio/domain-core/graph-construct/add-nodes-edges/index.tsx @@ -38,14 +38,17 @@ export const AddNodesEdges: React.FC = ({ onVisible, }) => { const [form] = Form.useForm(); + const { visible, onShow, onClose } = useVisible({ defaultVisible: true }); - const isNode = type === 'node'; + const [state, updateState] = useImmer<{ startList: Array; attrList: Array; configList: Array; + isNode: boolean; }>({ startList: [], + isNode: true, attrList: [ { id: 'primary-key', @@ -64,7 +67,11 @@ export const AddNodesEdges: React.FC = ({ useEffect(() => { onVisible?.(visible); }, [visible]); - + useEffect(() => { + updateState(draft => { + draft.isNode = type === 'node'; + }); + }, [type]); const propertyList = () => { const attrPropertyNames = map( filter(attrList, attr => !attr.optional && !attr.primaryField), @@ -195,10 +202,11 @@ export const AddNodesEdges: React.FC = ({ inputType: EditType.SELECT, prop: { defaultValue: false, - disabled: record.primaryField, + disabled: state.isNode && record.primaryField, options: [ { - label: record.primaryField ? '否(主键)' : '否', + label: + state.isNode && record.primaryField ? '否(主键)' : '否', value: false, }, { label: '是', value: true }, @@ -212,7 +220,7 @@ export const AddNodesEdges: React.FC = ({ dataIndex: 'operate', key: 'operate', render: (_, record: any) => - record.primaryField ? ( + state.isNode && record.primaryField ? (