From 84646a6cc13953f6444719fc74aec9cc1b22020e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Toma=CC=81s=CC=8C=20Durc=CC=8Ca=CC=81k?= Date: Fri, 15 Nov 2024 20:38:46 +0100 Subject: [PATCH] Refactoring after review --- Gemfile | 2 +- Gemfile.lock | 2 +- .../common/down_button_component.html.erb | 3 -- .../common/down_button_component.rb | 4 --- app/components/common/icon_component.rb | 1 + .../common/up_button_component.html.erb | 3 -- app/components/common/up_button_component.rb | 4 --- .../layout/filter_list_component.rb | 2 +- .../message_options_component.html.erb | 4 +-- ...ge_threads_bulk_actions_component.html.erb | 4 +-- .../list_row_component.html.erb | 28 +++++++++++++++---- app/policies/filter_policy.rb | 8 ------ 12 files changed, 30 insertions(+), 35 deletions(-) delete mode 100644 app/components/common/down_button_component.html.erb delete mode 100644 app/components/common/down_button_component.rb delete mode 100644 app/components/common/up_button_component.html.erb delete mode 100644 app/components/common/up_button_component.rb diff --git a/Gemfile b/Gemfile index 07e845b52..3146f6c5e 100644 --- a/Gemfile +++ b/Gemfile @@ -39,7 +39,7 @@ gem 'jwt' gem 'stimulus-rails' gem 'jsbundling-rails' gem 'pdf-reader' -gem "acts_as_list", "~> 1.1" +gem "acts_as_list" # Monitoring gem 'rollbar' diff --git a/Gemfile.lock b/Gemfile.lock index 2d3924f10..bc6aad9e0 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -504,7 +504,7 @@ PLATFORMS x86_64-linux DEPENDENCIES - acts_as_list (~> 1.1) + acts_as_list annotate bootsnap (>= 1.4.4) brakeman diff --git a/app/components/common/down_button_component.html.erb b/app/components/common/down_button_component.html.erb deleted file mode 100644 index 653b30946..000000000 --- a/app/components/common/down_button_component.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
- <%= render Icons::ChevronDownComponent.new %> -
diff --git a/app/components/common/down_button_component.rb b/app/components/common/down_button_component.rb deleted file mode 100644 index b1d36031b..000000000 --- a/app/components/common/down_button_component.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Common - class DownButtonComponent < ViewComponent::Base - end -end diff --git a/app/components/common/icon_component.rb b/app/components/common/icon_component.rb index e295b6b99..06e2d11ea 100644 --- a/app/components/common/icon_component.rb +++ b/app/components/common/icon_component.rb @@ -16,6 +16,7 @@ class IconComponent < ViewComponent::Base "bell-slash" => "M9.143 17.082a24.248 24.248 0 003.844.148m-3.844-.148a23.856 23.856 0 01-5.455-1.31 8.964 8.964 0 002.3-5.542m3.155 6.852a3 3 0 005.667 1.97m1.965-2.277L21 21m-4.225-4.225a23.81 23.81 0 003.536-1.003A8.967 8.967 0 0118 9.75V9A6 6 0 006.53 6.53m10.245 10.245L6.53 6.53M3 3l3.53 3.53", "chat-bubble-left-right" => "M20.25 8.511c.884.284 1.5 1.128 1.5 2.097v4.286c0 1.136-.847 2.1-1.98 2.193-.34.027-.68.052-1.02.072v3.091l-3-3c-1.354 0-2.694-.055-4.02-.163a2.115 2.115 0 01-.825-.242m9.345-8.334a2.126 2.126 0 00-.476-.095 48.64 48.64 0 00-8.048 0c-1.131.094-1.976 1.057-1.976 2.192v4.286c0 .837.46 1.58 1.155 1.951m9.345-8.334V6.637c0-1.621-1.152-3.026-2.76-3.235A48.455 48.455 0 0011.25 3c-2.115 0-4.198.137-6.24.402-1.608.209-2.76 1.614-2.76 3.235v6.226c0 1.621 1.152 3.026 2.76 3.235.577.075 1.157.14 1.74.194V21l4.155-4.155", "chevron-down" => "m19.5 8.25-7.5 7.5-7.5-7.5", + "chevron-up" => "M4.5 15.75l7.5-7.5 7.5 7.5", "archive-box" => "M20.25 7.5l-.625 10.632a2.25 2.25 0 01-2.247 2.118H6.622a2.25 2.25 0 01-2.247-2.118L3.75 7.5M10 11.25h4M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125z", "archive-box-x-mark" => "m20.25 7.5-.625 10.632a2.25 2.25 0 0 1-2.247 2.118H6.622a2.25 2.25 0 0 1-2.247-2.118L3.75 7.5m6 4.125 2.25 2.25m0 0 2.25 2.25M12 13.875l2.25-2.25M12 13.875l-2.25 2.25M3.375 7.5h17.25c.621 0 1.125-.504 1.125-1.125v-1.5c0-.621-.504-1.125-1.125-1.125H3.375c-.621 0-1.125.504-1.125 1.125v1.5c0 .621.504 1.125 1.125 1.125Z", "trash" => "M14.74 9l-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 01-2.244 2.077H8.084a2.25 2.25 0 01-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 00-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 013.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 00-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 00-7.5 0", diff --git a/app/components/common/up_button_component.html.erb b/app/components/common/up_button_component.html.erb deleted file mode 100644 index d2bb7975d..000000000 --- a/app/components/common/up_button_component.html.erb +++ /dev/null @@ -1,3 +0,0 @@ -
- <%= render Icons::ChevronUpComponent.new %> -
diff --git a/app/components/common/up_button_component.rb b/app/components/common/up_button_component.rb deleted file mode 100644 index 71d156a8f..000000000 --- a/app/components/common/up_button_component.rb +++ /dev/null @@ -1,4 +0,0 @@ -module Common - class UpButtonComponent < ViewComponent::Base - end -end diff --git a/app/components/layout/filter_list_component.rb b/app/components/layout/filter_list_component.rb index 5459d81ae..a77931d34 100644 --- a/app/components/layout/filter_list_component.rb +++ b/app/components/layout/filter_list_component.rb @@ -10,7 +10,7 @@ def initialize(label: nil, filters:, sortable: false) def icon_for(filter) return Common::IconComponent.new(filter.icon) if filter.icon.present? - if filter.tag_id.present? + if filter.tag.present? return Common::IconComponent.new(filter.tag.icon) if filter.tag.icon.present? return Icons::TagComponent.new end diff --git a/app/components/message_options_component.html.erb b/app/components/message_options_component.html.erb index 06127ebd5..0a36d3c43 100644 --- a/app/components/message_options_component.html.erb +++ b/app/components/message_options_component.html.erb @@ -32,12 +32,12 @@ <% if @mode == :thread_view && @message.collapsible? %> <% if @message.collapsed %> <%= button_to message_path(@message), params: { collapsed: false }, method: :patch, class: 'whitespace-nowrap flex gap-3', role: 'menu-item', tabindex: -1 do %> - <%= render Icons::ChevronDownComponent.new(css_classes: "w-5 h-5") %> + <%= render Common::IconComponent.new("chevron-down", classes: "w-5 h-5") %> Vždy zobrazovať <% end %> <% else %> <%= button_to message_path(@message), params: { collapsed: true }, method: :patch, class: 'whitespace-nowrap flex gap-3', role: 'menu-item', tabindex: -1 do %> - <%= render Icons::ChevronUpComponent.new(css_classes: "w-5 h-5") %> + <%= render Common::IconComponent.new("chevron-up", classes: "w-5 h-5") %> Zbaliť a už nerozbaľovať <% end %> <% end %> diff --git a/app/components/message_threads_bulk_actions_component.html.erb b/app/components/message_threads_bulk_actions_component.html.erb index 245dd9947..fc5f9d4ab 100644 --- a/app/components/message_threads_bulk_actions_component.html.erb +++ b/app/components/message_threads_bulk_actions_component.html.erb @@ -24,7 +24,7 @@
@@ -126,7 +126,7 @@
diff --git a/app/components/settings/user_filter_visibilities/list_row_component.html.erb b/app/components/settings/user_filter_visibilities/list_row_component.html.erb index 9d21c0d53..b60639d1a 100644 --- a/app/components/settings/user_filter_visibilities/list_row_component.html.erb +++ b/app/components/settings/user_filter_visibilities/list_row_component.html.erb @@ -8,27 +8,43 @@ <%= form_with model: [:settings, Current.user.user_filter_visibilities.new(filter: @filter)], method: :post do |form| %> <%= form.hidden_field :filter_id, value: @filter.id %> <%= form.hidden_field :visible, value: !@visibility.visible %> - <%= form.button class: "#{@visibility.hidden ? "bg-gray-200" : "bg-indigo-600"} relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2", role: :switch, aria: { checked: @visibility.hidden.to_s } do %> + <%= form.button class: class_names('relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2', { "bg-gray-200": @visibility.hidden, "bg-indigo-600": @visibility.visible }), role: :switch, aria: { checked: @visibility.hidden.to_s } do %> Use setting - + <% end %> <% end %> <% else %> <%= form_with model: [:settings, @visibility], method: :patch do |form| %> <%= form.hidden_field :visible, value: !@visibility.visible %> - <%= form.button class: "#{@visibility.hidden ? "bg-gray-200" : "bg-indigo-600"} relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2", role: :switch, aria: { checked: @visibility.hidden.to_s } do %> + <%= form.button class: class_names('relative inline-flex h-6 w-11 flex-shrink-0 cursor-pointer rounded-full border-2 border-transparent transition-colors duration-200 ease-in-out focus:outline-none focus:ring-2 focus:ring-indigo-600 focus:ring-offset-2', { "bg-gray-200": @visibility.hidden, "bg-indigo-600": @visibility.visible }), role: :switch, aria: { checked: @visibility.hidden.to_s } do %> Use setting - + <% end %> <% end %> <%= form_with model: [:move_higher, :settings, @visibility], method: :post do |form| %> <%= form.button do %> - <%= render Common::UpButtonComponent.new %> +
+ <%= render Common::IconComponent.new("chevron-up") %> +
<% end %> <% end %> <%= form_with model: [:move_lower, :settings, @visibility], method: :post do |form| %> <%= form.button do %> - <%= render Common::DownButtonComponent.new %> +
+ <%= render Common::IconComponent.new("chevron-down") %> +
<% end %> <% end %> <% end %> diff --git a/app/policies/filter_policy.rb b/app/policies/filter_policy.rb index 183a3a3b1..02312a42d 100644 --- a/app/policies/filter_policy.rb +++ b/app/policies/filter_policy.rb @@ -60,14 +60,6 @@ def destroy? @user.admin? || is_author_current_user? end - def pin? - is_author_current_user? - end - - def unpin? - pin? - end - def sort? is_author_current_user? end