diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 6069640b9c81ed7535d119418f86b75839cd9a4e..dfa86f52e4067403a6c46fdfb0758a8c64143d83 100644 --- a/app/helpers/issuables_helper.rb +++ b/app/helpers/issuables_helper.rb @@ -362,6 +362,10 @@ module IssuablesHelper end end + def has_filter_bar_param? + finder.class.scalar_params.any? { |p| params[p].present? } + end + private def sidebar_gutter_collapsed? diff --git a/app/views/shared/empty_states/_issues.html.haml b/app/views/shared/empty_states/_issues.html.haml index 2e26fe63d3ea4a87d17898cd360658da955b3699..0ddc56dc6c325ecdb5a3376681082fc57d64ee43 100644 --- a/app/views/shared/empty_states/_issues.html.haml +++ b/app/views/shared/empty_states/_issues.html.haml @@ -8,7 +8,12 @@ = image_tag 'illustrations/issues.svg' .col-12 .text-content - - if current_user + - if has_filter_bar_param? + %h4.text-center + = _("Sorry, your filter produced no results") + %p.text-center + = _("To widen your search, change or remove filters above") + - elsif current_user %h4 = _("The Issue Tracker is the place to add things that need to be improved or solved in a project") %p diff --git a/app/views/shared/empty_states/_merge_requests.html.haml b/app/views/shared/empty_states/_merge_requests.html.haml index 421a1b2415bea104ab18d3d5fd6fdbdeab0a09f4..06ceb9738bc644ad3ecf0921c985a860e070a0db 100644 --- a/app/views/shared/empty_states/_merge_requests.html.haml +++ b/app/views/shared/empty_states/_merge_requests.html.haml @@ -8,16 +8,19 @@ = image_tag 'illustrations/merge_requests.svg' .col-12 .text-content - - if has_button + - if has_filter_bar_param? + %h4.text-center + = _("Sorry, your filter produced no results") + %p.text-center + = _("To widen your search, change or remove filters above") + - else %h4 = _("Merge requests are a place to propose changes you've made to a project and discuss those changes with others") %p = _("Interested parties can even contribute by pushing commits if they want to.") - .text-center - - if project_select_button - = render 'shared/new_project_item_select', path: 'merge_requests/new', label: _('New merge request'), type: :merge_requests, with_feature_enabled: 'merge_requests' - - else - = link_to _('New merge request'), button_path, class: 'btn btn-success', title: _('New merge request'), id: 'new_merge_request_link' - - else - %h4.text-center - = _("There are no merge requests to show") + - if has_button + .text-center + - if project_select_button + = render 'shared/new_project_item_select', path: 'merge_requests/new', label: _('New merge request'), type: :merge_requests, with_feature_enabled: 'merge_requests' + - else + = link_to _('New merge request'), button_path, class: 'btn btn-success', title: _('New merge request'), id: 'new_merge_request_link' diff --git a/changelogs/unreleased/53326-improve-issues-empty-state.yml b/changelogs/unreleased/53326-improve-issues-empty-state.yml new file mode 100644 index 0000000000000000000000000000000000000000..7632db808b5599ad2463cdb532d97850d440392f --- /dev/null +++ b/changelogs/unreleased/53326-improve-issues-empty-state.yml @@ -0,0 +1,5 @@ +--- +title: Show different empty state for filtered issues and MRs +merge_request: 22775 +author: Heinrich Lee Yu +type: changed diff --git a/locale/gitlab.pot b/locale/gitlab.pot index ff4fd0c8aec5a8fe344b1648a226480cf775ad47..64c01a7cdc409f18a70d53eaddf656d50c7d952d 100644 --- a/locale/gitlab.pot +++ b/locale/gitlab.pot @@ -5841,6 +5841,9 @@ msgstr "" msgid "Something went wrong. Please try again." msgstr "" +msgid "Sorry, your filter produced no results" +msgstr "" + msgid "Sort by" msgstr "" @@ -6296,9 +6299,6 @@ msgstr "" msgid "There are no labels yet" msgstr "" -msgid "There are no merge requests to show" -msgstr "" - msgid "There are no projects shared with this group yet" msgstr "" @@ -6723,6 +6723,9 @@ msgstr "" msgid "To validate your GitLab CI configurations, go to 'CI/CD → Pipelines' inside your project, and click on the 'CI Lint' button." msgstr "" +msgid "To widen your search, change or remove filters above" +msgstr "" + msgid "Today" msgstr "" diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 4d9b8a10e043405f49e2f8af46f01ce07bb19fb9..5c1ffb76351ebfee56a9f73bd546c4816a9cf749 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -8,6 +8,17 @@ describe 'Issues' do let(:user) { create(:user) } let(:project) { create(:project, :public) } + shared_examples_for 'empty state with filters' do + it 'user sees empty state with filters' do + create(:issue, author: user, project: project) + + visit project_issues_path(project, milestone_title: "1.0") + + expect(page).to have_content('Sorry, your filter produced no results') + expect(page).to have_content('To widen your search, change or remove filters above') + end + end + describe 'while user is signed out' do describe 'empty state' do it 'user sees empty state' do @@ -17,6 +28,8 @@ describe 'Issues' do expect(page).to have_content('The Issue Tracker is the place to add things that need to be improved or solved in a project.') expect(page).to have_content('You can register or sign in to create issues for this project.') end + + it_behaves_like 'empty state with filters' end end @@ -37,6 +50,8 @@ describe 'Issues' do expect(page).to have_content('Issues can be bugs, tasks or ideas to be discussed. Also, issues are searchable and filterable.') expect(page).to have_content('New issue') end + + it_behaves_like 'empty state with filters' end describe 'Edit issue' do diff --git a/spec/features/merge_request/user_sees_empty_state_spec.rb b/spec/features/merge_request/user_sees_empty_state_spec.rb index 482f31b02d455f5ea9e24b8c2654feaf6ea19e27..012bfd6e4580348b3bb0f90b4eeebe755bdfd0bf 100644 --- a/spec/features/merge_request/user_sees_empty_state_spec.rb +++ b/spec/features/merge_request/user_sees_empty_state_spec.rb @@ -19,12 +19,20 @@ describe 'Merge request > User sees empty state' do context 'if there are merge requests' do before do create(:merge_request, source_project: project) - - visit project_merge_requests_path(project) end it 'does not show an empty state' do + visit project_merge_requests_path(project) + expect(page).not_to have_selector('.empty-state') end + + it 'shows empty state when filter results empty' do + visit project_merge_requests_path(project, milestone_title: "1.0") + + expect(page).to have_selector('.empty-state') + expect(page).to have_content('Sorry, your filter produced no results') + expect(page).to have_content('To widen your search, change or remove filters above') + end end end