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

Verify Translation in Development #9878

Merged
merged 7 commits into from
Jul 20, 2021
Merged

Verify Translation in Development #9878

merged 7 commits into from
Jul 20, 2021

Conversation

imajit
Copy link
Contributor

@imajit imajit commented Jul 2, 2021

Fixes #9686
To review of FTOs easily, now the contributor can quickly change the required files and run it on Gitpod. As some of the FTOs related to translation need UI checks, in PR contributors can add the Gitpod UI screenshots.
ezgif com-gif-maker
I read about this method to show the button in development mode only, not sure if this is the best practice, also some numbers are attached to the link whenever the button is pressed, it doesn't affect the result though not sure how it is getting added each time.

@gitpod-io
Copy link

gitpod-io bot commented Jul 2, 2021

redirect_to '/change_locale/zh-CN'
end

def switch_off_translation
Copy link

Choose a reason for hiding this comment

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

Inconsistent indentation detected.

end

def switch_off_translation
UserTag.remove_if_exists(current_user.uid,'translation-helper')
Copy link

Choose a reason for hiding this comment

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

Use 2 (not 4) spaces for indentation.

@@ -47,6 +47,16 @@ def dashboard
end
end

def switch_on_translation
UserTag.create_if_absent(current_user.uid,'translation-helper')
Copy link

Choose a reason for hiding this comment

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

Space missing after comma.

end

def switch_off_translation
UserTag.remove_if_exists(current_user.uid,'translation-helper')
Copy link

Choose a reason for hiding this comment

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

Space missing after comma.

@codecov
Copy link

codecov bot commented Jul 2, 2021

Codecov Report

Merging #9878 (0047d80) into main (d12a468) will increase coverage by 3.88%.
The diff coverage is 77.27%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #9878      +/-   ##
==========================================
+ Coverage   78.24%   82.12%   +3.88%     
==========================================
  Files          98       98              
  Lines        5947     5964      +17     
==========================================
+ Hits         4653     4898     +245     
+ Misses       1294     1066     -228     
Impacted Files Coverage Δ
app/channels/room_channel.rb 71.42% <0.00%> (ø)
app/controllers/tag_controller.rb 80.42% <ø> (+0.61%) ⬆️
app/controllers/user_tags_controller.rb 82.43% <50.00%> (-1.86%) ⬇️
app/helpers/application_helper.rb 85.41% <66.66%> (+5.20%) ⬆️
app/models/tag.rb 97.53% <100.00%> (+12.03%) ⬆️
app/models/user.rb 86.12% <100.00%> (+3.32%) ⬆️
app/services/search_service.rb 95.09% <0.00%> (+0.04%) ⬆️
app/controllers/notes_controller.rb 84.87% <0.00%> (+0.40%) ⬆️
app/models/revision.rb 88.29% <0.00%> (+3.19%) ⬆️
... and 11 more

@noi5e
Copy link
Contributor

noi5e commented Jul 12, 2021

@imajit Nice work!

@imajit imajit force-pushed the verifytranslationbutton branch from 58eaa73 to 200ef11 Compare July 12, 2021 20:53
@imajit
Copy link
Contributor Author

imajit commented Jul 13, 2021

The tests commit fails , is this because the code the tests are checking is not there in the code-base yet ?

@@ -47,6 +47,16 @@ def dashboard
end
end

def switch_on_translation
Copy link
Member

Choose a reason for hiding this comment

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

maybe we should name this

Suggested change
def switch_on_translation
def switch_on_translation_helper

Is this only for development mode? If so, couldn't we use an existing route somehow -- https://github.com/publiclab/plots2/blob/main/test/functional/user_tags_controller_test.rb#L8-L15 maybe? To add the tag? though i guess it's 2 steps.

@jywarren
Copy link
Member

The tests commit fails , is this because the code the tests are checking is not there in the code-base yet ?

If the code is not there yet, then yes! But you can then add the code and the test would then begin to pass. That would be "Test Driven Development" - a nice pattern!

