Skip to content

Commit

Permalink
Clean ButtonComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
B-Rass committed Oct 17, 2024
1 parent f282fd1 commit cf3d1af
Show file tree
Hide file tree
Showing 39 changed files with 52 additions and 52 deletions.
2 changes: 1 addition & 1 deletion app/components/button_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ class ButtonComponent < ApplicationComponent
VARIANTS = %i[default primary secondary success danger warning info light dark link outline_primary].freeze
SIZES = %i[sm default lg].freeze

def initialize(title:, url:, variant: :default, size: :default, icon: nil, is_responsive: false, extra_classes: "", **html_options) # rubocop:disable Metrics/ParameterLists
def initialize(title, url:, variant: :default, size: :default, icon: nil, is_responsive: false, extra_classes: "", **html_options) # rubocop:disable Metrics/ParameterLists
@title = title
@url = url
@variant = variant&.to_sym
Expand Down
4 changes: 2 additions & 2 deletions app/components/page/heading_edit_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(resource:, title:, breadcrumb_steps:)
def call
render HeadingComponent.new(title: @title, breadcrumb_steps: @breadcrumb_steps) do |heading|
heading.with_left_content do
render ButtonComponent.new(title: t("action.back"),
render ButtonComponent.new(t("action.back"),
url: polymorphic_url(@resource.class),
icon: "chevron-left",
is_responsive: true)
Expand All @@ -25,7 +25,7 @@ def call
tag.div class: "align-self-center d-inline-flex" do
concat(extra_buttons) if extra_buttons?

concat(render(ButtonComponent.new(title: t("action.show"),
concat(render(ButtonComponent.new(t("action.show"),
url: @resource,
variant: :primary,
icon: "eye",
Expand Down
2 changes: 1 addition & 1 deletion app/components/page/heading_new_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ def call
render HeadingComponent.new(title: @title, breadcrumb_steps: @breadcrumb_steps) do |heading|
heading.with_left_content do
tag.span class: "flex-grow-1" do
render ButtonComponent.new(title: t("action.back"),
render ButtonComponent.new(t("action.back"),
url: polymorphic_url(@resource.class),
icon: "chevron-left",
is_responsive: true)
Expand Down
4 changes: 2 additions & 2 deletions app/components/page/heading_show_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ def initialize(resource:, title:, breadcrumb_steps:)
def call
render HeadingComponent.new(title: @title, breadcrumb_steps: @breadcrumb_steps) do |heading|
heading.with_left_content do
render ButtonComponent.new(title: t("action.back"),
render ButtonComponent.new(t("action.back"),
url: polymorphic_url(@resource.class),
icon: "chevron-left",
is_responsive: true)
Expand All @@ -25,7 +25,7 @@ def call
tag.div class: "align-self-center d-inline-flex" do
concat(extra_buttons) if extra_buttons?

concat(render(ButtonComponent.new(title: t("action.edit"),
concat(render(ButtonComponent.new(t("action.edit"),
url: [:edit, @resource],
variant: :info,
icon: "pencil",
Expand Down
2 changes: 1 addition & 1 deletion app/views/air_conditioners/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_air_conditioner"),
<% render ButtonComponent.new(t(".new_air_conditioner"),
url: new_air_conditioner_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/architectures/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_architecture"),
<% render ButtonComponent.new(t(".new_architecture"),
url: new_architecture_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/bays/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
<%= render Page::HeadingComponent.new(title: t(".title"), breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_bay"),
<% render ButtonComponent.new(t(".new_bay"),
url: new_bay_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/bays/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingShowComponent.new(resource: @bay, title:, breadcrumb_steps:) do |heading| %>
<% heading.with_extra_buttons do %>
<% render ButtonComponent.new(title: t("visualization.title"),
<% render ButtonComponent.new(t("visualization.title"),
url: visualization_bay_path(@bay),
variant: :primary,
icon: "diagram-3-fill",
Expand Down
2 changes: 1 addition & 1 deletion app/views/card_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_card_type"),
<% render ButtonComponent.new(t(".new_card_type"),
url: new_card_type_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/categories/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_category"),
<% render ButtonComponent.new(t(".new_category"),
url: new_category_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/changelog_entries/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_left_content do %>
<span class="flex-grow-1">
<%= render ButtonComponent.new(title: t("action.back"),
<%= render ButtonComponent.new(t("action.back"),
url: changelog_entries_path,
icon: "chevron-left",
is_responsive: true) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/clusters/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_cluster"),
<% render ButtonComponent.new(t(".new_cluster"),
url: new_cluster_path,
variant: :success,
icon: "plus-lg",
Expand Down
4 changes: 2 additions & 2 deletions app/views/connections/edit.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@
<%= render Page::HeadingComponent.new(title: t(".title"), breadcrumb_steps:) do |heading| %>
<% heading.with_left_content do %>
<% render ButtonComponent.new(title: t("action.back"),
<% render ButtonComponent.new(t("action.back"),
url: connections_path,
icon: "chevron-left",
is_responsive: true) %>
<% end %>
<% heading.with_right_content do %>
<% if @cable %>
<% render ButtonComponent.new(title: t("action.delete"),
<% render ButtonComponent.new(t("action.delete"),
url: cable_path(id: @cable.id, redirect_to_port_id: @from_port.id),
variant: :danger,
icon: "trash",
Expand Down
2 changes: 1 addition & 1 deletion app/views/contract_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_contract_type"),
<% render ButtonComponent.new(t(".new_contract_type"),
url: new_contract_type_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/disk_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_disk_type"),
<% render ButtonComponent.new(t(".new_disk_type"),
url: new_disk_type_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/domaines/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_domaine"),
<% render ButtonComponent.new(t(".new_domaine"),
url: new_domaine_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/frames/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_frame"),
<% render ButtonComponent.new(t(".new_frame"),
url: new_frame_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/frames/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
resource: @frame, title: t(".title", frame: @frame.name), breadcrumb_steps:
) do |heading| %>
<% heading.with_extra_buttons do %>
<% render ButtonComponent.new(title: t("visualization.title"),
<% render ButtonComponent.new(t("visualization.title"),
url: visualization_frame_path(@frame),
variant: :primary,
icon: "diagram-3-fill",
Expand Down
2 changes: 1 addition & 1 deletion app/views/gestions/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_gestion"),
<% render ButtonComponent.new(t(".new_gestion"),
url: new_gestion_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/islets/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_islet"),
<% render ButtonComponent.new(t(".new_islet"),
url: new_islet_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/maintainers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_maintainer"),
<% render ButtonComponent.new(t(".new_maintainer"),
url: new_maintainer_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/manufacturers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_manufacturer"),
<% render ButtonComponent.new(t(".new_manufacturer"),
url: new_manufacturer_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/memory_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_memory_type"),
<% render ButtonComponent.new(t(".new_memory_type"),
url: new_memory_type_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/modeles/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_modele"),
<% render ButtonComponent.new(t(".new_modele"),
url: new_modele_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/moves/frame.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title: t(".title", frame: @frame), breadcrumb_steps:) do |heading| %>
<% heading.with_left_content do %>
<span class="flex-grow-1">
<%= render ButtonComponent.new(title: t("action.back"),
<%= render ButtonComponent.new(t("action.back"),
url: moves_path,
icon: "chevron-left",
is_responsive: true) %>
Expand Down
2 changes: 1 addition & 1 deletion app/views/moves/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_move"),
<% render ButtonComponent.new(t(".new_move"),
url: new_move_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/port_types/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_port_type"),
<% render ButtonComponent.new(t(".new_port_type"),
url: new_port_type_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/rooms/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title: title, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_room"),
<% render ButtonComponent.new(t(".new_room"),
url: new_room_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/rooms/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
title: "#{Room.model_name.human} #{@room.name}",
breadcrumb_steps:) do |heading| %>
<%= heading.with_extra_buttons do %>
<% render ButtonComponent.new(title: t("visualization.title"),
<% render ButtonComponent.new(t("visualization.title"),
url: visualization_room_path(@room),
variant: :primary,
icon: "diagram-3-fill",
Expand Down
2 changes: 1 addition & 1 deletion app/views/servers/import_csv.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= render Page::HeadingComponent.new(title: t(".title"), breadcrumb_steps:) do |heading| %>
<% heading.with_left_content do %>
<span class="flex-grow-1">
<%= render ButtonComponent.new(title: t("action.back"),
<%= render ButtonComponent.new(t("action.back"),
url: servers_path,
icon: "chevron-left",
is_responsive: true) %>
Expand Down
6 changes: 3 additions & 3 deletions app/views/servers/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -3,19 +3,19 @@
<%= render Page::HeadingComponent.new(title: t(".title"), breadcrumb_steps: { t(".title") => "" } ) do |heading| %>
<% heading.with_right_content do %>
<div class="align-self-center">
<%= render ButtonComponent.new(title: t(".sync_with_external_apps"),
<%= render ButtonComponent.new(t(".sync_with_external_apps"),
url: external_app_records_path,
variant: :primary,
icon: "arrow-repeat",
is_responsive: true) %>
<%= render ButtonComponent.new(title: t(".add_server_via_csv"),
<%= render ButtonComponent.new(t(".add_server_via_csv"),
url: import_csv_servers_path,
variant: :success,
icon: "filetype-csv",
is_responsive: true) %>
<%= render ButtonComponent.new(title: t(".new_server"),
<%= render ButtonComponent.new(t(".new_server"),
url: new_server_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/servers/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= render Page::HeadingShowComponent.new(resource: @server, title: title, breadcrumb_steps:) do |heading| %>
<% heading.with_extra_buttons do %>
<% render ButtonComponent.new(title: t("action.duplicate"),
<% render ButtonComponent.new(t("action.duplicate"),
url: duplicate_server_path(@server.slug),
variant: :success,
icon: "copy",
Expand Down
2 changes: 1 addition & 1 deletion app/views/servers_grids/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: "Exporter au format CSV",
<% render ButtonComponent.new("Exporter au format CSV",
url: url_for(format: :csv, params: @merged_params || {}),
variant: :outline_primary,
icon: "filetype-csv",
Expand Down
2 changes: 1 addition & 1 deletion app/views/sites/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<%= render Page::HeadingComponent.new(title: t(".title"), breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_site"),
<% render ButtonComponent.new(t(".new_site"),
url: new_site_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/stacks/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_stack"),
<% render ButtonComponent.new(t(".new_stack"),
url: new_stack_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/users/index.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<%= render Page::HeadingComponent.new(title:, breadcrumb_steps:) do |heading| %>
<% heading.with_right_content do %>
<% render ButtonComponent.new(title: t(".new_user"),
<% render ButtonComponent.new(t(".new_user"),
url: new_user_path,
variant: :success,
icon: "plus-lg",
Expand Down
2 changes: 1 addition & 1 deletion app/views/visualization/bays/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
<% heading.with_right_content do %>
<div class="d-flex flex-wrap gap-2 flex-column flex-lg-row">
<%= render "rooms/action_buttons", view_side: params[:view] %>
<%= render(ButtonComponent.new(title: t("action.show"),
<%= render(ButtonComponent.new(t("action.show"),
url: @bay,
size: :sm,
variant: :primary,
Expand Down
2 changes: 1 addition & 1 deletion app/views/visualization/frames/show.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<% heading.with_right_content do %>
<div class="d-flex flex-wrap gap-2 flex-column flex-lg-row">
<%= render "rooms/action_buttons", view_side: Frame::VIEW_SIDES[:both] %>
<%= render(ButtonComponent.new(title: t("action.show"),
<%= render(ButtonComponent.new(t("action.show"),
url: @frame,
size: :sm,
variant: :primary,
Expand Down
Loading

0 comments on commit cf3d1af

Please sign in to comment.