Skip to content

Commit

Permalink
Change preferences page into appearance, notifications, and other (ma…
Browse files Browse the repository at this point in the history
  • Loading branch information
Gargron authored and hiyuki2578 committed Oct 2, 2019
1 parent fc4995f commit 81ec1ee
Show file tree
Hide file tree
Showing 100 changed files with 129 additions and 295 deletions.
32 changes: 0 additions & 32 deletions app/controllers/settings/notifications_controller.rb

This file was deleted.

9 changes: 9 additions & 0 deletions app/controllers/settings/preferences/appearance_controller.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Settings::Preferences::AppearanceController < Settings::PreferencesController
private

def after_update_redirect_path
settings_preferences_appearance_path
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# frozen_string_literal: true

class Settings::Preferences::NotificationsController < Settings::PreferencesController
private

def after_update_redirect_path
settings_preferences_notifications_path
end
end
8 changes: 6 additions & 2 deletions app/controllers/settings/preferences_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,18 @@ def update

if current_user.update(user_params)
I18n.locale = current_user.locale
redirect_to settings_preferences_path, notice: I18n.t('generic.changes_saved_msg')
redirect_to after_update_redirect_path, notice: I18n.t('generic.changes_saved_msg')
else
render :show
end
end

private

def after_update_redirect_path
settings_preferences_path
end

def user_settings
UserSettingsDecorator.new(current_user)
end
Expand Down Expand Up @@ -51,7 +55,7 @@ def user_settings_params
:setting_show_application,
:setting_advanced_layout,
notification_emails: %i(follow follow_request reblog favourite mention digest report pending_account),
interactions: %i(must_be_follower must_be_following)
interactions: %i(must_be_follower must_be_following must_be_following_dm)
)
end
end
3 changes: 2 additions & 1 deletion app/javascript/styles/mastodon/accounts.scss
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,8 @@
}
}

.account-role {
.account-role,
.simple_form .recommended {
display: inline-block;
padding: 4px 6px;
cursor: default;
Expand Down
10 changes: 10 additions & 0 deletions app/javascript/styles/mastodon/forms.scss
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,12 @@ code {
text-decoration: none;
}
}

.recommended {
position: absolute;
margin: 0 4px;
margin-top: -2px;
}
}
}

Expand Down Expand Up @@ -443,6 +449,10 @@ code {
height: 41px;
}

h4 {
margin-bottom: 15px !important;
}

.label_input {
&__wrapper {
position: relative;
Expand Down
2 changes: 1 addition & 1 deletion app/views/layouts/mailer.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
%tbody
%td.column-cell
%p= t 'about.hosted_on', domain: site_hostname
%p= link_to t('application_mailer.notification_preferences'), settings_notifications_url
%p= link_to t('application_mailer.notification_preferences'), settings_preferences_notifications_url
%td.column-cell.text-right
= link_to root_url do
= image_tag full_pack_url('media/images/mailer/logo_transparent.png'), alt: 'Mastodon', height: 24
41 changes: 41 additions & 0 deletions app/views/settings/preferences/appearance/show.html.haml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
- content_for :page_title do
= t('settings.appearance')

= simple_form_for current_user, url: settings_preferences_appearance_path, html: { method: :put } do |f|
.fields-row
.fields-group.fields-row__column.fields-row__column-6
= f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale, hint: false
.fields-group.fields-row__column.fields-row__column-6
= f.input :setting_theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false, hint: false

%h4= t 'appearance.advanced_web_interface'

%p.hint= t 'appearance.advanced_web_interface_hint'

.fields-group
= f.input :setting_advanced_layout, as: :boolean, wrapper: :with_label, hint: false

%h4= t 'appearance.animations_and_accessibility'

.fields-group
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label, recommended: true
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label

%h4= t 'appearance.confirmation_dialogs'

.fields-group
= f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label
= f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
= f.input :setting_delete_modal, as: :boolean, wrapper: :with_label

%h4= t 'appearance.sensitive_content'

.fields-group
= f.input :setting_display_media, collection: ['default', 'show_all', 'hide_all'],label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li', wrapper: :with_floating_label

.fields-group
= f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label

.actions
= f.button :button, t('generic.save_changes'), type: :submit
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
- content_for :page_title do
= t('settings.notifications')

= simple_form_for current_user, url: settings_notifications_path, html: { method: :put } do |f|
= simple_form_for current_user, url: settings_preferences_notifications_path, html: { method: :put } do |f|
= render 'shared/error_messages', object: current_user

.fields-group
Expand Down
48 changes: 9 additions & 39 deletions app/views/settings/preferences/show.html.haml
Original file line number Diff line number Diff line change
@@ -1,67 +1,37 @@
- content_for :page_title do
= t('settings.preferences')

%ul.quick-nav
%li= link_to t('preferences.languages'), '#settings_languages'
%li= link_to t('preferences.publishing'), '#settings_publishing'
%li= link_to t('preferences.other'), '#settings_other'
%li= link_to t('preferences.web'), '#settings_web'
%li= link_to t('settings.notifications'), settings_notifications_path

= simple_form_for current_user, url: settings_preferences_path, html: { method: :put } do |f|
= render 'shared/error_messages', object: current_user

.fields-row#settings_languages
.fields-group.fields-row__column.fields-row__column-6
= f.input :locale, collection: I18n.available_locales, wrapper: :with_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, selected: I18n.locale
.fields-group.fields-row__column.fields-row__column-6
= f.input :setting_default_language, collection: [nil] + filterable_languages.sort, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.language_detection') : human_locale(locale) }, required: false, include_blank: false

.fields-group
= f.input :chosen_languages, collection: filterable_languages.sort, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'

%hr#settings_publishing/

.fields-group
= f.input :setting_default_privacy, collection: Status.selectable_visibilities, wrapper: :with_floating_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), content_tag(:span, I18n.t("statuses.visibilities.#{visibility}_long"), class: 'hint')]) }, required: false, as: :radio_buttons, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'

