Commit 840e7e0e authored by Kushal Pandya's avatar Kushal Pandya

Merge branch '25043-empty-states' into 'master'

Add actionable empty states for Issues and Merge requests

Closes #25043

See merge request gitlab-org/gitlab-ce!24077
parents 2064565a f9b54ae1
......@@ -2,6 +2,10 @@
- project_select_button = local_assigns.fetch(:project_select_button, false)
- show_import_button = local_assigns.fetch(:show_import_button, false) && Feature.enabled?(:issues_import_csv) && can?(current_user, :import_issues, @project)
- has_button = button_path || project_select_button
- closed_issues_count = issuables_count_for_state(:issues, :closed)
- opened_issues_count = issuables_count_for_state(:issues, :opened)
- is_opened_state = params[:state] == 'opened'
- is_closed_state = params[:state] == 'closed'
.row.empty-state
.col-12
......@@ -14,6 +18,20 @@
= _("Sorry, your filter produced no results")
%p.text-center
= _("To widen your search, change or remove filters above")
- if show_new_issue_link?(@project)
.text-center
= link_to _("New issue"), new_project_issue_path(@project), class: "btn btn-success", title: _("New issue"), id: "new_issue_body_link"
- elsif is_opened_state && opened_issues_count == 0 && closed_issues_count > 0
%h4.text-center
= _("There are no open issues")
%p.text-center
= _("To keep this project going, create a new issue")
- if show_new_issue_link?(@project)
.text-center
= link_to _("New issue"), new_project_issue_path(@project), class: "btn btn-success", title: _("New issue"), id: "new_issue_body_link"
- elsif is_closed_state && opened_issues_count > 0 && closed_issues_count == 0
%h4.text-center
= _("There are no closed issues")
- elsif current_user
%h4
= _("The Issue Tracker is the place to add things that need to be improved or solved in a project")
......
- button_path = local_assigns.fetch(:button_path, false)
- project_select_button = local_assigns.fetch(:project_select_button, false)
- has_button = button_path || project_select_button
- closed_merged_count = issuables_count_for_state(:merged, :closed)
- opened_merged_count = issuables_count_for_state(:merged, :opened)
- is_opened_state = params[:state] == 'opened'
- is_closed_state = params[:state] == 'closed'
- can_create_merge_request = merge_request_source_project_for_project(@project)
.row.empty-state.merge-requests
.col-12
......@@ -13,6 +18,20 @@
= _("Sorry, your filter produced no results")
%p.text-center
= _("To widen your search, change or remove filters above")
.text-center
- if can_create_merge_request
= link_to _("New merge request"), project_new_merge_request_path(@project), class: "btn btn-success", title: _("New merge request"), id: "new_merge_request_body_link"
- elsif is_opened_state && opened_merged_count == 0 && closed_merged_count > 0
%h4.text-center
= _("There are no open merge requests")
%p.text-center
= _("To keep this project going, create a new merge request")
.text-center
- if can_create_merge_request
= link_to _("New merge request"), project_new_merge_request_path(@project), class: "btn btn-success", title: _("New merge request"), id: "new_merge_request_body_link"
- elsif is_closed_state && opened_merged_count > 0 && closed_merged_count == 0
%h4.text-center
= _("There are no closed merge requests")
- else
%h4
= _("Merge requests are a place to propose changes you've made to a project and discuss those changes with others")
......
---
title: Make issuable empty states actionable
merge_request: 24077
author:
type: changed
......@@ -6764,12 +6764,24 @@ msgstr ""
msgid "There are no archived projects yet"
msgstr ""
msgid "There are no closed issues"
msgstr ""
msgid "There are no closed merge requests"
msgstr ""
msgid "There are no issues to show"
msgstr ""
msgid "There are no labels yet"
msgstr ""
msgid "There are no open issues"
msgstr ""
msgid "There are no open merge requests"
msgstr ""
msgid "There are no projects shared with this group yet"
msgstr ""
......@@ -7194,6 +7206,12 @@ msgstr ""
msgid "To import an SVN repository, check out %{svn_link}."
msgstr ""
msgid "To keep this project going, create a new issue"
msgstr ""
msgid "To keep this project going, create a new merge request"
msgstr ""
msgid "To link Sentry to GitLab, enter your Sentry URL and Auth Token."
msgstr ""
......
......@@ -23,14 +23,52 @@ describe 'Group empty states' do
end
context "the project has #{issuable_name}s" do
before do
it 'does not display an empty state' do
create(issuable, project_relation => project)
visit path
expect(page).not_to have_selector('.empty-state')
end
it 'does not display an empty state' do
expect(page).not_to have_selector('.empty-state')
it "displays link to create new #{issuable} when no open #{issuable} is found" do
create("closed_#{issuable}", project_relation => project)
issuable_link_fn = "project_#{issuable}s_path"
visit public_send(issuable_link_fn, project)
page.within(find('.empty-state')) do
expect(page).to have_content(/There are no open #{issuable.to_s.humanize.downcase}/)
expect(page).to have_selector("#new_#{issuable}_body_link")
end
end
it 'displays link to create new issue when the current search gave no results' do
create(issuable, project_relation => project)
issuable_link_fn = "project_#{issuable}s_path"
visit public_send(issuable_link_fn, project, author_username: 'foo', scope: 'all', state: 'opened')
page.within(find('.empty-state')) do
expect(page).to have_content(/Sorry, your filter produced no results/)
new_issuable_path = issuable == :issue ? 'new_project_issue_path' : 'project_new_merge_request_path'
path = public_send(new_issuable_path, project)
expect(page).to have_selector("#new_#{issuable}_body_link[href='#{path}']")
end
end
it "displays conditional text when no closed #{issuable} is found" do
create(issuable, project_relation => project)
issuable_link_fn = "project_#{issuable}s_path"
visit public_send(issuable_link_fn, project, state: 'closed')
page.within(find('.empty-state')) do
expect(page).to have_content(/There are no closed #{issuable.to_s.humanize.downcase}/)
end
end
end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment