From 0803a350b09d2c80a7ff1c2d1e17712989b7a0c2 Mon Sep 17 00:00:00 2001 From: Josep Llaneras Date: Wed, 12 Oct 2016 01:22:09 +0200 Subject: Issue #13823: random message when all Todos are Done --- CHANGELOG.md | 1 + app/controllers/dashboard/todos_controller.rb | 4 ++++ app/helpers/todos_helper.rb | 11 +++++++++++ app/views/dashboard/todos/index.html.haml | 2 +- config/initializers/1_settings.rb | 1 + config/no_todos_messages.yml | 16 ++++++++++++++++ spec/features/todos/todos_spec.rb | 6 +++--- 7 files changed, 37 insertions(+), 4 deletions(-) create mode 100644 config/no_todos_messages.yml 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 -- cgit v1.2.1 From e4189ee690de9e45e15712e699c574a7e9dc1a8a Mon Sep 17 00:00:00 2001 From: Josep Llaneras Date: Fri, 28 Oct 2016 22:50:54 +0200 Subject: Remove author --- app/controllers/dashboard/todos_controller.rb | 4 ---- app/helpers/todos_helper.rb | 11 ----------- app/views/dashboard/todos/index.html.haml | 4 ++-- config/no_todos_messages.yml | 15 ++++----------- 4 files changed, 6 insertions(+), 28 deletions(-) diff --git a/app/controllers/dashboard/todos_controller.rb b/app/controllers/dashboard/todos_controller.rb index ca65f75daac..d425d0f9014 100644 --- a/app/controllers/dashboard/todos_controller.rb +++ b/app/controllers/dashboard/todos_controller.rb @@ -4,10 +4,6 @@ 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 b7ca48ffa08..09c69786791 100644 --- a/app/helpers/todos_helper.rb +++ b/app/helpers/todos_helper.rb @@ -138,20 +138,9 @@ 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 773645707d3..24811fc7a51 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 - = no_todos_message + = Gitlab.config.gitlab.no_todos_messages.sample %p.text-center Are you looking for things to do? Take a look at = succeed "," do @@ -108,4 +108,4 @@ @mention in a comment, this will trigger a new item in your todo list, automatically. %p - You will always know what to work on next. + You will always know what to work on next. \ No newline at end of file diff --git a/config/no_todos_messages.yml b/config/no_todos_messages.yml index 92182d100e8..5aea70e4386 100644 --- a/config/no_todos_messages.yml +++ b/config/no_todos_messages.yml @@ -1,16 +1,9 @@ -# When the Todos list on the user's dashboard is empty, one of the messages below shows up randomly. +# When the Todos list on the user's dashboard becomes 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" +- Good job! Looks like you don't have any todos left. +- Coffee really tastes better without any todos left. +- Isn't an empty To Do list beautiful? \ No newline at end of file -- cgit v1.2.1 From 17ae29828ab8d1d58de91982642fa92abaeea422 Mon Sep 17 00:00:00 2001 From: Josep Llaneras Date: Sat, 5 Nov 2016 12:36:47 +0100 Subject: Add new messages --- config/no_todos_messages.yml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/config/no_todos_messages.yml b/config/no_todos_messages.yml index 5aea70e4386..8372fb4ebe9 100644 --- a/config/no_todos_messages.yml +++ b/config/no_todos_messages.yml @@ -6,4 +6,8 @@ --- - Good job! Looks like you don't have any todos left. - Coffee really tastes better without any todos left. -- Isn't an empty To Do list beautiful? \ No newline at end of file +- Isn't an empty To Do list beautiful? +- Time for a rewarding coffee break +- Give yourself a pat on the back! +- High five! +- Hence forth you shall be known as 'Todo Destroyer' \ No newline at end of file -- cgit v1.2.1 From 5ab8536f4663a831bbe2e3acb6fd485a7d68c39f Mon Sep 17 00:00:00 2001 From: Josep Llaneras Date: Fri, 11 Nov 2016 21:53:17 +0100 Subject: Review comments Nov 11th --- CHANGELOG.md | 1 - app/views/dashboard/todos/index.html.haml | 2 +- changelogs/unreleased/issue-13823.yml | 4 ++++ 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/unreleased/issue-13823.yml diff --git a/CHANGELOG.md b/CHANGELOG.md index 171924d2865..86a37d5bdb1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -55,7 +55,6 @@ 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/views/dashboard/todos/index.html.haml b/app/views/dashboard/todos/index.html.haml index 24811fc7a51..472d698486b 100644 --- a/app/views/dashboard/todos/index.html.haml +++ b/app/views/dashboard/todos/index.html.haml @@ -108,4 +108,4 @@ @mention in a comment, this will trigger a new item in your todo list, automatically. %p - You will always know what to work on next. \ No newline at end of file + You will always know what to work on next. diff --git a/changelogs/unreleased/issue-13823.yml b/changelogs/unreleased/issue-13823.yml new file mode 100644 index 00000000000..c1b5760f7df --- /dev/null +++ b/changelogs/unreleased/issue-13823.yml @@ -0,0 +1,4 @@ +--- +title: Show random messages when the To Do list is empty +merge_request: 6818 +author: Josep Llaneras -- cgit v1.2.1