config/routes.rb Outdated
@@ -378,6 +378,8 @@
post 'comment/react/delete/:id' => 'comment#react_delete'
post 'comment/react/update/:id' => 'comment#react_update'

get 'switch_on_translation' => 'home#switch_on_translation'
Copy link
Member

Choose a reason for hiding this comment

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

Yes, if possible if we could use existing routes, we'd be able to skip some of the tests because we wouldn't be introducing a whole new route, you know? That would keep codebase complexity down a bit, which is really helpful in the long run on a big project like this.

@imajit
Copy link
Contributor Author

imajit commented Jul 15, 2021

ezgif com-gif-maker(1)
I initially kept this button in the welcome message I could not see it anymore so I just placed it in the top part. I added an extra parameter to the existing route and changed the controller so now no new routes or controllers are needed. Thanks @jywarren for the suggestion it was a bit more complex but yes it keeps the codebase simple now 😄 . I'm not sure why codecov is failing though for codeclimate I guess I'll add a commit later.
@noi5e @jywarren should I move the button to some other place ?

@jywarren
Copy link
Member

This is looking great! As to another place, it's only in development mode, but maybe it'd confuse people? What if we put it in the navbar menu? And don't worry about CodeCov, i'm working on that in #9905

Thanks!

@imajit
Copy link
Contributor Author

imajit commented Jul 16, 2021

The top Nav-bar right ? the one with the search bar

@Tlazypanda
Copy link
Collaborator

Ohh @imajit can't say for sure but I think yes @jywarren meant the top nav bar 😅 looping him here in case I missed it

@imajit
Copy link
Contributor Author

imajit commented Jul 17, 2021

This is how it looks in top-nav
ezgif com-gif-maker(2)

@jywarren
Copy link
Member

jywarren commented Jul 17, 2021 via email

@imajit imajit requested a review from a team as a code owner July 18, 2021 07:40
@imajit
Copy link
Contributor Author

imajit commented Jul 18, 2021

ezgif com-gif-maker(3)

@@ -68,6 +68,9 @@ def create
else
@output[:errors] << I18n.t('user_tags_controller.value_cannot_be_empty')
end
if params[:translationswitch]
redirect_to URI.parse('/change_locale/zh-CN').path and return
Copy link

Choose a reason for hiding this comment

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

Use && instead of and.

@@ -105,6 +108,10 @@ def delete
output[:errors] = I18n.t('user_tags_controller.tag_doesnt_exist')
end

if params[:translationswitch]
redirect_to URI.parse('/change_locale/en').path and return
Copy link

Choose a reason for hiding this comment

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

Use && instead of and.

@codeclimate
Copy link

codeclimate bot commented Jul 18, 2021

Code Climate has analyzed commit 0047d80 and detected 2 issues on this pull request.

Here's the issue category breakdown:

Category Count
Style 2

View more on Code Climate.

@noi5e
Copy link
Contributor

noi5e commented Jul 19, 2021

Looks good to me! @jywarren, the Switch on Translation button is now in the nav, so I believe this one is merge-ready

@jywarren
Copy link
Member

Excellent, thank you so much!!!

@jywarren jywarren merged commit 23d4e63 into main Jul 20, 2021
reginaalyssa pushed a commit to reginaalyssa/plots2 that referenced this pull request Oct 16, 2021
* Added check verify translation button

* Adding spaces

* Added route tests

* Reusing existing routes

* Removed tests

* Moved button to Top-Nav

* Moved button to profile dropdown

Co-authored-by: imajit <ajit.171it233@nitk.edu.in>
billymoroney1 pushed a commit to billymoroney1/plots2 that referenced this pull request Dec 28, 2021
* Added check verify translation button

* Adding spaces

* Added route tests

* Reusing existing routes

* Removed tests

* Moved button to Top-Nav

* Moved button to profile dropdown

Co-authored-by: imajit <ajit.171it233@nitk.edu.in>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Planning] Translation System Refinement
4 participants