Skip to content
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

removed test-digest-button for Users other than Admins and Moderators #4293

Merged
merged 12 commits into from Dec 16, 2018

Conversation

uzorjchibuzor
Copy link
Contributor

Fixes #4286

This PR removes the Test-Digest-Button from Production, it is still present in other environments.

Kindly merge if approved.

Thanks. @publiclab/reviewers

@plotsbot
Copy link
Collaborator

plotsbot commented Dec 13, 2018

1 Message
📖 @uzorjchibuzor Thank you for your pull request! I’m here to help with some tips and recommendations. Please take a look at the list provided and help us review and accept your contribution! And don’t be discouraged if you see errors – we’re here to help.

Generated by 🚫 Danger

@sashadev-sky
Copy link
Member

@uzorjchibuzor Thank you! Can you post a screenshot please?

app/views/users/profile.html.erb Outdated Show resolved Hide resolved
app/views/users/profile.html.erb Outdated Show resolved Hide resolved
@sashadev-sky
Copy link
Member

@uzorjchibuzor Great, thank you so much! Just need to see a screenshot

@uzorjchibuzor
Copy link
Contributor Author

shot

@sashadev-sky
Copy link
Member

@uzorjchibuzor I think you may have switched your conditional around since your 1st commit: you changed it to render the button if it is in production... the issue is asking for the other way around.

Please let me know if this was intentional and if not please update!

@uzorjchibuzor
Copy link
Contributor Author

@sashadev-sky, Thanks for spotting that, It wasn't intentional I am going push a new commit that corrects that.

@uzorjchibuzor
Copy link
Contributor Author

screenshot from 2018-12-13 10-07-46

@sashadev-sky
Copy link
Member

@uzorjchibuzor Thank you for the edits. Your code looks good to me 👍

Sorry for confusion over the screenshot -- we always ask for screenshots of front-end updates rendered in your localhost, but I realize now that doesn't apply here because the update is for the production environment.

@sashadev-sky
Copy link
Member

@jywarren @gauravano I think this PR is ready to be merged

@uzorjchibuzor
Copy link
Contributor Author

Yes, I was trying to figure out a way to run passenger in production, I was having troubles until you sent the screenshot of the code section. Thank you for the review

@uzorjchibuzor Thank you for the edits. Your code looks good to me 👍 ...

@sashadev-sky

Sent with GitHawk

@sashadev-sky
Copy link
Member

@gauravano just saw your additional request on the original issue so I assigned you as a reviewer

@uzorjchibuzor uzorjchibuzor changed the title removed test-digest-button from production environment removed test-digest-button for Users other than Admins and Moderators Dec 13, 2018
@uzorjchibuzor
Copy link
Contributor Author

admin
moderator
user

Screenshot for admin, moderator and user profile pages, in that order
.

@uzorjchibuzor
Copy link
Contributor Author

code

@uzorjchibuzor
Copy link
Contributor Author

@sashadev-sky Travis is failing, don’t know why. I made sure not to track any files apart from the profile.erb

Sent with GitHawk

@@ -233,11 +233,16 @@
</div>
</div>
<% end %>
<% if current_user.can_moderate? || current_user.role == "admin" %>
Copy link
Member

Choose a reason for hiding this comment

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

  1. can_moderate method checks for both admin and moderator
  2. You are directly calling current_user.mod.. and current_user.role what if there is no user currently logged in, then current_user would be containing nil. This is reason for test failure
  3. This if condition can be removed, how about adding && current_user.can_moderate? at below if where we are checking profile_user and current_user

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the clarification. I am going make changes. I am happy I got to work on this issue

Copy link
Member

Choose a reason for hiding this comment

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

@uzorjchibuzor let me know if you need any help! I will be available over the next few hours

Also I have one more change I think you should add:

  • You should move the line that checks if there is a current_user above the one that checks if the current_user is a moderator or admin. Otherwise, if there is not a current_user then the 1st method will throw an error

Copy link
Member

@grvsachdeva grvsachdeva left a comment

Choose a reason for hiding this comment

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

Some changes. Thanks!

Copy link
Member

@sashadev-sky sashadev-sky left a comment

Choose a reason for hiding this comment

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

One change request from me as well! Thank you

@uzorjchibuzor
Copy link
Contributor Author

image

