Extract component for remote translations button
So we're consistent with the rest of the code in the header, which renders components and not partials.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
<div class="remote-translations-button callout primary text-center">
|
||||
<% if display_remote_translation_button? %>
|
||||
<%= 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 %>
|
||||
</div>
|
||||
@@ -0,0 +1,20 @@
|
||||
class Layout::RemoteTranslationsButtonComponent < ApplicationComponent
|
||||
attr_reader :remote_translations
|
||||
|
||||
def initialize(remote_translations)
|
||||
@remote_translations = remote_translations
|
||||
end
|
||||
|
||||
def render?
|
||||
remote_translations.present? &&
|
||||
RemoteTranslations::Microsoft::AvailableLocales.include_locale?(I18n.locale)
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def display_remote_translation_button?
|
||||
remote_translations.none? do |remote_translation|
|
||||
RemoteTranslation.remote_translation_enqueued?(remote_translation)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user