-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix(): set default mount point to empty, refine data icon #395
Conversation
Walkthrough此次更改涉及三个主要文件,主要集中在拖放功能和节点数据处理的改进。 Changes
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (4)
🚧 Files skipped from review as they are similar to previous changes (2)
🔇 Additional comments (2)
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
bricks/next-builder/src/workbench-brick-tree/WorkbenchBrickTree.tsx (1)
Line range hint
428-445
: 优化了节点匹配逻辑通过添加
node.data.type !== "mount-point"
的类型检查,避免了对挂载点节点进行不必要的 deepMatch 调用,提高了性能和准确性。建议考虑将类型检查提取为一个独立的辅助函数,以提高代码的可维护性:
+function isMountPointNode(node: WorkbenchBrickTreeNode): boolean { + return node.type === "mount-point"; +} function matchBrickNode( node: WorkbenchNodeData<WorkbenchBrickTreeNode>, lowerTrimmedQuery?: string ): boolean { return ( - node.data.type !== "mount-point" && + !isMountPointNode(node.data) && deepMatch( isCustomTemplateNode(node.data) ? { name: node.data.name, proxy: node.data.proxy, previewSettings: node.data.previewSettings, } : isSnippetNode(node.data) ? node.name : [node.name, node.data.$$normalized], lowerTrimmedQuery ) ); }bricks/next-builder/src/preview-container/PreviewContainer.tsx (3)
Line range hint
363-370
: 建议优化拖放状态的处理逻辑当前的拖放状态判断和 mountPoint 赋值逻辑可以进一步优化,建议:
- 使用枚举类型定义拖放状态
- 将状态判断逻辑抽取为独立函数
+enum DragStatus { + Inside = 'inside', + Top = 'top', + Bottom = 'bottom' +} +const getDragStatus = (direction: Direction): DragStatus => { + if (direction === "inside") return DragStatus.Inside; + if (["top", "left"].includes(direction)) return DragStatus.Top; + return DragStatus.Bottom; +}; -const dragStatus = - direction === "inside" - ? "inside" - : ["top", "left"].includes(direction) - ? "top" - : ["right", "bottom"].includes(direction) - ? "bottom" - : ""; +const dragStatus = getDragStatus(direction);
Line range hint
365-370
: 建议优化父节点获取逻辑parentNodes 的映射操作可以使用更简洁的方式实现。
-parentNodes: parentNodes.map((node) => - omit(node, ["parent", "children"]) -), +parentNodes: parentNodes.map(({ parent, children, ...rest }) => rest),
Line range hint
32-38
: 建议添加性能优化在
getAllParentEdges
函数中,可以使用 Set 来避免重复的边缘节点。const getAllParentEdges = ( edge: BuilderRuntimeEdge, - list: number[] = [] + visited: Set<number> = new Set() ): number[] => { - list.push(edge.parent); + visited.add(edge.parent); const nodeEdge = edges.find((item) => item.child === edge.parent); if (nodeEdge) { - list = list.concat(getAllParentEdges(nodeEdge)); + getAllParentEdges(nodeEdge, visited); } - return list; + return Array.from(visited); };
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
📒 Files selected for processing (3)
- bricks/next-builder/src/custom-processors/getWorkbenchDataTree.ts (1 hunks)
- bricks/next-builder/src/preview-container/PreviewContainer.tsx (1 hunks)
- bricks/next-builder/src/workbench-brick-tree/WorkbenchBrickTree.tsx (1 hunks)
🔇 Additional comments (3)
bricks/next-builder/src/custom-processors/getWorkbenchDataTree.ts (1)
73-73
: 图标更改看起来合理,建议确认设计规范图标从 "link" 改为 "database" 在语义上更准确地表达了解析(resolve)操作可能涉及数据库查询的含义。
建议运行以下脚本验证项目中图标使用的一致性:
✅ Verification successful
Let me gather more context about the usage of database icons and related components to ensure consistency.
根据搜索结果,我可以生成最终的验证结论了。
图标使用符合设计规范,无需调整
database
图标在项目中主要用于以下场景:
- 在
WorkbenchBrickTree
中用于数据相关节点- 在事件编辑器中用于
UseProvider
类型的处理器- 在工作台数据树中用于带有
resolve
属性的节点这些使用场景都与数据获取和处理相关,显示为数据库图标符合直觉和设计语义。原来使用的
link
图标主要用于链接和跳转场景,改为database
更准确地表达了数据操作的含义。🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:检查项目中数据库相关操作是否统一使用 database 图标 # 测试:搜索其他使用 database 图标的地方 rg '"database"' --type tsLength of output: 582
Script:
#!/bin/bash # 检查 HandlerType.UseProvider 的定义和使用场景 rg "HandlerType.UseProvider" -A 2 -B 2 # 检查 WorkbenchBrickTree 中数据库图标的使用上下文 ast-grep --pattern 'icon = "database"' # 检查是否有其他数据相关的图标使用 rg '"link"|"data"|"table"' --type tsLength of output: 44398
bricks/next-builder/src/workbench-brick-tree/WorkbenchBrickTree.tsx (1)
325-325
: 将 mountPoint 的默认值设置为空字符串这个改动使得挂载点的处理更加灵活。空字符串作为默认值比硬编码的 "content" 更合适,并且与 PreviewContainer.tsx 中的变更保持一致。
让我们验证这个改动是否与其他相关文件保持一致:
✅ Verification successful
Let's gather more information about the mountPoint usage across the codebase to verify this change properly.
从搜索结果中我们可以看到关于 mountPoint 的关键信息:
- 在 PreviewContainer.tsx 中,当 dragStatus 为 "inside" 时,mountPoint 被设置为空字符串
- 在 buildStoryboardV2.ts 中,mountPoint 的默认值也是空字符串
- 这种处理方式在整个代码库中是一致的模式
让我们再确认一下这个改动的影响:
将 mountPoint 设置为空字符串是正确且一致的做法
从代码分析中可以看到:
- 在 PreviewContainer.tsx 中,当 dragStatus 为 "inside" 时,mountPoint 被设置为空字符串是有意为之的设计。
- 在 buildStoryboardV2.ts 中,mountPoint 的默认值也是空字符串。
- 这种处理方式在整个代码库中保持一致,表明这是一个标准的模式。
因此,将 mountPoint 从 "content" 改为空字符串的修改是合理的,它与现有代码库的处理逻辑保持一致。
🏁 Scripts executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # 描述:检查其他文件中的 mountPoint 赋值逻辑 # 预期:相关文件中的 mountPoint 赋值逻辑应该与此处保持一致 rg -A 3 'mountPoint.*=.*"content"'Length of output: 36
Script:
#!/bin/bash # 搜索所有包含 mountPoint 的相关代码 rg -A 3 'mountPoint.*=' # 特别关注 PreviewContainer.tsx 中的相关逻辑 fd -e tsx -e ts PreviewContainer --exec cat {} # 查找可能的挂载点相关配置或常量定义 rg -A 3 'MOUNT_POINT|mountPoints?'Length of output: 292083
Script:
#!/bin/bash # 检查 dragStatus 为 "inside" 时的 mountPoint 处理逻辑 rg -A 3 'dragStatus.*=.*"inside".*mountPoint' # 检查默认的 mountPoint 赋值 rg -A 3 'mountPoint.*=.*""'Length of output: 1427
bricks/next-builder/src/preview-container/PreviewContainer.tsx (1)
364-364
: 修改了拖放操作中的挂载点逻辑当拖放状态为 "inside" 时,将 mountPoint 设置为空字符串而不是使用 hoverEdge.mountPoint,这样可以避免不必要的嵌套层级。
1e3dde2
to
1f375c5
Compare
依赖检查
组件之间的依赖声明,是微服务组件架构下的重要信息,请确保其正确性。
请勾选以下两组选项其中之一:
或者:
提交信息检查
Git 提交信息将决定包的版本发布及自动生成的 CHANGELOG,请检查工作内容与提交信息是否相符,并在以下每组选项中都依次确认。
破坏性变更:
feat
作为提交类型。BREAKING CHANGE: 你的变更说明
。新特性:
feat
作为提交类型。问题修复:
fix
作为提交类型。杂项工作:
即所有对下游使用者无任何影响、且没有必要显示在 CHANGELOG 中的改动,例如修改注释、测试用例、开发文档等:
chore
,docs
,test
等作为提交类型。Summary by CodeRabbit
新功能
测试