diff options
author | Robert Speicher <robert@gitlab.com> | 2016-10-04 09:45:04 +0000 |
---|---|---|
committer | Robert Speicher <robert@gitlab.com> | 2016-10-04 09:45:04 +0000 |
commit | 006cd7f7b29fbe8f566ff72afb9236e90502d8ca (patch) | |
tree | 790fd990923f77750cd66c7001b9ff944591f404 | |
parent | 66613f1ac9e277da9b68ff6ddbd0fb7eca3507bf (diff) | |
parent | f917bf80e81b433f5bbf06ea90bc3d3d0b880bc7 (diff) | |
download | gitlab-ce-006cd7f7b29fbe8f566ff72afb9236e90502d8ca.tar.gz |
Merge branch 'todo-issue-due-date' into 'master'
Todo issue due date
## What does this MR do?
Adds the text 'Due today' or 'Due [DATE]' next to issues in todos.
This does not add anyway to filter by due date - little steps.
## What are the relevant issue numbers?
#18218
See merge request !6351
-rw-r--r-- | CHANGELOG | 1 | ||||
-rw-r--r-- | app/helpers/todos_helper.rb | 20 | ||||
-rw-r--r-- | app/views/dashboard/todos/_todo.html.haml | 1 | ||||
-rw-r--r-- | spec/features/todos/todos_spec.rb | 8 |
4 files changed, 29 insertions, 1 deletions
diff --git a/CHANGELOG b/CHANGELOG index bfc312ca19c..395ee8d3980 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -146,6 +146,7 @@ v 8.12.0 - Increase ci_builds artifacts_size column to 8-byte integer to allow larger files - Add textarea autoresize after comment (ClemMakesApps) - Do not write SSH public key 'comments' to authorized_keys !6381 + - Add due date to issue todos - Refresh todos count cache when an Issue/MR is deleted - Fix branches page dropdown sort alignment (ClemMakesApps) - Hides merge request button on branches page is user doesn't have permissions diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb index 1e86f648203..a9db8bb2b82 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -114,6 +114,26 @@ module TodosHelper selected_type ? selected_type[:text] : default_type end + def todo_due_date(todo) + return unless todo.target.try(:due_date) + + is_due_today = todo.target.due_date.today? + is_overdue = todo.target.overdue? + css_class = + if is_due_today + 'text-warning' + elsif is_overdue + 'text-danger' + else + '' + end + + html = "· ".html_safe + html << content_tag(:span, class: css_class) do + "Due #{is_due_today ? "today" : todo.target.due_date.to_s(:medium)}" + end + end + private def show_todo_state?(todo) diff --git a/app/views/dashboard/todos/_todo.html.haml b/app/views/dashboard/todos/_todo.html.haml index b40395c74de..cc077fad32a 100644 --- a/app/views/dashboard/todos/_todo.html.haml +++ b/app/views/dashboard/todos/_todo.html.haml @@ -19,6 +19,7 @@ (removed) · #{time_ago_with_tooltip(todo.created_at)} + = todo_due_date(todo) .todo-body .todo-note diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb index fc555a74f30..bf93c1d1251 100644 --- a/spec/features/todos/todos_spec.rb +++ b/spec/features/todos/todos_spec.rb @@ -4,7 +4,7 @@ describe 'Dashboard Todos', feature: true do let(:user) { create(:user) } let(:author) { create(:user) } let(:project) { create(:project, visibility_level: Gitlab::VisibilityLevel::PUBLIC) } - let(:issue) { create(:issue) } + let(:issue) { create(:issue, due_date: Date.today) } describe 'GET /dashboard/todos' do context 'User does not have todos' do @@ -28,6 +28,12 @@ describe 'Dashboard Todos', feature: true do expect(page).to have_selector('.todos-list .todo', count: 1) end + it 'shows due date as today' do + page.within first('.todo') do + expect(page).to have_content 'Due today' + end + end + describe 'deleting the todo' do before do first('.done-todo').click |