Skip to content

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

Closed

Conversation

sudongyuer
Copy link

@sudongyuer sudongyuer commented Dec 13, 2022

#99

@sudongyuer sudongyuer marked this pull request as draft December 13, 2022 15:34
Comment on lines 531 to 535
if(node?.parentNode && !node.position.x && dragging){
node.parentNode = undefined
node.data!.parent = 'ROOT'
setPodParent({ id, parent: 'ROOT', dirty: false });
}
Copy link
Collaborator

@lihebi lihebi Dec 13, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Two issues:

  1. this allows only dragging a pod out of a scope from left side, but not other 3 sides. This behavior sounds inconsistent.
  2. 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

Comment on lines 1137 to 1151
{/*<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}*/}
{/*/>*/}
Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Collaborator

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!

Comment on lines 1152 to 1154
{/*<Controls showInteractive={role !== RoleType.GUEST} />*/}

{/*<Background />*/}
Copy link
Collaborator

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?

Copy link
Author

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

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ditto

Copy link
Collaborator

@lihebi lihebi left a 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.

@sudongyuer sudongyuer marked this pull request as ready for review December 14, 2022 14:04
@sudongyuer sudongyuer changed the title feat: pod dissociate from scope feat: support toggle extent Dec 14, 2022
@sudongyuer
Copy link
Author

sudongyuer commented Dec 15, 2022

This is this PR's behavior

Screen.Recording.2022-12-15.at.11.25.26.mov

@forrestbao
Copy link
Collaborator

@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?

@sudongyuer
Copy link
Author

sudongyuer commented Dec 15, 2022

@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

@sudongyuer
Copy link
Author

You can see more contexts in #99
image

@forrestbao
Copy link
Collaborator

@sudongyuer yes, i saw the discussion in #99. Should we update the parent then? Otherwise, the code scoping is not correct.

@sudongyuer
Copy link
Author

@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

@lihebi
Copy link
Collaborator

lihebi commented Dec 15, 2022

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.

@sudongyuer
Copy link
Author

Screen.Recording.2022-12-16.at.13.20.56.mov

@sudongyuer sudongyuer requested a review from lihebi December 16, 2022 05:22
@li-xin-yi
Copy link
Collaborator

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

@sudongyuer sudongyuer changed the title feat: support toggle extent feat: support remove scope Dec 16, 2022
@forrestbao
Copy link
Collaborator

forrestbao commented Dec 16, 2022

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.

@sudongyuer
Copy link
Author

sudongyuer commented Dec 16, 2022

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 remove from scope button , it will just remove the parent relationship , it's not save the relationship before , so when you click again , it will not restore the previous parent-son state , if you want to restore the previous state, you just need drag it into scope again , so recursive update is necessary now.

@li-xin-yi
Copy link
Collaborator

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.

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?

@lihebi
Copy link
Collaborator

lihebi commented Dec 19, 2022

Screen.Recording.2022-12-16.at.13.20.56.mov

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.

@lihebi
Copy link
Collaborator

lihebi commented Dec 19, 2022

[xinyi] you should update nodesMap[id].level recursively as well
[forrest] Is recursive updating necessary?
[xinyi] It's always necessary to update the levels

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.

[forrest] After a user clicks the "remove extent" button of a cell/scope, the cell/scope will move with the mouse.

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.

[xinyi] what will a collaborator see during the process of changing scope?

This will no longer be a problem if we adopt the "drop-to-ROOT-scope" approach above.

@sudongyuer sudongyuer closed this Dec 20, 2022
@sudongyuer sudongyuer reopened this Dec 20, 2022
@sudongyuer
Copy link
Author

Thx xinyi ~

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants