diff options
| -rw-r--r-- | app/helpers/issuables_helper.rb | 4 | ||||
| -rw-r--r-- | app/services/ci/register_job_service.rb | 6 | ||||
| -rw-r--r-- | app/views/shared/empty_states/_issues.html.haml | 7 | ||||
| -rw-r--r-- | app/views/shared/empty_states/_merge_requests.html.haml | 21 | ||||
| -rw-r--r-- | changelogs/unreleased/53326-improve-issues-empty-state.yml | 5 | ||||
| -rw-r--r-- | locale/gitlab.pot | 9 | ||||
| -rw-r--r-- | spec/features/issues_spec.rb | 15 | ||||
| -rw-r--r-- | spec/features/merge_request/user_sees_empty_state_spec.rb | 12 |
8 files changed, 60 insertions, 19 deletions
diff --git a/app/helpers/issuables_helper.rb b/app/helpers/issuables_helper.rb index 6069640b9c8..dfa86f52e40 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/services/ci/register_job_service.rb b/app/services/ci/register_job_service.rb index 2abc4a67dd6..13321b2682e 100644 --- a/app/services/ci/register_job_service.rb +++ b/app/services/ci/register_job_service.rb @@ -36,7 +36,7 @@ module Ci builds = builds.with_any_tags end - selection = builds.find do |build| + builds.each do |build| next unless runner.can_pick?(build) begin @@ -45,7 +45,7 @@ module Ci if assign_runner!(build, params) register_success(build) - break build + return Result.new(build, true) end rescue StateMachines::InvalidTransition, ActiveRecord::StaleObjectError # We are looping to find another build that is not conflicting @@ -61,8 +61,6 @@ module Ci end end - return Result.new(selection, true) if selection - register_failure Result.new(nil, valid) end diff --git a/app/views/shared/empty_states/_issues.html.haml b/app/views/shared/empty_states/_issues.html.haml index 2e26fe63d3e..0ddc56dc6c3 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 421a1b2415b..06ceb9738bc 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 00000000000..7632db808b5 --- /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 ff4fd0c8aec..64c01a7cdc4 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 4d9b8a10e04..5c1ffb76351 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 482f31b02d4..012bfd6e458 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 |
