Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
b37a65f
Add a registry of global settings pages
machisuji Oct 14, 2026
2b0ab6e
Register the hand-written global settings pages
machisuji Oct 14, 2026
013a95a
Register settings changed outside of settings forms
machisuji Oct 14, 2026
3a472fc
Build a tree of the searchable global settings
machisuji Oct 14, 2026
d36b282
Add a settings search to the admin side menu
machisuji Oct 14, 2026
7ad5aea
Highlight the setting selected in the settings search
machisuji Oct 14, 2026
01e1c1c
Extract the visibility of custom field form attributes
machisuji Oct 14, 2026
6d52846
Find settings of entities in the settings search
machisuji Oct 14, 2026
78778f3
List every admin page and its actions in the settings search
machisuji Oct 16, 2026
b799153
Find admin records like providers in the settings search
machisuji Oct 16, 2026
ee31d76
Document the settings search
machisuji Oct 16, 2026
f8ecbcd
Cache the tree of the settings search
machisuji Oct 19, 2026
72b6f63
Match entity names and words regardless of accents
machisuji Oct 19, 2026
b4a7e48
Move the collaboration setting translations to the documents module
machisuji Oct 19, 2026
40433ff
Cut the query of the settings search at a length and word count
machisuji Oct 19, 2026
53cd686
Show why a setting was found by its description
machisuji Oct 23, 2026
c5c8137
fix border radius for setting highlight box
machisuji Oct 23, 2026
53bdbe6
Check that settings are registered with the settings search
machisuji Oct 26, 2026
debedbb
Find the custom PDF export fonts in the settings search
machisuji Oct 26, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
84 changes: 84 additions & 0 deletions .github/dangerfiles/settings_search/Dangerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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.
#++