@uzorjchibuzor
Copy link
Contributor Author

@sashadev-sky kindly review.

Sent with GitHawk

@sashadev-sky
Copy link
Member

@uzorjchibuzor approved! Great job making edits. Thank you for the screenshots of the page. We are only looking for these, not screenshots of your code.

@gauravano does this cover the conditions you wanted for this button rendering? Also just a note: I was considering ways to refactor this so its less verbose, and since this pattern is all over the page I think it might be a good separate issue to open after this one is merged? Let me know what you think!

@uzorjchibuzor
Copy link
Contributor Author

@uzorjchibuzor approved! Great job making edits. Thank you for the screenshots of the page. We are only looking for these, not screenshots of your code. ...

@sashadev-sky I noticed that too when I was looking at the file. I would love to be a part of that, if it was ever an issue.

Sent with GitHawk

<% if @profile_user && current_user && current_user.can_moderate? && @profile_user == current_user %>

<%= form_tag "/users/test_digest_email", method: :post do %>
<%= submit_tag "Test Digest Email", class: "btn btn-primary" %>
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
<%= submit_tag "Test Digest Email", class: "btn btn-primary" %>
<%= submit_tag "Test Digest Email", class: "btn btn-secondary" %>

As secondary would look little lighter. What do you think?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the btn-secondary bootstrap class is grayish, but the btn-info in a bit lighter than the primary. I have gone with that.

@@ -233,12 +233,17 @@
</div>
</div>
<% end %>

Copy link
Member

Choose a reason for hiding this comment

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

Please add a <br /> here to add some space between buttons. And, please remove the extra spaces like line #239, 243, 245, 256. Thanks!

Copy link
Member

Choose a reason for hiding this comment

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

@uzorjchibuzor the functionality is working great, please do the above changes to optimize design a little. Also, if you have idea for more clean design than you can try.

Thanks!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will implement the changes suggested and also thoroughly look at the code to what can be refactored

@grvsachdeva
Copy link
Member

Hi @sashadev-sky I would love to hear ideas about shrinking the repeated code to a function or so, feel free to open a new issue. And, @uzorjchibuzor you are welcome to help on this issue. What do you think @sashadev-sky?

Thanks!

@sashadev-sky
Copy link
Member

@gauravano I am not at my computer right now but maybe we can add a new method to application controller or at the top of the erb file? I will collaborate with @uzorjchibuzor and we will decide and open issue!

@uzorjcibuzor is Sunday ok?

@uzorjchibuzor
Copy link
Contributor Author

uzorjchibuzor commented Dec 15, 2018 via email

Copy link
Member

@grvsachdeva grvsachdeva left a comment

Choose a reason for hiding this comment

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

Nice work @uzorjchibuzor !

@grvsachdeva grvsachdeva merged commit 8843717 into publiclab:master Dec 16, 2018
@grvsachdeva
Copy link
Member

Merged 🎉 💯 🎈

@sashadev-sky
Copy link
Member

@uzorjchibuzor would you be able to get on Gitter?

@uzorjchibuzor
Copy link
Contributor Author

I have a gitter account, what is the name of the community there?

@sashadev-sky
Copy link
Member

@uzorjchibuzor if you click 'Gitter' in my above comment it should take you directly to the public lab page

@uzorjchibuzor uzorjchibuzor deleted the hide-test-button branch December 17, 2018 05:55
@uzorjchibuzor uzorjchibuzor restored the hide-test-button branch December 17, 2018 05:55
@uzorjchibuzor
Copy link
Contributor Author

I have joined the room, installed the app too as I am not going to be on the computer for a long time today. @sashadev-sky

@sashadev-sky
Copy link
Member

@uzorjchibuzor ok great, I sent you a message so that we can coordinate 👍

SrinandanPai pushed a commit to SrinandanPai/plots2 that referenced this pull request May 5, 2019
…publiclab#4293)

* removed test-digest-button from production environment

* added space between conditionals

* improved code readability

* indented tags

* corrected error in conditional statement

* restricted the Test-Digest-Button to be viewed by Admins and Mods only regardless of the ENV

* changed the style of the test button to btn-primary like all the other buttons

* added a space between conditionals and tags

* removed redundant if statement

* adding && current_user.can_moderate?

* removed extra spaces to make code cleaner

* Button size changed
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.

None yet

4 participants