FEATURE: add new user option `skip_new_user_tips`. (#10437)

And add new site setting `default_other_skip_new_user_tips` in user preferences category.
This commit is contained in:
Vinoth Kannan 2020-08-14 19:10:56 +05:30 committed by GitHub
parent 6287c8e171
commit 476d26159a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
19 changed files with 42 additions and 8 deletions

View File

@ -167,6 +167,7 @@ export default Mixin.create({
"default_other_enable_defer",
"default_other_dynamic_favicon",
"default_other_like_notification_frequency",
"default_other_skip_new_user_tips",
"default_topics_automatic_unpin",
"default_categories_watching",
"default_categories_tracking",

View File

@ -43,7 +43,8 @@ export default Controller.extend({
"homepage_id",
"hide_profile_and_presence",
"text_size",
"title_count_mode"
"title_count_mode",
"skip_new_user_tips"
];
if (makeDefault) {

View File

@ -318,7 +318,8 @@ const User = RestModel.extend({
"hide_profile_and_presence",
"text_size",
"title_count_mode",
"timezone"
"timezone",
"skip_new_user_tips"
];
if (fields) {

View File

@ -103,6 +103,7 @@
onChange=(action (mut model.user_option.title_count_mode))
}}
</div>
{{preference-checkbox labelKey="user.skip_new_user_tips" checked=model.user_option.skip_new_user_tips class="pref-new-user-tips"}}
</div>
{{plugin-outlet name="user-preferences-interface" args=(hash model=model save=(action "save"))}}

View File

@ -194,6 +194,7 @@ class Admin::SiteSettingsController < Admin::AdminController
default_other_auto_track_topics_after_msecs: "auto_track_topics_after_msecs",
default_other_notification_level_when_replying: "notification_level_when_replying",
default_other_like_notification_frequency: "like_notification_frequency",
default_other_skip_new_user_tips: "skip_new_user_tips",
default_email_digest_frequency: "digest_after_minutes",
default_include_tl0_in_digests: "include_tl0_in_digests",
default_text_size: "text_size_key",

View File

@ -57,6 +57,7 @@ class UserOption < ActiveRecord::Base
self.enable_defer = SiteSetting.default_other_enable_defer
self.external_links_in_new_tab = SiteSetting.default_other_external_links_in_new_tab
self.dynamic_favicon = SiteSetting.default_other_dynamic_favicon
self.skip_new_user_tips = SiteSetting.default_other_skip_new_user_tips
self.new_topic_duration_minutes = SiteSetting.default_other_new_topic_duration_minutes
self.auto_track_topics_after_msecs = SiteSetting.default_other_auto_track_topics_after_msecs

View File

@ -47,7 +47,8 @@ class CurrentUserSerializer < BasicUserSerializer
:ignored_users,
:title_count_mode,
:timezone,
:featured_topic
:featured_topic,
:skip_new_user_tips
def groups
object.visible_groups.pluck(:id, :name).map { |id, name| { id: id, name: name.downcase } }
@ -204,6 +205,10 @@ class CurrentUserSerializer < BasicUserSerializer
object.user_option.mailing_list_mode
end
def skip_new_user_tips
object.user_option.skip_new_user_tips
end
def include_primary_group_id?
object.primary_group_id.present?
end

View File

@ -30,7 +30,8 @@ class UserOptionSerializer < ApplicationSerializer
:text_size,
:text_size_seq,
:title_count_mode,
:timezone
:timezone,
:skip_new_user_tips
def auto_track_topics_after_msecs
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs

View File

@ -43,7 +43,8 @@ class UserUpdater
:hide_profile_and_presence,
:text_size,
:title_count_mode,
:timezone
:timezone,
:skip_new_user_tips
]
def initialize(actor, user)

View File

@ -930,6 +930,7 @@ en:
dismiss_notifications_tooltip: "Mark all unread notifications as read"
first_notification: "Your first notification! Select it to begin."
dynamic_favicon: "Show counts on browser icon"
skip_new_user_tips: "Skip new user onboarding tips and badges"
theme_default_on_all_devices: "Make this the default theme on all my devices"
dark_mode: "Dark Mode"
dark_mode_enable: "Enable automatic dark mode color scheme"

View File

@ -2157,6 +2157,7 @@ en:
default_other_enable_quoting: "Enable quote reply for highlighted text by default."
default_other_enable_defer: "Enable defer topic functionality by default."
default_other_dynamic_favicon: "Show new/updated topic count on browser icon by default."
default_other_skip_new_user_tips: "Skip new user onboarding tips and badges."
default_other_like_notification_frequency: "Notify users on likes by default"

View File

@ -2133,6 +2133,7 @@ user_preferences:
default_other_enable_quoting: true
default_other_enable_defer: false
default_other_dynamic_favicon: false
default_other_skip_new_user_tips: false
default_other_like_notification_frequency:
enum: "LikeNotificationFrequencySiteSetting"
default: 1

View File

@ -0,0 +1,7 @@
# frozen_string_literal: true
class AddSkipNewUserTipsToUserOptions < ActiveRecord::Migration[6.0]
def change
add_column :user_options, :skip_new_user_tips, :boolean, default: false, null: false
end
end

View File

@ -159,7 +159,8 @@ def insert_user_options
new_topic_duration_minutes,
auto_track_topics_after_msecs,
notification_level_when_replying,
like_notification_frequency
like_notification_frequency,
skip_new_user_tips
)
SELECT u.id
, #{SiteSetting.default_email_mailing_list_mode}
@ -179,6 +180,7 @@ def insert_user_options
, #{SiteSetting.default_other_auto_track_topics_after_msecs}
, #{SiteSetting.default_other_notification_level_when_replying}
, #{SiteSetting.default_other_like_notification_frequency}
, #{SiteSetting.default_other_skip_new_user_tips}
FROM users u
LEFT JOIN user_options uo ON uo.user_id = u.id
WHERE uo.user_id IS NULL

View File

@ -56,6 +56,7 @@ describe UserOption do
SiteSetting.default_other_enable_defer = true
SiteSetting.default_other_external_links_in_new_tab = true
SiteSetting.default_other_dynamic_favicon = true
SiteSetting.default_other_skip_new_user_tips = true
user = Fabricate(:user)
@ -63,6 +64,7 @@ describe UserOption do
expect(user.user_option.enable_defer).to eq(true)
expect(user.user_option.external_links_in_new_tab).to eq(true)
expect(user.user_option.dynamic_favicon).to eq(true)
expect(user.user_option.skip_new_user_tips).to eq(true)
end
end

View File

@ -1658,6 +1658,7 @@ describe User do
SiteSetting.default_other_external_links_in_new_tab = true
SiteSetting.default_other_enable_quoting = false
SiteSetting.default_other_dynamic_favicon = true
SiteSetting.default_other_skip_new_user_tips = true
SiteSetting.default_topics_automatic_unpin = false
@ -1677,6 +1678,7 @@ describe User do
expect(options.external_links_in_new_tab).to eq(true)
expect(options.enable_quoting).to eq(false)
expect(options.dynamic_favicon).to eq(true)
expect(options.skip_new_user_tips).to eq(true)
expect(options.automatically_unpin_topics).to eq(false)
expect(options.new_topic_duration_minutes).to eq(-1)
expect(options.auto_track_topics_after_msecs).to eq(0)

View File

@ -30,13 +30,14 @@ describe UserSerializer do
user = Fabricate.build(:user,
id: 1,
user_profile: Fabricate.build(:user_profile),
user_option: UserOption.new(dynamic_favicon: true),
user_option: UserOption.new(dynamic_favicon: true, skip_new_user_tips: true),
user_stat: UserStat.new
)
json = UserSerializer.new(user, scope: Guardian.new(user), root: false).as_json
expect(json[:user_option][:dynamic_favicon]).to eq(true)
expect(json[:user_option][:skip_new_user_tips]).to eq(true)
expect(json[:user_option][:new_topic_duration_minutes]).to eq(60 * 24)
expect(json[:user_option][:auto_track_topics_after_msecs]).to eq(0)
expect(json[:user_option][:notification_level_when_replying]).to eq(3)

View File

@ -29,7 +29,8 @@ export default {
dismissed_banner_key: null,
akismet_review_count: 0,
title_count_mode: "notifications",
timezone: "Australia/Brisbane"
timezone: "Australia/Brisbane",
skip_new_user_tips: false
}
}
};

View File

@ -176,6 +176,7 @@ export default {
new_topic_duration_minutes: 1440,
external_links_in_new_tab: false,
dynamic_favicon: true,
skip_new_user_tips: false,
enable_quoting: true,
muted_category_ids: [],
tracked_category_ids: [],
@ -2641,6 +2642,7 @@ export default {
email_level: 1,
external_links_in_new_tab: false,
dynamic_favicon: false,
skip_new_user_tips: false,
enable_quoting: true,
digest_after_minutes: 10080,
automatically_unpin_topics: true,
@ -2951,6 +2953,7 @@ export default {
email_messages_level: 0,
external_links_in_new_tab: false,
dynamic_favicon: false,
skip_new_user_tips: false,
enable_quoting: true,
enable_defer: false,
digest_after_minutes: 1440,