-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #16038 from opf/implementation/55961-define-the-pr…
…oject-lists-query-for-activated-storages [#55961] Define the project lists query for activated storages
- Loading branch information
Showing
10 changed files
with
192 additions
and
46 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
modules/storages/app/components/storages/project_storages/projects/row_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
#-- 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. | ||
#++ | ||
|
||
# Purpose: Defines how to format the components within a table row of Projects | ||
# associated with a Storage | ||
module Storages::ProjectStorages::Projects | ||
class RowComponent < Projects::RowComponent # rubocop:disable OpenProject/AddPreviewForViewComponent | ||
end | ||
end |
48 changes: 48 additions & 0 deletions
48
modules/storages/app/components/storages/project_storages/projects/table_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#-- 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. | ||
#++ | ||
|
||
# Purpose: Defines a table based on TableComponent for listing the | ||
# Projects for a given Storage. | ||
# See also: row_component.rb, which contains a method | ||
# for every "column" defined below. | ||
module Storages::ProjectStorages::Projects | ||
class TableComponent < Projects::TableComponent # rubocop:disable OpenProject/AddPreviewForViewComponent | ||
include OpTurbo::Streamable | ||
|
||
def sortable? | ||
false | ||
end | ||
|
||
# Overwritten to avoid loading data that is not needed in this context | ||
def projects(query) | ||
query | ||
.results | ||
.paginate(page: helpers.page_param(params), per_page: helpers.per_page_param(params)) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 0 additions & 36 deletions
36
modules/storages/app/views/storages/admin/storages/project_mappings.html.erb
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
87 changes: 87 additions & 0 deletions
87
modules/storages/spec/features/storages/admin/project_storages_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,87 @@ | ||
# 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. | ||
#++ | ||
|
||
require "spec_helper" | ||
require_module_spec_helper | ||
|
||
RSpec.describe "Admin lists project mappings for a storage", | ||
:js, | ||
:storage_server_helpers, | ||
with_flag: { enable_storage_for_multiple_projects: true } do | ||
shared_let(:admin) { create(:admin, preferences: { time_zone: "Etc/UTC" }) } | ||
shared_let(:non_admin) { create(:user) } | ||
shared_let(:project) { create(:project, name: "My active Project") } | ||
shared_let(:archived_project) { create(:project, active: false, name: "My archived Project") } | ||
shared_let(:storage) { create(:nextcloud_storage, name: "My Nextcloud Storage") } | ||
shared_let(:project_storage) { create :project_storage, project:, storage: } | ||
shared_let(:archived_project_project_storage) { create :project_storage, project: archived_project, storage: } | ||
|
||
current_user { admin } | ||
|
||
context "with insufficient permissions" do | ||
it "is not accessible" do | ||
login_as(non_admin) | ||
visit admin_settings_storage_project_storages_path(storage) | ||
|
||
expect(page).to have_text("You are not authorized to access this page.") | ||
end | ||
end | ||
|
||
context "with sufficient permissions" do | ||
before do | ||
login_as(admin) | ||
visit admin_settings_storage_project_storages_path(storage) | ||
end | ||
|
||
it "renders a list of projects linked to the storage" do | ||
aggregate_failures "shows a correct breadcrumb menu" do | ||
within ".PageHeader-breadcrumbs" do | ||
expect(page).to have_link("Administration") | ||
expect(page).to have_link("Files") | ||
expect(page).to have_link("My Nextcloud Storage") | ||
end | ||
end | ||
|
||
aggregate_failures "shows tab navigation" do | ||
within_test_selector("storage_detail_header") do | ||
expect(page).to have_link("Details") | ||
expect(page).to have_link("Enabled in projects") | ||
end | ||
end | ||
|
||
aggregate_failures "shows the correct project mappings" do | ||
within "#project-table" do | ||
expect(page).to have_text(project.name) | ||
expect(page).to have_text(archived_project.name) | ||
end | ||
end | ||
end | ||
end | ||
end |