diff options
author | Jacopo <beschi.jacopo@gmail.com> | 2017-04-10 17:51:15 +0200 |
---|---|---|
committer | Jacopo <beschi.jacopo@gmail.com> | 2017-04-28 14:24:32 +0200 |
commit | 60e9405bb71cef461a4bc2d6a5d706a558a9dc32 (patch) | |
tree | acde27624d0e76f7384010f1d4e9c615db7e2e51 /app | |
parent | 9a905e1b9f9575bb8d637560cb3c59fd82079d2d (diff) | |
download | gitlab-ce-60e9405bb71cef461a4bc2d6a5d706a558a9dc32.tar.gz |
Improve text on todo list when the todo action comes from yourself
Improved todo message when an issue is assigned to yourself.
- The new message when an user assign to himself an issue or a mr is: "You
assigned issue xx to yourself"
- The new message when an user adds a todo to himself is: "You added a
todo for issue xx"
- The new message when and user mention himself is: "You mentioned
yourself on issue xx"
- The new message when an user directly address himself is: "You
directly addressed yourself on issue xx"
- The new message when an user mark himself as an approver is: "You set
yourself as an approver for merge request xx"
Diffstat (limited to 'app')
-rw-r--r-- | app/helpers/events_helper.rb | 5 | ||||
-rw-r--r-- | app/helpers/todos_helper.rb | 12 | ||||
-rw-r--r-- | app/models/todo.rb | 12 | ||||
-rw-r--r-- | app/views/dashboard/todos/_todo.html.haml | 6 |
4 files changed, 28 insertions, 7 deletions
diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 5f5c76d3722..960111ca045 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -10,11 +10,12 @@ module EventsHelper 'deleted' => 'icon_trash_o' }.freeze - def link_to_author(event) + def link_to_author(event, self_added: false) author = event.author if author - link_to author.name, user_path(author.username), title: author.name + name = self_added ? 'You' : author.name + link_to name, user_path(author.username), title: name else event.author_name end diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 4f5adf623f2..f19e2f9db9c 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -13,13 +13,13 @@ module TodosHelper def todo_action_name(todo) case todo.action - when Todo::ASSIGNED then 'assigned you' - when Todo::MENTIONED then 'mentioned you on' + when Todo::ASSIGNED then todo.self_added? ? 'assigned' : 'assigned you' + when Todo::MENTIONED then "mentioned #{todo_action_subject(todo)} on" when Todo::BUILD_FAILED then 'The build failed for' when Todo::MARKED then 'added a todo for' - when Todo::APPROVAL_REQUIRED then 'set you as an approver for' + when Todo::APPROVAL_REQUIRED then "set #{todo_action_subject(todo)} as an approver for" when Todo::UNMERGEABLE then 'Could not merge' - when Todo::DIRECTLY_ADDRESSED then 'directly addressed you on' + when Todo::DIRECTLY_ADDRESSED then "directly addressed #{todo_action_subject(todo)} on" end end @@ -148,6 +148,10 @@ module TodosHelper private + def todo_action_subject(todo) + todo.self_added? ? 'yourself' : 'you' + end + def show_todo_state?(todo) (todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && %w(closed merged).include?(todo.target.state) end diff --git a/app/models/todo.rb b/app/models/todo.rb index da3fa7277c2..b011001b235 100644 --- a/app/models/todo.rb +++ b/app/models/todo.rb @@ -84,6 +84,10 @@ class Todo < ActiveRecord::Base action == BUILD_FAILED end + def assigned? + action == ASSIGNED + end + def action_name ACTION_NAMES[action] end @@ -117,6 +121,14 @@ class Todo < ActiveRecord::Base end end + def self_added? + author == user + end + + def self_assigned? + assigned? && self_added? + end + private def keep_around_commit diff --git a/app/views/dashboard/todos/_todo.html.haml b/app/views/dashboard/todos/_todo.html.haml index d0c12aa57ae..38fd053ae65 100644 --- a/app/views/dashboard/todos/_todo.html.haml +++ b/app/views/dashboard/todos/_todo.html.haml @@ -9,7 +9,7 @@ .title-item.author-name - if todo.author - = link_to_author(todo) + = link_to_author(todo, self_added: todo.self_added?) - else (removed) @@ -22,6 +22,10 @@ - else (removed) + - if todo.self_assigned? + .title-item.action-name + to yourself + .title-item · |