SETTINGS_SEARCH_REGISTRIES = %w[
config/initializers/settings_pages.rb
config/initializers/settings_entity_kinds.rb
].freeze
MODULE_ENGINE_REGEX = %r{\Amodules/[^/]+/lib/.+/engine\.rb\z}
CORE_ADMIN_UI_DIRECTORIES = %w[admin custom_fields work_package_types types statuses roles groups ldap_auth_sources oauth].freeze
CORE_ADMIN_UI_REGEX = %r{\Aapp/(views|forms|components)/(.+/)?(#{CORE_ADMIN_UI_DIRECTORIES.join('|')})/}
MODULE_UI_REGEX = %r{\A(modules/[^/]+)/app/(views|forms|components)/}
SETTINGS_SEARCH_UI_REGEX = %r{\Aapp/components/admin/settings_search}
SETTINGS_SEARCH_DOCS_URL =
"https://github.com/opf/openproject/blob/dev/docs/development/concepts/settings-search/README.md" \
"#checklist-when-changing-an-admin-page"

def registers_with_settings_search?(module_dir)
Dir.glob("#{module_dir}/lib/**/engine.rb").any? do |engine|
File.read(engine).match?(/Settings::(Pages|EntityKinds)\.draw/)
end
end

def admin_ui_file?(file)
return false if file.match?(SETTINGS_SEARCH_UI_REGEX)
return true if file.match?(CORE_ADMIN_UI_REGEX)

module_dir = file[MODULE_UI_REGEX, 1]
!module_dir.nil? && registers_with_settings_search?(module_dir)
end

changed_files = git.modified_files + git.added_files
admin_ui_files = changed_files.select { |file| admin_ui_file?(file) }
registries_changed = changed_files.any? do |file|
SETTINGS_SEARCH_REGISTRIES.include?(file) || file.match?(MODULE_ENGINE_REGEX)
end

if admin_ui_files.any? && !registries_changed
message_lines = [
"**Settings search:** admin pages were changed without changing the settings search registries:",
""
]

admin_ui_files.each do |file|
message_lines << "- #{file}"
end

message_lines << <<~MESSAGE

If settings, form fields or actions creating an entity were added, renamed or moved, please update
`config/initializers/settings_pages.rb`, `config/initializers/settings_entity_kinds.rb` or the
registrations in the module's engine, following the [checklist](#{SETTINGS_SEARCH_DOCS_URL}).
Specs catch unregistered global settings, but the fields of entities such as types or providers are
only checked against what is registered.
MESSAGE

warn message_lines.join("\n")
end
1 change: 1 addition & 0 deletions Dangerfile
Original file line number Diff line number Diff line change
Expand Up @@ -33,3 +33,4 @@ danger.import_dangerfile(path: ".github/dangerfiles/project_id_contract/Dangerfi
danger.import_dangerfile(path: ".github/dangerfiles/op_primer_changes/Dangerfile")
danger.import_dangerfile(path: ".github/dangerfiles/migration_index_names/Dangerfile")
danger.import_dangerfile(path: ".github/dangerfiles/html_safe/Dangerfile")
danger.import_dangerfile(path: ".github/dangerfiles/settings_search/Dangerfile")
1 change: 1 addition & 0 deletions app/components/_index.sass
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@import "admin/settings_search_component"
@import "ai/text_transforms/result_pane_component"
@import "colors/swatch_component"
@import "enterprise_edition/banner_component"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ See COPYRIGHT and LICENSE files for more details.
flex_layout(align_items: :center, justify_content: :space_between) do |container|
container.with_column do
render(Primer::Beta::Link.new(href: admin_departments_path, underline: false, color: :default)) do
render(Primer::Beta::Heading.new(tag: :h4)) { organization_name }
render(Primer::Beta::Heading.new(tag: :h4, data: { setting_name: "organization_name" })) { organization_name }
end
end

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ def initialize(name:, columns:, selected:, protected:)
def call
helpers.angular_component_tag(
"opce-draggable-autocompleter",
data: { setting_name: name },
inputs: {
autofocus: false,
options: columns,
Expand Down
43 changes: 43 additions & 0 deletions app/components/admin/settings_search/tree_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 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(
Primer::Alpha::TreeView.new(
node_variant: :anchor,
data: { target: "filterable-tree-view.treeViewList" }
)
) do |tree_view| %>
<% if @tree.query_words.any? %>
<% if @tree.nodes.empty? %>
<% tree_view.with_leaf(label: t("admin.settings_search.no_results"), disabled: true) %>
<% else %>
<% @tree.nodes.each { add_node(tree_view, it) } %>
<% end %>
<% end %>
<% end %>
68 changes: 68 additions & 0 deletions app/components/admin/settings_search/tree_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Admin
module SettingsSearch
class TreeComponent < ApplicationComponent
include SearchHighlightingHelper

def initialize(tree:)
super()
@tree = tree
end

private

def add_node(parent, node)
if node.children.any?
parent.with_sub_tree(label: label(node), href: node.href, expanded: true, select_variant: :none,
data: node_data(node)) do |sub_tree|
node.children.each { add_node(sub_tree, it) }
end
else
parent.with_leaf(label: label(node), href: node.href, select_variant: :none, data: node_data(node))
end
end

def label(node)
label = highlight_text_by_terms(node.label, @tree.query_words)
excerpt = @tree.excerpt(node)
return label unless excerpt

safe_join([label, content_tag(:span, highlight_text_by_terms(excerpt, @tree.query_words),
class: "op-admin-settings-search--excerpt")])
end

def node_data(node)
{ node_id: node.key, test_selector: "op-admin-settings-search--node" }
end
end
end
end
60 changes: 60 additions & 0 deletions app/components/admin/settings_search_component.html.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<%#-- copyright
OpenProject is an open source project management software.
Copyright (C) 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(
Primer::Box.new(
classes: "op-admin-settings-search",
data: { controller: "admin--settings-search", test_selector: "op-admin-settings-search" }
)
) do %>
<%= render(
Primer::OpenProject::FilterableTreeView.new(
src: helpers.tree_admin_settings_search_path,
classes: "op-sidemenu-filterable-tree",
show_search_highlighting: false,
include_sub_items_check_box_arguments: { hidden: true },
filter_mode_control_arguments: { hidden: true },
filter_input_arguments: {
name: :settings_search_query,
label: t("admin.settings_search.title"),
type: :text,
show_clear_button: false,
autofocus: @autofocus,
autocomplete: "off",
placeholder: t("admin.settings_search.filter_placeholder"),
data: {
test_selector: "op-admin-settings-search--filter",
admin__settings_search_target: "input",
action: "input->admin--settings-search#update keydown.esc->admin--settings-search#clear"
}
},
no_results_node_arguments: { label: t("admin.settings_search.no_results") }
)
) %>
<% end %>
42 changes: 42 additions & 0 deletions app/components/admin/settings_search_component.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# frozen_string_literal: true

#-- copyright
# OpenProject is an open source project management software.
# Copyright (C) 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 Admin
class SettingsSearchComponent < ApplicationComponent
def initialize(autofocus: false)
super()
@autofocus = autofocus
end

def render?
User.current.admin?
end
end
end
70 changes: 70 additions & 0 deletions app/components/admin/settings_search_component.sass
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
//-- copyright
// OpenProject is an open source project management software.
// Copyright (C) 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.
//++

.op-admin-settings-search
display: flex
flex-direction: column
flex-shrink: 0
min-height: 0
margin-bottom: var(--base-size-8)

filterable-tree-view
flex: 1
min-height: 0

&[data-searching]
flex: 1

&:not([data-searching]) .FilterableTreeViewTreeContainer
display: none

&--excerpt
display: block
font-size: var(--text-body-size-small)
opacity: 0.8

#menu-sidebar:has(.op-admin-settings-search[data-searching]) .menu_root
display: none

@keyframes op-setting-highlight-fade
to
opacity: 0

.op-setting--highlighted
position: relative
isolation: isolate

&::before
content: ""
position: absolute
inset: calc(-1 * var(--base-size-8))
z-index: -1
border-radius: var(--borderRadius-medium)
background-color: var(--bgColor-attention-muted)
pointer-events: none
animation: op-setting-highlight-fade 1s ease-out 3s forwards
Loading
Loading