summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--app/views/shared/empty_states/_issues.html.haml18
-rw-r--r--app/views/shared/empty_states/_merge_requests.html.haml19
-rw-r--r--changelogs/unreleased/25043-empty-states.yml5
-rw-r--r--locale/gitlab.pot18
-rw-r--r--spec/features/groups/empty_states_spec.rb44
5 files changed, 101 insertions, 3 deletions
diff --git a/app/views/shared/empty_states/_issues.html.haml b/app/views/shared/empty_states/_issues.html.haml
index 0434860dec4..2691ec4cd46 100644
--- a/app/views/shared/empty_states/_issues.html.haml
+++ b/app/views/shared/empty_states/_issues.html.haml
@@ -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")
diff --git a/app/views/shared/empty_states/_merge_requests.html.haml b/app/views/shared/empty_states/_merge_requests.html.haml
index 06ceb9738bc..be5b1c6b6ce 100644
--- a/app/views/shared/empty_states/_merge_requests.html.haml
+++ b/app/views/shared/empty_states/_merge_requests.html.haml
@@ -1,6 +1,11 @@
- 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")
diff --git a/changelogs/unreleased/25043-empty-states.yml b/changelogs/unreleased/25043-empty-states.yml
new file mode 100644
index 00000000000..529a8b3206f
--- /dev/null
+++ b/changelogs/unreleased/25043-empty-states.yml
@@ -0,0 +1,5 @@
+---
+title: Make issuable empty states actionable
+merge_request: 24077
+author:
+type: changed
diff --git a/locale/gitlab.pot b/locale/gitlab.pot
index 59e9dd67774..9fd16c7bbc1 100644
--- a/locale/gitlab.pot
+++ b/locale/gitlab.pot
@@ -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 ""
diff --git a/spec/features/groups/empty_states_spec.rb b/spec/features/groups/empty_states_spec.rb
index 8f5ca781b2c..e4eb0d355d1 100644
--- a/spec/features/groups/empty_states_spec.rb
+++ b/spec/features/groups/empty_states_spec.rb
@@ -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