Skip to content

Commit

Permalink
Merge pull request #15676 from opf/bug/55196-wrong-menu-entry-when-de…
Browse files Browse the repository at this point in the history
…activating-a-project-attribute-(not-delete)

[#55196] Wrong menu entry when deactivating a project attribute (not "Delete")

https://community.openproject.org/work_packages/55196
  • Loading branch information
akabiru authored May 29, 2024
2 parents 1472e55 + 14d343f commit d7c6d15
Show file tree
Hide file tree
Showing 5 changed files with 47 additions and 30 deletions.
2 changes: 1 addition & 1 deletion app/components/projects/row_component.rb
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ def action_menu
label:,
test_selector: "project-list-row--action-menu-item",
content_arguments: button_options) do |item|
item.with_leading_visual_icon(icon:)
item.with_leading_visual_icon(icon:) if icon
end
end
end
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ def more_menu_items
def more_menu_detach_project
if User.current.admin
{
scheme: :danger,
icon: :trash,
label: I18n.t(:button_delete),
scheme: :default,
icon: nil,
label: I18n.t("projects.settings.project_custom_fields.actions.deactivate_for_project"),
href: unlink_admin_settings_project_custom_field_path(
id: @table.params[:custom_field].id,
project_custom_field_project_mapping: { project_id: model.first.id }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,17 @@ See COPYRIGHT and LICENSE files for more details.
%>

<%=
render(Settings::ProjectCustomFields::ProjectCustomFieldMapping::TableComponent.new(
query: @project_custom_field_mappings_query,
params: { custom_field: @custom_field })
)

if @custom_field.required?
render Primer::Beta::Blankslate.new(border: true) do |component|
component.with_visual_icon(icon: :checklist)
component.with_heading(tag: :h2).with_content(I18n.t("projects.settings.project_custom_fields.is_required_blank_slate.heading"))
component.with_description { I18n.t("projects.settings.project_custom_fields.is_required_blank_slate.description") }
end
else
render(Settings::ProjectCustomFields::ProjectCustomFieldMapping::TableComponent.new(
query: @project_custom_field_mappings_query,
params: { custom_field: @custom_field })
)
end
%>
4 changes: 4 additions & 0 deletions config/locales/en.yml
Original file line number Diff line number Diff line change
Expand Up @@ -327,8 +327,12 @@ Project attributes and sections are defined in the <a href=%{admin_settings_url}
actions:
label_enable_single: "Active in this project, click to disable"
label_disable_single: "Inactive in this project, click to enable"
deactivate_for_project: "Deactivate for this project"
label_enable_all: "Enable all"
label_disable_all: "Disable all"
is_required_blank_slate:
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.
types:
no_results_title_text: There are currently no types available.
form:
Expand Down
48 changes: 26 additions & 22 deletions spec/features/admin/project_custom_fields/project_mappings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -52,38 +52,42 @@
visit project_mappings_admin_settings_project_custom_field_path(project_custom_field)
end

it "shows a correct breadcrumb menu" do
within ".PageHeader-breadcrumbs" do
expect(page).to have_link("Administration")
expect(page).to have_link("Projects")
expect(page).to have_link("Project attributes")
expect(page).to have_text(project_custom_field.name)
it "renders the project custom field mappings page" do
aggregate_failures "shows a correct breadcrumb menu" do
within ".PageHeader-breadcrumbs" do
expect(page).to have_link("Administration")
expect(page).to have_link("Projects")
expect(page).to have_link("Project attributes")
expect(page).to have_text(project_custom_field.name)
end
end
end

it "shows tab navigation" do
within_test_selector("project_attribute_detail_header") do
expect(page).to have_link("Details")
expect(page).to have_link("Projects")
aggregate_failures "shows tab navigation" do
within_test_selector("project_attribute_detail_header") do
expect(page).to have_link("Details")
expect(page).to have_link("Projects")
end
end
end

it "shows the correct project mappings" do
within "#project-table" do
expect(page).to have_text(project.name)
aggregate_failures "shows the correct project mappings" do
within "#project-table" do
expect(page).to have_text(project.name)
end
end
end

it "renders more menu list item" do
project_custom_field_mappings_page.activate_menu_of(project) do |menu|
expect(menu).to have_link("Delete")
aggregate_failures "allows to unlinking a project" do
project_custom_field_mappings_page.click_menu_item_of("Deactivate for this project", project)

expect(page).to have_no_text(project.name)
end
end

it "allows to unlink a project" do
project_custom_field_mappings_page.click_menu_item_of("Delete", project)
context "and the project custom field is required" do
shared_let(:project_custom_field) { create(:project_custom_field, is_required: true) }

expect(page).to have_no_text(project.name)
it "renders a blank slate" do
expect(page).to have_text("Required in all projects")
end
end
end
end

0 comments on commit d7c6d15

Please sign in to comment.