Skip to content

Commit

Permalink
fix: optimize variable panel scroll ui & onCancel bug (#166)
Browse files Browse the repository at this point in the history
  • Loading branch information
BoBoooooo authored May 30, 2024
1 parent f83c6bc commit a0ed57f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 3 deletions.
15 changes: 13 additions & 2 deletions packages/designer/src/components/variable-tree/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ export function VariableTree(props: VariableTreeProps) {

return (
<Box display="flex" columnGap="l" className="VariableTree" css={varTreeStyle} {...rest}>
<Box className="VariableList" width="40%">
<Box className="VariableList" width="40%" overflow="auto">
{renderHeaderExtra?.(props, state)}
<Box mb="m" position="sticky" top="0" bg="white" zIndex={2}>
<Search placeholder="请输入变量名" onChange={(val) => setKeyword(val?.trim())} />
Expand Down Expand Up @@ -203,7 +203,11 @@ export function VariableTree(props: VariableTreeProps) {
<Box flex="0 0 72px" textAlign="right">
{node.showRemoveButton && (
<Popconfirm
zIndex={99999}
title={`确认删除吗 ${node.title}?该操作会导致引用此模型的代码报错,请谨慎操作!`}
onCancel={(e) => {
e.stopPropagation();
}}
onConfirm={(e) => {
e.stopPropagation();
if (isStoreVariablePath(node.key)) {
Expand Down Expand Up @@ -333,7 +337,14 @@ export function VariableTree(props: VariableTreeProps) {
}}
/>
) : (
<ValueDefine data={activeNode} onSave={onUpdateStoreVariable} />
<ValueDefine
data={activeNode}
onSave={(variableKey, code) => {
onUpdateStoreVariable(variableKey, code);
// 更新当前节点 code
setActiveNode((pre) => ({ ...pre, raw: code }));
}}
/>
)
}
</ValueDetail>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ export function ValueDefine({ data, onSave = noop }: ValueDefineProps) {
onClick={() => {
off();
setError('');
// 重置到原始值
setValue(data.raw);
}}
>
取消
Expand Down
3 changes: 2 additions & 1 deletion packages/designer/src/sidebar/variable-panel.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export const VariablePanel = observer(
新建模型
</Button>
}
bodyProps={{ p: 'm' }}
bodyProps={{ p: 'm', height: '100%' }}
>
{isAdd ? (
<AddStoreForm
Expand All @@ -42,6 +42,7 @@ export const VariablePanel = observer(
/>
) : (
<VariableTree
height="100%"
defaultValueDetailMode="define"
dataSource={storeVariables}
onAddStoreVariable={(storeName, data) => {
Expand Down

0 comments on commit a0ed57f

Please sign in to comment.