Skip to content

first pass at UI for warning about protected branches - #7826

Merged
niik merged 32 commits into
developmentfrom
prototype-ui-for-protected-branch-warning
Jun 25, 2019
Merged

niik merged 32 commits into
developmentfrom
prototype-ui-for-protected-branch-warning

Conversation

@shiftkey

@shiftkey shiftkey commented Jun 18, 2019 •

Copy link
Copy Markdown
Member

Overview

Related to #7023

Description

This PR is a quick-and-dirty implementation of the flow outlined in #7023 (comment) to gather feedback and ponder more on the warning and the initial flow.

We don't block committing currently, because some teams can be exempt from the branch protection enforcement. However we can't get a full picture of the branch protection details from the API - in particular from Enterprise Server instances - because teams can be private. I'm talking with the team responsible for this to see if there are other was for us to be able to check "can i push?" without exposing sensitive information.

Because of that limitation, I went with a mixture of the "Alternate option" and the proposed flow on this first attempt. You'll note from the GIF above that we:

  • provide a warning, but also a clickable link to let the user switch branches
    • this is our way to help them to a solution, which feels more complete than a warning without anything actionable
  • don't provide any more context after opening the branch switcher
    • my gut feeling after using it a bit is that we could put them straight into a "Create branch" flow to avoid confusion, but I'd love others to try this out and see how it feels

TODO:

  • polish styles to match designs
  • wrap on long branch names
  • investigate whether we can hook into the stash options to indicate that we are always bringing our changes with us? If that's not easy, it might need some refactoring in advance of landing this PR.
  • gather feedback
  • improve API updating to more quickly indicate when a branch is protected
  • handle context menu to prevent a menu being displayed
  • rebase once new feature flag for protected branches UI work #7825 has been merged

Release notes

Notes: no-notes

@billygriffin

Copy link
Copy Markdown
Contributor

cc: @ampinsk and @desktop/design on the direction @shiftkey is proposing here, which is a bit of a hybrid of the two approaches. We don't block the flow, but provide a slightly more guided way to switch branches from the commit area.

@outofambit

Copy link
Copy Markdown
Contributor

@billygriffin @shiftkey i really like this UX approach. i'd like to lessen our reliance on popups, and i think this is a great alternate pattern. i wonder if there's a way we could explain what a protected branch is (it's probably not uncommon for someone to run into this if they don't know what a protected branch is), either with like a tooltip or making it a hyperlink to a help article?

