From fe3c9d47fa2d4c00d5095ea8c11ccbdcbbd8d3b3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Javi=20Mart=C3=ADn?= Date: Sun, 29 Jan 2023 17:54:17 +0100 Subject: [PATCH] Make the translation button condition more readable I was finding this part hard to follow, but after changing the name of the condition suddenly I understood what was going on. --- .../layout/remote_translations_button_component.html.erb | 6 +++--- .../layout/remote_translations_button_component.rb | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/app/components/layout/remote_translations_button_component.html.erb b/app/components/layout/remote_translations_button_component.html.erb index 99a590def..faa551128 100644 --- a/app/components/layout/remote_translations_button_component.html.erb +++ b/app/components/layout/remote_translations_button_component.html.erb @@ -1,11 +1,11 @@
- <% if display_remote_translation_button? %> + <% if translations_in_progress? %> + <%= t("remote_translations.all_remote_translations_enqueued_text") %> + <% else %> <%= form_tag remote_translations_path do %> <%= hidden_field_tag :remote_translations, remote_translations.to_json %> <%= t("remote_translations.text") %> <%= submit_tag t("remote_translations.button") %> <% end %> - <% else %> - <%= t("remote_translations.all_remote_translations_enqueued_text") %> <% end %>
diff --git a/app/components/layout/remote_translations_button_component.rb b/app/components/layout/remote_translations_button_component.rb index 44e3a380f..593f2cdaf 100644 --- a/app/components/layout/remote_translations_button_component.rb +++ b/app/components/layout/remote_translations_button_component.rb @@ -12,7 +12,7 @@ class Layout::RemoteTranslationsButtonComponent < ApplicationComponent private - def display_remote_translation_button? - remote_translations.none?(&:enqueued?) + def translations_in_progress? + remote_translations.any?(&:enqueued?) end end