Skip to content

Commit

Permalink
Refactoring after review
Browse files Browse the repository at this point in the history
  • Loading branch information
Tomáš Durčák committed Nov 15, 2024
1 parent 0776ad3 commit 84646a6
Show file tree
Hide file tree
Showing 12 changed files with 30 additions and 35 deletions.
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down
2 changes: 1 addition & 1 deletion Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -504,7 +504,7 @@ PLATFORMS
x86_64-linux

DEPENDENCIES
acts_as_list (~> 1.1)
acts_as_list
annotate
bootsnap (>= 1.4.4)
brakeman
Expand Down
3 changes: 0 additions & 3 deletions app/components/common/down_button_component.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/components/common/down_button_component.rb

This file was deleted.

1 change: 1 addition & 0 deletions app/components/common/icon_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
3 changes: 0 additions & 3 deletions app/components/common/up_button_component.html.erb

This file was deleted.

4 changes: 0 additions & 4 deletions app/components/common/up_button_component.rb

This file was deleted.

2 changes: 1 addition & 1 deletion app/components/layout/filter_list_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions app/components/message_options_component.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@
<div>
<button type="button" data-action="dropdown#toggle click@window->dropdown#hide" class="inline-flex w-full justify-center items-center gap-x-1.5 rounded-md bg-white px-2 py-1 sm:px-3 sm:py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" id="menu-button" aria-expanded="true" aria-haspopup="true">
Hromadné akcie
<%= render Icons::ChevronDownComponent.new(css_classes: "w-4 h-4 text-gray-400", stroke_width: 2) %>
<%= render Icons::IconComponent.new('chevron-down', classes: "w-4 h-4 text-gray-400", stroke_width: 2) %>
</button>
</div>

Expand Down Expand Up @@ -126,7 +126,7 @@
<div>
<button type="button" data-action="dropdown#toggle click@window->dropdown#hide" class="inline-flex w-full justify-center items-center gap-x-1.5 rounded-md bg-white px-2 py-1 sm:px-3 sm:py-2 text-sm font-semibold text-gray-900 shadow-sm ring-1 ring-inset ring-gray-300 hover:bg-gray-50" id="menu-button" aria-expanded="true" aria-haspopup="true">
Vytvoriť novú správu
<%= render Icons::ChevronDownComponent.new(css_classes: "w-4 h-4 text-gray-400", stroke_width: 2) %>
<%= render Common::IconComponent.new('chevron-down', classes: "w-4 h-4 text-gray-400", stroke_width: 2) %>
</button>
</div>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 %>
<span class="sr-only">Use setting</span>
<span aria-hidden="true" class="<%= @visibility.hidden ? "translate-x-0" : "translate-x-5" %> pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
<span
aria-hidden="true"
class="<%= class_names(
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-2',
{ 'translate-x-0': @visibility.hidden, 'translate-x-5': @visibility.visible }
) %>"
></span>
<% 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 %>
<span class="sr-only">Use setting</span>
<span aria-hidden="true" class="<%= @visibility.hidden ? "translate-x-0" : "translate-x-5" %> pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out"></span>
<span
aria-hidden="true"
class="<%= class_names(
'pointer-events-none inline-block h-5 w-5 transform rounded-full bg-white shadow ring-0 transition duration-200 ease-in-out',
{ 'translate-x-0': @visibility.hidden, 'translate-x-5': @visibility.visible }
) %>"
></span>
<% end %>
<% end %>
<%= form_with model: [:move_higher, :settings, @visibility], method: :post do |form| %>
<%= form.button do %>
<%= render Common::UpButtonComponent.new %>
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md bg-white border border-gray-300 hover:bg-gray-100">
<%= render Common::IconComponent.new("chevron-up") %>
</div>
<% end %>
<% end %>
<%= form_with model: [:move_lower, :settings, @visibility], method: :post do |form| %>
<%= form.button do %>
<%= render Common::DownButtonComponent.new %>
<div class="flex justify-center items-center flex-grow-0 flex-shrink-0 relative overflow-hidden gap-2.5 px-3.5 py-2.5 rounded-md bg-white border border-gray-300 hover:bg-gray-100">
<%= render Common::IconComponent.new("chevron-down") %>
</div>
<% end %>
<% end %>
<% end %>
Expand Down
8 changes: 0 additions & 8 deletions app/policies/filter_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 84646a6

Please sign in to comment.