-
Notifications
You must be signed in to change notification settings - Fork 80
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
refactor: split up library context #1539
refactor: split up library context #1539
Conversation
Thanks for the pull request, @rpenido! What's next?Please work through the following steps to get your changes ready for engineering review: 🔘 Get product approvalIf you haven't already, check this list to see if your contribution needs to go through the product review process.
🔘 Provide contextTo help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:
🔘 Get a green buildIf one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green. 🔘 Let us know that your PR is ready for review:Who will review my changes?This repository is currently maintained by Where can I find more information?If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:
When can I expect my changes to be merged?Our goal is to get community contributions seen and reviewed as efficiently as possible. However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:
💡 As a result it may take up to several weeks or months to complete a review and merge your PR. |
00e4b2e
to
3662b82
Compare
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #1539 +/- ##
==========================================
+ Coverage 92.94% 92.96% +0.01%
==========================================
Files 1073 1075 +2
Lines 21098 21171 +73
Branches 4550 4554 +4
==========================================
+ Hits 19610 19682 +72
- Misses 1422 1423 +1
Partials 66 66 ☔ View full report in Codecov by Sentry. |
7eb7e15
to
1819bc5
Compare
</Routes> | ||
<CreateCollectionModal /> | ||
<ComponentEditorModal /> | ||
<LibraryTeamModal /> |
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.
Once the LibraryTeamModal
was used only inside the LibraryInfo
, I moved the Modal there and removed the methods from the LibraryContext
.
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.
@rpenido Thanks! Looks good. Left a comment about default values for sidebar context.
- I tested this: (Tested libraries normal functionality, like adding component, using sidebar, editing component, adding collection etc.)
- I read through the code
- I checked for accessibility issues
- Includes documentation
if (ctx === undefined) { | ||
/* istanbul ignore next */ | ||
throw new Error('useSidebarContext() was used in a component without a <SidebarProvider> ancestor.'); | ||
} |
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.
We need to set a default context instead of raising an error as per this issue: #1510
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 for catching this, @navinkarkera!
I changed the LibaryContext
and the SidebarContext
to return default values here: 829cb5a
It went fine for the SidebarContext
. For the LibraryContext
, we will need to handle the case where libraryId = undefined
at the component level if we don't throw (check the CD/CI errors), and I think it would be better to throw the error at the context level.
What do you think?
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.
@rpenido Yes, I think that LibraryContext doesn't need a default, because of that reason - it's annoying to account for libraryId being undefined everywhere, and it doesn't make sense - libraryId is never undefined on any library page. Since our tests already include that context, I think it's better to make it have no default and throw an error in as it was before.
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 @bradenmacdonald!
Done here: c805858
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.
@rpenido Thanks!
526b915
to
829cb5a
Compare
0de1c07
to
c805858
Compare
<SidebarProvider> | ||
{children} | ||
</SidebarProvider> |
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.
@rpenido Now that we have default values for sidebar context, the providers can be removed from tests that don't actually use it. For example, this one works without SidebarProvider
. Similarly we can simplify other tests, which was the reason for adding default values.
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 @navinkarkera! Fixed!
if (ctx === undefined) { | ||
/* istanbul ignore next */ | ||
throw new Error('useSidebarContext() was used in a component without a <SidebarProvider> ancestor.'); | ||
} |
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.
@rpenido Thanks!
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.
@rpenido Looks good! Great work!
Description
This PR split the library context into smaller contexts:
Addition Information
Testing Instructions
Private ref: FAL-3983