mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-05 17:31:12 +00:00
Move posting defaults to their own preferences sub-category (#35966)
This commit is contained in:
parent
f21d9f64db
commit
ab698ff521
|
@ -0,0 +1,9 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
class Settings::Preferences::PostingDefaultsController < Settings::Preferences::BaseController
|
||||||
|
private
|
||||||
|
|
||||||
|
def after_update_redirect_path
|
||||||
|
settings_preferences_posting_defaults_path
|
||||||
|
end
|
||||||
|
end
|
|
@ -15,45 +15,6 @@
|
||||||
recommended: true,
|
recommended: true,
|
||||||
wrapper: :with_label
|
wrapper: :with_label
|
||||||
|
|
||||||
%h4= t 'preferences.posting_defaults'
|
|
||||||
|
|
||||||
.fields-group
|
|
||||||
= ff.input :default_privacy,
|
|
||||||
collection: Status.selectable_visibilities,
|
|
||||||
selected: current_user.setting_default_privacy,
|
|
||||||
hint: false,
|
|
||||||
include_blank: false,
|
|
||||||
label_method: ->(visibility) { safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') },
|
|
||||||
label: I18n.t('simple_form.labels.defaults.setting_default_privacy'),
|
|
||||||
required: false,
|
|
||||||
wrapper: :with_label
|
|
||||||
|
|
||||||
.fields-group
|
|
||||||
= ff.input :default_quote_policy,
|
|
||||||
collection: %w(public followers nobody),
|
|
||||||
include_blank: false,
|
|
||||||
label_method: ->(policy) { I18n.t("statuses.quote_policies.#{policy}") },
|
|
||||||
label: I18n.t('simple_form.labels.defaults.setting_default_quote_policy'),
|
|
||||||
hint: I18n.t('simple_form.hints.defaults.setting_default_quote_policy'),
|
|
||||||
required: false,
|
|
||||||
wrapper: :with_label
|
|
||||||
|
|
||||||
.fields-group
|
|
||||||
= ff.input :default_language,
|
|
||||||
collection: [nil] + filterable_languages,
|
|
||||||
hint: false,
|
|
||||||
include_blank: false,
|
|
||||||
label_method: ->(locale) { locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) },
|
|
||||||
label: I18n.t('simple_form.labels.defaults.setting_default_language'),
|
|
||||||
required: false,
|
|
||||||
wrapper: :with_label
|
|
||||||
|
|
||||||
.fields-group
|
|
||||||
= ff.input :default_sensitive,
|
|
||||||
hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive'),
|
|
||||||
label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'),
|
|
||||||
wrapper: :with_label
|
|
||||||
|
|
||||||
%h4= t 'preferences.public_timelines'
|
%h4= t 'preferences.public_timelines'
|
||||||
|
|
||||||
.fields-group
|
.fields-group
|
||||||
|
|
|
@ -0,0 +1,48 @@
|
||||||
|
- content_for :page_title do
|
||||||
|
= t('preferences.posting_defaults')
|
||||||
|
|
||||||
|
- content_for :heading_actions do
|
||||||
|
= button_tag t('generic.save_changes'), class: 'button', form: 'edit_preferences'
|
||||||
|
|
||||||
|
= simple_form_for current_user, url: settings_preferences_posting_defaults_path, html: { id: :edit_preferences } do |f|
|
||||||
|
= render 'shared/error_messages', object: current_user
|
||||||
|
|
||||||
|
= f.simple_fields_for :settings, current_user.settings do |ff|
|
||||||
|
.flash-message= t('posting_defaults.explanation')
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= ff.input :default_privacy,
|
||||||
|
collection: Status.selectable_visibilities,
|
||||||
|
selected: current_user.setting_default_privacy,
|
||||||
|
hint: false,
|
||||||
|
include_blank: false,
|
||||||
|
label_method: ->(visibility) { safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') },
|
||||||
|
label: I18n.t('simple_form.labels.defaults.setting_default_privacy'),
|
||||||
|
required: false,
|
||||||
|
wrapper: :with_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= ff.input :default_quote_policy,
|
||||||
|
collection: %w(public followers nobody),
|
||||||
|
include_blank: false,
|
||||||
|
label_method: ->(policy) { I18n.t("statuses.quote_policies.#{policy}") },
|
||||||
|
label: I18n.t('simple_form.labels.defaults.setting_default_quote_policy'),
|
||||||
|
hint: I18n.t('simple_form.hints.defaults.setting_default_quote_policy'),
|
||||||
|
required: false,
|
||||||
|
wrapper: :with_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= ff.input :default_language,
|
||||||
|
collection: [nil] + filterable_languages,
|
||||||
|
hint: false,
|
||||||
|
include_blank: false,
|
||||||
|
label_method: ->(locale) { locale.nil? ? I18n.t('statuses.default_language') : native_locale_name(locale) },
|
||||||
|
label: I18n.t('simple_form.labels.defaults.setting_default_language'),
|
||||||
|
required: false,
|
||||||
|
wrapper: :with_label
|
||||||
|
|
||||||
|
.fields-group
|
||||||
|
= ff.input :default_sensitive,
|
||||||
|
hint: I18n.t('simple_form.hints.defaults.setting_default_sensitive'),
|
||||||
|
label: I18n.t('simple_form.labels.defaults.setting_default_sensitive'),
|
||||||
|
wrapper: :with_label
|
|
@ -1740,6 +1740,8 @@ en:
|
||||||
self_vote: You cannot vote in your own polls
|
self_vote: You cannot vote in your own polls
|
||||||
too_few_options: must have more than one item
|
too_few_options: must have more than one item
|
||||||
too_many_options: can't contain more than %{max} items
|
too_many_options: can't contain more than %{max} items
|
||||||
|
posting_defaults:
|
||||||
|
explanation: These settings will be used as defaults when you create new posts, but you can edit them per post within the composer.
|
||||||
preferences:
|
preferences:
|
||||||
other: Other
|
other: Other
|
||||||
posting_defaults: Posting defaults
|
posting_defaults: Posting defaults
|
||||||
|
|
|
@ -16,6 +16,7 @@ SimpleNavigation::Configuration.run do |navigation|
|
||||||
|
|
||||||
n.item :preferences, safe_join([material_symbol('settings'), t('settings.preferences')]), settings_preferences_path, if: -> { current_user.functional? && !self_destruct } do |s|
|
n.item :preferences, safe_join([material_symbol('settings'), t('settings.preferences')]), settings_preferences_path, if: -> { current_user.functional? && !self_destruct } do |s|
|
||||||
s.item :appearance, safe_join([material_symbol('computer'), t('settings.appearance')]), settings_preferences_appearance_path
|
s.item :appearance, safe_join([material_symbol('computer'), t('settings.appearance')]), settings_preferences_appearance_path
|
||||||
|
s.item :posting_defaults, safe_join([material_symbol('edit_square'), t('preferences.posting_defaults')]), settings_preferences_posting_defaults_path
|
||||||
s.item :notifications, safe_join([material_symbol('mail'), t('settings.notifications')]), settings_preferences_notifications_path
|
s.item :notifications, safe_join([material_symbol('mail'), t('settings.notifications')]), settings_preferences_notifications_path
|
||||||
s.item :other, safe_join([material_symbol('tune'), t('preferences.other')]), settings_preferences_other_path
|
s.item :other, safe_join([material_symbol('tune'), t('preferences.other')]), settings_preferences_other_path
|
||||||
end
|
end
|
||||||
|
|
|
@ -9,6 +9,7 @@ namespace :settings do
|
||||||
|
|
||||||
namespace :preferences do
|
namespace :preferences do
|
||||||
resource :appearance, only: [:show, :update], controller: :appearance
|
resource :appearance, only: [:show, :update], controller: :appearance
|
||||||
|
resource :posting_defaults, only: [:show, :update], controller: :posting_defaults
|
||||||
resource :notifications, only: [:show, :update]
|
resource :notifications, only: [:show, :update]
|
||||||
resource :other, only: [:show, :update], controller: :other
|
resource :other, only: [:show, :update], controller: :other
|
||||||
end
|
end
|
||||||
|
|
|
@ -15,11 +15,9 @@ RSpec.describe 'Settings preferences other page' do
|
||||||
|
|
||||||
check language_field(:es)
|
check language_field(:es)
|
||||||
check language_field(:fr)
|
check language_field(:fr)
|
||||||
check mark_sensitive_field
|
|
||||||
|
|
||||||
expect { save_changes }
|
expect { save_changes }
|
||||||
.to change { user.reload.chosen_languages }.to(%w(es fr))
|
.to change { user.reload.chosen_languages }.to(%w(es fr))
|
||||||
.and(change { user.reload.settings.default_sensitive }.to(true))
|
|
||||||
expect(page)
|
expect(page)
|
||||||
.to have_title(I18n.t('settings.preferences'))
|
.to have_title(I18n.t('settings.preferences'))
|
||||||
end
|
end
|
||||||
|
@ -28,10 +26,6 @@ RSpec.describe 'Settings preferences other page' do
|
||||||
within('form') { click_on submit_button }
|
within('form') { click_on submit_button }
|
||||||
end
|
end
|
||||||
|
|
||||||
def mark_sensitive_field
|
|
||||||
form_label('defaults.setting_default_sensitive')
|
|
||||||
end
|
|
||||||
|
|
||||||
def language_field(key)
|
def language_field(key)
|
||||||
LanguagesHelper::SUPPORTED_LOCALES[key].last
|
LanguagesHelper::SUPPORTED_LOCALES[key].last
|
||||||
end
|
end
|
||||||
|
|
31
spec/system/settings/preferences/posting_defaults_spec.rb
Normal file
31
spec/system/settings/preferences/posting_defaults_spec.rb
Normal file
|
@ -0,0 +1,31 @@
|
||||||
|
# frozen_string_literal: true
|
||||||
|
|
||||||
|
require 'rails_helper'
|
||||||
|
|
||||||
|
RSpec.describe 'Settings preferences posting defaults page' do
|
||||||
|
let(:user) { Fabricate :user }
|
||||||
|
|
||||||
|
before { sign_in user }
|
||||||
|
|
||||||
|
it 'Views and updates user prefs' do
|
||||||
|
visit settings_preferences_posting_defaults_path
|
||||||
|
|
||||||
|
expect(page)
|
||||||
|
.to have_private_cache_control
|
||||||
|
|
||||||
|
check mark_sensitive_field
|
||||||
|
|
||||||
|
expect { save_changes }
|
||||||
|
.to change { user.reload.settings.default_sensitive }.to(true)
|
||||||
|
expect(page)
|
||||||
|
.to have_title(I18n.t('preferences.posting_defaults'))
|
||||||
|
end
|
||||||
|
|
||||||
|
def save_changes
|
||||||
|
click_on submit_button
|
||||||
|
end
|
||||||
|
|
||||||
|
def mark_sensitive_field
|
||||||
|
form_label('defaults.setting_default_sensitive')
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user