-
Notifications
You must be signed in to change notification settings - Fork 16
feat: support remove scope #143
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
feat: support remove scope #143
Conversation
ui/src/components/Canvas.tsx
Outdated
if(node?.parentNode && !node.position.x && dragging){ | ||
node.parentNode = undefined | ||
node.data!.parent = 'ROOT' | ||
setPodParent({ id, parent: 'ROOT', dirty: false }); | ||
} |
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.
Two issues:
- this allows only dragging a pod out of a scope from left side, but not other 3 sides. This behavior sounds inconsistent.
- we need to update the position (which is relative to the parent scope), otherwise, the pod will "jump" upon moving out.
More broadly speaking, we probably want another way to dissociate the pod from the scope, other than simply dragging, because the current pod-cannot-be-moved-out behavior is useful. We could probably add a "release button" which, once clicked, temporarily remove extent: 'parent'
field to allow it to be moved out.
See more discussion on issue #99
ui/src/components/Canvas.tsx
Outdated
{/*<MiniMap*/} | ||
{/* nodeStrokeColor={(n) => {*/} | ||
{/* if (n.style?.borderColor) return n.style.borderColor;*/} | ||
{/* if (n.type === "code") return "#d6dee6";*/} | ||
{/* if (n.type === "scope") return "#f4f6f8";*/} | ||
|
||
{/* return "#d6dee6";*/} | ||
{/* }}*/} | ||
{/* nodeColor={(n) => {*/} | ||
{/* if (n.style?.backgroundColor) return n.style.backgroundColor;*/} | ||
|
||
{/* return "#f4f6f8";*/} | ||
{/* }}*/} | ||
{/* nodeBorderRadius={2}*/} | ||
{/*/>*/} |
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.
Why do you remove the minimap?
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.
Because i don't know many context about the source code , i just remove them for debug , when i make this pr ready for review , i will reset them
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.
Ah, I see, sounds good!
ui/src/components/Canvas.tsx
Outdated
{/*<Controls showInteractive={role !== RoleType.GUEST} />*/} | ||
|
||
{/*<Background />*/} |
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.
and the controls and the canvas backgrounds?
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.
Thanks, sudongyuer! There appear to be a few coding and design issues.
Yes , so i make this pr to Draft
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.
ditto
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.
Thanks, sudongyuer! There appear to be a few coding and design issues.
This is this PR's behavior Screen.Recording.2022-12-15.at.11.25.26.mov |
@sudongyuer What will happen if you move the scope after the code cell has been moved out of it? Is the parent of the cell updated to the scope at the outer layer? |
The node's parent will not change , it will remain the relationship before Screen.Recording.2022-12-15.at.12.28.48.mov |
You can see more contexts in #99 |
@sudongyuer yes, i saw the discussion in #99. Should we update the parent then? Otherwise, the code scoping is not correct. |
I just think this pr is to control the extent option in node , if you want to remove node's parent relationship , should be better add another feature to support that . Also need some suggestions from @lihebi |
Controlling only the "extent" option itself doesn't make a useful feature. We should implement the logic for updating node parent relations in this PR. |
Screen.Recording.2022-12-16.at.13.20.56.mov |
Thanks for the great PR! Please take care when updating the parent, you should update nodesMap[id].level recursively as well. My previous PR for reference: #145 |
Is recursive updating necessary? After a user clicks the "remove extent" button (the name needs to be changed later into something like "change scope") of a cell/scope, the cell/scope will move with the mouse. The user can move the mouse to move the cell/scope to where s/he sees fit and drop it there by clicking the mouse again. Just detect the node on which the mouse click happens and let it be the parent of the cell/scope just moved. |
Now when click the |
It's always necessary to update the levels of all involved nodes when any scope relationship changes. The level determines the pod color in the mini-map, we need to show everything in the mini-map correctly in time. The idea to drag and release sounds cool. But I want to make sure about something related to my implementation: what will a collaborator see during the process of changing scope? the complete movement track or nothing until it finishes? |
Thanks! When you click the release button, the pod "jumps" out. It is because you updated its parent but didn't update its position (which is relative to the parent). We don't want that jump. |
Xinyi had explained it. Just an echo: Xinyi was talking about recursively updating the "levels" property of descendant nodes, which is missing in this PR.
To make things simple, we could just drop the node to ROOT scope when the release button is clicked. We probably want to show some indicators (e.g., a highlighted shadow) to mark it global. Then we can drag-n-drop to the location.
This will no longer be a problem if we adopt the "drop-to-ROOT-scope" approach above. |
Thx xinyi ~ |
#99