From 60bf55456edb3e06ba57dd1da20dffb5d0bfead7 Mon Sep 17 00:00:00 2001 From: Mehdi Lahmam Date: Sun, 5 Nov 2017 23:52:39 +0100 Subject: Add /lock and /unlock quick actions Closes #39173 --- app/services/quick_actions/interpret_service.rb | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'app/services/quick_actions') diff --git a/app/services/quick_actions/interpret_service.rb b/app/services/quick_actions/interpret_service.rb index a4c4c9e4812..be9d1e48435 100644 --- a/app/services/quick_actions/interpret_service.rb +++ b/app/services/quick_actions/interpret_service.rb @@ -489,6 +489,30 @@ module QuickActions "#{comment} #{TABLEFLIP}" end + desc "Lock the discussion" + explanation "Locks the discussion" + condition do + issuable.is_a?(Issuable) && + issuable.persisted? && + !issuable.discussion_locked? && + current_user.can?(:"admin_#{issuable.to_ability_name}", issuable) + end + command :lock do + @updates[:discussion_locked] = true + end + + desc "Unlock the discussion" + explanation "Unlocks the discussion" + condition do + issuable.is_a?(Issuable) && + issuable.persisted? && + issuable.discussion_locked? && + current_user.can?(:"admin_#{issuable.to_ability_name}", issuable) + end + command :unlock do + @updates[:discussion_locked] = false + end + # This is a dummy command, so that it appears in the autocomplete commands desc 'CC' params '@user' -- cgit v1.2.1