do we need to think through if there are multiple warnings above the commit message box? do they stack? (i should know this but i don't remember right now...)

@tierninho

Copy link
Copy Markdown
Contributor

Nice approach on this feature. I agree that we should add a tooltip to explain what protected branches is.

Should we add a warning when doing merging or rebasing? The fetch branch in this example is protected.

Screen Shot 2019-06-18 at 11 36 09 AM

Need a wrap on longer branch names...
Screen Shot 2019-06-18 at 11 40 40 AM

@shiftkey

Copy link
Copy Markdown
Member Author

@outofambit

i'd like to lessen our reliance on popups, and i think this is a great alternate pattern.

The only concern I have about this flow currently is that opening the branch list might not be enough here to get the user in a happy place:

  • they could choose an existing branch which is divergent from the protected branch
  • end up in the stash flow and accidentally put their stashed changes back in the protected branch, putting them further away from their intended goal of making the commit

Part of me wants to nudge the user towards the GitHub Flow here by changing the action to "Want to create a new branch?" which could open the "Create branch" popup, set to base the branch off the current branch, and then bypass the stashing flow as designed.

But I guess that taps into what the goal here is - just preventing the user from committing to the wrong branch, or helping with making the GitHub flow easier, or just leaving it up to the user to put their work in the right spot?

. i wonder if there's a way we could explain what a protected branch is (it's probably not uncommon for someone to run into this if they don't know what a protected branch is), either with like a tooltip or making it a hyperlink to a help article?

This is probably worth exploring as part of this UI work - I lean towards leveraging our existing GitHub docs, but at the moment I have no strong feels on an approach.

do we need to think through if there are multiple warnings above the commit message box? do they stack? (i should know this but i don't remember right now...)

This is the first proper warning message we use in the commit form area, so I wouldn't hold this PR up to address this, but it's probably worth thinking about if these would need to stack in the future and how to organize the information in a wa

@tierninho

Should we add a warning when doing merging or rebasing? The fetch branch in this example is protected.

I'd prefer to think of these separate to this original case, because the resulting flow may be different:

  • merging a branch into a protected branch feels similar to making a new commit, but in this case it containing a bunch of commits
  • any protected branch cannot be rebased and force pushed, so starting a rebase doesn't feel optimal

I want to keep in mind with these cases "what is the user trying to do?" as that should guide our thinking about what the app should do to help them out (if anything).

Need a wrap on longer branch names...

Good shout, added to my list

@ampinsk

ampinsk commented Jun 19, 2019

Copy link
Copy Markdown
Contributor

I really like this as a happy medium! I like that we're not blocking committing, but still providing the user a way out. I'm a bit iffy on using the link style here. Seeing it in action it doesn't bother me too much, but I might expect it to open an external link.

I'd be curious to see a version where we prompt the user to create a branch! Your reasoning makes a lot of sense to me @shiftkey (especially where GitHub Flow and stashing is concerned) but my only concern is I'm not sure how blocking that flow would be. If we keep this flow, I think we should skip the stashing step, since it feels inherent to this action that you'd be bringing the changes with you and the extra click feels unnecessary.

As far as explaining protected branches goes, I actually don't find that necessary here. I think including an explanation in context feels a bit heavy handed - we don't tend to explain concepts in the app and instead rely on using google-able and clear language, which I think this accomplishes. "Protected branch" isn't too confusing, and if I don't know what that is it's easy to google and find our docs.

@shiftkey shiftkey changed the title [WIP] first pass at UI for warning about protected branches first pass at UI for warning about protected branches Jun 19, 2019
@shiftkey

Copy link
Copy Markdown
Member Author

Having chatted about this a bunch over the last day, I think we're trying to avoid bringing in too much change here to the flow, and instead aiming to focus on two things for the next beta:

  • get feedback about the message being shown to users
  • get feedback about whether the flow as-is is helpful to users

@billygriffin @nerdneha @ampinsk is there anything else that we should have in-scope for the beta we're aiming for next week?

@tierninho I'd love your feedback on this from a QA perspective if you have some time

@shiftkey

Copy link
Copy Markdown
Member Author

Just pushed up the last commit to ensure this warning message handles wraps correctly for long branch names:

@shiftkey shiftkey added the ready-for-review Pull Requests that are ready to be reviewed by the maintainers label Jun 19, 2019
@billygriffin

Copy link
Copy Markdown
Contributor

This seems great to me as our first iteration!

@tierninho

Copy link
Copy Markdown
Contributor

Testing notes below. All in all it is good to ship as-is.

  • I noticed a slight lag in the API updating the commit area with the new messaging. Took about a minute for the new warning to appear. It was enough time for me to make a commit and miss seeing the messaging. Not a huge deal but wanted to point it out.

  • UX should match the merge conflict? That is icon with no strikethrough and messaging below that, like so:
    Screen Shot 2019-06-19 at 9 40 56 AM

  • attempting to right-click the switch branches link pulls up co-authors menu. Don't think there is much we can do about it as the co-authors menu affects the whole area.

  • consistency with GH/GH in messaging may be worth considering. Notice the icon and suggested next step which matches your "create a branch" idea

Screen Shot 2019-06-19 at 9 59 08 AM

  • Can't "switch branch" if user is working on only one branch. This also leads to another issue: admins who are unencumbered by this change are still seeing it. Perhaps on a future iteration.

96e65e903e, mac

@billygriffin

Copy link
Copy Markdown
Contributor

@tierninho These are great notes, thank you!

I noticed a slight lag in the API updating the commit area with the new messaging. Took about a minute for the new warning to appear. It was enough time for me to make a commit and miss seeing the messaging. Not a huge deal but wanted to point it out.

This feels pretty important to me to ensure is working as expected.

Can't "switch branch" if user is working on only one branch. This also leads to another issue: admins who are unencumbered by this change are still seeing it. Perhaps on a future iteration.

But you can create a new branch from the branch dropdown that gets triggered when you click it, right? Your idea about admins still seeing it is a known thing and something we're hoping to be able to get more from the API about to be able to know more and provide a more guided flow only for those who can't push to the branch.

consistency with GH/GH in messaging may be worth considering. Notice the icon and suggested next step which matches your "create a branch" idea

This is a great spot! I think people may work a bit different locally in keeping certain branches around to reuse and such, but I think we're all open to putting this in people's hands and then seeing if it's more natural to just guide to creating a branch.

@shiftkey

Copy link
Copy Markdown
Member Author

I'll follow up on the other feedback tomorrow, just wanted to add some extra context while it's fresh:

I noticed a slight lag in the API updating the commit area with the new messaging. Took about a minute for the new warning to appear. It was enough time for me to make a commit and miss seeing the messaging. Not a huge deal but wanted to point it out.

I'll see if I can reproduce this myself but I wonder if this is related to the API being refreshed (and updating local state about branch protections - such as a new branch being marked as protected). Steps to reproduce this would be grand if it's repeatable.

UX should match the merge conflict? That is icon with no strikethrough and messaging below that, like so:

I didn't follow that pattern because there's already a separator between the branches list and the rest of the form (so the line felt unnecessary there). This was removed from the Merge panel in #5957 as part of reordering the elements.

In the commit form there's no separator between the form and the button, which is why I believe this was included.

Screen Shot 2019-06-19 at 6 53 32 PM

  • attempting to right-click the switch branches link pulls up co-authors menu. Don't think there is much we can do about it as the co-authors menu affects the whole area.

It'd be great to be able to prevent this from happening. I'll see if there's an event I can hook into.

@tierninho

Copy link
Copy Markdown
Contributor

Steps to reproduce this would be grand if it's repeatable.

  • Go to .com and protect any branch
  • On Desktop, make a commit on that branch, push it up to see error
  • Go do something else, i suggest this
  • The new messaging should show up soon in the UI

The API was triggered when we pushed but didn't seem to update the new warning message until a short time later.

@shiftkey

Copy link
Copy Markdown
Member Author

The API was triggered when we pushed but didn't seem to update the new warning message until a short time later.

The code to update this bit of application state was hooking into when a GitStore was updated (to track when the user changes branches) and it sounds like there wasn't any Git state changes immediately after the failed push to refresh the state. I'll find the right hook to also handle this case...

@shiftkey
shiftkey force-pushed the prototype-ui-for-protected-branch-warning branch from 5888147 to 78d1390 Compare June 20, 2019 14:03
@shiftkey

Copy link
Copy Markdown
Member Author

I'll find the right hook to also handle this case...

So this wasn't as easy as I had hoped, because of how these updates are prioritized...

Updating the API information for the repository is buried deep inside repositoryWithRefreshedGitHubRepository, which is only fired in a few situations:

  • adding a repository to the app
  • publishing the repository to a remote
  • user switching to the repository in the list
  • before doing a fetch/push/pull in the app

Because of that last part, where pushing a new branch will be marked as protected immediately, it felt excessive to do a full refresh of the API again after a push.

Instead I refactored out the work to update branch protections into two functions, AppStore.updateBranchProtectionsFromAPI (for the remote information) and AppStore.refreshBranchProtectionState (for updating the application state) to better manage when this work is run.

@shiftkey

Copy link
Copy Markdown
Member Author

I noticed a slight lag in the API updating the commit area with the new messaging. Took about a minute for the new warning to appear. It was enough time for me to make a commit and miss seeing the messaging.

The context for this is outlined in #7826 (comment), but the current build should be much more snappy to update.

UX should match the merge conflict? That is icon with no strikethrough and messaging below that, like so:

cc @desktop/design for feels here, but I think the current designs are fine to ship

attempting to right-click the switch branches link pulls up co-authors menu. Don't think there is much we can do about it as the co-authors menu affects the whole area.

Fixed in 5138205

consistency with GH/GH in messaging may be worth considering. Notice the icon and suggested next step which matches your "create a branch" idea

I'm going to defer to @desktop/design and @desktop/product here for future iterations, but I'm not planning to make any more changes in this PR.

Can't "switch branch" if user is working on only one branch.

I'm not clear on this one - I created a branch new repository, protected the master branch, saw the prompt and was able to open the branch switcher. Can you elaborate on this?

This also leads to another issue: admins who are unencumbered by this change are still seeing it. Perhaps on a future iteration.

There's a bigger headache here about visibility into protection rules that I'm talking with the teams about. We have plans to iterate here, but for the moment this doesn't block on committing for those users who know they can. We'll see what shakes out from the feedback here.

@shiftkey
shiftkey force-pushed the prototype-ui-for-protected-branch-warning branch from 5810f4f to ff48b83 Compare June 21, 2019 12:39
@shiftkey
shiftkey changed the base branch from development to new-feature-flag-for-ui June 21, 2019 12:39
@shiftkey

Copy link
Copy Markdown
Member Author

@niik thanks for the feedback!

Given that the flag is cleared when closing a foldout anyway would it make more sense to convert it from a persistent state to an ephemeral one tied to the workflow by having the Branch foldout and the CreateBranch popup carry the state?

I'll give this a try and see how it feels, but I worry I still have to track some app state as well as manage these popups.

@shiftkey
shiftkey requested a review from niik June 24, 2019 18:32
const repo = await this._checkoutBranch(
repository,
branch,
uncommittedChangesStrategy

@shiftkey shiftkey Jun 24, 2019 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I want to call out this change because we had no way for AppStore.createBranch to pass its uncommittedChangesStrategy parameter to AppStore.checkoutBranch.

Without this parameter we'd always inherit the default behaviour 'AskForConfirmation', which means it would always show the "Switch Branch" dialog. But with this PR we want to bypass any other dialogs because we're assuming the user wants to take those changes with them, hence why I've added this parameter.

@tierninho

Copy link
Copy Markdown
Contributor

I'm not clear on this one - I created a branch new repository, protected the master branch, saw the prompt and was able to open the branch switcher. Can you elaborate on this?

If there is only one branch then the text "Want to switch branches?" implies there is already two branches. This was more of an observation in case we wanted to change the wording in a future iteration to something like "Want to create a new branch?".

@shiftkey

Copy link
Copy Markdown
Member Author

If there is only one branch then the text "Want to switch branches?" implies there is already two branches. This was more of an observation in case we wanted to change the wording in a future iteration to something like "Want to create a new branch?".

I've not got feels on this change. @billygriffin what do you think?

@billygriffin

Copy link
Copy Markdown
Contributor

I'm happy with it for now. I'm 100% down to be more discerning in future iterations of this, which I'm very excited about.

@tierninho
tierninho self-requested a review June 24, 2019 20:11

@tierninho tierninho left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Current build is much more snappy to update and thanks for fixing the right-click on the switch branches. Also tested branch protection using fnmatch and works 💯 I am 👍 for the first iteration.

@niik niik left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I'm much happier with this approach to managing state @shiftkey, thank you so much for taking the extra time to try it out.

My only remaining concern now is with how we're dealing with failed API requests. Consumers of the fetchProtectedBranches method have no way of differentiating between an API request that returned zero protected branches and one that failed meaning that if we attempt to refresh the list of protected branches while there's no internet connectivity we'll immediately clear the internal list of protected branches. Given that this is a pre-existing behavior I don't think it should hold up this PR but I feel like it warrants further investigation to determine if that's the behavior we want.

@shiftkey

Copy link
Copy Markdown
Member Author

@niik good point - I've opened #7864 to track that

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready-for-review Pull Requests that are ready to be reviewed by the maintainers

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants