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

Fix preview button text to go back editing #7140

Closed

Conversation

DouglasLutz
Copy link
Contributor

Fixes #7122

Bug:

The preview button text was not being altered when clicked. With this you would need to click 'Preview' again to go back to editing.

I found this happening both in comments (create and edit) and in the legacy editor.

  • Old behaviour:
    Not working new comment

How it was fixed:

There were two bugs in app/assets/javascripts/editor.js file, the toggle_preview was getting the button by it's class but there were cases that multiple preview buttons were in the same page causing it to fail. Also the jquery .button('text') function was not altering the button text.

It has been created a parameter to receive the button object to ensure the right button is being accessed.

  • New behaviour:
    Working new comment

@DouglasLutz DouglasLutz requested a review from a team as a code owner January 7, 2020 19:19
@codecov
Copy link

codecov bot commented Jan 7, 2020

Codecov Report

Merging #7140 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@          Coverage Diff           @@
##           master   #7140   +/-   ##
======================================
  Coverage    81.6%   81.6%           
======================================
  Files          97      97           
  Lines        5599    5599           
======================================
  Hits         4569    4569           
  Misses       1030    1030

Copy link
Contributor

@nstjean nstjean left a comment

Choose a reason for hiding this comment

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

This is great so far!! Excellent work! This works on the comments but I notice it's still not changing the button for the /wiki/new/ path. I think the code for it is here:
https://github.com/publiclab/plots2/blob/master/app/views/wiki/edit.html.erb
Can you see if you can update that one too? Thank you!!

@DouglasLutz
Copy link
Contributor Author

@nstjean Sure! Now that you said I looked up and also found the preview button on app/views/features/_form.html.erb and app/views/editor/question.html.erb, I will apply the changes on those too

Copy link
Contributor

@nstjean nstjean left a comment

Choose a reason for hiding this comment

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

Fantastic!!! Thanks so much! 🎉

@jywarren
Copy link
Member

jywarren commented Jan 8, 2020

This is fantastic. I think this has been broken for a little while. Would you be able to write a short system test to protect this fix for the future?

It could be based on this; and it could be pretty minimal but it'd be great to just check each of these use cases: https://github.com/publiclab/plots2/blob/master/test/system/comment_test.rb

That way this excellent fix gets protected. I think that we're re-using code a lot which is efficient, but it means people may not realize when they break a different use case for the same code!

BTW, Does this fix #6297? 🎉

Also noting possible links to #5531, #6833

Awesome!!!!

@DouglasLutz
Copy link
Contributor Author

@jywarren Sure, I'll work on the tests.

@DouglasLutz
Copy link
Contributor Author

I noticed that #6297 is still occurring with the changes

@jywarren
Copy link
Member

Hi, just checking if you've gotten stuck on this at all, or if I could help in any way? Thanks!

@@ -61,4 +61,22 @@ class CommentTest < ApplicationSystemTestCase
assert_selector("#{parentid} .comment .comment-body p", text: 'batman')
end

test 'the text change on preview button click' do
Copy link
Member

Choose a reason for hiding this comment

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

Hm, so did the original fix not resolve it, or is the test not passing but it should be?

@SidharthBansal
Copy link
Member

There are some conflicts. Kindly resolve

@DouglasLutz DouglasLutz force-pushed the fix-preview-button-text branch from e7bfbcb to c9284bf Compare January 17, 2020 17:50
@plotsbot
Copy link
Collaborator

1 Warning
⚠️ There was an error with Danger bot’s Junit parsing: No JUnit file was found at output.xml
2 Messages
📖 @DouglasLutz 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.
📖 #
Screenshots 📸 (click to expand)

7140-test_questions.png

7140-test_embeddable_grids.png

7140-test_signup.png

7140-test_viewing_the_settings_page.png

7140-test_tag_by_author_page.png

7140-test_wiki_page_with_inline_grids.png

7140-test_stats.png

7140-test_viewing_the_dashboard.png

7140-test_searching_an_item_from_the_homepage.png

7140-test_signup_modal_form_validation.png

7140-test_tag_stats.png

7140-failures_test_drag_and_drop_image_upload_to_wiki_post_editor.png

7140-test_login_modal_form_validation.png

7140-test_questions_shadow.png

7140-test_login_modal.png

7140-test_profile_page.png

7140-test_comments.png

7140-test_tags.png

7140-test_signup_modal.png

7140-failures_test_edit_wiki.png

7140-test_wiki.png

7140-test_methods.png

7140-test_tag_page.png

7140-failures_test_comment_preview_button.png

7140-test_blog_page_with_location_modal.png

7140-test_tag_wildcard.png

7140-test_signup_modal_disabled_submit_button_on_empty_username.png

7140-test_embeddable_thumbnail_grids.png

7140-test_front_page_with_navbar_search_autocomplete.png

7140-test_spam_moderation_page.png

7140-test_login.png

7140-test_viewing_the_dropdown_menu.png

7140-failures_test_add_a_comment_manually.png

7140-failures_test_the_text_change_on_preview_button_click.png

7140-test_viewing_question_post.png

7140-test_mobile_displays.png

7140-failures_test_comment_image_drag_and_drop_upload.png

7140-test_simple-data-grapher_powertag.png

7140-failures_test_comment_image_upload.png

7140-test_front.png

7140-test_question_page.png

7140-test_tag_contributors_page.png

7140-test_blog.png

7140-test_people.png

7140-test_wiki_revisions.png

Learn about automated screenshots

Generated by 🚫 Danger

@SidharthBansal
Copy link
Member

As the person is inactive for more than a month, I am closing the PR. In case you want to push changes please feel free to open a new PR OR reopen this PR and add additional changes to it.
Thanks for contributing on Public Lab

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.

Wiki "Preview" state does not show a way to go back to editing
5 participants