Skip to content

feat(extendRoutes): allow relative paths in EditableTreeNode #431

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
wants to merge 17 commits into from

Conversation

robertmoura
Copy link
Contributor

@robertmoura robertmoura commented Jun 25, 2024

BREAKING CHANGE: allow relative path overrides

Closes #341

  • Support relative paths for EditableTreeNode
  • Require absolute paths at the base of the tree and the root's children

Copy link
Owner

@posva posva left a comment

Choose a reason for hiding this comment

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

Could you add a test? I would like to see the error reproduced

@robertmoura
Copy link
Contributor Author

robertmoura commented Jun 25, 2024

I'm not entirely sure how the trees are structured or created. I had to update the code to check that the parent was the root. Can you think of any cases where this would not work?

@robertmoura robertmoura requested a review from posva June 25, 2024 23:18
@posva
Copy link
Owner

posva commented Jun 26, 2024

Do you have a bug reproduction? This doesn't seem to be fixing something 😅
Changing paths with non absolute routes is not supported yet #341

@robertmoura
Copy link
Contributor Author

robertmoura commented Jun 26, 2024

Quite right! It's actually more of a feature 😊 #341 is exactly the problem I was trying to solve 😊

@robertmoura robertmoura changed the title fix(extendRoutes): override child with relative paths feat(extendRoutes): override child with relative paths Jun 26, 2024
@robertmoura robertmoura changed the title feat(extendRoutes): override child with relative paths feat(extendRoutes): non absolute paths in EditableTreeNode Jun 26, 2024
@robertmoura
Copy link
Contributor Author

robertmoura commented Jun 26, 2024

I think I'm seeing the problem now. Here's a snippet out of TreeNode. The path is assumed to be relative (a path segment) or absolute if there is a path override. Interesting behaviour... There has to be a bit more thought put into this. The way I'd expect this to work would mean that the current behaviour would be broken. Just going to close this for now 😊 I might come up with something later. We'll see 😄

  get path() {
    return (
      this.value.overrides.path ??
      (this.parent?.isRoot() ? '/' : '') + this.value.pathSegment
    )
  }

@robertmoura robertmoura changed the title feat(extendRoutes): non absolute paths in EditableTreeNode feat(extendRoutes): allow relative paths in EditableTreeNode Jun 28, 2024
@robertmoura robertmoura reopened this Jun 28, 2024
@robertmoura
Copy link
Contributor Author

robertmoura commented Jun 28, 2024

If we were to make a slight change to the behaviour of the TreeNode's fullPath getter I think relative paths could be supported. It would be a breaking change though. Can you see any reasons why this would be a bad idea?

I just need to think a little about what this would mean for the route block and definePage.

@robertmoura robertmoura marked this pull request as draft June 28, 2024 05:02
@posva
Copy link
Owner

posva commented Jun 28, 2024

The fullPath shouldn’t change its behavior, or at least it shouldn’t be needed

@robertmoura
Copy link
Contributor Author

I'll have a look at where it is being used and see if I can remove it 😊

@robertmoura
Copy link
Contributor Author

Sorry, I was overcomplicating this a lot. I didn't realise that you could have absolute paths as child routes. I just assumed you had to put an extra / in the URL or something. Does what I'm doing now make more sense?

@robertmoura robertmoura requested a review from posva June 28, 2024 06:53
Copy link

codecov bot commented Jun 28, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 73.61%. Comparing base (75160e0) to head (16807d7).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #431      +/-   ##
==========================================
+ Coverage   73.29%   73.61%   +0.31%     
==========================================
  Files          34       34              
  Lines        5767     5775       +8     
  Branches      581      589       +8     
==========================================
+ Hits         4227     4251      +24     
+ Misses       1530     1514      -16     
  Partials       10       10              

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@robertmoura robertmoura requested a review from posva June 28, 2024 11:00
@posva posva marked this pull request as ready for review June 28, 2024 12:47
@posva
Copy link
Owner

posva commented Jun 28, 2024

Looking good. I will probably give this a review and merge next Monday during the stream

@robertmoura
Copy link
Contributor Author

Closing in favour of #519

@robertmoura robertmoura closed this Oct 4, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Support non absolute paths in EditableTreeNode
2 participants