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
Ruby agile-developmentangularbcfboardsbug-trackerganttgantt-chartifcissue-trackerjira-alternativekanbanopenprojectproduct-managementproject-managementproject-planningroadmaprubyscrumtimelineworkflows
use component for global and project definition administration
ulfertsa1cb5b933db0
diff --git a/app/components/projects/life_cycle_component.html.erb b/app/components/projects/life_cycle_component.html.erbdeleted file mode 100644index 3f9a0f06e6f..00000000000--- a/app/components/projects/life_cycle_component.html.erb+++ /dev/null@@ -1,8 +0,0 @@-<%= flex_layout(align_items: :center) do |type_container|- type_container.with_column(mr: 1, classes: icon_color_class) do- render Primer::Beta::Octicon.new(icon: icon)- end- type_container.with_column do- render(Primer::Beta::Text.new(**text_options)) { text }- end- end %>diff --git a/app/components/projects/phase_definition_component.html.erb b/app/components/projects/phase_definition_component.html.erbnew file mode 100644index 00000000000..0b3092e71ee--- /dev/null+++ b/app/components/projects/phase_definition_component.html.erb@@ -0,0 +1,15 @@+<%= flex_layout(align_items: :center) do |type_container|+ type_container.with_column(classes: icon_color_class, mr: 1) do+ render Primer::Beta::Octicon.new(icon: icon)+ end+ type_container.with_column(test_selector: "project-life-cycle-step-definition-name", classes: "ellipsis") do+ if edit_link?+ render(Primer::Beta::Link.new(href: phase_href, **phase_text_options)) { phase_text }+ else+ render(Primer::Beta::Text.new(**phase_text_options)) { phase_text }+ end+ end+ type_container.with_column(ml: 2, classes: "no-wrap") do+ render(Primer::Beta::Text.new(**gates_text_options)) { gates_text }+ end+ end %>diff --git a/app/components/projects/life_cycle_component.rb b/app/components/projects/phase_definition_component.rbsimilarity index 82%rename from app/components/projects/life_cycle_component.rbrename to app/components/projects/phase_definition_component.rbindex f96e1453c73..09e87404243 100644--- a/app/components/projects/life_cycle_component.rb+++ b/app/components/projects/phase_definition_component.rb@@ -28,14 +28,22 @@# See COPYRIGHT and LICENSE files for more details.# ++module Projects- class LifeCycleComponent < ApplicationComponent+ class PhaseDefinitionComponent < ApplicationComponentinclude OpPrimer::ComponentHelpers# TODO: This component is currently not in use! It should be a shared component# between the Projects::Settings::LifeCycleSteps::StepComponent and the# Settings::ProjectLifeCycleStepDefinitions::RowComponent.# It should hold the icon, definition name and gate text information.- def text+ def phase_text+ model.name+ end++ def phase_href+ edit_admin_settings_project_phase_definition_path(model)+ end++ def gates_textif model.start_gate? && model.finish_gate?I18n.t("settings.project_phase_definitions.both_gate")elsif model.start_gate?@@ -52,14 +60,22 @@ module Projectsenddef icon_color_class- helpers.hl_inline_class("project_phase_definition", model)+ helpers.hl_inline_class("project_phase_definition", model.id)end- def text_options+ def gates_text_options# The tag: :div is is a hack to fix the line height difference# caused by font_size: :small. That line height difference# would otherwise lead to the text being not on the same height as the icon- { color: :muted, font_size: :small, tag: :div }.merge(options)+ { color: :muted, font_size: :small, tag: :div }.merge(options[:gates_text_options] || {})+ end++ def phase_text_options+ { font_weight: :bold }.merge(options[:phase_text_options] || {})+ end++ def edit_link?+ options[:edit_link]endendenddiff --git a/app/components/projects/settings/life_cycle_steps/step_component.html.erb b/app/components/projects/settings/life_cycle_steps/step_component.html.erbindex 7d777ea72c5..c198e9f52bf 100644--- a/app/components/projects/settings/life_cycle_steps/step_component.html.erb+++ b/app/components/projects/settings/life_cycle_steps/step_component.html.erb@@ -3,16 +3,14 @@align_items: :center,justify_content: :space_between) do |step_container|- step_container.with_column(flex_layout: true, mr: 2, classes: "min-width-0") do |title_container|- title_container.with_column(pt: 1, mr: 1, classes: icon_color_class) do- render Primer::Beta::Octicon.new(icon: icon)- end- title_container.with_column(pt: 1, mr: 2, classes: "ellipsis") do- render(Primer::Beta::Text.new(classes: "filter-target-visible-text")) { definition.name }- end- title_container.with_column(pt: 1, classes: "no-wrap") do- render(Primer::Beta::Text.new(**gate_text_options)) { gate_info }- end+ step_container.with_column(mr: 2, classes: "min-width-0") do+ render(+ Projects::PhaseDefinitionComponent.new(+ definition,+ edit_link: User.current.admin?,+ phase_text_options: { classes: "filter-target-visible-text" }+ )+ )end# py: 1 quick fix: prevents the row from bouncing as the toggle switch currently changes height while togglingstep_container.with_column(py: 1, mr: 2) dodiff --git a/app/components/projects/settings/life_cycle_steps/step_component.rb b/app/components/projects/settings/life_cycle_steps/step_component.rbindex 08a2cf32264..2dd0f59b647 100644--- a/app/components/projects/settings/life_cycle_steps/step_component.rb+++ b/app/components/projects/settings/life_cycle_steps/step_component.rb@@ -37,32 +37,6 @@ module Projectsoptions :definition,:active?- # TODO: Remove these helper methods once the Projects::LifeCycleComponent- # has been refactored.- def icon- :"op-phase"- end-- def icon_color_class- helpers.hl_inline_class("project_phase_definition", definition)- end-- def gate_info- if definition.start_gate? && definition.finish_gate?- I18n.t("settings.project_phase_definitions.both_gate")- elsif definition.start_gate?- I18n.t("settings.project_phase_definitions.start_gate")- elsif definition.finish_gate?- I18n.t("settings.project_phase_definitions.finish_gate")- else- I18n.t("settings.project_phase_definitions.no_gate")- end- end-- def gate_text_options- { color: :muted, font_size: :small }.merge(options)- end-def toggle_aria_labelI18n.t("projects.settings.life_cycle.step.use_in_project", step: definition.name)enddiff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erbindex 9c40ff194f1..ae6983e7de3 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.html.erb@@ -39,28 +39,14 @@ See COPYRIGHT and LICENSE files for more details.)endend- title_container.with_column(classes: icon_color_class) do- render Primer::Beta::Octicon.new(icon: icon)- end- title_container.with_column(classes: "ellipsis", test_selector: "project-life-cycle-step-definition-name") do- render(- if allowed_to_customize_life_cycle?- Primer::Beta::Link.new(- classes: "filter-target-visible-text",- href: edit_admin_settings_project_phase_definition_path(definition),- font_weight: :bold- )- else- Primer::Beta::Text.new(- font_weight: :bold- )- end- ) do- definition.name- end- endtitle_container.with_column do- render(Primer::Beta::Text.new(**gate_text_options)) { gate_info }+ render(+ Projects::PhaseDefinitionComponent.new(+ definition,+ edit_link: allowed_to_customize_life_cycle?,+ phase_text_options: { classes: "filter-target-visible-text" }+ )+ )endtitle_container.with_column(classes: "no-wrap") dorender(Primer::Beta::Text.new) { t("project.count", count: definition.project_count) }diff --git a/app/components/settings/project_life_cycle_step_definitions/row_component.rb b/app/components/settings/project_life_cycle_step_definitions/row_component.rbindex 7f92dd5684f..777fcf1b76c 100644--- a/app/components/settings/project_life_cycle_step_definitions/row_component.rb+++ b/app/components/settings/project_life_cycle_step_definitions/row_component.rb@@ -39,32 +39,6 @@ module Settingsoptions :first?,:last?- # TODO: Remove these helper classes once the Projects::LifeCycleComponent- # has been refactored.- def icon- :"op-phase"- end-- def icon_color_class- helpers.hl_inline_class("project_phase_definition", definition)- end-- def gate_info- if definition.start_gate? && definition.finish_gate?- I18n.t("settings.project_phase_definitions.both_gate")- elsif definition.start_gate?- I18n.t("settings.project_phase_definitions.start_gate")- elsif definition.finish_gate?- I18n.t("settings.project_phase_definitions.finish_gate")- else- I18n.t("settings.project_phase_definitions.no_gate")- end- end-- def gate_text_options- { color: :muted, font_size: :small }.merge(options)- end-privatedef move_action(menu:, move_to:, label:, icon:)diff --git a/lookbook/previews/open_project/projects/life_cycle_component_preview/phase.html.erb b/lookbook/previews/open_project/projects/life_cycle_component_preview/phase.html.erbdeleted file mode 100644index ffd42d8cf05..00000000000--- a/lookbook/previews/open_project/projects/life_cycle_component_preview/phase.html.erb+++ /dev/null@@ -1,6 +0,0 @@-<!-- Depends on having the color defined in the highlighting/styles.css.erb file. -->-<style>- .__hl_inline_life_cycle_step_definition_1 { color: red; }-</style>--<%= render(::Projects::LifeCycleComponent.new(model)) %>diff --git a/lookbook/previews/open_project/projects/life_cycle_component_preview.rb b/lookbook/previews/open_project/projects/phase_definition_component_preview.rbsimilarity index 86%rename from lookbook/previews/open_project/projects/life_cycle_component_preview.rbrename to lookbook/previews/open_project/projects/phase_definition_component_preview.rbindex fa5daee61ab..f20d20201e7 100644--- a/lookbook/previews/open_project/projects/life_cycle_component_preview.rb+++ b/lookbook/previews/open_project/projects/phase_definition_component_preview.rb@@ -31,12 +31,14 @@module OpenProjectmodule Projects# @logical_path OpenProject/Projects- class LifeCycleComponentPreview < Lookbook::Preview+ class PhaseDefinitionComponentPreview < Lookbook::Preview+ # @param edit_link [boolean]# @param start_gate [boolean]# @param finish_gate [boolean]- def phase(start_gate: false, finish_gate: false)+ def phase(edit_link: false, start_gate: false, finish_gate: false)model = Project::PhaseDefinition.new(id: 1, name: "The first phase", start_gate:, finish_gate:)- render_with_template(locals: { model: })++ render_with_template(locals: { model:, edit_link: })endendenddiff --git a/lookbook/previews/open_project/projects/phase_definition_component_preview/phase.html.erb b/lookbook/previews/open_project/projects/phase_definition_component_preview/phase.html.erbnew file mode 100644index 00000000000..7cc860782cf--- /dev/null+++ b/lookbook/previews/open_project/projects/phase_definition_component_preview/phase.html.erb@@ -0,0 +1,6 @@+<!-- Depends on having the color defined in the highlighting/styles.css.erb file. -->+<style>+ .__hl_inline_project_phase_definition_1 { color: red; }+</style>++<%= render(::Projects::PhaseDefinitionComponent.new(model, edit_link:)) %>