= f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label

%hr#settings_other/

.fields-group
= f.input :setting_noindex, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_hide_network, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_show_application, as: :boolean, wrapper: :with_label
= f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label, recommended: true

%hr#settings_web/
%h4= t 'preferences.posting_defaults'

.fields-row
.fields-group.fields-row__column.fields-row__column-6
= f.input :setting_theme, collection: Themes.instance.names, label_method: lambda { |theme| I18n.t("themes.#{theme}", default: theme) }, wrapper: :with_label, include_blank: false, hint: false
= f.input :setting_default_privacy, collection: Status.selectable_visibilities, wrapper: :with_label, include_blank: false, label_method: lambda { |visibility| safe_join([I18n.t("statuses.visibilities.#{visibility}"), I18n.t("statuses.visibilities.#{visibility}_long")], ' - ') }, required: false, hint: false

.fields-group.fields-row__column.fields-row__column-6
= f.input :setting_display_media, collection: ['default', 'show_all', 'hide_all'], wrapper: :with_label, include_blank: false, label_method: lambda { |item| t("simple_form.hints.defaults.setting_display_media_#{item}") }, hint: false
= f.input :setting_default_language, collection: [nil] + filterable_languages.sort, wrapper: :with_label, label_method: lambda { |locale| locale.nil? ? I18n.t('statuses.language_detection') : human_locale(locale) }, required: false, include_blank: false, hint: false

.fields-group
= f.input :setting_advanced_layout, as: :boolean, wrapper: :with_label
= f.input :setting_default_sensitive, as: :boolean, wrapper: :with_label

.fields-group
= f.input :setting_unfollow_modal, as: :boolean, wrapper: :with_label
= f.input :setting_boost_modal, as: :boolean, wrapper: :with_label
= f.input :setting_delete_modal, as: :boolean, wrapper: :with_label
= f.input :setting_show_application, as: :boolean, wrapper: :with_label, recommended: true

.fields-group
= f.input :setting_aggregate_reblogs, as: :boolean, wrapper: :with_label
%h4= t 'preferences.public_timelines'

.fields-group
= f.input :setting_auto_play_gif, as: :boolean, wrapper: :with_label
= f.input :setting_expand_spoilers, as: :boolean, wrapper: :with_label
= f.input :setting_reduce_motion, as: :boolean, wrapper: :with_label
= f.input :setting_system_font_ui, as: :boolean, wrapper: :with_label
= f.input :chosen_languages, collection: filterable_languages.sort, wrapper: :with_block_label, include_blank: false, label_method: lambda { |locale| human_locale(locale) }, required: false, as: :check_boxes, collection_wrapper_tag: 'ul', item_wrapper_tag: 'li'

.actions
= f.button :button, t('generic.save_changes'), type: :submit
2 changes: 1 addition & 1 deletion app/views/settings/profiles/show.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

- if Setting.profile_directory
.fields-group
= f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path)
= f.input :discoverable, as: :boolean, wrapper: :with_label, hint: t('simple_form.hints.defaults.discoverable_html', min_followers: Account::MIN_FOLLOWERS_DISCOVERY, path: explore_path), recommended: true

%hr.spacer/

Expand Down
2 changes: 1 addition & 1 deletion config/i18n-tasks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ ignore_unused:
- 'activerecord.errors.*'
- '{devise,pagination,doorkeeper}.*'
- '{date,datetime,time,number}.*'
- 'simple_form.{yes,no}'
- 'simple_form.{yes,no,recommended}'
- 'simple_form.{placeholders,hints,labels}.*'
- 'simple_form.{error_notification,required}.:'
- 'errors.messages.*'
Expand Down
10 changes: 10 additions & 0 deletions config/initializers/simple_form.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,16 @@ def append(wrapper_options = nil)
end
end

module RecommendedComponent
def recommended(wrapper_options = nil)
return unless options[:recommended]
options[:label_text] = ->(raw_label_text, _required_label_text, _label_present) { safe_join([raw_label_text, ' ', content_tag(:span, I18n.t('simple_form.recommended'), class: 'recommended')]) }
nil
end
end

