Skip to content

Commit 83da29a

Browse files
authored
Merge pull request #21827 from opf/merge-release/17.1-20260131041200
Merge release/17.1 into dev
2 parents 4a5fd2c + ac41475 commit 83da29a

File tree

98 files changed

+2557
-578
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2557
-578
lines changed
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module McpConfigurations
32+
class EditRowComponent < OpPrimer::BorderBoxRowComponent
33+
def name
34+
render(
35+
Primer::Beta::Text.new(
36+
font_weight: :bold,
37+
data: { test_selector: "mcp-configuration--config-row-name" }
38+
)
39+
) { config.identifier.split("/", 2).last }
40+
end
41+
42+
def title
43+
render(
44+
Primer::Alpha::TextField.new(
45+
name: "mcp_configurations[#{config.identifier}][title]",
46+
label: McpConfiguration.human_attribute_name(:title),
47+
visually_hide_label: true,
48+
value: config.title,
49+
data: { test_selector: "mcp-configuration--title-input-#{config.identifier}" }
50+
)
51+
)
52+
end
53+
54+
def description
55+
render(
56+
Primer::Alpha::TextArea.new(
57+
name: "mcp_configurations[#{config.identifier}][description]",
58+
label: McpConfiguration.human_attribute_name(:description),
59+
visually_hide_label: true,
60+
value: config.description,
61+
rows: 4,
62+
data: { test_selector: "mcp-configuration--description-input-#{config.identifier}" }
63+
)
64+
)
65+
end
66+
67+
def enabled
68+
render(
69+
Primer::Alpha::CheckBox.new(
70+
name: "mcp_configurations[#{config.identifier}][enabled]",
71+
label: McpConfiguration.human_attribute_name(:enabled),
72+
visually_hide_label: true,
73+
checked: config.enabled,
74+
test_selector: "mcp-configuration--enabled-input-#{config.identifier}"
75+
)
76+
)
77+
end
78+
79+
private
80+
81+
def config
82+
model
83+
end
84+
end
85+
end
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module McpConfigurations
32+
class EditTableComponent < OpPrimer::BorderBoxTableComponent
33+
columns :name, :title, :description, :enabled
34+
35+
def headers
36+
[
37+
[:name, { caption: McpConfiguration.human_attribute_name(:name) }],
38+
[:title, { caption: McpConfiguration.human_attribute_name(:title) }],
39+
[:description, { caption: McpConfiguration.human_attribute_name(:description) }],
40+
[:enabled, { caption: McpConfiguration.human_attribute_name(:enabled) }]
41+
]
42+
end
43+
44+
def mobile_title
45+
"TODO: Does mobile even make sense?"
46+
end
47+
48+
def row_class
49+
EditRowComponent
50+
end
51+
end
52+
end
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<%#-- copyright
2+
OpenProject is an open source project management software.
3+
Copyright (C) the OpenProject GmbH
4+
5+
This program is free software; you can redistribute it and/or
6+
modify it under the terms of the GNU General Public License version 3.
7+
8+
OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
9+
Copyright (C) 2006-2013 Jean-Philippe Lang
10+
Copyright (C) 2010-2013 the ChiliProject Team
11+
12+
This program is free software; you can redistribute it and/or
13+
modify it under the terms of the GNU General Public License
14+
as published by the Free Software Foundation; either version 2
15+
of the License, or (at your option) any later version.
16+
17+
This program is distributed in the hope that it will be useful,
18+
but WITHOUT ANY WARRANTY; without even the implied warranty of
19+
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20+
GNU General Public License for more details.
21+
22+
You should have received a copy of the GNU General Public License
23+
along with this program; if not, write to the Free Software
24+
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
25+
26+
See COPYRIGHT and LICENSE files for more details.
27+
28+
++#%>
29+
30+
<%= primer_form_with(url: multi_update_mcp_configurations_path) do %>
31+
<%= render(McpConfigurations::EditTableComponent.new(rows: configurations)) %>
32+
33+
<%= render(Primer::Beta::Button.new(type: :submit, mt: 3)) { submit_label } %>
34+
<% end %>
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module McpConfigurations
32+
class MultipleConfigurationsComponent < ApplicationComponent
33+
include OpPrimer::ComponentHelpers
34+
35+
attr_reader :submit_label
36+
37+
alias_method :configurations, :model
38+
39+
def initialize(*, submit_label:, **)
40+
super(*, **)
41+
42+
@submit_label = submit_label
43+
end
44+
end
45+
end
Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module Admin
32+
class McpConfigurationsController < ::ApplicationController
33+
include OpTurbo::ComponentStream
34+
35+
before_action :require_admin
36+
37+
menu_item :mcp_configurations
38+
39+
layout "admin"
40+
41+
def index
42+
@server_config = McpConfiguration.server_config
43+
@tool_configs = McpConfiguration.where(identifier: McpTools.tools_by_name.keys)
44+
45+
@resource_configs = McpConfiguration.where(identifier: McpResources.resources_by_name.keys)
46+
end
47+
48+
def update
49+
config = McpConfiguration.find(params[:id])
50+
if config.update(mcp_config_params)
51+
flash[:notice] = t(".success")
52+
else
53+
flash[:error] = t(".failure")
54+
end
55+
56+
redirect_to action: :index
57+
end
58+
59+
def multi_update
60+
updates = params[:mcp_configurations]
61+
updates.transform_values! { |hash| hash.permit(:title, :description, :enabled) }
62+
63+
updates.each do |identifier, attributes|
64+
McpConfiguration.find_by!(identifier:).update!(attributes)
65+
end
66+
67+
flash[:notice] = t(".success")
68+
redirect_to action: :index
69+
end
70+
71+
private
72+
73+
def mcp_config_params
74+
params.expect(mcp_configuration: %i[enabled title description])
75+
end
76+
end
77+
end
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
# frozen_string_literal: true
2+
3+
#-- copyright
4+
# OpenProject is an open source project management software.
5+
# Copyright (C) the OpenProject GmbH
6+
#
7+
# This program is free software; you can redistribute it and/or
8+
# modify it under the terms of the GNU General Public License version 3.
9+
#
10+
# OpenProject is a fork of ChiliProject, which is a fork of Redmine. The copyright follows:
11+
# Copyright (C) 2006-2013 Jean-Philippe Lang
12+
# Copyright (C) 2010-2013 the ChiliProject Team
13+
#
14+
# This program is free software; you can redistribute it and/or
15+
# modify it under the terms of the GNU General Public License
16+
# as published by the Free Software Foundation; either version 2
17+
# of the License, or (at your option) any later version.
18+
#
19+
# This program is distributed in the hope that it will be useful,
20+
# but WITHOUT ANY WARRANTY; without even the implied warranty of
21+
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22+
# GNU General Public License for more details.
23+
#
24+
# You should have received a copy of the GNU General Public License
25+
# along with this program; if not, write to the Free Software
26+
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
27+
#
28+
# See COPYRIGHT and LICENSE files for more details.
29+
#++
30+
31+
module McpConfigurations
32+
class ServerForm < ApplicationForm
33+
include Redmine::I18n
34+
35+
form do |f|
36+
# TODO: Hide rest of form (and rest of page) when disabled, show when enabled (only after pressing "Update")
37+
f.check_box(
38+
name: :enabled,
39+
label: McpConfiguration.human_attribute_name(:enabled)
40+
)
41+
42+
if server_enabled?
43+
f.text_field(
44+
name: :title,
45+
label: McpConfiguration.human_attribute_name(:title),
46+
caption: I18n.t("admin.mcp_configurations.server_form.title_caption"),
47+
input_width: :large
48+
)
49+
50+
f.text_area(
51+
name: :description,
52+
label: McpConfiguration.human_attribute_name(:description),
53+
caption: I18n.t("admin.mcp_configurations.server_form.description_caption"),
54+
input_width: :large,
55+
rows: 4
56+
)
57+
end
58+
59+
f.submit(
60+
name: :submit,
61+
label: I18n.t(:button_update),
62+
scheme: :secondary
63+
)
64+
end
65+
66+
private
67+
68+
def server_enabled?
69+
model.enabled?
70+
end
71+
end
72+
end

app/models/mcp_configuration.rb

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,4 +29,11 @@
2929
#++
3030

3131
class McpConfiguration < ApplicationRecord
32+
SERVER_CONFIGURATION_IDENTIFIER = "mcp_server"
33+
34+
class << self
35+
def server_config
36+
McpConfiguration.find_or_initialize_by(identifier: SERVER_CONFIGURATION_IDENTIFIER)
37+
end
38+
end
3239
end

0 commit comments

Comments
 (0)