Skip to content

Commit

Permalink
Merge pull request #16018 from opf/implementation/55966-define-add-pr…
Browse files Browse the repository at this point in the history
…ojects-dialog-that-allows-selecting-one-or-many-projects-for-activation-with-include-subprojects-option

[#55966] Define "Enabled in Projects" as a fully qualified nested resource
  • Loading branch information
judithroth authored Jul 4, 2024
2 parents f71c4e9 + 79bf1d0 commit 62c5de2
Show file tree
Hide file tree
Showing 11 changed files with 127 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def render?
private

def title
I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects")
I18n.t(:label_add_projects)
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ def initialize(project_mapping:, project_custom_field:)
private

def title
I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects")
I18n.t(:label_add_projects)
end

def cancel_button_text
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ See COPYRIGHT and LICENSE files for more details.
data: { controller: "async-dialog" }
)) do |button|
button.with_leading_visual_icon(icon: 'op-include-projects')
I18n.t("projects.settings.project_custom_fields.new_project_mapping_form.add_projects")
I18n.t(:label_add_projects)
end
end
end unless @custom_field.required?
Expand Down
2 changes: 1 addition & 1 deletion config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,6 @@ en:
heading: Required in all projects
description: This project attribute is activated in all projects since the "Required in all projects" option is checked. It cannot be deactivated for individual projects.
new_project_mapping_form:
add_projects: Add projects
include_sub_projects: Include sub-projects
types:
no_results_title_text: There are currently no types available.
Expand Down Expand Up @@ -1921,6 +1920,7 @@ en:
label_add_another_file: "Add another file"
label_add_columns: "Add selected columns"
label_add_note: "Add a note"
label_add_projects: "Add projects"
label_add_related_work_packages: "Add related work packages"
label_add_subtask: "Add subtask"
label_added: "added"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,9 @@ See COPYRIGHT and LICENSE files for more details.
label_storage_name_with_provider_label
end
end

header.with_breadcrumbs(breadcrumbs_items)

header.with_action_button(scheme: :danger,
mobile_icon: :trash,
mobile_label: I18n.t("button_delete"),
Expand All @@ -43,6 +45,7 @@ See COPYRIGHT and LICENSE files for more details.
button.with_leading_visual_icon(icon: :trash)
I18n.t("button_delete")
end

if OpenProject::FeatureDecisions.enable_storage_for_multiple_projects_active?
header.with_tab_nav(label: nil, test_selector: :project_attribute_detail_header) do |tab_nav|
tab_nav.with_tab(
Expand All @@ -54,7 +57,7 @@ See COPYRIGHT and LICENSE files for more details.

tab_nav.with_tab(
selected: tab_selected?(:project_mappings),
href: project_mappings_admin_settings_storage_path(@storage)
href: admin_settings_storage_project_storages_path(@storage)
) do |tab|
tab.with_text { t(:label_project_mappings) }
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ def body_text
if authorized
success_title = I18n.t("storages.oauth_grant_nudge_modal.access_granted")
success_subtitle = I18n.t("storages.oauth_grant_nudge_modal.storage_ready", storage: project_storage.storage.name)
concat(render(Storages::OpenProjectStorageModalComponent::Body.new(:success, success_subtitle:, success_title:)))
concat(render(::Storages::OpenProjectStorageModalComponent::Body.new(:success, success_subtitle:, success_title:)))
else
I18n.t("storages.oauth_grant_nudge_modal.body", storage: project_storage.storage.name)
end
Expand All @@ -94,9 +94,9 @@ def confirm_button_url

def find_project_storage(project_storage_record_or_id)
return if project_storage_record_or_id.blank?
return project_storage_record_or_id if project_storage_record_or_id.is_a?(Storages::ProjectStorage)
return project_storage_record_or_id if project_storage_record_or_id.is_a?(::Storages::ProjectStorage)

Storages::ProjectStorage.find_by(id: project_storage_record_or_id)
::Storages::ProjectStorage.find_by(id: project_storage_record_or_id)
end
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,8 @@ def self.wrapper_key = :storage_openproject_oauth_section
def oauth_application_details_link
render(
Primer::Beta::Link.new(
href: Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(storage.host,
"settings/admin/openproject"),
href: ::Storages::Peripherals::StorageInteraction::Nextcloud::Util.join_uri_path(storage.host,
"settings/admin/openproject"),
target: "_blank"
)
) { I18n.t("storages.instructions.oauth_application_details_link_text") }
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
# 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.
#++

class Storages::Admin::Storages::ProjectStoragesController < ApplicationController
include OpTurbo::ComponentStream

layout "admin"

model_object Storages::Storage

before_action :require_admin
before_action :find_model_object

menu_item :external_file_storages

def index; end
def new; end
def create; end
def destroy; end

private

def find_model_object(object_id = :storage_id)
super
@storage = @object
end
end
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class ProviderDriveIdInputForm < ApplicationForm
form do |storage_form|
storage_form.text_field(
name: :drive_id,
label: Storages::Admin::LABEL_DRIVE_ID,
label: ::Storages::Admin::LABEL_DRIVE_ID,
visually_hide_label: false,
required: true,
caption: caption.html_safe, # rubocop:disable Rails/OutputSafety
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
<%#-- 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.
++#%>
<%=
render(Storages::Admin::EditFormHeaderComponent.new(
storage: @storage,
selected: :project_mappings
)
)
%>
<%=
render(Primer::OpenProject::SubHeader.new) do |component|
component.with_action_component do
render(Primer::Beta::Button.new(
scheme: :primary,
tag: :a,
href: new_admin_settings_storage_project_storage_path(@storage),
data: { controller: "async-dialog" }
)) do |button|
button.with_leading_visual_icon(icon: 'op-include-projects')
I18n.t(:label_add_projects)
end
end
end
%>
8 changes: 7 additions & 1 deletion modules/storages/config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,16 @@

resource :automatically_managed_project_folders,
controller: "/storages/admin/automatically_managed_project_folders",
only: %i[new create edit update]
only: %i[index new create edit update]

resource :access_management, controller: "/storages/admin/access_management", only: %i[new create edit update]

scope module: :storages do
resources :project_storages,
controller: "/storages/admin/storages/project_storages",
only: %i[index new create destroy]
end

resource :connection_validation,
controller: "/storages/admin/connection_validation",
only: [] do
Expand Down

0 comments on commit 62c5de2

Please sign in to comment.