SimpleForm.include_component(AppendComponent)
SimpleForm.include_component(RecommendedComponent)

SimpleForm.setup do |config|
# Wrappers are used by the form builder to generate a
Expand Down Expand Up @@ -65,6 +74,7 @@ def append(wrapper_options = nil)
b.use :html5

b.wrapper tag: :div, class: :label_input do |ba|
ba.optional :recommended
ba.use :label

ba.wrapper tag: :div, class: :label_input__wrapper do |bb|
Expand Down
3 changes: 0 additions & 3 deletions config/locales/ar.yml
Original file line number Diff line number Diff line change
Expand Up @@ -736,10 +736,7 @@ ar:
prev: السابق
truncate: و
preferences:
languages: اللغات
other: إعدادات أخرى
publishing: النشر
web: الويب
remote_follow:
acct: قم بإدخال عنوان حسابك username@domain الذي من خلاله تود النشاط
missing_resource: تعذر العثور على رابط التحويل المطلوب الخاص بحسابك
Expand Down
4 changes: 0 additions & 4 deletions config/locales/ast.yml
Original file line number Diff line number Diff line change
Expand Up @@ -245,10 +245,6 @@ ast:
format: "%n%u"
pagination:
next: Siguiente
preferences:
languages: Llingües
publishing: Espublización
web: Web
remote_follow:
acct: Introduz el nome_usuariu@dominiu dende'l que lo quies facer
no_account_html: "¿Nun tienes una cuenta? Pues <a href='%{sign_up_path}' target='_blank'>rexistrate equí</a>"
Expand Down
3 changes: 0 additions & 3 deletions config/locales/ca.yml
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,7 @@ ca:
too_few_options: ha de tenir més d'una opció
too_many_options: no pot contenir més de %{max} opcions
preferences:
languages: Llengues
other: Altre
publishing: Publicant
web: Web
relationships:
activity: Activitat del compte
dormant: Inactiu
Expand Down
3 changes: 0 additions & 3 deletions config/locales/co.yml
Original file line number Diff line number Diff line change
Expand Up @@ -777,10 +777,7 @@ co:
too_few_options: deve avè più d'un'uzzione
too_many_options: ùn pò micca avè più di %{max} uzzione
preferences:
languages: Lingue
other: Altre
publishing: Pubblicazione
web: Web
relationships:
activity: Attività di u contu
dormant: Inattivu
Expand Down
3 changes: 0 additions & 3 deletions config/locales/cs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -788,10 +788,7 @@ cs:
too_few_options: musí mít více než jednu položku
too_many_options: nesmí obsahovat více než %{max} položky
preferences:
languages: Jazyky
other: Ostatní
publishing: Publikování
web: Web
relationships:
activity: Aktivita účtu
dormant: Nečinné
Expand Down
3 changes: 0 additions & 3 deletions config/locales/cy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -746,10 +746,7 @@ cy:
prev: Blaenorol
truncate: "&hellip;"
preferences:
languages: Ieithoedd
other: Arall
publishing: Cyhoeddi
web: Gwe
remote_follow:
acct: Mewnbynnwch eich enwdefnyddiwr@parth yr ydych eisiau gweithredu ohonno
missing_resource: Ni ellir canfod yr URL ailgyferio angenrheidiol i'ch cyfrif
Expand Down
3 changes: 0 additions & 3 deletions config/locales/da.yml
Original file line number Diff line number Diff line change
Expand Up @@ -634,10 +634,7 @@ da:
prev: Forrige
truncate: "...&hellip;"
preferences:
languages: Sprog
other: Andet
publishing: Offentligører
web: Web
remote_follow:
acct: Indtast dit brugernavn@domæne du vil handle fra
missing_resource: Kunne ikke finde det påkrævede omdirigerings link for din konto
Expand Down
3 changes: 0 additions & 3 deletions config/locales/de.yml
Original file line number Diff line number Diff line change
Expand Up @@ -776,10 +776,7 @@ de:
too_few_options: muss mindestens einen Eintrag haben
too_many_options: kann nicht mehr als %{max} Einträge beinhalten
preferences:
languages: Sprachen
other: Weiteres
publishing: Beiträge
web: Web
relationships:
activity: Kontoaktivität
dormant: Inaktiv
Expand Down
3 changes: 0 additions & 3 deletions config/locales/el.yml
Original file line number Diff line number Diff line change
Expand Up @@ -764,10 +764,7 @@ el:
too_few_options: πρέπει να έχει περισσότερες από μια επιλογές
too_many_options: δεν μπορεί να έχει περισσότερες από %{max} επιλογές
preferences:
languages: Γλώσσες
other: Άλλο
publishing: Δημοσίευση
web: Διαδίκτυο
relationships:
activity: Δραστηριότητα λογαριασμού
dormant: Αδρανής
Expand Down
Loading

0 comments on commit 81ec1ee

Please sign in to comment.