From 6b626765a84385e99cdf24060f31bc2d3d2f1501 Mon Sep 17 00:00:00 2001 From: Karina Kwiatek Date: Thu, 23 Dec 2021 00:03:42 +0100 Subject: [PATCH] Create views for managing muted words --- app/controllers/user_controller.rb | 6 ++++++ app/views/settings/_muted.haml | 17 +++++++++++++++++ app/views/tabs/_settings.haml | 1 + app/views/user/edit_mute.haml | 4 ++++ config/routes.rb | 1 + 5 files changed, 29 insertions(+) create mode 100644 app/views/settings/_muted.haml create mode 100644 app/views/user/edit_mute.haml diff --git a/app/controllers/user_controller.rb b/app/controllers/user_controller.rb index edf88087..dcb5c57c 100644 --- a/app/controllers/user_controller.rb +++ b/app/controllers/user_controller.rb @@ -224,4 +224,10 @@ class UserController < ApplicationController @recovery_keys = TotpRecoveryCode.generate_for(current_user) render 'settings/security/recovery_keys' end + + # region Muting + def edit_mute + @rules = MuteRule.where(user: current_user) + end + # endregion end diff --git a/app/views/settings/_muted.haml b/app/views/settings/_muted.haml new file mode 100644 index 00000000..5bb51661 --- /dev/null +++ b/app/views/settings/_muted.haml @@ -0,0 +1,17 @@ +.card + .card-body + %h2 Muted words + %p Muting words (or longer phrases) will prevent questions containing those to appear in your inbox. + %p Note: Filtered questions are discarded completely from your inbox, and won't reappear if you remove a filter later on. + - @rules.each do |rule| + .form-group + .input-group + %input.form-control#new-rule-text{disabled: true, value: rule.muted_phrase} + .input-group-append + %button.btn.btn-danger#new-rule-submit{type: 'button'} Remove + .form-group + %form + .input-group + %input.form-control#new-rule-text{placeholder: 'Add a new muted word...'} + .input-group-append + %button.btn.btn-primary#new-rule-submit{type: 'submit'} Add \ No newline at end of file diff --git a/app/views/tabs/_settings.haml b/app/views/tabs/_settings.haml index d6210214..9195899a 100644 --- a/app/views/tabs/_settings.haml +++ b/app/views/tabs/_settings.haml @@ -5,6 +5,7 @@ = list_group_item t('views.settings.tabs.privacy'), edit_user_privacy_path = list_group_item t('views.settings.tabs.security'), edit_user_security_path = list_group_item t('views.settings.tabs.sharing'), services_path + = list_group_item 'Muted words', edit_user_mute_rules_path = list_group_item 'Theme', edit_user_theme_path = list_group_item 'Your Data', user_data_path = list_group_item 'Export', user_export_path diff --git a/app/views/user/edit_mute.haml b/app/views/user/edit_mute.haml new file mode 100644 index 00000000..aa4c6812 --- /dev/null +++ b/app/views/user/edit_mute.haml @@ -0,0 +1,4 @@ += render 'settings/muted' + +- provide(:title, generate_title('Muted words')) +- parent_layout 'user/settings' diff --git a/config/routes.rb b/config/routes.rb index 1e321272..6ff41bee 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -73,6 +73,7 @@ Rails.application.routes.draw do match '/settings/security/2fa', to: 'user#update_2fa', via: :patch, as: :update_user_2fa match '/settings/security/2fa', to: 'user#destroy_2fa', via: :delete, as: :destroy_user_2fa match '/settings/security/recovery', to: 'user#reset_user_recovery_codes', via: :delete, as: :reset_user_recovery_codes + match '/settings/muted', to: 'user#edit_mute', via: :get, as: :edit_user_mute_rules # resources :services, only: [:index, :destroy] match '/settings/services', to: 'services#index', via: 'get', as: :services