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
removed test-digest-button for Users other than Admins and Moderators #4293
Conversation
Generated by 🚫 Danger |
@uzorjchibuzor Thank you! Can you post a screenshot please? |
@uzorjchibuzor Great, thank you so much! Just need to see a screenshot |
@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! |
@sashadev-sky, Thanks for spotting that, It wasn't intentional I am going push a new commit that corrects that. |
@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. |
@jywarren @gauravano I think this PR is ready to be merged |
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
Sent with GitHawk |
@gauravano just saw your additional request on the original issue so I assigned you as a reviewer |
…y regardless of the ENV
@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 |
app/views/users/profile.html.erb
Outdated
@@ -233,11 +233,16 @@ | |||
</div> | |||
</div> | |||
<% end %> | |||
<% if current_user.can_moderate? || current_user.role == "admin" %> |
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.
can_moderate
method checks for both admin and moderator- 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
- 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
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 the clarification. I am going make changes. I am happy I got to work on this issue
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.
@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
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.
Some changes. 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.
One change request from me as well! Thank you
@sashadev-sky kindly review. Sent with GitHawk |
@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! |
@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 |
app/views/users/profile.html.erb
Outdated
<% 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" %> |
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.
<%= 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?
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 btn-secondary bootstrap class is grayish, but the btn-info in a bit lighter than the primary. I have gone with that.
app/views/users/profile.html.erb
Outdated
@@ -233,12 +233,17 @@ | |||
</div> | |||
</div> | |||
<% 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.
Please add a <br />
here to add some space between buttons. And, please remove the extra spaces like line #239, 243, 245, 256. 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.
@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!
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 will implement the changes suggested and also thoroughly look at the code to what can be refactored
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! |
@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? |
Sunday is good
|
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.
Nice work @uzorjchibuzor !
Merged 🎉 💯 🎈 |
@uzorjchibuzor would you be able to get on Gitter? |
I have a gitter account, what is the name of the community there? |
@uzorjchibuzor if you click 'Gitter' in my above comment it should take you directly to the public lab page |
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 |
@uzorjchibuzor ok great, I sent you a message so that we can coordinate 👍 |
…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
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