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

feat[#49397]: Member check flow blueprint

Kabiru Mwenja79d790ec4e0d
diff --git a/modules/storages/app/components/storages/projects_storages/members/row_component.rb b/modules/storages/app/components/storages/projects_storages/members/row_component.rb
new file mode 100644
index 00000000000..e6355740b49
--- /dev/null
+++ b/modules/storages/app/components/storages/projects_storages/members/row_component.rb
@@ -0,0 +1,80 @@
+#-- 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.
+#++
+
+# Purpose: Defines how to format the components within a table row of ProjectStorages
+# associated with a project
+module Storages::ProjectsStorages::Members
+ class RowComponent < ::RowComponent
+ property :principal,
+ :created_at
+
+ def member
+ row
+ end
+
+ def row_css_id
+ "member-#{member.id}"
+ end
+
+ def row_css_class
+ "member #{principal_class_name}".strip
+ end
+
+ def name
+ icon = helpers.avatar principal, size: :mini
+
+ icon + principal_link
+ end
+
+ def status
+ # FIXME: Status based on Nextcloud OAuth Client Token Presence
+ 'Connected'
+ end
+
+ private
+
+ def principal_link
+ link_to principal.name, principal_show_path
+ end
+
+ def principal_class_name
+ principal.model_name.singular
+ end
+
+ def principal_show_path
+ case principal
+ when User
+ user_path(principal)
+ when Group
+ show_group_path(principal)
+ else
+ placeholder_user_path(principal)
+ end
+ end
+ end
+end
diff --git a/modules/storages/app/components/storages/projects_storages/members/table_component.rb b/modules/storages/app/components/storages/projects_storages/members/table_component.rb
new file mode 100644
index 00000000000..6e10d1ac324
--- /dev/null
+++ b/modules/storages/app/components/storages/projects_storages/members/table_component.rb
@@ -0,0 +1,54 @@
+# 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::ProjectsStorages::Members
+ class TableComponent < ::TableComponent
+ columns :name, :status
+
+ def initial_sort
+ %i[created_at asc]
+ end
+
+ def sortable?
+ false
+ end
+
+ def empty_row_message
+ I18n.t 'storages.no_results'
+ end
+
+ def headers
+ [
+ ['name', { caption: I18n.t('storages.label_name') }],
+ ['status', { caption: I18n.t('storages.label_status') }]
+ ]
+ end
+ end
+end
diff --git a/modules/storages/app/components/storages/projects_storages/row_component.rb b/modules/storages/app/components/storages/projects_storages/row_component.rb
index a4dcc942466..099cf16ea99 100644
--- a/modules/storages/app/components/storages/projects_storages/row_component.rb
+++ b/modules/storages/app/components/storages/projects_storages/row_component.rb
@@ -50,7 +50,17 @@ module Storages::ProjectsStorages
end
def button_links
- [edit_link, delete_link]
+ [edit_link, delete_link].tap do |links|
+ links.unshift members_check_link if OpenProject::FeatureDecisions.storage_project_members_check_active?
+ end
+ end
+
+ def members_check_link
+ link_to '',
+ project_settings_projects_storage_members_path(project_id: project_storage.project,
+ projects_storage_id: project_storage),
+ class: 'icon icon-group',
+ title: I18n.t(:'storages.page_titles.project_settings.members_check')
end
def edit_link
diff --git a/modules/storages/app/controllers/storages/project_settings/project_storage_members_controller.rb b/modules/storages/app/controllers/storages/project_settings/project_storage_members_controller.rb
new file mode 100644
index 00000000000..e064859cfcd
--- /dev/null
+++ b/modules/storages/app/controllers/storages/project_settings/project_storage_members_controller.rb
@@ -0,0 +1,78 @@
+#-- 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.
+#++
+
+# Purpose: Let OpenProject create folders per project automatically.
+# This is recommended as it ensures that every team member always has the correct access permissions.
+#
+class Storages::ProjectSettings::ProjectStorageMembersController < ApplicationController
+ # This is the resource handled in this controller.
+ # So the controller knows that the ID in params (URl) refer to instances of this model.
+ # This defines @object as the model instance.
+ model_object Storages::ProjectStorage
+
+ before_action :find_model_object, only: %i[index] # Fill @object with ProjectStorage
+ # No need to before_action :find_project_by_project_id as SettingsController already checks
+ # No need to check for before_action :authorize, as the SettingsController already checks this.
+
+ # This MenuController method defines the default menu item to be used (highlighted)
+ # when rendering the main menu in the left (part of the base layout).
+ # The menu item itself is registered in modules/storages/lib/open_project/storages/engine.rb
+ menu_item :settings_projects_storages
+
+ # A list of project storage members showing their OAuth connection status.
+ # Called by: Project -> Settings -> File Storages -> Members
+ def index
+ @memberships = Member
+ .where(project: @project)
+ .includes(:principal, :oauth_client_tokens)
+
+ render '/storages/project_settings/project_storage_members/index'
+ end
+
+ def default_breadcrumb
+ ActionController::Base.helpers
+ .link_to t(:project_module_storages), project_settings_projects_storages_path(project_id: @project)
+ end
+
+ # See: default_breadcrum above
+ # Defines whether to show breadcrumbs on the page or not.
+ def show_local_breadcrumb
+ true
+ end
+
+ private
+
+ # Override default url param `:id` to `:storage` controller is a nested project_storage resource
+ # GET /projects/:project_id/settings/project_storages/:projects_storage_id/members
+ def find_model_object(object_id = :projects_storage_id)
+ super(object_id)
+ @project_storage = @object
+ @storage = @project_storage.storage
+ @project = @project_storage.project
+ end
+end
diff --git a/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb b/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb
new file mode 100644
index 00000000000..be219065c8b
--- /dev/null
+++ b/modules/storages/app/views/storages/project_settings/project_storage_members/index.html.erb
@@ -0,0 +1,43 @@
+<%#-- 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.
+
+++#%>
+<!-- Standard Ruby view, please see the controller for comments -->
+<% html_title t(:label_administration), t("project_module_storages"), t(@storage.name) %>
+<% local_assigns[:additional_breadcrumb] = t(:'storages.page_titles.project_settings.members_check') %>
+<%= toolbar title: t("storages.page_titles.project_storage_members.title"),
+ subtitle: t("storages.page_titles.project_storage_members.subtitle",
+ storage_name_link: link_to(@storage.name, admin_settings_storage_path(@storage)))
+%>
+
+<% if @memberships %>
+ <%= render(::Storages::ProjectsStorages::Members::TableComponent.new(rows: @memberships)) %>
+<% else %>
+ <%# FIXME: Update template %>
+ <%= render partial: '/storages/project_settings/toast_no_storage_set_up' %>
+<% end %>
+
diff --git a/modules/storages/config/locales/en.yml b/modules/storages/config/locales/en.yml
index 3083831789a..85e84b36428 100644
--- a/modules/storages/config/locales/en.yml
+++ b/modules/storages/config/locales/en.yml
@@ -79,6 +79,10 @@ en:
new: "Add a file storage to this project"
edit: "Edit the file storage to this project"
delete: "Delete file storage"
+ members_check: "Members check"
+ project_storage_members:
+ title: "Members check"
+ subtitle: "Check the connection status for the storage %{storage_name_link} of all project members."
instructions:
type: "Please make sure you have administration privileges in your Nextcloud instance and have the following application installed before doing the setup:"
type_link_text: "“Integration OpenProject”"
@@ -142,6 +146,7 @@ en:
label_no_selected_folder: "No selected folder"
label_storage: "Storage"
label_storages: "Storages"
+ label_status: "Status"
no_results: "No storages set up yet."
provider_types:
label: "Provider type"
diff --git a/modules/storages/config/routes.rb b/modules/storages/config/routes.rb
index d8215473550..673cd803374 100644
--- a/modules/storages/config/routes.rb
+++ b/modules/storages/config/routes.rb
@@ -48,6 +48,8 @@ OpenProject::Application.routes.draw do
# Destroy uses a get request to prompt the user before the actual DELETE request
get :destroy_info, as: 'confirm_destroy'
end
+
+ resources :members, controller: '/storages/project_settings/project_storage_members', only: %i[index]
end
end
end
diff --git a/modules/storages/lib/open_project/storages/engine.rb b/modules/storages/lib/open_project/storages/engine.rb
index 09b345f53a8..0e016c99b38 100644
--- a/modules/storages/lib/open_project/storages/engine.rb
+++ b/modules/storages/lib/open_project/storages/engine.rb
@@ -42,6 +42,7 @@ module OpenProject::Storages
initializer 'openproject_storages.feature_decisions' do
OpenProject::FeatureDecisions.add :storage_file_picking_select_all
+ OpenProject::FeatureDecisions.add :storage_project_members_check
end
initializer 'openproject_storages.event_subscriptions' do
@@ -82,7 +83,9 @@ module OpenProject::Storages
dependencies: %i[view_file_links],
contract_actions: { file_links: %i[manage] }
permission :manage_storages_in_project,
- { 'storages/admin/projects_storages': %i[index new edit update create destroy destroy_info set_permissions] },
+ { 'storages/admin/projects_storages': %i[index members new edit update create destroy destroy_info
+ set_permissions],
+ 'storages/project_settings/project_storage_members': %i[index] },
dependencies: %i[]
permission :read_files,