mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: Split hide_profile_and_presence user option (#29632)
It splits the hide_profile_and_presence user option and the default_hide_profile_and_presence site setting for more granular control. It keeps the option to hide the profile under /u/username/preferences/interface and adds the presence toggle in the quick user menu. Co-authored-by: Régis Hanol <regis@hanol.fr>
This commit is contained in:
38
db/migrate/20241030210727_split_hide_profile_and_presence.rb
Normal file
38
db/migrate/20241030210727_split_hide_profile_and_presence.rb
Normal file
@@ -0,0 +1,38 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
class SplitHideProfileAndPresence < ActiveRecord::Migration[7.1]
|
||||
def up
|
||||
# Split default_hide_profile_and_presence if setting exists
|
||||
result =
|
||||
execute(
|
||||
"SELECT value, data_type FROM site_settings WHERE name = 'default_hide_profile_and_presence' LIMIT 1",
|
||||
).first
|
||||
|
||||
if result
|
||||
value = result["value"]
|
||||
data_type = result["data_type"]
|
||||
|
||||
execute "DELETE FROM site_settings WHERE name = 'default_hide_profile_and_presence'"
|
||||
execute <<-SQL
|
||||
INSERT INTO site_settings (name, value, data_type, created_at, updated_at)
|
||||
VALUES
|
||||
('default_hide_profile', '#{value}', '#{data_type}', NOW(), NOW()),
|
||||
('default_hide_presence', '#{value}', '#{data_type}', NOW(), NOW());
|
||||
SQL
|
||||
end
|
||||
|
||||
# Add new columns to user_options
|
||||
execute "ALTER TABLE user_options ADD COLUMN hide_profile BOOLEAN DEFAULT FALSE NOT NULL"
|
||||
execute "ALTER TABLE user_options ADD COLUMN hide_presence BOOLEAN DEFAULT FALSE NOT NULL"
|
||||
execute <<-SQL
|
||||
UPDATE user_options
|
||||
SET hide_profile = hide_profile_and_presence,
|
||||
hide_presence = hide_profile_and_presence
|
||||
WHERE hide_profile_and_presence;
|
||||
SQL
|
||||
end
|
||||
|
||||
def down
|
||||
raise ActiveRecord::IrreversibleMigration
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user