Skip to content
代码片段 群组 项目
未验证 提交 ac995378 编辑于 作者: Nicolas Dular's avatar Nicolas Dular 提交者: GitLab
浏览文件

Merge branch 'jj-470548-hide_type_quickaction_on_epics' into 'master'

Disable /type quick action on epic work items

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/160735



Merged-by: default avatarNicolas Dular <ndular@gitlab.com>
Approved-by: default avatarAman Luthra <aluthra@gitlab.com>
Approved-by: default avatarNicolas Dular <ndular@gitlab.com>
Reviewed-by: default avatarNicolas Dular <ndular@gitlab.com>
Co-authored-by: default avatarJoseph Wambua <jjoshua@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -38,6 +38,11 @@ def promote_to_map ...@@ -38,6 +38,11 @@ def promote_to_map
super.merge(key_result: 'Objective') super.merge(key_result: 'Objective')
end end
override :type_change_allowed?
def type_change_allowed?
true unless quick_action_target.work_item_type.epic?
end
def find_frequency(frequency) def find_frequency(frequency)
return unless frequency return unless frequency
......
...@@ -1001,40 +1001,16 @@ def work_item_status ...@@ -1001,40 +1001,16 @@ def work_item_status
context 'for epic work item type' do context 'for epic work item type' do
let(:input) { { 'descriptionWidget' => { 'description' => "/type objective" } } } let(:input) { { 'descriptionWidget' => { 'description' => "/type objective" } } }
let_it_be(:epic) { create(:epic, :with_synced_work_item, group: group) }
let(:work_item) { epic.work_item }
context 'when epic work item does not have a synced epic' do it 'does not update work item type' do
let_it_be_with_refind(:work_item) do expect do
create(:work_item, :epic, namespace: group) post_graphql_mutation(mutation, current_user: current_user)
end work_item.reload
end.not_to change { work_item.work_item_type.base_type }
it 'updates work item type' do
expect do
post_graphql_mutation(mutation, current_user: current_user)
work_item.reload
end.to change { work_item.work_item_type.base_type }.from('epic').to('objective')
expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['workItem']['workItemType']).to include(
{ 'name' => 'Objective' }
)
end
end
context 'when epic work item has a synced epic' do
let_it_be(:epic) { create(:epic, :with_synced_work_item, group: group) }
let(:work_item) { epic.work_item }
it 'does not update work item type' do
expect do
post_graphql_mutation(mutation, current_user: current_user)
work_item.reload
end.not_to change { work_item.work_item_type.base_type }
expect(response).to have_gitlab_http_status(:success) expect(response).to have_gitlab_http_status(:success)
expect(mutation_response['errors'].first).to eq(
"Work item type cannot be changed to objective when the work item is a legacy epic synced work item"
)
end
end end
end end
end end
......
...@@ -3,6 +3,21 @@ ...@@ -3,6 +3,21 @@
RSpec.shared_examples 'quick actions that change work item type ee' do RSpec.shared_examples 'quick actions that change work item type ee' do
include_context 'with work item change type context' include_context 'with work item change type context'
describe 'type command' do
let(:new_type) { 'issue' }
let(:command) { "/type #{new_type}" }
context 'with epic' do
let_it_be(:work_item) { create(:work_item, :epic, namespace: group, title: 'Work item Epic') }
let(:with_access) { true }
it 'does not change work item type' do
expect { service.execute(command, work_item) }
.not_to change { work_item.work_item_type.base_type }
end
end
end
describe 'promote_to command' do describe 'promote_to command' do
let(:new_type) { 'objective' } let(:new_type) { 'objective' }
let(:command) { "/promote_to #{new_type}" } let(:command) { "/promote_to #{new_type}" }
......
...@@ -13,6 +13,7 @@ module WorkItemActions ...@@ -13,6 +13,7 @@ module WorkItemActions
end end
types WorkItem types WorkItem
params 'Task | Objective | Key Result | Issue' params 'Task | Objective | Key Result | Issue'
condition { type_change_allowed? }
command :type do |type_name| command :type do |type_name|
@execution_message[:type] = update_type(type_name, :type) @execution_message[:type] = update_type(type_name, :type)
end end
...@@ -134,6 +135,10 @@ def promotion_allowed? ...@@ -134,6 +135,10 @@ def promotion_allowed?
current_user.can?(:update_work_item, quick_action_target) current_user.can?(:update_work_item, quick_action_target)
end end
def type_change_allowed?
true
end
def supports_promote_to?(type_name) def supports_promote_to?(type_name)
type_name == promote_to_map[current_type.base_type] type_name == promote_to_map[current_type.base_type]
end end
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册