hide parent selection on portfolio creation

This commit is contained in:
ulferts
2025-11-26 17:03:55 +01:00
parent a911744b47
commit dd7378cc05
5 changed files with 14 additions and 6 deletions
@@ -40,7 +40,7 @@ See COPYRIGHT and LICENSE files for more details.
Primer::Forms::FormList.new(
Projects::Settings::NameForm.new(f),
Projects::Settings::DescriptionForm.new(f),
Projects::Settings::RelationsForm.new(f, visible: params[:parent_id].blank?),
Projects::Settings::RelationsForm.new(f, visible: relation_form_visible?),
Projects::Settings::TypeForm.new(f)
)
)
+4
View File
@@ -53,5 +53,9 @@ module Projects
url_for(workspace_type.pluralize.to_sym)
end
def relation_form_visible?
project.parent_allowed? && params[:parent_id].blank?
end
end
end
-2
View File
@@ -279,8 +279,6 @@ class Project < ApplicationRecord
name
end
def allowed_parent_workspace_types = ALLOWED_PARENT_WORKSPACE_TYPES[workspace_type] || []
def workspace_label
case workspace_type
when "program"
+6
View File
@@ -171,5 +171,11 @@ module Projects::Hierarchy
end
stmt
end
def allowed_parent_workspace_types = Project::ALLOWED_PARENT_WORKSPACE_TYPES[workspace_type] || []
def parent_allowed?
allowed_parent_workspace_types.any?
end
end
end
+3 -3
View File
@@ -65,9 +65,9 @@ RSpec.describe "Portfolios",
# Step 2: Fill in project details
fill_in "Name", with: "Foo bar"
expect(page).to have_combo_box "Subproject of"
parent_field.expect_no_option "Other portfolio"
parent_field.expect_no_option "Root portfolio" # Since no a project cannot have a parent
# No parent field since portfolios are always root elements
expect(page)
.not_to have_combo_box "Subproject of"
click_on "Complete"