FEATURE: Add button to reset seen popups (#18586)

This commit is contained in:
Bianca Nenciu 2022-10-20 04:06:39 +03:00 committed by GitHub
parent f1f2c1acd4
commit 66904f2cd2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 45 additions and 1 deletions

View File

@ -58,6 +58,7 @@ export default Controller.extend({
"text_size",
"title_count_mode",
"skip_new_user_tips",
"seen_popups",
"color_scheme_id",
"dark_scheme_id",
];
@ -418,5 +419,13 @@ export default Controller.extend({
lightStylesheet.remove();
}
},
resetSeenPopups() {
this.model.set("skip_new_user_tips", false);
this.model.set("seen_popups", null);
this.model.set("user_option.skip_new_user_tips", false);
this.model.set("user_option.seen_popups", null);
return this.model.save(["skip_new_user_tips", "seen_popups"]);
},
},
});

View File

@ -117,6 +117,9 @@
<ComboBox @valueProperty="value" @content={{this.titleCountModes}} @value={{this.model.user_option.title_count_mode}} @id="user-title-count-mode" @onChange={{action (mut this.model.user_option.title_count_mode)}} />
</div>
<PreferenceCheckbox @labelKey="user.skip_new_user_tips.description" @checked={{this.model.user_option.skip_new_user_tips}} @class="pref-new-user-tips" />
{{#if this.site.onboarding_popup_types}}
<DButton @class="pref-reset-seen-popups" @action={{action "resetSeenPopups"}}>{{i18n "user.reset_seen_popups"}}</DButton>
{{/if}}
</fieldset>
<PluginOutlet @name="user-preferences-interface" @tagName="span" @connectorTagName="div" @args={{hash model=this.model save=(action "save")}} />

View File

@ -16,6 +16,14 @@ import userFixtures from "discourse/tests/fixtures/user-fixtures";
acceptance("User Preferences - Interface", function (needs) {
needs.user();
let lastUserData;
needs.pretender((server, helper) => {
server.put("/u/eviltrout.json", (request) => {
lastUserData = helper.parsePostData(request.requestBody);
return helper.response({ user: {} });
});
});
test("font size change", async function (assert) {
removeCookie("text_size");
@ -135,6 +143,25 @@ acceptance("User Preferences - Interface", function (needs) {
document.querySelector("meta[name='discourse_theme_id']").remove();
});
test("shows reset seen onboarding popups button", async function (assert) {
let site = Site.current();
site.set("onboarding_popup_types", { first_notification: 1 });
await visit("/u/eviltrout/preferences/interface");
assert.ok(
exists(".pref-reset-seen-popups"),
"has reset seen popups button"
);
await click(".pref-reset-seen-popups");
assert.deepEqual(lastUserData, {
seen_popups: "",
skip_new_user_tips: "false",
});
});
});
acceptance(

View File

@ -34,7 +34,8 @@ class UserOptionSerializer < ApplicationSerializer
:timezone,
:skip_new_user_tips,
:default_calendar,
:oldest_search_log_date
:oldest_search_log_date,
:seen_popups,
def auto_track_topics_after_msecs
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs

View File

@ -1160,6 +1160,7 @@ en:
not_first_time: "Not your first time?"
skip_link: "Skip these tips"
read_later: "I'll read it later."
reset_seen_popups: "Show onboarding tips again"
theme_default_on_all_devices: "Make this the default theme on all my devices"
color_scheme_default_on_all_devices: "Set default color scheme(s) on all my devices"
color_scheme: "Color Scheme"

View File

@ -770,6 +770,9 @@
},
"sidebar_list_destination": {
"type": "string"
},
"seen_popups": {
"type": ["array", "null"]
}
},
"required": [