Commit 6262a91e authored by Stan Hu's avatar Stan Hu

Merge branch 'todos/include-issue-mr-titles' into 'master'

Add Issue and Merge Request titles to Todo items

Closes #63488

See merge request gitlab-org/gitlab-ce!30435
parents 2ad1621c 4ca32c2b
...@@ -72,12 +72,7 @@ ...@@ -72,12 +72,7 @@
@include transition(opacity); @include transition(opacity);
.todo-title { .todo-title {
display: flex;
> .title-item { > .title-item {
flex: 0 0 auto;
margin: 0 2px;
&:first-child { &:first-child {
margin-left: 0; margin-left: 0;
} }
...@@ -105,8 +100,12 @@ ...@@ -105,8 +100,12 @@
font-size: 14px; font-size: 14px;
} }
.action-name { .todo-label,
font-weight: $gl-font-weight-normal; .todo-project {
a {
color: $blue-600;
font-weight: $gl-font-weight-normal;
}
} }
.todo-body { .todo-body {
...@@ -170,7 +169,7 @@ ...@@ -170,7 +169,7 @@
} }
} }
@include media-breakpoint-down(xs) { @include media-breakpoint-down(sm) {
.todo { .todo {
.avatar { .avatar {
display: none; display: none;
...@@ -179,7 +178,6 @@ ...@@ -179,7 +178,6 @@
.todo-item { .todo-item {
.todo-title { .todo-title {
flex-flow: row wrap;
margin-bottom: 10px; margin-bottom: 10px;
.todo-label { .todo-label {
......
...@@ -33,7 +33,23 @@ module TodosHelper ...@@ -33,7 +33,23 @@ module TodosHelper
todo.target_reference todo.target_reference
end end
link_to text, todo_target_path(todo), class: 'has-tooltip', title: todo.target.title link_to text, todo_target_path(todo)
end
def todo_target_title(todo)
if todo.target
"\"#{todo.target.title}\""
else
""
end
end
def todo_parent_path(todo)
if todo.parent.is_a?(Group)
link_to todo.parent.name, group_path(todo.parent)
else
link_to_project(todo.project)
end
end end
def todo_target_type_name(todo) def todo_target_type_name(todo)
......
...@@ -186,9 +186,9 @@ class Todo < ApplicationRecord ...@@ -186,9 +186,9 @@ class Todo < ApplicationRecord
def target_reference def target_reference
if for_commit? if for_commit?
target.reference_link_text(full: true) target.reference_link_text
else else
target.to_reference(full: true) target.to_reference
end end
end end
......
...@@ -2,41 +2,49 @@ ...@@ -2,41 +2,49 @@
.todo-avatar .todo-avatar
= author_avatar(todo, size: 40) = author_avatar(todo, size: 40)
.todo-item.todo-block .todo-item.todo-block.align-self-center
.todo-title.title .todo-title
- unless todo.build_failed? || todo.unmergeable? - unless todo.build_failed? || todo.unmergeable?
= todo_target_state_pill(todo) = todo_target_state_pill(todo)
.title-item.author-name %span.title-item.author-name.bold
- if todo.author - if todo.author
= link_to_author(todo, self_added: todo.self_added?) = link_to_author(todo, self_added: todo.self_added?)
- else - else
(removed) (removed)
.title-item.action-name %span.title-item.action-name
= todo_action_name(todo) = todo_action_name(todo)
.title-item.todo-label %span.title-item.todo-label.todo-target-link
- if todo.target - if todo.target
= todo_target_link(todo) = todo_target_link(todo)
- else - else
(removed) = _("(removed)")
%span.title-item.todo-target-title
= todo_target_title(todo)
%span.title-item.todo-project.todo-label
at
= todo_parent_path(todo)
- if todo.self_assigned? - if todo.self_assigned?
.title-item.action-name %span.title-item.action-name
to yourself to yourself
.title-item %span.title-item
&middot; &middot;
.title-item %span.title-item.todo-timestamp
#{time_ago_with_tooltip(todo.created_at)} #{time_ago_with_tooltip(todo.created_at)}
= todo_due_date(todo) = todo_due_date(todo)
.todo-body - if todo.note.present?
.todo-note.break-word .todo-body
.md .todo-note.break-word
= first_line_in_markdown(todo, :body, 150, project: todo.project) .md
= first_line_in_markdown(todo, :body, 150, project: todo.project)
- if todo.pending? - if todo.pending?
.todo-actions .todo-actions
......
---
title: Add Issue and Merge Request titles to Todo items
merge_request: 30435
author: Arun Kumar Mohan
type: changed
...@@ -309,6 +309,9 @@ msgstr "" ...@@ -309,6 +309,9 @@ msgstr ""
msgid "(external source)" msgid "(external source)"
msgstr "" msgstr ""
msgid "(removed)"
msgstr ""
msgid "+ %{amount} more" msgid "+ %{amount} more"
msgstr "" msgstr ""
......
...@@ -31,9 +31,9 @@ describe 'Dashboard > User filters todos', :js do ...@@ -31,9 +31,9 @@ describe 'Dashboard > User filters todos', :js do
end end
it 'displays all todos without a filter' do it 'displays all todos without a filter' do
expect(page).to have_content issue1.to_reference(full: true) expect(page).to have_content issue1.to_reference(full: false)
expect(page).to have_content merge_request.to_reference(full: true) expect(page).to have_content merge_request.to_reference(full: false)
expect(page).to have_content issue2.to_reference(full: true) expect(page).to have_content issue2.to_reference(full: false)
end end
it 'filters by project' do it 'filters by project' do
...@@ -58,9 +58,9 @@ describe 'Dashboard > User filters todos', :js do ...@@ -58,9 +58,9 @@ describe 'Dashboard > User filters todos', :js do
wait_for_requests wait_for_requests
expect(page).to have_content issue1.to_reference(full: true) expect(page).to have_content "issue #{issue1.to_reference} \"issue\" at #{group1.name} / project_1"
expect(page).to have_content merge_request.to_reference(full: true) expect(page).to have_content "merge request #{merge_request.to_reference}"
expect(page).not_to have_content issue2.to_reference(full: true) expect(page).not_to have_content "issue #{issue2.to_reference} \"issue\" at #{group2.name} / project_3"
end end
context 'Author filter' do context 'Author filter' do
......
...@@ -42,33 +42,33 @@ describe 'Dashboard > User sorts todos' do ...@@ -42,33 +42,33 @@ describe 'Dashboard > User sorts todos' do
click_link 'Last created' click_link 'Last created'
results_list = page.find('.todos-list') results_list = page.find('.todos-list')
expect(results_list.all('p')[0]).to have_content('merge_request_1') expect(results_list.all('.todo-title')[0]).to have_content('merge_request_1')
expect(results_list.all('p')[1]).to have_content('issue_1') expect(results_list.all('.todo-title')[1]).to have_content('issue_1')
expect(results_list.all('p')[2]).to have_content('issue_3') expect(results_list.all('.todo-title')[2]).to have_content('issue_3')
expect(results_list.all('p')[3]).to have_content('issue_2') expect(results_list.all('.todo-title')[3]).to have_content('issue_2')
expect(results_list.all('p')[4]).to have_content('issue_4') expect(results_list.all('.todo-title')[4]).to have_content('issue_4')
end end
it 'sorts with newest created todos first' do it 'sorts with newest created todos first' do
click_link 'Oldest created' click_link 'Oldest created'
results_list = page.find('.todos-list') results_list = page.find('.todos-list')
expect(results_list.all('p')[0]).to have_content('issue_4') expect(results_list.all('.todo-title')[0]).to have_content('issue_4')
expect(results_list.all('p')[1]).to have_content('issue_2') expect(results_list.all('.todo-title')[1]).to have_content('issue_2')
expect(results_list.all('p')[2]).to have_content('issue_3') expect(results_list.all('.todo-title')[2]).to have_content('issue_3')
expect(results_list.all('p')[3]).to have_content('issue_1') expect(results_list.all('.todo-title')[3]).to have_content('issue_1')
expect(results_list.all('p')[4]).to have_content('merge_request_1') expect(results_list.all('.todo-title')[4]).to have_content('merge_request_1')
end end
it 'sorts by label priority' do it 'sorts by label priority' do
click_link 'Label priority' click_link 'Label priority'
results_list = page.find('.todos-list') results_list = page.find('.todos-list')
expect(results_list.all('p')[0]).to have_content('issue_3') expect(results_list.all('.todo-title')[0]).to have_content('issue_3')
expect(results_list.all('p')[1]).to have_content('merge_request_1') expect(results_list.all('.todo-title')[1]).to have_content('merge_request_1')
expect(results_list.all('p')[2]).to have_content('issue_1') expect(results_list.all('.todo-title')[2]).to have_content('issue_1')
expect(results_list.all('p')[3]).to have_content('issue_2') expect(results_list.all('.todo-title')[3]).to have_content('issue_2')
expect(results_list.all('p')[4]).to have_content('issue_4') expect(results_list.all('.todo-title')[4]).to have_content('issue_4')
end end
end end
...@@ -93,9 +93,9 @@ describe 'Dashboard > User sorts todos' do ...@@ -93,9 +93,9 @@ describe 'Dashboard > User sorts todos' do
click_link 'Label priority' click_link 'Label priority'
results_list = page.find('.todos-list') results_list = page.find('.todos-list')
expect(results_list.all('p')[0]).to have_content('issue_1') expect(results_list.all('.todo-title')[0]).to have_content('issue_1')
expect(results_list.all('p')[1]).to have_content('issue_2') expect(results_list.all('.todo-title')[1]).to have_content('issue_2')
expect(results_list.all('p')[2]).to have_content('merge_request_1') expect(results_list.all('.todo-title')[2]).to have_content('merge_request_1')
end end
end end
end end
...@@ -3,10 +3,10 @@ ...@@ -3,10 +3,10 @@
require 'spec_helper' require 'spec_helper'
describe 'Dashboard Todos' do describe 'Dashboard Todos' do
let(:user) { create(:user) } let(:user) { create(:user, username: 'john') }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:project) { create(:project, :public) } let(:project) { create(:project, :public) }
let(:issue) { create(:issue, due_date: Date.today) } let(:issue) { create(:issue, due_date: Date.today, title: "Fix bug") }
context 'User does not have todos' do context 'User does not have todos' do
before do before do
...@@ -135,7 +135,7 @@ describe 'Dashboard Todos' do ...@@ -135,7 +135,7 @@ describe 'Dashboard Todos' do
it 'shows issue assigned to yourself message' do it 'shows issue assigned to yourself message' do
page.within('.js-todos-all') do page.within('.js-todos-all') do
expect(page).to have_content("You assigned issue #{issue.to_reference(full: true)} to yourself") expect(page).to have_content("You assigned issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name} to yourself")
end end
end end
end end
...@@ -148,7 +148,7 @@ describe 'Dashboard Todos' do ...@@ -148,7 +148,7 @@ describe 'Dashboard Todos' do
it 'shows you added a todo message' do it 'shows you added a todo message' do
page.within('.js-todos-all') do page.within('.js-todos-all') do
expect(page).to have_content("You added a todo for issue #{issue.to_reference(full: true)}") expect(page).to have_content("You added a todo for issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
expect(page).not_to have_content('to yourself') expect(page).not_to have_content('to yourself')
end end
end end
...@@ -162,7 +162,7 @@ describe 'Dashboard Todos' do ...@@ -162,7 +162,7 @@ describe 'Dashboard Todos' do
it 'shows you mentioned yourself message' do it 'shows you mentioned yourself message' do
page.within('.js-todos-all') do page.within('.js-todos-all') do
expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference(full: true)}") expect(page).to have_content("You mentioned yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
expect(page).not_to have_content('to yourself') expect(page).not_to have_content('to yourself')
end end
end end
...@@ -176,14 +176,14 @@ describe 'Dashboard Todos' do ...@@ -176,14 +176,14 @@ describe 'Dashboard Todos' do
it 'shows you directly addressed yourself message' do it 'shows you directly addressed yourself message' do
page.within('.js-todos-all') do page.within('.js-todos-all') do
expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference(full: true)}") expect(page).to have_content("You directly addressed yourself on issue #{issue.to_reference} \"Fix bug\" at #{project.namespace.owner_name} / #{project.name}")
expect(page).not_to have_content('to yourself') expect(page).not_to have_content('to yourself')
end end
end end
end end
context 'approval todo' do context 'approval todo' do
let(:merge_request) { create(:merge_request) } let(:merge_request) { create(:merge_request, title: "Fixes issue") }
before do before do
create(:todo, :approval_required, user: user, project: project, target: merge_request, author: user) create(:todo, :approval_required, user: user, project: project, target: merge_request, author: user)
...@@ -192,7 +192,7 @@ describe 'Dashboard Todos' do ...@@ -192,7 +192,7 @@ describe 'Dashboard Todos' do
it 'shows you set yourself as an approver message' do it 'shows you set yourself as an approver message' do
page.within('.js-todos-all') do page.within('.js-todos-all') do
expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference(full: true)}") expect(page).to have_content("You set yourself as an approver for merge request #{merge_request.to_reference} \"Fixes issue\" at #{project.namespace.owner_name} / #{project.name}")
expect(page).not_to have_content('to yourself') expect(page).not_to have_content('to yourself')
end end
end end
...@@ -354,7 +354,7 @@ describe 'Dashboard Todos' do ...@@ -354,7 +354,7 @@ describe 'Dashboard Todos' do
it 'links to the pipelines for the merge request' do it 'links to the pipelines for the merge request' do
href = pipelines_project_merge_request_path(project, todo.target) href = pipelines_project_merge_request_path(project, todo.target)
expect(page).to have_link "merge request #{todo.target.to_reference(full: true)}", href: href expect(page).to have_link "merge request #{todo.target.to_reference}", href: href
end end
end end
end end
...@@ -121,12 +121,12 @@ describe Todo do ...@@ -121,12 +121,12 @@ describe Todo do
subject.target_type = 'Commit' subject.target_type = 'Commit'
subject.commit_id = commit.id subject.commit_id = commit.id
expect(subject.target_reference).to eq commit.reference_link_text(full: true) expect(subject.target_reference).to eq commit.reference_link_text(full: false)
end end
it 'returns full reference for issuables' do it 'returns full reference for issuables' do
subject.target = issue subject.target = issue
expect(subject.target_reference).to eq issue.to_reference(full: true) expect(subject.target_reference).to eq issue.to_reference(full: false)
end end
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