diff --git a/CHANGELOG.md b/CHANGELOG.md index 86a37d5bdb1b4a4195e9c4046c062f68de85b1d8..171924d28652335849b0f53d5c6520841c34cd8d 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 d425d0f90146c918d428856ae977cabc5fdca5b6..ca65f75daacf391a7f42c7497acc882856726963 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 09c6978679137bc1e69b71d448d8f8a4c5340819..b7ca48ffa08bde77a4f12694ccf5889bc6c7d06e 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 5b2465e25ee75d751919a6b5b16d2d344f6377cb..773645707d3aa3c57e9cb6c70661f9d6d1d0772a 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 9fec2ad6bf77018513ea8a65e1de26f795245ec2..9ddd15548111aa78dd7457ece5e8a4be3ef1f694 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 0000000000000000000000000000000000000000..92182d100e8ad85dbb7100132fb03d528757e133 --- /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 3ae83ac082d5ea3aff2496704cb2b1176e5607bf..88eabea7e3a8c74a6a151a6cfaef31ba77e8c3ae 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