Skip to content
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

Core 617 orphan collection #215

Merged
merged 4 commits into from
Jan 16, 2025
Merged

Conversation

TylerZeroMaster
Copy link
Contributor

https://openstax.atlassian.net/browse/CORE-617

Screenshot 2025-01-02 at 2 09 30 PM

I also fixed a problem where ancillary tree items were being rendered with the same icon as a subbook despite being closer to pages.

Copy link
Member

@Dantemss Dantemss left a comment

Choose a reason for hiding this comment

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

My first time looking at this codebase, but I'll give it a shot

}

async renameNode(node: BookOrTocNode) {
// TODO Implement the rename functionality using inline editing (wait for the API to be available)
// https://github.com/microsoft/vscode/issues/97190
// https://stackoverflow.com/questions/70594061/change-an-existing-label-name-in-tree-view-vscode-extension
let oldTitle: string | undefined = ''
if (node.type !== BookRootNode.Singleton && 'title' in node.value) {
/* istanbul ignore next */
if (isClientTocNode(node)) {
Copy link
Member

Choose a reason for hiding this comment

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

The naming seems a bit confusing because isClientTocNode and ClientOnlyTocKinds seem to mean opposite things. Maybe isServerTocNode? Or isClientOnlyTocNode and invert the logic?

Copy link
Contributor Author

@TylerZeroMaster TylerZeroMaster Jan 14, 2025

Choose a reason for hiding this comment

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

What about isTocLeafNode? The function is for checking if the node can be moved/renamed/deleted (leaf nodes).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree that this was a little confusing. My goal was to illustrate that the orphan collection is something that is specific to the tree view. I did not want to entangle it with the ClientTocNode. I replaced the ClientOnlyTocKinds enum with an OrphanCollectionKind constant in hopes of making the difference more clear.

dragging.type !== BookRootNode.Singleton
) {
if (target.type === ClientOnlyTocKinds.OrphanCollection) {
await this.removeNode(dragging)
Copy link
Member

Choose a reason for hiding this comment

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

So they never get put in the OrphanCollection, they just go under it somehow? How does the OrphanCollection actually gets elements, like in your screenshot?

Copy link
Contributor Author

@TylerZeroMaster TylerZeroMaster Jan 14, 2025

Choose a reason for hiding this comment

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

  • Orphans are sent by the language server here after the remove event is handled.
  • This updates the client's toc tree with books and orphans.
  • Orphans are added to the OrphanCollection here on update.
  • The OrphanCollection is added as the last top level tree item here and rendered here and then the OrphanCollection's children are eventually returned here.

So the language server is telling the client which modules are orphaned and the client renders them under the orphan collection.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Also, here's a video instead of a screenshot.

Screen.Recording.2025-01-14.at.5.06.57.PM.mov

Use OrphanCollectionKind instead
Copy link
Member

@Dantemss Dantemss left a comment

Choose a reason for hiding this comment

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

Thanks for the clarifications, and the change looks good to me.

@TylerZeroMaster TylerZeroMaster merged commit 99943cc into main Jan 16, 2025
1 check passed
@TylerZeroMaster TylerZeroMaster deleted the core-617-orphan-collection branch January 16, 2025 20:33
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.

2 participants