summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosep Llaneras <pepmanuel@gmail.com>2016-10-12 01:22:09 +0200
committerJosep Llaneras <pepmanuel@gmail.com>2016-11-11 20:59:54 +0100
commit0803a350b09d2c80a7ff1c2d1e17712989b7a0c2 (patch)
tree42a6fb389abb4417c1dbacae1caf0a1b16a92ef1
parent0e1e42885a792145dafc6aa28165d069b1cb5c03 (diff)
downloadgitlab-ce-0803a350b09d2c80a7ff1c2d1e17712989b7a0c2.tar.gz
Issue #13823: random message when all Todos are Done
-rw-r--r--CHANGELOG.md1
-rw-r--r--app/controllers/dashboard/todos_controller.rb4
-rw-r--r--app/helpers/todos_helper.rb11
-rw-r--r--app/views/dashboard/todos/index.html.haml2
-rw-r--r--config/initializers/1_settings.rb1
-rw-r--r--config/no_todos_messages.yml16
-rw-r--r--spec/features/todos/todos_spec.rb6
7 files changed, 37 insertions, 4 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 86a37d5bdb1..171924d2865 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -55,6 +55,7 @@ entry.
- Remove 'Edit' button from wiki edit view !7143 (Hiroyuki Sato)
- Cleaned up global namespace JS !19661 (Jose Ivan Vargas)
- Refactor Jira service to use jira-ruby gem
+- Show random messages when the To Do list is empty. !13823 (jllaneras)
- Improved todos empty state
- Add hover to trash icon in notes !7008 (blackst0ne)
- Hides project activity tabs when features are disabled
diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb
index d425d0f9014..ca65f75daac 100644
--- a/app/controllers/dashboard/todos_controller.rb
+++ b/app/controllers/dashboard/todos_controller.rb
@@ -4,6 +4,10 @@ class Dashboard::TodosController < Dashboard::ApplicationController
def index
@sort = params[:sort]
@todos = @todos.page(params[:page])
+
+ if @todos.empty? && current_user.todos.any?
+ @no_todos_message = Gitlab.config.gitlab.no_todos_messages.sample
+ end
end
def destroy
diff --git a/app/helpers/todos_helper.rb b/app/helpers/todos_helper.rb
index 09c69786791..b7ca48ffa08 100644
--- a/app/helpers/todos_helper.rb
+++ b/app/helpers/todos_helper.rb
@@ -138,9 +138,20 @@ module TodosHelper
end
end
+ def no_todos_message
+ message, author = @no_todos_message.values_at('message', 'author')
+
+ if author
+ message += " -- " + author
+ end
+
+ message
+ end
+
private
def show_todo_state?(todo)
(todo.target.is_a?(MergeRequest) || todo.target.is_a?(Issue)) && ['closed', 'merged'].include?(todo.target.state)
end
+
end
diff --git a/app/views/dashboard/todos/index.html.haml b/app/views/dashboard/todos/index.html.haml
index 5b2465e25ee..773645707d3 100644
--- a/app/views/dashboard/todos/index.html.haml
+++ b/app/views/dashboard/todos/index.html.haml
@@ -84,7 +84,7 @@
= render "shared/empty_states/todos_all_done.svg"
- if todos_filter_empty?
%h4.text-center
- Good job! Looks like you don't have any todos left.
+ = no_todos_message
%p.text-center
Are you looking for things to do? Take a look at
= succeed "," do
diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb
index 9fec2ad6bf7..9ddd1554811 100644
--- a/config/initializers/1_settings.rb
+++ b/config/initializers/1_settings.rb
@@ -215,6 +215,7 @@ Settings.gitlab.default_projects_features['visibility_level'] = Settings.send(
Settings.gitlab['domain_whitelist'] ||= []
Settings.gitlab['import_sources'] ||= %w[github bitbucket gitlab google_code fogbugz git gitlab_project]
Settings.gitlab['trusted_proxies'] ||= []
+Settings.gitlab['no_todos_messages'] ||= YAML.load_file(Rails.root.join('config', 'no_todos_messages.yml'))
#
# CI
diff --git a/config/no_todos_messages.yml b/config/no_todos_messages.yml
new file mode 100644
index 00000000000..92182d100e8
--- /dev/null
+++ b/config/no_todos_messages.yml
@@ -0,0 +1,16 @@
+# When the Todos list on the user's dashboard is empty, one of the messages below shows up randomly.
+#
+# If you come up with a fun one, please feel free to contribute it to GitLab!
+# https://about.gitlab.com/contributing/
+
+---
+-
+ message: "Good job! Looks like you don't have any todos left."
+-
+ message: "You're all done!"
+-
+ message: "Coffee really tastes better without any todos left."
+ author: "Josep Llaneras"
+-
+ message: "Isn't an empty To Do list beautiful?"
+ author: "Josep Llaneras"
diff --git a/spec/features/todos/todos_spec.rb b/spec/features/todos/todos_spec.rb
index 3ae83ac082d..88eabea7e3a 100644
--- a/spec/features/todos/todos_spec.rb
+++ b/spec/features/todos/todos_spec.rb
@@ -44,7 +44,7 @@ describe 'Dashboard Todos', feature: true do
end
it 'shows "All done" message' do
- expect(page).to have_content("Good job! Looks like you don't have any todos left.")
+ expect(page).to have_selector('.todos-all-done', count: 1)
end
end
@@ -64,7 +64,7 @@ describe 'Dashboard Todos', feature: true do
end
it 'shows "All done" message' do
- expect(page).to have_content("Good job! Looks like you don't have any todos left.")
+ expect(page).to have_selector('.todos-all-done', count: 1)
end
end
end
@@ -152,7 +152,7 @@ describe 'Dashboard Todos', feature: true do
within('.todos-pending-count') { expect(page).to have_content '0' }
expect(page).to have_content 'To do 0'
expect(page).to have_content 'Done 0'
- expect(page).to have_content "Good job! Looks like you don't have any todos left."
+ expect(page).to have_selector('.todos-all-done', count: 1)
end
end
end