Merge pull request #354 from Retrospring/refactor/export-locales

This commit is contained in:
Andreas Nedbal 2022-02-13 17:05:54 +01:00 committed by GitHub
commit e6ff2e444d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 32 additions and 22 deletions

View File

@ -170,16 +170,16 @@ class UserController < ApplicationController
def export
if current_user.export_processing
flash[:info] = 'An export is currently in progress for this account.'
flash[:info] = t(".info")
end
end
def begin_export
if current_user.can_export?
ExportWorker.perform_async(current_user.id)
flash[:success] = 'Your account is currently being exported. This will take a little while.'
flash[:success] = t(".success")
else
flash[:error] = 'Nice try, kid.'
flash[:error] = t(".error")
end
redirect_to user_export_path

View File

@ -1,29 +1,20 @@
.card
.card-body
%h2 Export your data
%p
The data is inside a
%code= '.tar.gz'
archive and available in three formats: YAML, JSON, and XML. The archive also contains a copy of your
profile picture and header picture in all sizes.
%p
Please note that you can only export your data once a week. Exporting your data
will take a while, so please be patient. You will receive a question once exporting
is done.
%h2= t(".heading")
= t(".body_html")
- if current_user.can_export?
%form{ action: begin_user_export_path, method: :post }
%p.text-center
%button.btn.btn-lg.btn-primary#export-btn{ type: :submit } Export
%button.btn.btn-lg.btn-primary#export-btn{ type: :submit }= t(".export")
= hidden_field_tag :authenticity_token, form_authenticity_token
- else
%p.text-center
%button.btn.btn-lg.btn-primary.disabled{ disabled: :disabled } Export
%button.btn.btn-lg.btn-primary.disabled{ disabled: :disabled }= t(".export")
%p
- if current_user.export_url.nil?
Once exporting your account is done, a download link will appear here.
= t(".export_url.none")
- else
Here is your export from
= succeed ':' do
= current_user.export_created_at
= t(".export_url.present", time: current_user.export_created_at)
%a{ href: current_user.export_url }
= File.basename current_user.export_url

View File

@ -1,4 +1,4 @@
= render 'settings/export'
= render "settings/export"
- provide(:title, generate_title('Export'))
- parent_layout 'user/settings'
- provide(:title, generate_title(t(".title")))
- parent_layout "user/settings"

View File

@ -22,6 +22,11 @@ en:
destroy:
success: "Service removed successfully."
user:
export:
info: "An export is currently in progress for this account."
begin_export:
success: "Your account is currently being exported. This will take a little while."
error: "Exporting is currently not possible."
update:
success: "Profile updated successfully."
error: "Unable to update profile."

View File

@ -39,6 +39,18 @@ en:
delete:
action: "Delete my account"
heading: "Unsatisfied?"
export:
heading: "Export your data"
body_html: |
<p>The data is inside a <code>.tar.gz</code> archive and available in three formats: YAML, JSON, and XML.
The archive also contains a copy of your profile picture and header picture in all sizes.</p>
<p>Please note that you can only export your data once a week. Exporting your data
will take a while, so please be patient. You will receive a question once exporting
is done.</p>
export: "Export"
export_url:
none: "Once exporting your account is done, a download link will appear here."
present: "Here's your export from %{time}"
profile:
adjust:
profile_picture: "Adjust your new profile picture"
@ -96,3 +108,5 @@ en:
title: "Profile Settings"
edit_theme:
title: "Theme Settings"
export:
title: "Export"