Skip to content

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

Remove NewStorageButtonComponent as it does not work outside a header any more and is thus obsolete

Henriette Dargeeea6bf87c45d
diff --git a/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb b/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb
deleted file mode 100644
index 90d627f3db2..00000000000
--- a/modules/storages/app/components/storages/admin/new_storage_button_component.html.erb
+++ /dev/null
@@ -1,22 +0,0 @@
-<% button_block = lambda do |button|
- button.with_leading_visual_icon(icon: :plus)
- button.with_trailing_action_icon(icon: :"triangle-down")
- label
-end %>
-
-<%=
- @header.with_action_menu(menu_arguments: { test_selector: 'storages-select-provider-action-menu', anchor_align: :end },
- button_arguments: { **show_button_options, button_block: button_block }) do |menu|
-
- ::Storages::Storage::PROVIDER_TYPES.each do |provider_type|
- short_provider_type = ::Storages::Storage.shorten_provider_type(provider_type)
-
- menu.with_item(
- label: I18n.t("storages.provider_types.#{short_provider_type}.name"),
- href: url_helpers.select_provider_admin_settings_storages_path(provider: short_provider_type)
- ) do |item|
- item.with_trailing_visual_icon(icon: "op-enterprise-addons", classes: "upsale-colored") if show_ee_icon?(provider_type:)
- end
- end
- end
-%>
diff --git a/modules/storages/app/components/storages/admin/new_storage_button_component.rb b/modules/storages/app/components/storages/admin/new_storage_button_component.rb
deleted file mode 100644
index a157eb5e5e6..00000000000
--- a/modules/storages/app/components/storages/admin/new_storage_button_component.rb
+++ /dev/null
@@ -1,55 +0,0 @@
-# frozen_string_literal: true
-
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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 # rubocop:disable OpenProject/AddPreviewForViewComponent
- options scheme: :primary,
- size: :medium
-
- def initialize(header, **options)
- @header = header
- super
- end
-
- def show_button_options
- { scheme:,
- size:,
- aria: { label: I18n.t("storages.label_add_new_storage") } }
- end
-
- def label
- I18n.t("storages.label_storage")
- end
-
- def show_ee_icon?(provider_type:)
- ::Storages::Storage::one_drive_without_ee_token?(provider_type)
- end
- 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.erb
index 7fb325f3ed5..61e09bd52bf 100644
--- a/modules/storages/app/views/storages/admin/storages/index.html.erb
+++ b/modules/storages/app/views/storages/admin/storages/index.html.erb
@@ -1,13 +1,37 @@
<!-- Standard Ruby view, please see the controller for comments -->
<% html_title t(:label_administration), t("project_module_storages") %>
+<% button_block = lambda do |button|
+ button.with_leading_visual_icon(icon: :plus)
+ button.with_trailing_action_icon(icon: :"triangle-down")
+ I18n.t("storages.label_storage")
+end %>
+
<%= render(Primer::OpenProject::PageHeader.new) do |header| %>
<% header.with_title { t("project_module_storages") } %>
<% header.with_description { t("storages.page_titles.file_storages.subtitle") } %>
<% header.with_breadcrumbs([{ href: admin_index_path, text: t("label_administration") },
t("project_module_storages")]) %>
- <%= render(Storages::Admin::NewStorageButtonComponent.new(header)) %>
+ <%= header.with_action_menu(menu_arguments: { test_selector: 'storages-select-provider-action-menu',
+ anchor_align: :end },
+ button_arguments: { scheme: :primary,
+ aria: { label: I18n.t("storages.label_add_new_storage") },
+ button_block: button_block }) do |menu|
+ ::Storages::Storage::PROVIDER_TYPES.each do |provider_type|
+ short_provider_type = ::Storages::Storage.shorten_provider_type(provider_type)
+
+ menu.with_item(
+ label: I18n.t("storages.provider_types.#{short_provider_type}.name"),
+ href: url_helpers.select_provider_admin_settings_storages_path(provider: short_provider_type)
+ ) do |item|
+ item.with_trailing_visual_icon(
+ icon: "op-enterprise-addons",
+ classes: "upsale-colored"
+ ) if ::Storages::Storage::one_drive_without_ee_token?(provider_type:)
+ end
+ end
+ end %>
<% end %>
<%= render(::Storages::Admin::StorageListComponent.new(@storages)) %>
diff --git a/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb b/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb
deleted file mode 100644
index 1ded64dab4f..00000000000
--- a/modules/storages/spec/components/storages/admin/new_storage_button_component_spec.rb
+++ /dev/null
@@ -1,42 +0,0 @@
-#-- copyright
-# OpenProject is an open source project management software.
-# Copyright (C) 2012-2024 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.
-#++
-#
-require "spec_helper"
-require_module_spec_helper
-
-RSpec.describe Storages::Admin::NewStorageButtonComponent, type: :component do
- include Rails.application.routes.url_helpers
-
- it 'renders a "New Storage" Action Menu' do
- render_inline(described_class.new)
- expect(page).to have_button "Storage", aria: { label: "Add new storage" }
-
- expect(page).to have_link "Nextcloud", href: select_provider_admin_settings_storages_path(provider: "nextcloud")
- expect(page).to have_link "OneDrive/SharePoint", href: select_provider_admin_settings_storages_path(provider: "one_drive")
- end
-end