Repository navigation
unify banner state in application to pay down some tech debt - #6884
Merged
Merged
Conversation
shiftkey
force-pushed
the
standardize-banner-state
branch
from
February 19, 2019 22:17
0eea825 to
0c86e6d
Compare
15 tasks done
Member
Author
Contributor
|
Glad to see the addition of a |
Member
Author
|
FYI @desktop/engineering I plan to merge this in tomorrow morning my time so #6698 will be ready to review, so let me know if there's any other feedback about this change. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Overview
This PR demonstrates how a unified banner API might work in the application. I need to implement some banners as part of the rebase flow in #6698, so I wanted to open this cleanup PR early and get feedback.
Shout out to @outofambit for brain dumping her thoughts earlier today to help me get started.
Description
This work came from our learnings about managing popups, with a slight improvement that I don't think we've done elsewhere.
First, we defined a unified
Bannertype to represent all the possible states of a banner:https://github.com/desktop/desktop/blob/0eea8253dc44554cd6b649332e08b97192665d02/app/src/models/banner.ts#L1-L22
Then, we defined a single
currentBannerstate insideapp-state, replacingsuccessfulMergeBannerStateandmergeConflictsBannerState.Lastly,
AppStoreandDispatchernow define a singlesetBanner/clearBannerfunctions to manage this state, rather than two pairs of functions to update each state.This PR differs from our current
Popupinfrastructure by moving the render function out to it's own module, rather than inlining it insideApp:https://github.com/desktop/desktop/blob/0eea8253dc44554cd6b649332e08b97192665d02/app/src/ui/app.tsx#L1888-L1896
This means
Appdoesn't need to be aware of the components it can render as banners (fewer imports, better separation of concerns), and we can useassertNeverto ensurerenderBannerhandles all of the states it should:https://github.com/desktop/desktop/blob/0eea8253dc44554cd6b649332e08b97192665d02/app/src/ui/banners/render-banner.tsx#L12-L41
You might note that the
UpdateAvailablebanner is technically a banner, but for the sake of this PR I'm not touching that logic or it's representation. I think it could live in there at some point, but I haven't thought about it.Release notes
Notes: no-notes