From daa8eac9cc1604ffdda570679cfd34edc04259f6 Mon Sep 17 00:00:00 2001 From: Colin Darie Date: Wed, 20 Sep 2023 16:04:22 +0200 Subject: [PATCH] style(exports): download link instead of button --- app/components/dossiers/export_link_component.rb | 9 ++++++--- .../export_link_component.en.yml | 4 ++-- .../export_link_component.fr.yml | 4 ++-- .../export_link_component.html.haml | 12 ++++++------ 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/app/components/dossiers/export_link_component.rb b/app/components/dossiers/export_link_component.rb index e79214ae5..fe3a358a2 100644 --- a/app/components/dossiers/export_link_component.rb +++ b/app/components/dossiers/export_link_component.rb @@ -61,16 +61,19 @@ class Dossiers::ExportLinkComponent < ApplicationComponent def export_button(export) if export.available? title = t(".everything_ready", export_format: ".#{export.format}") - content_tag(:a, title, { href: export.file.url, title: new_tab_suffix(title), target: "_blank", rel: "noopener", class: 'fr-btn' }) + render Dsfr::DownloadComponent.new(attachment: export.file, name: title) elsif export.pending? - content_tag(:a, t('.refresh_page'), { href: "", class: 'fr-btn fr-btn fr-btn--tertiary' }) + content_tag(:a, t('.refresh_page'), { href: "", class: 'fr-btn fr-btn--sm fr-btn--tertiary' }) end end def refresh_button_options(export) { title: t(".refresh_old_export", export_format: ".#{export.format}"), - class: "fr-btn fr-btn--tertiary" + "aria-label" => t(".refresh_old_export", export_format: ".#{export.format}"), + class: class_names("fr-btn fr-btn--sm fr-icon-refresh-line fr-btn--tertiary" => true, + "fr-btn--icon" => !export.failed?, + "fr-btn--icon-left" => export.failed?) } end end diff --git a/app/components/dossiers/export_link_component/export_link_component.en.yml b/app/components/dossiers/export_link_component/export_link_component.en.yml index 81217dd25..b4280b376 100644 --- a/app/components/dossiers/export_link_component/export_link_component.en.yml +++ b/app/components/dossiers/export_link_component/export_link_component.en.yml @@ -6,8 +6,8 @@ en: everything_zip_html: Request an export in .zip format
(does not contains timestamp nor operation logs) everything_json_html: Request an export in .json format (GeoJSON) everything_short: Request an export in %{export_format} format - refresh_old_export: Recreate this export - everything_ready: Download in %{export_format} format + refresh_old_export: Regenerate this export + everything_ready: Download export %{export_format} success_label: Ready failed_label: Failed pending_label: In progress diff --git a/app/components/dossiers/export_link_component/export_link_component.fr.yml b/app/components/dossiers/export_link_component/export_link_component.fr.yml index a2a7db1c4..84e889cb3 100644 --- a/app/components/dossiers/export_link_component/export_link_component.fr.yml +++ b/app/components/dossiers/export_link_component/export_link_component.fr.yml @@ -6,8 +6,8 @@ fr: everything_zip_html: Demander un export au format .zip
(ne contient pas l'horodatage ni le journal de log) everything_json_html: Demander un export au format .json (GeoJSON) everything_short: Demander un export au format %{export_format} - refresh_old_export: Recréer cet export - everything_ready: Télécharger au format %{export_format} + refresh_old_export: Regénérer cet export + everything_ready: Télécharger l’export %{export_format} success_label: Prêt failed_label: Erreur pending_label: En préparation diff --git a/app/components/dossiers/export_link_component/export_link_component.html.haml b/app/components/dossiers/export_link_component/export_link_component.html.haml index e9fcb77ee..f7c7d0ee8 100644 --- a/app/components/dossiers/export_link_component/export_link_component.html.haml +++ b/app/components/dossiers/export_link_component/export_link_component.html.haml @@ -9,10 +9,10 @@ = time_info(export) .fr-ml-auto = badge(export) - %ul.fr-btns-group.fr-btns-group--inline-sm - %li - = export_button(export) - - if export.old? - %li - = button_to refresh_button_options(export)[:title], download_export_path(export_format: export.format, statut: export.statut, force_export: true), refresh_button_options(export) + .flex.flex-gap-2 + = export_button(export) + + - if export.old? || export.failed? + = button_to refresh_button_options(export)[:title], download_export_path(export_format: export.format, statut: export.statut, force_export: true), refresh_button_options(export) +