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
Improve gem login scope selection #7342
Improve gem login scope selection #7342
Conversation
Thanks for opening a pull request and helping make RubyGems and Bundler better! Someone from the RubyGems team will take a look at your pull request shortly and leave any feedback. Please make sure that your pull request has tests for any changes or added functionality. We use GitHub Actions to test and make sure your change works functionally and uses acceptable conventions, you can review the current progress of GitHub Actions in the PR status window below. If you have any questions or concerns that you wish to ask, feel free to leave a comment in this PR or join our #rubygems or #bundler channel on Slack. For more information about contributing to the RubyGems project feel free to review our CONTRIBUTING guide |
22b3d20
to
a7e30c1
Compare
a7e30c1
to
f542364
Compare
@martinemde any feedback on this? |
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.
This is great. I think we could clean up a little and then I'm happy to approve.
7dd92e8
to
4b35f6a
Compare
@martinemde thanks! updated with suggestions 😃 |
4b35f6a
to
93197b0
Compare
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 working on this, left a comment on approach and implementation!
selected = ask_yes_no(s.to_s, false) | ||
scope_params[s] = true if selected | ||
end | ||
end |
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.
How about this alternative implementation?
diff --git a/lib/rubygems/gemcutter_utilities.rb b/lib/rubygems/gemcutter_utilities.rb
index 9b50b55ede..1236861eac 100644
--- a/lib/rubygems/gemcutter_utilities.rb
+++ b/lib/rubygems/gemcutter_utilities.rb
@@ -322,23 +322,23 @@ def get_scope_params(scope)
say "\n"
customise = ask_yes_no("Do you want to customise scopes?", false)
if customise
- scope_params = {}
- exclusive_scope = nil
EXCLUSIVELY_API_SCOPES.each do |s|
selected = ask_yes_no(s.to_s, false)
- exclusive_scope = s if selected
- break if selected
- end
- if exclusive_scope
- say "You selected #{exclusive_scope}, which must be enabled exclusively. Other scopes will be disabled."
+ next unless selected
+
+ say "You selected #{s}, which must be enabled exclusively. Other scopes will be disabled."
keep_selection = ask_yes_no("Is this fine? (type no for selecting other scopes)", true)
- scope_params = { exclusive_scope => true } if keep_selection
+
+ return { s => true } if keep_selection
+
+ break
end
- if exclusive_scope.nil? || (exclusive_scope && !keep_selection)
- API_SCOPES.each do |s|
- selected = ask_yes_no(s.to_s, false)
- scope_params[s] = true if selected
- end
+
+ scope_params = {}
+
+ API_SCOPES.each do |s|
+ selected = ask_yes_no(s.to_s, false)
+ scope_params[s] = true if selected
end
end
say "\n"
Seems more straightforward to me. If an exclusive scope is selected, return it if it's fine, or directly skip to non exclusive scopes if it's not.
Alternatively, we could inform of exclusivity while asking, so we don't need yet another prompt?
The default access scope is:
index_rubygems: y
Do you want to customise scopes? [yN] y
show_dashboard (answering yes disables other scopes) [yN] N
index_rubygems [yN] N
push_rubygem [yN] y
...
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!
I think the alternative makes sense as well...
I can update to that if we think its better.. let me know...
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.
I think it's a bit simpler and usable, but let's check with @martinemde before you implement anything.
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.
I like it, @deivid-rodriguez. Saying ahead of time what will happen by choosing show_dashboard will produce less mistakes. I'm making a similar change to the web UI so that show_dashboard is presented at the top with the heading "Exclusive Scopes". On the CLI the best we can do is explain it up front.
Btw, no where do we explain why this is the case. What are the scopes? Do we need to add a ?/h
option that prints a brief explanation of the scope? (this should be a follow up PR, imho)
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.
this:
show_dashboard (answering yes disables other scopes)
or
show_dashboard (exclusive scope, answering yes will not prompt for other scopes)
?
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.
The latter seems more clear to me 👍.
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.
updated 🙂
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.
sorry for the back and forwards, I should have waited for more discussions on the issue itself.. was just looking to contribute to something...
If theres something similar already implemented for adding a ? /h option
, or some guidance on how to do that, I can try a PR for that as well... 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.
Yeah, this is great.
And don't worry, we always go back and forth on stuff like this. I appreciate your patience! 😀
d25962e
to
821ea2d
Compare
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.
Looks ready to me. Could you squash the commits?
354f71a
to
37429c5
Compare
@deivid-rodriguez ready to merge with your approval. |
37429c5
to
26c7abe
Compare
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.
Awesome!
…nhancement Improve gem login scope selection (cherry picked from commit d06e104)
What was the end-user or developer problem that led to this PR?
Gem login api scopes is confusing and difficult as show_dashboard permission invalidates the rest.
More details in issue #7238
What is your fix for the problem, implemented in this PR?
Enhance scope selection by prompting first exclusively scopes and message about when one of those is selected (other scopes will be disabled). updated prompt:
Make sure the following tasks are checked