Commit 2022243a authored by Peter Leitzen's avatar Peter Leitzen

Create empty Commits::UpdateService and wire it up

parent d23fbbc6
......@@ -448,6 +448,10 @@ class Commit
true
end
def to_ability_name
model_name.singular
end
def touch
# no-op but needs to be defined since #persisted? is defined
end
......
class CommitPolicy < BasePolicy
delegate { @subject.project }
end
# frozen_string_literal: true
module Commits
class UpdateService < BaseService
def execute(commit)
# TODO authorize user
end
end
end
......@@ -4,7 +4,8 @@ module Notes
class QuickActionsService < BaseService
UPDATE_SERVICES = {
'Issue' => Issues::UpdateService,
'MergeRequest' => MergeRequests::UpdateService
'MergeRequest' => MergeRequests::UpdateService,
'Commit' => Commits::UpdateService
}.freeze
def self.noteable_update_service(note)
......
......@@ -60,6 +60,7 @@ module QuickActions
"Closes this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.open? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
......@@ -75,6 +76,7 @@ module QuickActions
"Reopens this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.closed? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
......@@ -149,6 +151,7 @@ module QuickActions
issuable.allows_multiple_assignees? ? '@user1 @user2' : ''
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
......@@ -188,6 +191,7 @@ module QuickActions
"Removes #{issuable.milestone.to_reference(format: :name)} milestone."
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.milestone_id? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
......@@ -231,6 +235,7 @@ module QuickActions
end
params '~label1 ~"label 2"'
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
......@@ -257,6 +262,7 @@ module QuickActions
end
params '~label1 ~"label 2"'
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
......@@ -317,6 +323,7 @@ module QuickActions
"Subscribes to this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
!issuable.subscribed?(current_user, project)
end
......@@ -329,6 +336,7 @@ module QuickActions
"Unsubscribes from this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.subscribed?(current_user, project)
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment