Skip to content

[Fork] "Do you want to fork this repository?" Dialog - #8889

Merged
niik merged 44 commits into
developmentfrom
feature/basic-use-the-fork-dialog
Jan 21, 2020
Merged

niik merged 44 commits into
developmentfrom
feature/basic-use-the-fork-dialog

Conversation

@outofambit

@outofambit outofambit commented Jan 9, 2020 •

Copy link
Copy Markdown
Contributor

closes #8548

This PR adds the basic "make a fork" dialog flow, triggered by a failed push to a repo that the user doesn't have write access to.

Create Fork Prompt
Screen Shot 2020-01-17 at 4 45 00 PM

Error Dialog
Screen Shot 2020-01-17 at 4 53 36 PM

Happy Flow
fork-yay

Description

  • Adds error handler for push rejections due to missing write access to a repo
  • Adds dialog for creating a fork
  • Adds a wrapper for creating a fork via the GitHub API
  • Adds AppStore method for redirecting a local repo to point to a fork

@outofambit outofambit changed the title [Forks] "Do you want to fork this repository?" Dialog [Fork] "Do you want to fork this repository?" Dialog Jan 9, 2020
@outofambit
outofambit force-pushed the feature/basic-use-the-fork-dialog branch from b8f1d48 to f41229c Compare January 15, 2020 23:20
@billygriffin

Copy link
Copy Markdown
Contributor

One question: once they fork, are we okay with swapping out the upstream repo for the forked one without informing the user? Maybe the user wants both? Not sure of the use case for this.

@tierninho Great question. We discussed this, and creating a new local repo such that they now have both would require somehow moving the in-progress work over from one repo to the other. It's also likely that if they're in this situation, they're an external contributor and therefore having both is likely redundant and potentially confusing.

@tierninho
tierninho self-requested a review January 18, 2020 01:35
tierninho
tierninho previously approved these changes Jan 18, 2020

@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.

All looks good after the new commits:

  • Supposed to be one dollar sign or two?

Screen Shot 2020-01-17 at 3 34 23 PM

@outofambit

Copy link
Copy Markdown
Contributor Author

Hey @niik thanks for all the great feedback!

Should we perhaps make it clear in the fork dialog that they're forking to their user account?

@ampinsk and I did a pass at the copy to make this more clear. I've included full repo names (owner/repo-name) in the dialog text and updated the screenshots in the PR description (but not the gif).

new copy

Can we put this behind a beta feature flag for the time being? Just flagging the insertion of the error handler should do the trick.

Good shout! Done in 2c51b27.

Looking at https://developer.github.com/v3/repos/forks/#create-a-fork

Note: Forking a Repository happens asynchronously. You may have to wait a short period of time before you can access the git objects. If this takes longer than 5 minutes, be sure to contact GitHub Support.

Should we perhaps make sure that the repository is all set up and ready for the user before we dismiss the fork dialog?

I have this question too. So far in using the API, I haven't hit a case where the repo isn't ready by the time it needs to be, but its certainly possible. I think I'd like to address this safeguard in a follow up pull request, if that's ok with you?

(My proposal would be some kind of polling with git ls-remote to make sure git objects are accessible, with a timeout. Perhaps max 3 seconds poll interval with a 60 second timeout? If it were to timeout but finish later, a subsequent run of the create fork flow would find that fork and use it, not try to make another (this is how the github fork api endpoint works).)

@outofambit

outofambit commented Jan 18, 2020 •

Copy link
Copy Markdown
Contributor Author

Supposed to be one dollar sign or two?

😆 @tierninho i fixed that right after in 94df80f. Good spot!

@Rexogamer

Rexogamer commented Jan 18, 2020 •

Copy link
Copy Markdown
Contributor

I’m a bit iffy about the grammar of the error dialog. It just... doesn’t feel right. Maybe word it “We could not create your fork ”?

<>
<DialogContent>
<div>
{`Making your fork `}

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.

Suggested change
{`Making your fork `}
{`We could not make your fork `}

<strong>
{`${props.account.login}/${props.repository.gitHubRepository.name}`}
</strong>
{` failed. `}

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.

Suggested change
{` failed. `}
{` . `}

@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.

Seems like the build is legit failing here. I suspect it's because you're using multiple prop interfaces in the same file, I doubt the tslint rule is set up to handle that. Or it's the use of React.SFC, idk. I'd recommend for time and efficiency's sake to just use renderContent / renderErrorContent instance methods like we do in most other places.

I have this question too. So far in using the API, I haven't hit a case where the repo isn't ready by the time it needs to be, but its certainly possible. I think I'd like to address this safeguard in a follow up pull request, if that's ok with you?

Yeah, a follow up is fine. It might not be a problem but we have run into this general type of problem before. I think identifying what the failure mode would be if this happens should be our first priority and if it's not gnarly then we can skip that implementation entirely or wait until we hear it being a problem.

(My proposal would be some kind of polling with git ls-remote to make sure git objects are accessible, with a timeout. Perhaps max 3 seconds poll interval with a 60 second timeout? If it were to timeout but finish later, a subsequent run of the create fork flow would find that fork and use it, not try to make another (this is how the github fork api endpoint works).)

Pretty much what I thought too except I think we could do a fetch since that's something we're going to have to do anyway (rather than an ls-remote). I think we could optimize for the ideal case and do a fetch almost immediately or perhaps after a 1 or 2 second initial delay and then ~3 more fetches with an increasing backoff in between to match an overall timeout at roughly 30 seconds or so.

Comment thread app/styles/ui/dialogs/_create-fork.scss Resolved
Comment thread app/src/ui/forks/create-fork-dialog.tsx Resolved
Comment thread app/src/ui/dispatcher/error-handlers.ts Resolved
Co-Authored-By: Markus Olsson <[email protected]>
@outofambit

Copy link
Copy Markdown
Contributor Author

@niik should all be good now!

Yeah, a follow up is fine. It might not be a problem but we have run into this general type of problem before. I think identifying what the failure mode would be if this happens should be our first priority and if it's not gnarly then we can skip that implementation entirely or wait until we hear it being a problem.

great point. i'm on it! #8949

@niik
niik merged commit f166859 into development Jan 21, 2020
@outofambit
outofambit deleted the feature/basic-use-the-fork-dialog branch April 27, 2020 16:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

epic:fork time-sensitive Pull Requests where reviews need to happen in a timely manner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Fork] After cloning without write access, fork and publish from Desktop

5 participants