Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Davila <rdavila84@gmail.com>2016-12-23 08:44:02 +0300
committerRuben Davila <rdavila84@gmail.com>2017-01-15 19:10:04 +0300
commit17196a2ff31c4eb65fa9ecff6f7208171e26059b (patch)
treee9a491799b764c42f3c0c20cb33fa763ebb520df /app/services/slash_commands
parent64dd41a0e21360c380cab394f8a5c9b4945b7fd1 (diff)
Backport backend work for time tracking.
Diffstat (limited to 'app/services/slash_commands')
-rw-r--r--app/services/slash_commands/interpret_service.rb47
1 files changed, 47 insertions, 0 deletions
diff --git a/app/services/slash_commands/interpret_service.rb b/app/services/slash_commands/interpret_service.rb
index d75c5b1800e..ea00415ae1f 100644
--- a/app/services/slash_commands/interpret_service.rb
+++ b/app/services/slash_commands/interpret_service.rb
@@ -243,6 +243,53 @@ module SlashCommands
@updates[:wip_event] = issuable.work_in_progress? ? 'unwip' : 'wip'
end
+ desc 'Set time estimate'
+ params '<1w 3d 2h 14m>'
+ condition do
+ current_user.can?(:"admin_#{issuable.to_ability_name}", project)
+ end
+ command :estimate do |raw_duration|
+ time_estimate = Gitlab::TimeTrackingFormatter.parse(raw_duration)
+
+ if time_estimate
+ @updates[:time_estimate] = time_estimate
+ end
+ end
+
+ desc 'Add or substract spent time'
+ params '<1h 30m | -1h 30m>'
+ condition do
+ current_user.can?(:"admin_#{issuable.to_ability_name}", issuable)
+ end
+ command :spend do |raw_duration|
+ reduce_time = raw_duration.sub!(/\A-/, '')
+ time_spent = Gitlab::TimeTrackingFormatter.parse(raw_duration)
+
+ if time_spent
+ time_spent *= -1 if reduce_time
+
+ @updates[:spend_time] = time_spent
+ end
+ end
+
+ desc 'Remove time estimate'
+ condition do
+ issuable.persisted? &&
+ current_user.can?(:"admin_#{issuable.to_ability_name}", project)
+ end
+ command :remove_estimate do
+ @updates[:time_estimate] = 0
+ end
+
+ desc 'Remove spent time'
+ condition do
+ issuable.persisted? &&
+ current_user.can?(:"admin_#{issuable.to_ability_name}", project)
+ end
+ command :remove_time_spent do
+ @updates[:spend_time] = :reset
+ end
+
# This is a dummy command, so that it appears in the autocomplete commands
desc 'CC'
params '@user'