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

added feature flag and fixed minor bugs

Jonas Jabari5b79645ac445
diff --git a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
index b2f20592c10..279fd228417 100644
--- a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
+++ b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.html.erb
@@ -1,10 +1,12 @@
<%=
component_wrapper do
- flex_layout(align_items: :center) do |custom_field_container|
+ flex_layout(align_items: :center, classes: 'op-project-custom-field', data: {
+ qa_selector: "project-custom-field-#{@project_custom_field.id}"
+ }) do |custom_field_container|
custom_field_container.with_column(mr: 1) do
toggle_button
end
- custom_field_container.with_column do
+ custom_field_container.with_column(data: { qa_selector: "custom-field-type" } ) do
render(Primer::Beta::Text.new(font_size: :small, color: :subtle)) do
@project_custom_field.field_format.capitalize
end
diff --git a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb
index 8161c9f254e..1b78fa474b0 100644
--- a/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb
+++ b/app/components/projects/settings/project_custom_field_sections/custom_field_row_component.rb
@@ -60,7 +60,8 @@ module Projects
href: toggle_project_settings_project_custom_fields_path(project_id: @project.id,
project_custom_field_id: @project_custom_field.id),
scheme: :invisible,
- data: { 'turbo-method': :put, 'turbo-stream': true }
+ data: { 'turbo-method': :put, 'turbo-stream': true,
+ qa_selector: "toggle-project-custom-field-mapping-#{@project_custom_field.id}" }
)) do |button|
button.with_leading_visual_icon(icon: (active_in_project? ? 'check-circle' : 'circle'))
@project_custom_field.name
diff --git a/app/components/projects/settings/project_custom_field_sections/show_component.html.erb b/app/components/projects/settings/project_custom_field_sections/show_component.html.erb
index 8fc6db3e704..db840362ceb 100644
--- a/app/components/projects/settings/project_custom_field_sections/show_component.html.erb
+++ b/app/components/projects/settings/project_custom_field_sections/show_component.html.erb
@@ -1,6 +1,8 @@
<%=
component_wrapper do
- render(Primer::Beta::BorderBox.new(mt: 3)) do |component|
+ render(Primer::Beta::BorderBox.new(mt: 3, classes: 'op-project-custom-field-section', data: {
+ qa_selector: "project-custom-field-section-#{@project_custom_field_section.id}"
+ })) do |component|
component.with_header(font_weight: :bold, py: 2) do
flex_layout(justify_content: :space_between, align_items: :center) do |section_header_container|
section_header_container.with_column(py: 2) do |content_container|
@@ -22,7 +24,7 @@
font_weight: :bold,
color: :subtle,
'aria-label': t('projects.settings.project_custom_fields.actions.label_enable_all'),
- data: { 'turbo-method': :put, 'turbo-stream': true }
+ data: { 'turbo-method': :put, 'turbo-stream': true, qa_selector: "enable-all-project-custom-field-mappings-#{@project_custom_field_section.id}" }
)) do |button|
button.with_leading_visual_icon(icon: 'check-circle', color: :subtle)
t('projects.settings.project_custom_fields.actions.label_enable_all')
@@ -39,7 +41,7 @@
font_weight: :bold,
color: :subtle,
'aria-label': t('projects.settings.project_custom_fields.actions.label_disable_all'),
- data: { 'turbo-method': :put, 'turbo-stream': true }
+ data: { 'turbo-method': :put, 'turbo-stream': true, qa_selector: "disable-all-project-custom-field-mappings-#{@project_custom_field_section.id}" }
)) do |button|
button.with_leading_visual_icon(icon: 'x-circle', color: :subtle)
t('projects.settings.project_custom_fields.actions.label_disable_all')
diff --git a/config/initializers/feature_decisions.rb b/config/initializers/feature_decisions.rb
index 401b2feb831..01ea7cebbf5 100644
--- a/config/initializers/feature_decisions.rb
+++ b/config/initializers/feature_decisions.rb
@@ -40,3 +40,4 @@ require_relative '../../lib_static/open_project/feature_decisions'
# end
OpenProject::FeatureDecisions.add :work_package_sharing
+OpenProject::FeatureDecisions.add :project_attributes
diff --git a/config/initializers/menus.rb b/config/initializers/menus.rb
index c836e456ecc..e74536420ce 100644
--- a/config/initializers/menus.rb
+++ b/config/initializers/menus.rb
@@ -37,7 +37,7 @@ Redmine::MenuManager.map :top_menu do |menu|
caption: I18n.t('label_projects_menu'),
icon: 'projects',
if: Proc.new {
- (User.current.logged? || !Setting.login_required?)
+ User.current.logged? || !Setting.login_required?
}
menu.push :activity,
@@ -139,7 +139,7 @@ Redmine::MenuManager.map :global_menu do |menu|
icon: 'projects',
after: :home,
if: Proc.new {
- (User.current.logged? || !Setting.login_required?)
+ User.current.logged? || !Setting.login_required?
}
menu.push :projects_query_select,
@@ -330,17 +330,25 @@ Redmine::MenuManager.map :admin_menu do |menu|
caption: Proc.new { Workflow.model_name.human },
parent: :admin_work_packages
- menu.push :admin_projects_settings,
- { controller: '/admin/settings/project_custom_fields', action: :index },
- if: Proc.new { User.current.admin? },
- caption: :label_project_plural,
- icon: 'projects'
-
- menu.push :project_custom_fields_settings,
- { controller: '/admin/settings/project_custom_fields', action: :index },
- if: Proc.new { User.current.admin? },
- caption: :label_project_attributes_plural,
- parent: :admin_projects_settings
+ if OpenProject::FeatureDecisions.project_attributes_active?
+ menu.push :admin_projects_settings,
+ { controller: '/admin/settings/project_custom_fields', action: :index },
+ if: Proc.new { User.current.admin? },
+ caption: :label_project_plural,
+ icon: 'projects'
+
+ menu.push :project_custom_fields_settings,
+ { controller: '/admin/settings/project_custom_fields', action: :index },
+ if: Proc.new { User.current.admin? },
+ caption: :label_project_attributes_plural,
+ parent: :admin_projects_settings
+ else
+ menu.push :admin_projects_settings,
+ { controller: '/admin/settings/projects_settings', action: :show },
+ if: Proc.new { User.current.admin? },
+ caption: :label_project_plural,
+ icon: 'projects'
+ end
menu.push :projects_settings,
{ controller: '/admin/settings/projects_settings', action: :show },
@@ -607,9 +615,8 @@ Redmine::MenuManager.map :project_menu do |menu|
icon: 'settings2',
allow_deeplink: true
- {
+ project_menu_items = {
general: :label_information_plural,
- project_custom_fields: :label_project_attributes_plural,
modules: :label_module_plural,
types: :label_work_package_types,
custom_fields: :label_custom_field_plural,
@@ -618,7 +625,13 @@ Redmine::MenuManager.map :project_menu do |menu|
repository: :label_repository,
time_entry_activities: :enumeration_activities,
storage: :label_required_disk_storage
- }.each do |key, caption|
+ }
+
+ if OpenProject::FeatureDecisions.project_attributes_active?
+ project_menu_items = project_menu_items.to_a.insert(1, %i[project_custom_fields label_project_attributes_plural]).to_h
+ end
+
+ project_menu_items.each do |key, caption|
menu.push :"settings_#{key}",
{ controller: "/projects/settings/#{key}", action: 'show' },
caption:,
diff --git a/frontend/src/app/features/overview/overview.component.ts b/frontend/src/app/features/overview/overview.component.ts
index d4644234f89..d0de3b2f2b8 100644
--- a/frontend/src/app/features/overview/overview.component.ts
+++ b/frontend/src/app/features/overview/overview.component.ts
@@ -14,9 +14,7 @@ export class OverviewComponent extends GridPageComponent {
}
protected isTurboFrameSidebarEnabled():boolean {
- // TODO: check if any project attributes are enabled for this project
- // if not, don't show the sidebar
- return true;
+ return this.configurationService.activeFeatureFlags.includes('projectAttributes')
}
protected turboFrameSidebarSrc():string {
diff --git a/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts b/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
index 56cf054414d..912cf8fa278 100644
--- a/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
+++ b/frontend/src/app/shared/components/grids/grid/page/grid-page.component.ts
@@ -9,6 +9,7 @@ import { GridResource } from 'core-app/features/hal/resources/grid-resource';
import { GridAddWidgetService } from 'core-app/shared/components/grids/grid/add-widget.service';
import { GridAreaService } from 'core-app/shared/components/grids/grid/area.service';
import { CurrentProjectService } from 'core-app/core/current-project/current-project.service';
+import { ConfigurationService } from 'core-app/core/config/configuration.service';
@Directive()
export abstract class GridPageComponent implements OnInit, OnDestroy {
@@ -26,11 +27,13 @@ export abstract class GridPageComponent implements OnInit, OnDestroy {
readonly title:Title,
readonly addWidget:GridAddWidgetService,
readonly renderer:Renderer2,
- readonly areas:GridAreaService) {}
-
+ readonly areas:GridAreaService,
+ readonly configurationService:ConfigurationService) {}
+
public grid:GridResource;
protected isTurboFrameSidebarEnabled():boolean {
+ // may be overridden by subclasses
return false;
}
diff --git a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.html.erb
index c4a0fc06047..09204591f3f 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.html.erb
@@ -1,15 +1,21 @@
<%=
- flex_layout(align_items: :flex_start, justify_content: :space_between) do |custom_field_value_container|
+ flex_layout(align_items: :flex_start, justify_content: :space_between, classes: 'op-project-custom-field-container', data: {
+ qa_selector: "project-custom-field-#{@project_custom_field.id}"
+ }) do |custom_field_value_container|
# temporarily using inline styles in order to align the content as desired
custom_field_value_container.with_row(mb: 1) do
render(Primer::Beta::Text.new(font_weight: :bold)) { @project_custom_field.name }
end
custom_field_value_container.with_row do
- if @project_custom_field_values.empty?
- render(Primer::Beta::Text.new(color: :subtle)) { t('label_not_set_yet') }
+ if not_set?
+ if @project_custom_field.default_value.present?
+ render(Primer::Beta::Text.new()) { render_formatted_default_value }
+ else
+ render(Primer::Beta::Text.new()) { t('label_not_set_yet') }
+ end
else
- render(Primer::Beta::Text.new()) { render_formated_value }
+ render(Primer::Beta::Text.new()) { render_formatted_value }
end
end
end
diff --git a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
index 0a877733c75..f3e4e0babfe 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
+++ b/modules/overviews/app/components/project_custom_fields/sections/project_custom_fields/show_component.rb
@@ -31,6 +31,7 @@ module ProjectCustomFields
module ProjectCustomFields
class ShowComponent < ApplicationComponent
include ApplicationHelper
+ include CustomFieldsHelper
include OpPrimer::ComponentHelpers
def initialize(project_custom_field:, project_custom_field_values:)
@@ -42,35 +43,24 @@ module ProjectCustomFields
private
- def render_formated_value
- return if @project_custom_field_values.empty?
+ def render_formatted_value
+ @project_custom_field_values&.map do |cf_value|
+ format_value(cf_value.value, @project_custom_field)
+ end&.join(", ")&.html_safe
+ end
- if @project_custom_field_values.one?
- render_single_value(@project_custom_field_values.first)
+ def render_formatted_default_value
+ if @project_custom_field.default_value.is_a?(Array)
+ @project_custom_field.default_value.map do |default_value|
+ format_value(default_value, @project_custom_field)
+ end.join(", ").html_safe
else
- render_multiple_values(@project_custom_field_values)
+ format_value(@project_custom_field.default_value, @project_custom_field)
end
end
- def render_single_value(value)
- formated_value(value)
- end
-
- def render_multiple_values(values)
- values.map do |value|
- formated_value(value)
- end.join(", ")
- end
-
- def formated_value(value)
- case @project_custom_field.field_format
- when "text"
- ::OpenProject::TextFormatting::Renderer.format_text(value.typed_value)
- when "date"
- format_date(value.typed_value)
- else
- value.typed_value&.to_s
- end
+ def not_set?
+ @project_custom_field_values.empty? || @project_custom_field_values.all? { |cf_value| cf_value.value.blank? }
end
end
end
diff --git a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
index 66c999d7ae6..44012a99acb 100644
--- a/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sections/show_component.html.erb
@@ -1,6 +1,8 @@
<%=
component_wrapper do
- flex_layout(border: :bottom, pb: 2) do |details_container|
+ flex_layout(border: :bottom, pb: 2, classes: 'op-project-custom-field-section-container', data: {
+ qa_selector: "project-custom-field-section-#{@project_custom_field_section.id}"
+ }) do |details_container|
details_container.with_row(mb: 2) do
flex_layout(align_items: :center, justify_content: :space_between) do |heading|
heading.with_column(flex: 1) do
@@ -14,7 +16,9 @@
size: :medium_portrait,
title: "#{t('label_edit')} #{ @project_custom_field_section.name }",
button_icon: :pencil,
- button_attributes: { scheme: :invisible }
+ button_attributes: { scheme: :invisible, data: {
+ qa_selector: "project-custom-field-section-edit-button"
+ } }
))
end
end
diff --git a/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb b/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb
index 94307c34265..ebbe0447486 100644
--- a/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb
+++ b/modules/overviews/app/components/project_custom_fields/sidebar_component.html.erb
@@ -2,7 +2,7 @@
content_tag("turbo-frame", id: "project-attributes-sidebar") do
component_wrapper do
if @active_project_custom_fields_grouped_by_section.any?
- flex_layout do |sections_container|
+ flex_layout(data: { qa_selector: "project-attributes-sidebar-async-content" }) do |sections_container|
@active_project_custom_fields_grouped_by_section.each do |project_custom_field_section_id, project_custom_fields|
sections_container.with_row(mb: 3) do
render(ProjectCustomFields::Sections::ShowComponent.new(
diff --git a/modules/overviews/app/controllers/overviews/overviews_controller.rb b/modules/overviews/app/controllers/overviews/overviews_controller.rb
index ce831151bf6..9d8bd5342fb 100644
--- a/modules/overviews/app/controllers/overviews/overviews_controller.rb
+++ b/modules/overviews/app/controllers/overviews/overviews_controller.rb
@@ -3,6 +3,8 @@ module ::Overviews
include OpTurbo::ComponentStream
before_action :jump_to_project_menu_item
+ before_action :check_project_attributes_feature_enabled,
+ only: %i[attributes_sidebar attribute_section_dialog update_attributes]
menu_item :overview
@@ -70,6 +72,10 @@ module ::Overviews
private
+ def check_project_attributes_feature_enabled
+ render_404 unless OpenProject::FeatureDecisions.project_attributes_active?
+ end
+
def project_attribute_params
params.require(:project).permit(
custom_field_values_attributes: [:value],