Skip to content

Commit

Permalink
[#55961] Adapt to new controller and naming
Browse files Browse the repository at this point in the history
Which was introduced with [#55966] Define "Enabled in Projects" as a fully qualified nested resource / pull request #16018
  • Loading branch information
judithroth committed Jul 4, 2024
1 parent 35b1ad0 commit 8c9669b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 63 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ See COPYRIGHT and LICENSE files for more details.
tab.with_text { t(:label_details) }
end
tab_nav.with_tab(
selected: tab_selected?(:project_mappings),
selected: tab_selected?(:project_storages),
href: admin_settings_storage_project_storages_path(@storage)
) do |tab|
tab.with_text { t(:label_project_mappings) }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ module Admin
class EditFormHeaderComponent < ApplicationComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
TAB_NAVS = %i[
edit
project_mappings
project_storages
].freeze

def initialize(storage:, selected:)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

# Purpose: Defines how to format the components within a table row of Projects
# associated with a Storage
module Storages::ProjectStorages::ProjectMapping
module Storages::ProjectStorages::Projects
class RowComponent < Projects::RowComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
# Projects for a given Storage.
# See also: row_component.rb, which contains a method
# for every "column" defined below.
module Storages::ProjectStorages::ProjectMapping
module Storages::ProjectStorages::Projects
class TableComponent < Projects::TableComponent # rubocop:disable OpenProject/AddPreviewForViewComponent
include OpTurbo::Streamable

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,16 @@ class Storages::Admin::Storages::ProjectStoragesController < ApplicationControll

menu_item :external_file_storages

def index; end
def index
@project_query = ProjectQuery.new(
name: "project-storage-mappings-#{@storage.id}"
) do |query|
query.where(:id, "=", @storage.projects.ids)
query.select(:name)
query.order("lft" => "asc")
end
end

def new; end
def create; end
def destroy; end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ class Storages::Admin::StoragesController < ApplicationController
before_action :require_admin
before_action :find_model_object,
only: %i[show_oauth_application destroy edit edit_host confirm_destroy update
change_health_notifications_enabled replace_oauth_application project_mappings]
change_health_notifications_enabled replace_oauth_application]
before_action :ensure_valid_provider_type_selected, only: %i[select_provider]
before_action :require_ee_token_for_one_drive, only: %i[select_provider]

Expand Down Expand Up @@ -245,16 +245,6 @@ def replace_oauth_application
end
end

def project_mappings
@project_query = ProjectQuery.new(
name: "project-storage-mappings-#{@storage.id}"
) do |query|
query.where(:id, "=", @storage.projects.ids)
query.select(:name)
query.order("lft" => "asc")
end
end

def default_breadcrumb; end

def show_local_breadcrumb
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ See COPYRIGHT and LICENSE files for more details.
<%=
render(Storages::Admin::EditFormHeaderComponent.new(
storage: @storage,
selected: :project_mappings
selected: :project_storages
)
)
%>
Expand All @@ -50,3 +50,11 @@ See COPYRIGHT and LICENSE files for more details.
end
end
%>

<%=
render(Storages::ProjectStorages::Projects::TableComponent.new(
query: @project_query,
params:
)
)
%>
1 change: 0 additions & 1 deletion modules/storages/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
patch :change_health_notifications_enabled
get :confirm_destroy
delete :replace_oauth_application
get :project_mappings
end

get :upsale, on: :collection
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@
context "with insufficient permissions" do
it "is not accessible" do
login_as(non_admin)
visit project_mappings_admin_settings_storage_path(storage)
visit admin_settings_storage_project_storages_path(storage)

expect(page).to have_text("You are not authorized to access this page.")
end
Expand All @@ -57,7 +57,7 @@
context "with sufficient permissions" do
before do
login_as(admin)
visit project_mappings_admin_settings_storage_path(storage)
visit admin_settings_storage_project_storages_path(storage)
end

it "renders a list of projects linked to the storage" do
Expand Down

0 comments on commit 8c9669b

Please sign in to comment.