Skip to content

OpenProject is the leading open source project management software for product, project and portfolio management. A powerful Jira alternative with agile planning, issue tracking, roadmaps, Gantt charts, time tracking, collaboration features, and more. Available on premises or in the cloud. ⭐ Star us on GitHub

2.6 KB
Raw Blame
<%= component_wrapper do %>
  <%=
    render Primer::OpenProject::PageHeader.new do |header|
      header.with_title(variant: :default) { t("settings.project_attributes.heading") }
      header.with_description { t("settings.project_attributes.heading_description") }
      header.with_breadcrumbs(breadcrumbs_items)
    end
  %>

  <%=
    render Primer::OpenProject::SubHeader.new do |subheader|
      subheader.with_action_menu(
        leading_icon: :plus,
        trailing_icon: :"triangle-down",
        label: I18n.t(:button_add),
        anchor_align: :end,
        button_arguments: {
          scheme: :primary,
          aria: { label: I18n.t(:button_add) },
          test_selector: "project-attributes-add-menu-button"
        }
      ) do |menu|
        menu.with_item(
          label: t("settings.project_attributes.label_new_section"),
          id: "dialog-show-project-custom-field-section-dialog",
          tag: :a,
          href: new_link_admin_settings_project_custom_field_sections_path,
          content_arguments: { data: { controller: "async-dialog", test_selector: "add-project-custom-field-section" } }
        )

        if allow_custom_field_creation?
          menu.with_sub_menu_item(
            label: t("settings.project_attributes.label_new_attribute"),
            content_arguments: { data: { test_selector: "add-project-custom-field-attribute" } }
          ) do |sub_menu|
            OpenProject::CustomFieldFormat.available_for_class_name("Project")
                                          # Reject hierarchy as long as the feature flag for scored lists is not active,
                                          # as they share the same selection component
                                          .reject { |format| format.name == "hierarchy" && !OpenProject::FeatureDecisions.scored_list_custom_fields_active? }
                                          .sort_by(&:name)
                                          .map do |format|
              sub_menu.with_item(
                label: helpers.label_for_custom_field_format(format.name),
                tag: :a,
                href: new_admin_settings_project_custom_field_path(field_format: format.name),
                content_arguments: { data: { turbo: "false",
                                             test_selector: "new-project-custom-field-button" } }
              ) do |item|
                if show_enterprise_icon?(format)
                  item.with_trailing_visual_icon(icon: :"op-enterprise-addons", classes: "upsell-colored")
                end
              end
            end
          end
        end
      end
    end
  %>
<% end %>