重构: Epic 支持 Milestone 功能
18.0 打开支持 milestone
Feature.enabled?(:work_item_epics) # Feature.enable(:work_item_epics)
Feature.enabled?(:work_items_alpha) # Feature.enable(:work_items_alpha)
细节部分
Click to expand
如何开启针对某些客户开启 epic 支持(milestone 以及 iteration)
检测是否可用
浏览器控制台中
gon.epic_support_milestone_and_iteration
# 前端显示为 false, 则 console 检测下面的代码返回
# jh/lib/jh/gitlab.rb
::Gitlab::Database.jh_database_configured? &&
!::Gitlab::Saas.enabled? &&
::Feature.enabled?(:epic_support_milestone_and_iteration)
检测相应的 ff 是否打开
Feature.enabled?(:work_item_epics) # Feature.enable(:work_item_epics)
Feature.enabled?(:work_items_alpha) # Feature.enable(:work_items_alpha)
此时已开启 milestone
硬编码打开 iteration
WorkItems::Type.find(8)
#<WorkItems::Type:0x000000031aeb8eb8
id: 8,
base_type: "epic",
cached_markdown_version: nil,
name: "Epic",
description: nil,
description_html: nil,
icon_name: "issue-type-epic",
created_at: Tue, 25 Feb 2025 06:41:44.408990000 UTC +00:00,
updated_at: Tue, 25 Feb 2025 06:41:44.408990000 UTC +00:00,
correct_id: 8,
old_id: nil>
epic 中新增支持新类型
WorkItems::Type.find(8).widget_definitions.create(widget_type: 'iteration', name: 'Iteration', id: 1000)
WorkItems::Type.find(8).widget_definitions.find(1000)
删除
widget = WorkItems::Type.find(8).widget_definitions.find(1000)
widget.destroy
epic 支持的所有类型
# WorkItems::Type.find(8).widget_definitions
[#<WorkItems::WidgetDefinition:0x0000000149032088
id: 1000,
work_item_type_id: 8,
widget_type: "iteration",
disabled: false,
name: "Iteration",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031f48
id: 110,
work_item_type_id: 8,
widget_type: "color",
disabled: false,
name: "Color",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x00000001490317c8
id: 111,
work_item_type_id: 8,
widget_type: "crm_contacts",
disabled: false,
name: "CRM contacts",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031688
id: 112,
work_item_type_id: 8,
widget_type: "current_user_todos",
disabled: false,
name: "Current user todos",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031548
id: 113,
work_item_type_id: 8,
widget_type: "custom_fields",
disabled: false,
name: "Custom fields",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031408
id: 114,
work_item_type_id: 8,
widget_type: "description",
disabled: false,
name: "Description",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x00000001490312c8
id: 115,
work_item_type_id: 8,
widget_type: "health_status",
disabled: false,
name: "Health status",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031188
id: 116,
work_item_type_id: 8,
widget_type: "hierarchy",
disabled: false,
name: "Hierarchy",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149031048
id: 117,
work_item_type_id: 8,
widget_type: "labels",
disabled: false,
name: "Labels",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030f08
id: 118,
work_item_type_id: 8,
widget_type: "linked_items",
disabled: false,
name: "Linked items",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030dc8
id: 119,
work_item_type_id: 8,
widget_type: "milestone",
disabled: false,
name: "Milestone",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030c88
id: 120,
work_item_type_id: 8,
widget_type: "notes",
disabled: false,
name: "Notes",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030b48
id: 121,
work_item_type_id: 8,
widget_type: "notifications",
disabled: false,
name: "Notifications",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030a08
id: 122,
work_item_type_id: 8,
widget_type: "participants",
disabled: false,
name: "Participants",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030788
id: 123,
work_item_type_id: 8,
widget_type: "start_and_due_date",
disabled: false,
name: "Start and due date",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030648
id: 125,
work_item_type_id: 8,
widget_type: "time_tracking",
disabled: false,
name: "Time tracking",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030508
id: 126,
work_item_type_id: 8,
widget_type: "weight",
disabled: false,
name: "Weight",
widget_options: {"rollup"=>true, "editable"=>false}>,
#<WorkItems::WidgetDefinition:0x00000001490303c8
id: 124,
work_item_type_id: 8,
widget_type: "verification_status",
disabled: false,
name: "Verification status",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030288
id: 108,
work_item_type_id: 8,
widget_type: "assignees",
disabled: false,
name: "Assignees",
widget_options: nil>,
#<WorkItems::WidgetDefinition:0x0000000149030148
id: 109,
work_item_type_id: 8,
widget_type: "award_emoji",
disabled: false,
name: "Award emoji",
widget_options: nil>]
此时刷新可显示 iteration ,并兼容之前的逻辑
不用修改前端代码
变动原因
上游计划在今年上半年支持为 epic 设置 milestone(但不支持设置 iteration),详见:https://gitlab.com/groups/gitlab-org/-/epics/14745 。
https://jihulab.com/groups/gitlab-cn/-/epics/5460
关联内容
因上游 18.0 已经删除了 import EEEpicForm from 'ee/epic/components/epic_form.vue' 导致 jh 的覆盖代码完全失效,因此需要确认是否要保留这部分功能,如果需要则重写新版的功能支持
上游删除的 MR Remove epic legacy new page
failed pipeline https://jihulab.com/gitlab-cn/gitlab/-/jobs/21181002
由 TianLu 编辑于
