Skip to content

feat: suggest the license to a repository from the license page - #610

Merged
mlinksva merged 12 commits into
github:gh-pagesfrom
felubra:suggest-license
Oct 21, 2018
Merged

mlinksva merged 12 commits into
github:gh-pagesfrom
felubra:suggest-license

Conversation

@felubra

@felubra felubra commented Oct 9, 2018 •

Copy link
Copy Markdown
Contributor

This PR implements #401 by adding a new "Suggest this license" feature in the sidebar of the license page. The user can input a repository URL and, upon pressing enter, being redirected to a page where he can open a PR to add the license to the project.

This PR is based on the idea and valuable feedback by @mlinksva.

Edit in 2018-10-19: this explains the behavior after 4f1eab6.

@mlinksva

Copy link
Copy Markdown
Contributor

Thanks @felubra! Glad to see this basically works.

The project selection/autocomplete seems a little finicky to me. I think maybe because it is only searching repo name, not the user/owner. I guess it would be possible to search by name and/or owner depending on what is typed in, and combine results when searching both, but it's probably hard to get exactly right.

Another way might be to not do any realtime lookup, but just take what user enters, do something with it upon hitting enter (initially only supporting full URL even), where something might be check that it is not licensed (glad you thought to filter for that, BTW) before sending on to the github.com license chooser?

@felubra

felubra commented Oct 11, 2018

Copy link
Copy Markdown
Contributor Author

@mlinksva thank you for the feedback!

Another way might be to not do any realtime lookup, but just take what user enters, do something with it upon hitting enter (initially only supporting full URL even), where something might be check that it is not licensed (glad you thought to filter for that, BTW) before sending on to the github.com license chooser?

I think this workflow is a better option, I will do something based on this. Thank you!

@felubra

felubra commented Oct 15, 2018

Copy link
Copy Markdown
Contributor Author

Following up on this, here is my implementation of your second suggestion @mlinksva. Thanks!

Comment thread assets/js/app.coffee Outdated
license = repositoryInfo.license
@setStatus "Error", @repositoryLicense repositoryFullName, license
else # The repository is unlicensed
window.open "https://github.com/#{repositoryFullName}/community/license/new?template=#{@licenseId}"

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.

This seems to trigger both Firefox and Chrome popup blockers. Would location.href work instead?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Good catch!

@mlinksva

Copy link
Copy Markdown
Contributor

This is great @felubra! If it can avoid a popup (see my review comment) I think it just needs a tiny bit of documentation, which I can suggest.

@felubra

felubra commented Oct 15, 2018

Copy link
Copy Markdown
Contributor Author

@mlinksva after making the change you requested, I've noticed that the URL to suggest a license to a third-party repo is restricted to logged-in Github users. Any logged-out attempts to access it would result in a 404 error. I've prefixed it with the https://github.com/login?return_to=, so the user can log-in before going to the restricted page. Not sure if this is the right way to do this 😊

@mlinksva

Copy link
Copy Markdown
Contributor

Hmm, 404 is definitely not a great experience. I don't think there's any way to detect if a visitor to choosealicense.com is logged into github.com, so guess the solution will have to be more up-front context, warning that one has to be logged into github.com?

Maybe in the case of a valid URL for a non-licensed repo, present a click-through that explains you need to be logged in -- in place of an error if you provide a non-valid URL or a licensed repo?

@felubra

felubra commented Oct 18, 2018

Copy link
Copy Markdown
Contributor Author

Hmm, 404 is definitely not a great experience. I don't think there's any way to detect if a visitor to choosealicense.com is logged into github.com, so guess the solution will have to be more up-front context, warning that one has to be logged into github.com?

After 2d3c449 the user will never get a 404 because he will be redirected to the login page of Github, that is, after pressing enter and if the URL typed is of a valid unlicensed repository, the browser will be redirected to https://github.com/login?return_to=%URL_to_suggest_the_license%. If the user is logged in, Github will redirected the user transparently to the %URL_to_suggest_the_license%; if not, a login form appears, the user has the opportunity to log in and, after doing so, will be redirected to %URL_to_suggest_the_license%.

Maybe in the case of a valid URL for a non-licensed repo, present a click-through that explains you need to be logged in -- in place of an error if you provide a non-valid URL or a licensed repo?

Sorry if I din't understood, but checking for a invalid URL or a already licensed repository does not require a logged in user. This is done by validating the URL against a regex and fetching the public Github API, respectively.

I agree with the need for more explanation. Maybe a paragraph above the input with something like:

You can suggest this license to a Github repository to make it easier for other people to contribute - this is done by opening a pull request, therefore you need to authenticate with your Github account to do this.

Sounds good?

@mlinksva

Copy link
Copy Markdown
Contributor

@felubra apologies, I failed to notice 2d3c449 or realize that return_to is a solution, I obviously did not read your comment closely, or think. 😳

Your suggestion for an explanation looks good to me. Thanks!

@felubra

felubra commented Oct 18, 2018

Copy link
Copy Markdown
Contributor Author

No problem 😊
I've added the explanation. Let me know if you need anything else.
Thanks!

@mlinksva

Copy link
Copy Markdown
Contributor

Great, thanks @felubra! I'm pretty happy with this now. I'm going to leave it open a few days to give others a chance to give feedback, since this is in a way a pretty big feature for choosealicense.com, though it didn't take much code or UI real estate.

@kfogel

kfogel commented Oct 19, 2018

Copy link
Copy Markdown

Just want to say thanks for taking action on this, @felubra!

@felubra

felubra commented Oct 19, 2018

Copy link
Copy Markdown
Contributor Author

@kfogel I'm having a great experience and learning a lot about contributing to OSS, thank you for the providing me this opportunity 😊

@kfogel

kfogel commented Oct 19, 2018 •

Copy link
Copy Markdown

Well I look forward to working with you more @felubra! Actually you and @mlinksva did the real work here. What I did was more "cheerleading" :-).

@mlinksva
mlinksva merged commit 8d57932 into github:gh-pages Oct 21, 2018
@felubra
felubra deleted the suggest-license branch October 22, 2018 02:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants