Skip to content

A platform for community discussion. Free, open, simple.

UX: move data export to preferences page for new user nav (#20141)

Krise5f557b97104
diff --git a/app/assets/javascripts/discourse/app/controllers/preferences/account.js b/app/assets/javascripts/discourse/app/controllers/preferences/account.js
index 7baeb206c29..2d90b4dd007 100644
--- a/app/assets/javascripts/discourse/app/controllers/preferences/account.js
+++ b/app/assets/javascripts/discourse/app/controllers/preferences/account.js
@@ -1,7 +1,7 @@
-import { gt, not, or } from "@ember/object/computed";
+import { alias, gt, not, or } from "@ember/object/computed";
import { propertyNotEqual, setting } from "discourse/lib/computed";
import CanCheckEmails from "discourse/mixins/can-check-emails";
-import Controller from "@ember/controller";
+import Controller, { inject as controller } from "@ember/controller";
import EmberObject, { action } from "@ember/object";
import I18n from "I18n";
import discourseComputed from "discourse-common/utils/decorators";
@@ -12,9 +12,13 @@ import { popupAjaxError } from "discourse/lib/ajax-error";
import { inject as service } from "@ember/service";
import { next } from "@ember/runloop";
import showModal from "discourse/lib/show-modal";
+import { exportUserArchive } from "discourse/lib/export-csv";
export default Controller.extend(CanCheckEmails, {
dialog: service(),
+ user: controller(),
+ canDownloadPosts: alias("user.viewingSelf"),
+
init() {
this._super(...arguments);
@@ -244,5 +248,12 @@ export default Controller.extend(CanCheckEmails, {
connectAccount(method) {
method.doLogin({ reconnect: true });
},
+
+ exportUserArchive() {
+ this.dialog.yesNoConfirm({
+ message: I18n.t("user.download_archive.confirm"),
+ didConfirm: () => exportUserArchive(),
+ });
+ },
},
});
diff --git a/app/assets/javascripts/discourse/app/templates/components/topic-progress.hbs b/app/assets/javascripts/discourse/app/templates/components/topic-progress.hbs
index ea39c80f647..edbe065bff7 100644
--- a/app/assets/javascripts/discourse/app/templates/components/topic-progress.hbs
+++ b/app/assets/javascripts/discourse/app/templates/components/topic-progress.hbs
@@ -15,6 +15,7 @@
<nav
title={{i18n "topic.progress.title"}}
+ aria-label={{i18n "topic.progress.title"}}
class={{if this.hideProgress "hidden"}}
id="topic-progress"
style={{html-safe this.progressStyle}}
diff --git a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
index 08739a114aa..400654ac0ae 100644
--- a/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
+++ b/app/assets/javascripts/discourse/app/templates/preferences/account.hbs
@@ -263,6 +263,23 @@
</div>
{{/if}}
+{{#if this.canDownloadPosts}}
+ <div class="control-group pref-data-export">
+ <label class="control-label">{{i18n "user.download_archive.title"}}</label>
+ <div class="controls">
+ <DButton
+ @action={{action "exportUserArchive"}}
+ @class="btn-default btn-request-archive"
+ @label="user.download_archive.button_text"
+ @icon="download"
+ />
+ </div>
+ <div class="instructions">
+ {{i18n "user.download_archive.description"}}
+ </div>
+ </div>
+{{/if}}
+
<span>
<PluginOutlet
@name="user-preferences-account"
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
index 431c0d28717..a08ad5b914f 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-activity-replies-test.js
@@ -1,6 +1,6 @@
import { acceptance, query } from "../helpers/qunit-helpers";
import { test } from "qunit";
-import { click, visit } from "@ember/test-helpers";
+import { visit } from "@ember/test-helpers";
import I18n from "I18n";
acceptance("User Activity / Replies - empty state", function (needs) {
@@ -33,39 +33,3 @@ acceptance("User Activity / Replies - empty state", function (needs) {
);
});
});
-
-acceptance("User Activity / Replies - Download All", function (needs) {
- const currentUser = "eviltrout";
- const anotherUser = "charlie";
- needs.user();
- needs.pretender((server, helper) => {
- server.post("/export_csv/export_entity.json", () => {
- return helper.response({});
- });
- });
-
- test("Can see and trigger download for own data replies", async function (assert) {
- await visit(`/u/${currentUser}/activity`);
-
- assert.ok(query(".user-additional-controls .btn"), "button exists");
-
- await click(".user-additional-controls .btn");
- await click("#dialog-holder .btn-primary");
-
- assert.equal(
- query(".dialog-body").innerText.trim(),
- I18n.t("user.download_archive.success")
- );
-
- await click("#dialog-holder .btn-primary");
- });
-
- test("Cannot see 'Download All' button for another user", async function (assert) {
- await visit(`/u/${anotherUser}/activity`);
-
- assert.notOk(
- query(".user-additional-controls .btn"),
- "download button is not present"
- );
- });
-});
diff --git a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
index 83d8162c6cc..00f753bbf88 100644
--- a/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
+++ b/app/assets/javascripts/discourse/tests/acceptance/user-preferences-account-test.js
@@ -307,3 +307,29 @@ acceptance("User Preferences - Account", function (needs) {
);
});
});
+
+acceptance("User Preferences — Account - Download Archive", function (needs) {
+ const currentUser = "eviltrout";
+ needs.user();
+ needs.pretender((server, helper) => {
+ server.post("/export_csv/export_entity.json", () => {
+ return helper.response({});
+ });
+ });
+
+ test("Can see and trigger download for account data", async function (assert) {
+ await visit(`/u/${currentUser}/preferences/account`);
+
+ assert.ok(query(".btn-request-archive"), "button exists");
+
+ await click(".btn-request-archive");
+ await click("#dialog-holder .btn-primary");
+
+ assert.equal(
+ query(".dialog-body").innerText.trim(),
+ I18n.t("user.download_archive.success")
+ );
+
+ await click("#dialog-holder .btn-primary");
+ });
+});
diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml
index 26517d4e088..da1d7be2a69 100644
--- a/config/locales/client.en.yml
+++ b/config/locales/client.en.yml
@@ -1047,10 +1047,12 @@ en:
mute: "Mute"
edit: "Edit Preferences"
download_archive:
- button_text: "Download All"
- confirm: "Are you sure you want to download your posts?"
- success: "Download initiated, you will be notified via message when the process is complete."
- rate_limit_error: "Posts can be downloaded once per day, please try again tomorrow."
+ title: "Export your data"
+ description: "Download an archive of your account activity and preferences."
+ button_text: "Request archive"
+ confirm: "Do you really want to download an archive of your account activity and preferences?"
+ success: "We've started collecting your archive, you will receive a message when the process is complete."
+ rate_limit_error: "Account archives can be downloaded once per day, please try again tomorrow."
new_private_message: "New Message"
private_message: "Message"
private_messages: "Messages"