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,7 +60,8 @@ module QuickActions
"Closes this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.open? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
......@@ -75,7 +76,8 @@ module QuickActions
"Reopens this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.closed? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
end
......@@ -149,7 +151,8 @@ module QuickActions
issuable.allows_multiple_assignees? ? '@user1 @user2' : ''
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
......@@ -188,7 +191,8 @@ module QuickActions
"Removes #{issuable.milestone.to_reference(format: :name)} milestone."
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.milestone_id? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
......@@ -231,7 +235,8 @@ module QuickActions
end
params '~label1 ~"label 2"'
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
......@@ -257,7 +262,8 @@ module QuickActions
end
params '~label1 ~"label 2"'
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project)
end
......@@ -317,7 +323,8 @@ module QuickActions
"Subscribes to this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
!issuable.subscribed?(current_user, project)
end
command :subscribe do
......@@ -329,7 +336,8 @@ module QuickActions
"Unsubscribes from this #{issuable.to_ability_name.humanize(capitalize: false)}."
end
condition do
issuable.persisted? &&
issuable.is_a?(Issuable) &&
issuable.persisted? &&
issuable.subscribed?(current_user, project)
end
command :unsubscribe do
......
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