-
Notifications
You must be signed in to change notification settings - Fork 3.3k
Primerize the administration user form. wp/72005 #23691
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
klaustopher
merged 15 commits into
dev
from
implementation/op-19485-primerization-of-the-user-form
Jun 23, 2026
Merged
Changes from 7 commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
43e1795
Primerize the administration user form. wp/72005
dfriquet e06580e
Primerize user avatar into edition form. OP-19485
dfriquet 892a3db
Refactor my account settings to display avatar and sections. OP-19485
dfriquet 1241a75
Fix 2FA spec expectations and test seeds. OP-19485
dfriquet 7a4ea0f
Primerize consent heading and tidy avatar layout CSS. OP-19485
dfriquet d5dd8b7
Consolidate user authentication settings into one fieldset. OP-19485
dfriquet 7d94cfe
Address remaining user form review comments. OP-19485
dfriquet d3124f5
Use standard sr-only class for avatar file upload. OP-19485
dfriquet ff169ed
Make user form section spacing consistent. OP-19485
dfriquet 34d635c
Re-arrange avatar form section (with proper view component). OP-19485
dfriquet cf8fe3b
Merge branch 'dev' into implementation/op-19485-primerization-of-the-…
klaustopher e018440
Consequently use mb-3 spacing
klaustopher 47a85a1
Use a date picker instead of a date field for date CFs
klaustopher d7a645c
Consistent spacing in the user edit admin page
klaustopher 88505b2
Revert "Use a date picker instead of a date field for date CFs"
klaustopher File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
5 changes: 0 additions & 5 deletions
5
app/components/users/form/custom_field_field_component.html.erb
This file was deleted.
Oops, something went wrong.
11 changes: 0 additions & 11 deletions
11
app/components/users/form/custom_field_section_component.html.erb
This file was deleted.
Oops, something went wrong.
62 changes: 0 additions & 62 deletions
62
app/components/users/form/custom_field_section_component.rb
This file was deleted.
Oops, something went wrong.
This file contains hidden or 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,15 @@ | ||
| <%= render(form_list) %> | ||
|
|
||
| <%= helpers.render_user_form_hooks(user: @user, form: @builder) %> | ||
|
|
||
| <% if show_consent? %> | ||
| <%= render("users/consent", user: @user) %> | ||
| <% end %> | ||
|
|
||
| <% if show_preferences? %> | ||
| <%= fields_for(:pref, @user.pref, builder: @builder.class) do |pref_f| %> | ||
| <%= render(Users::Form::PreferencesForm.new(pref_f)) %> | ||
| <% end %> | ||
| <% end %> | ||
|
|
||
| <%= render(Primer::Beta::Button.new(type: :submit, scheme: :primary, name: "submit")) { creating? ? I18n.t(:button_create) : I18n.t(:button_save) } %> | ||
This file contains hidden or 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,103 @@ | ||
| # 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 Users | ||
| # Coordinates the administration user form: receives the surrounding | ||
| # `settings_primer_form_with` builder, composes the inner forms into a | ||
| # Primer::Forms::FormList and renders the read-only / plain bits (status, | ||
| # consent, external auth, hooks, submit) and the pref-scoped preferences form | ||
| # around it. Create vs edit is derived from `user.new_record?`. | ||
| class FormComponent < ApplicationComponent | ||
| def initialize(builder:, user:, contract:) | ||
| super() | ||
| @builder = builder | ||
| @user = user | ||
| @contract = contract | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def creating? = @user.new_record? | ||
| def editing? = !creating? | ||
|
|
||
| def form_list | ||
| Primer::Forms::FormList.new(*input_forms) | ||
| end | ||
|
|
||
| def input_forms | ||
| forms = [Users::Form::AttributesForm.new(@builder, user: @user, contract: @contract)] | ||
| if show_authentication? | ||
| forms << Users::Form::AuthenticationForm.new(@builder, | ||
| user: @user, | ||
| render_auth_source: show_auth_source?, | ||
| render_password: show_password?, | ||
| render_no_login_message: show_no_login_message?, | ||
| render_external_auth: show_external_auth?, | ||
| assign_random_password_checked: assign_random_password_checked?) | ||
| end | ||
| forms | ||
| end | ||
|
|
||
| def show_authentication? | ||
| show_auth_source? || show_password? || show_no_login_message? || show_external_auth? | ||
| end | ||
|
|
||
| def show_auth_source? | ||
| return false if editing? && @user.uses_external_authentication? | ||
|
|
||
| creating? ? can_users_have_auth_source? : (User.current.admin? || can_users_have_auth_source?) | ||
| end | ||
|
|
||
| def show_password? | ||
| editing? && User.current.admin? && !@user.uses_external_authentication? && !disable_password_login? | ||
| end | ||
|
|
||
| def show_preferences? = editing? && User.current.admin? | ||
| def show_external_auth? = editing? && @user.uses_external_authentication? | ||
|
|
||
| def show_no_login_message? | ||
| editing? && User.current.admin? && !@user.uses_external_authentication? && disable_password_login? | ||
| end | ||
|
|
||
| def show_consent? = editing? && Setting.consent_required? | ||
|
|
||
| def can_users_have_auth_source? | ||
| LdapAuthSource.any? && !disable_password_login? | ||
| end | ||
|
|
||
| def disable_password_login? | ||
| OpenProject::Configuration.disable_password_login? | ||
| end | ||
|
|
||
| def assign_random_password_checked? | ||
| helpers.params.dig(:user, :assign_random_password).present? | ||
| end | ||
| end | ||
| end |
This file contains hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.