mirror of
https://github.com/discourse/discourse.git
synced 2024-11-22 09:42:02 +08:00
DEV: Setup experimental sidebar skeleton (#16575)
* hidden siteSetting to enable experimental sidebar * user preference to enable experimental sidebar * `experimental_sidebar_enabled` attribute for current user * Empty glimmer component for Sidebar
This commit is contained in:
parent
9f9131efbe
commit
98c49acad5
|
@ -0,0 +1,3 @@
|
|||
import GlimmerComponent from "discourse/components/glimmer";
|
||||
|
||||
export default class Sidebar extends GlimmerComponent {}
|
|
@ -58,6 +58,7 @@ export default Controller.extend({
|
|||
"skip_new_user_tips",
|
||||
"color_scheme_id",
|
||||
"dark_scheme_id",
|
||||
"enable_experimental_sidebar",
|
||||
];
|
||||
|
||||
if (makeThemeDefault) {
|
||||
|
|
|
@ -99,6 +99,7 @@ let userOptionFields = [
|
|||
"skip_new_user_tips",
|
||||
"default_calendar",
|
||||
"bookmark_auto_delete_preference",
|
||||
"enable_experimental_sidebar",
|
||||
];
|
||||
|
||||
export function addSaveableUserOptionField(fieldName) {
|
||||
|
|
|
@ -25,6 +25,11 @@
|
|||
{{create-topics-notice}}
|
||||
{{plugin-outlet name="top-notices" connectorTagName="div" args=(hash currentPath=router._router.currentPath)}}
|
||||
</div>
|
||||
|
||||
{{#if currentUser.experimental_sidebar_enabled}}
|
||||
<Sidebar />
|
||||
{{/if}}
|
||||
|
||||
{{outlet}}
|
||||
{{outlet "user-card"}}
|
||||
</div>
|
||||
|
|
|
@ -133,6 +133,10 @@
|
|||
<fieldset class="control-group other">
|
||||
<legend class="control-label">{{i18n "user.other_settings"}}</legend>
|
||||
|
||||
{{#if siteSettings.enable_experimental_sidebar}}
|
||||
{{preference-checkbox labelKey="user.enable_experimental_sidebar" checked=model.user_option.enable_experimental_sidebar class="pref-external-links"}}
|
||||
{{/if}}
|
||||
|
||||
{{preference-checkbox labelKey="user.external_links_in_new_tab" checked=model.user_option.external_links_in_new_tab class="pref-external-links"}}
|
||||
{{preference-checkbox labelKey="user.enable_quoting" checked=model.user_option.enable_quoting class="pref-enable-quoting"}}
|
||||
{{preference-checkbox labelKey="user.enable_defer" checked=model.user_option.enable_defer class="pref-defer-undread"}}
|
||||
|
|
|
@ -261,6 +261,7 @@ end
|
|||
# default_calendar :integer default("none_selected"), not null
|
||||
# oldest_search_log_date :datetime
|
||||
# bookmark_auto_delete_preference :integer default(3), not null
|
||||
# enable_experimental_sidebar :boolean default(FALSE)
|
||||
#
|
||||
# Indexes
|
||||
#
|
||||
|
|
|
@ -69,7 +69,8 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||
:draft_count,
|
||||
:default_calendar,
|
||||
:bookmark_auto_delete_preference,
|
||||
:pending_posts_count
|
||||
:pending_posts_count,
|
||||
:experimental_sidebar_enabled
|
||||
|
||||
delegate :user_stat, to: :object, private: true
|
||||
delegate :any_posts, :draft_count, :pending_posts_count, :read_faq?, to: :user_stat
|
||||
|
@ -327,4 +328,12 @@ class CurrentUserSerializer < BasicUserSerializer
|
|||
def include_has_topic_draft?
|
||||
Draft.has_topic_draft(object)
|
||||
end
|
||||
|
||||
def experimental_sidebar_enabled
|
||||
object.user_option.enable_experimental_sidebar
|
||||
end
|
||||
|
||||
def include_experimental_sidebar_enabled?
|
||||
SiteSetting.enable_experimental_sidebar
|
||||
end
|
||||
end
|
||||
|
|
|
@ -35,6 +35,7 @@ class UserOptionSerializer < ApplicationSerializer
|
|||
:skip_new_user_tips,
|
||||
:default_calendar,
|
||||
:oldest_search_log_date,
|
||||
:enable_experimental_sidebar
|
||||
|
||||
def auto_track_topics_after_msecs
|
||||
object.auto_track_topics_after_msecs || SiteSetting.default_other_auto_track_topics_after_msecs
|
||||
|
@ -52,4 +53,8 @@ class UserOptionSerializer < ApplicationSerializer
|
|||
object.theme_ids.presence || [SiteSetting.default_theme_id]
|
||||
end
|
||||
|
||||
def include_enable_experimental_sidebar?
|
||||
SiteSetting.enable_experimental_sidebar
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -47,7 +47,8 @@ class UserUpdater
|
|||
:title_count_mode,
|
||||
:timezone,
|
||||
:skip_new_user_tips,
|
||||
:default_calendar
|
||||
:default_calendar,
|
||||
:enable_experimental_sidebar
|
||||
]
|
||||
|
||||
NOTIFICATION_SCHEDULE_ATTRS = -> {
|
||||
|
|
|
@ -1156,6 +1156,7 @@ en:
|
|||
external_links_in_new_tab: "Open all external links in a new tab"
|
||||
enable_quoting: "Enable quote reply for highlighted text"
|
||||
enable_defer: "Enable defer to mark topics unread"
|
||||
enable_experimental_sidebar: "Enable experimental sidebar"
|
||||
change: "change"
|
||||
featured_topic: "Featured Topic"
|
||||
moderator: "%{user} is a moderator"
|
||||
|
|
|
@ -1957,6 +1957,10 @@ developer:
|
|||
enable_safe_mode:
|
||||
default: true
|
||||
client: true
|
||||
enable_experimental_sidebar:
|
||||
default: false
|
||||
client: true
|
||||
hidden: true
|
||||
|
||||
embedding:
|
||||
embed_by_username:
|
||||
|
|
|
@ -0,0 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class AddEnableExperimentalSidebarToUserOptions < ActiveRecord::Migration[6.1]
|
||||
def change
|
||||
add_column :user_options, :enable_experimental_sidebar, :boolean, default: false
|
||||
end
|
||||
end
|
|
@ -2309,6 +2309,21 @@ describe UsersController do
|
|||
expect(response).to be_forbidden
|
||||
expect(user.reload.name).not_to eq 'Jim Tom'
|
||||
end
|
||||
|
||||
context 'enabling experimental sidebar' do
|
||||
before do
|
||||
sign_in(user)
|
||||
end
|
||||
|
||||
it "should be able to update UserOption#enable_experimental_sidebar" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
|
||||
put "/u/#{user.username}.json", params: { enable_experimental_sidebar: 'true' }
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(user.user_option.enable_experimental_sidebar).to eq(true)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
@ -3882,6 +3897,23 @@ describe UsersController do
|
|||
expect(topic_post_count[topic.id.to_s]).to eq(2)
|
||||
end
|
||||
end
|
||||
|
||||
it "includes UserOption#enable_experimental_sidebar when SiteSetting.enable_experimental_sidebar is true" do
|
||||
SiteSetting.enable_experimental_sidebar = true
|
||||
user1.user_option.update!(enable_experimental_sidebar: true)
|
||||
|
||||
get "/u/#{user1.username}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["user"]["user_option"]["enable_experimental_sidebar"]).to eq(true)
|
||||
end
|
||||
|
||||
it "does not include UserOption#enable_experimental_sidebar when SiteSetting.enable_experimental_sidebar is false" do
|
||||
get "/u/#{user1.username}.json"
|
||||
|
||||
expect(response.status).to eq(200)
|
||||
expect(response.parsed_body["user"]["user_option"]["enable_experimental_sidebar"]).to eq(nil)
|
||||
end
|
||||
end
|
||||
|
||||
it "should be able to view a user" do
|
||||
|
|
Loading…
Reference in New Issue
Block a user