OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
chore[#50212]: Combine StorageButtonComponent with options
Kabiru Mwenja03dd1a03f9d6
diff --git a/modules/storages/app/components/storages/admin/configuration_checks_component.rb b/modules/storages/app/components/storages/admin/configuration_checks_component.rbdeleted file mode 100644index d454457f060..00000000000--- a/modules/storages/app/components/storages/admin/configuration_checks_component.rb+++ /dev/null@@ -1,46 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2023 the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-#-module Storages::Admin- class ConfigurationChecksComponent < Primer::Beta::Flash- def initialize(storage:, spacious: true, dismissible: false, icon: :alert, scheme: :danger, **kwargs)- @storage = storage- super(spacious:, dismissible:, icon:, scheme:, **kwargs)- end-- def render?- end-- def content- I18n.t('storages.configuration_checks.incomplete')- end- end-enddiff --git a/modules/storages/app/components/storages/admin/new_storage_button_component.rb b/modules/storages/app/components/storages/admin/new_storage_button_component.rbdeleted file mode 100644index 5de250128fc..00000000000--- a/modules/storages/app/components/storages/admin/new_storage_button_component.rb+++ /dev/null@@ -1,50 +0,0 @@-# frozen_string_literal: true--#-- copyright-# OpenProject is an open source project management software.-# Copyright (C) 2012-2023 the OpenProject GmbH-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License version 3.-#-# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:-# Copyright (C) 2006-2013 Jean-Philippe Lang-# Copyright (C) 2010-2013 the ChiliProject Team-#-# This program is free software; you can redistribute it and/or-# modify it under the terms of the GNU General Public License-# as published by the Free Software Foundation; either version 2-# of the License, or (at your option) any later version.-#-# This program is distributed in the hope that it will be useful,-# but WITHOUT ANY WARRANTY; without even the implied warranty of-# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the-# GNU General Public License for more details.-#-# You should have received a copy of the GNU General Public License-# along with this program; if not, write to the Free Software-# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.-#-# See COPYRIGHT and LICENSE files for more details.-#++-#-module Storages::Admin- class NewStorageButtonComponent < ApplicationComponent- options scheme: :primary,- size: :medium,- tag: :a-- def button_options- { scheme:,- size:,- tag:,- role: :button,- href: Rails.application.routes.url_helpers.new_admin_settings_storage_path,- aria: { label: I18n.t("storages.label_add_new_storage") } }- end-- def label- I18n.t("storages.label_storage")- end- end-enddiff --git a/modules/storages/app/components/storages/admin/delete_storage_button_component.html.erb b/modules/storages/app/components/storages/admin/storage_button_component.html.erbsimilarity index 62%rename from modules/storages/app/components/storages/admin/delete_storage_button_component.html.erbrename to modules/storages/app/components/storages/admin/storage_button_component.html.erbindex d0d61eaf5fc..dfea66c001e 100644--- a/modules/storages/app/components/storages/admin/delete_storage_button_component.html.erb+++ b/modules/storages/app/components/storages/admin/storage_button_component.html.erb@@ -1,6 +1,6 @@<%=render(Primer::Beta::Button.new(**button_options)) do |button|- button.with_leading_visual_icon(icon: :trash)+ button.with_leading_visual_icon(icon: icon_name)labelend%>diff --git a/modules/storages/app/components/storages/admin/delete_storage_button_component.rb b/modules/storages/app/components/storages/admin/storage_button_component.rbsimilarity index 61%rename from modules/storages/app/components/storages/admin/delete_storage_button_component.rbrename to modules/storages/app/components/storages/admin/storage_button_component.rbindex a7d900c5a40..b1af473b536 100644--- a/modules/storages/app/components/storages/admin/delete_storage_button_component.rb+++ b/modules/storages/app/components/storages/admin/storage_button_component.rb@@ -29,28 +29,42 @@#++#module Storages::Admin- class DeleteStorageButtonComponent < ApplicationComponent- options scheme: :danger,+ class StorageButtonComponent < ApplicationComponent+ options action: :new,size: :medium,tag: :aalias_method :storage, :model- private-def button_options- { scheme:,- size:,+ { size:,tag:,- role: :button,- href: admin_settings_storage_path(storage),- aria: { label: I18n.t("storages.label_delete_storage") },- data: { confirm: I18n.t('storages.delete_warning.storage') },- method: :delete }+ role: :button }.merge(button_options_from_action)+ end++ private++ def button_options_from_action+ case action+ when :new+ { scheme: :primary, href: Rails.application.routes.url_helpers.new_admin_settings_storage_path,+ aria: { label: I18n.t("storages.label_add_new_storage") } }+ when :delete+ { scheme: :danger, href: Rails.application.routes.url_helpers.admin_settings_storage_path(storage),+ aria: { label: I18n.t("storages.label_delete_storage") },+ data: { confirm: I18n.t('storages.delete_warning.storage') },+ method: :delete }+ endenddef label- I18n.t('button_delete')+ { new: I18n.t("storages.label_storage"),+ delete: I18n.t('button_delete') }[action]+ end++ def icon_name+ { new: 'plus',+ delete: 'trash' }[action]endendenddiff --git a/modules/storages/app/components/storages/admin/storage_list_component.html.erb b/modules/storages/app/components/storages/admin/storage_list_component.html.erbindex b94af3508fc..80090df7892 100644--- a/modules/storages/app/components/storages/admin/storage_list_component.html.erb+++ b/modules/storages/app/components/storages/admin/storage_list_component.html.erb@@ -57,7 +57,7 @@component.with_heading(tag: :h2).with_content(I18n.t('storages.storage_list_blank_slate.heading'))component.with_description { I18n.t('storages.storage_list_blank_slate.description') }- component.with_primary_action(**Storages::Admin::NewStorageButtonComponent.new.button_options) do |button|+ component.with_primary_action(**Storages::Admin::StorageButtonComponent.new(action: :new).button_options) do |button|button.with_leading_visual_icon(icon: :plus)I18n.t("storages.label_storage")enddiff --git a/modules/storages/app/views/storages/admin/storages/edit.html.erb b/modules/storages/app/views/storages/admin/storages/edit.html.erbindex 183143788b2..26cb7aea56a 100644--- a/modules/storages/app/views/storages/admin/storages/edit.html.erb+++ b/modules/storages/app/views/storages/admin/storages/edit.html.erb@@ -36,7 +36,7 @@ See COPYRIGHT and LICENSE files for more details.<% end %><% header.with_actions do %>- <%= render(Storages::Admin::DeleteStorageButtonComponent.new(@storage)) %>+ <%= render(Storages::Admin::StorageButtonComponent.new(@storage, action: :delete)) %><% end %><% end %>diff --git a/modules/storages/app/views/storages/admin/storages/index.html.erb b/modules/storages/app/views/storages/admin/storages/index.html.erbindex eb97aad3343..cdf2756c3f3 100644--- a/modules/storages/app/views/storages/admin/storages/index.html.erb+++ b/modules/storages/app/views/storages/admin/storages/index.html.erb@@ -12,7 +12,7 @@<% end %><% header.with_actions do %>- <%= render(Storages::Admin::NewStorageButtonComponent.new) %>+ <%= render(Storages::Admin::StorageButtonComponent.new(action: :new)) %><% end %><% end %>