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 ...@@ -448,6 +448,10 @@ class Commit
true true
end end
def to_ability_name
model_name.singular
end
def touch def touch
# no-op but needs to be defined since #persisted? is defined # no-op but needs to be defined since #persisted? is defined
end 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 ...@@ -4,7 +4,8 @@ module Notes
class QuickActionsService < BaseService class QuickActionsService < BaseService
UPDATE_SERVICES = { UPDATE_SERVICES = {
'Issue' => Issues::UpdateService, 'Issue' => Issues::UpdateService,
'MergeRequest' => MergeRequests::UpdateService 'MergeRequest' => MergeRequests::UpdateService,
'Commit' => Commits::UpdateService
}.freeze }.freeze
def self.noteable_update_service(note) def self.noteable_update_service(note)
......
...@@ -60,6 +60,7 @@ module QuickActions ...@@ -60,6 +60,7 @@ module QuickActions
"Closes this #{issuable.to_ability_name.humanize(capitalize: false)}." "Closes this #{issuable.to_ability_name.humanize(capitalize: false)}."
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.open? && issuable.open? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable) current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
...@@ -75,6 +76,7 @@ module QuickActions ...@@ -75,6 +76,7 @@ module QuickActions
"Reopens this #{issuable.to_ability_name.humanize(capitalize: false)}." "Reopens this #{issuable.to_ability_name.humanize(capitalize: false)}."
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.closed? && issuable.closed? &&
current_user.can?(:"update_#{issuable.to_ability_name}", issuable) current_user.can?(:"update_#{issuable.to_ability_name}", issuable)
...@@ -149,6 +151,7 @@ module QuickActions ...@@ -149,6 +151,7 @@ module QuickActions
issuable.allows_multiple_assignees? ? '@user1 @user2' : '' issuable.allows_multiple_assignees? ? '@user1 @user2' : ''
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.assignees.any? && issuable.assignees.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
...@@ -188,6 +191,7 @@ module QuickActions ...@@ -188,6 +191,7 @@ module QuickActions
"Removes #{issuable.milestone.to_reference(format: :name)} milestone." "Removes #{issuable.milestone.to_reference(format: :name)} milestone."
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.milestone_id? && issuable.milestone_id? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
...@@ -231,6 +235,7 @@ module QuickActions ...@@ -231,6 +235,7 @@ module QuickActions
end end
params '~label1 ~"label 2"' params '~label1 ~"label 2"'
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.labels.any? && issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
...@@ -257,6 +262,7 @@ module QuickActions ...@@ -257,6 +262,7 @@ module QuickActions
end end
params '~label1 ~"label 2"' params '~label1 ~"label 2"'
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.labels.any? && issuable.labels.any? &&
current_user.can?(:"admin_#{issuable.to_ability_name}", project) current_user.can?(:"admin_#{issuable.to_ability_name}", project)
...@@ -317,6 +323,7 @@ module QuickActions ...@@ -317,6 +323,7 @@ module QuickActions
"Subscribes to this #{issuable.to_ability_name.humanize(capitalize: false)}." "Subscribes to this #{issuable.to_ability_name.humanize(capitalize: false)}."
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
!issuable.subscribed?(current_user, project) !issuable.subscribed?(current_user, project)
end end
...@@ -329,6 +336,7 @@ module QuickActions ...@@ -329,6 +336,7 @@ module QuickActions
"Unsubscribes from this #{issuable.to_ability_name.humanize(capitalize: false)}." "Unsubscribes from this #{issuable.to_ability_name.humanize(capitalize: false)}."
end end
condition do condition do
issuable.is_a?(Issuable) &&
issuable.persisted? && issuable.persisted? &&
issuable.subscribed?(current_user, project) issuable.subscribed?(current_user, project)
end 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