Commit fab440b2 authored by Luke Duncalfe's avatar Luke Duncalfe Committed by Dmytro Zaporozhets

Show confluence CTA on project wiki empty state

When viewing an empty wiki, an admin will now be prompted to activate
the Confluence service.

https://gitlab.com/gitlab-org/gitlab/-/issues/220934
parent c6eb657f
...@@ -147,3 +147,7 @@ ul.wiki-pages-list.content-list { ...@@ -147,3 +147,7 @@ ul.wiki-pages-list.content-list {
} }
} }
} }
.empty-state-wiki .text-content {
max-width: 490px; // Widen to allow for the Confluence button
}
...@@ -95,10 +95,13 @@ module WikiHelper ...@@ -95,10 +95,13 @@ module WikiHelper
def wiki_empty_state_messages(wiki) def wiki_empty_state_messages(wiki)
case wiki.container case wiki.container
when Project when Project
writable_body = s_("WikiEmpty|A wiki is where you can store all the details about your project. This can include why you've created it, its principles, how to use it, and so on.")
writable_body += s_("WikiEmpty| Have a Confluence wiki already? Use that instead.") if show_enable_confluence_integration?(wiki.container)
{ {
writable: { writable: {
title: s_('WikiEmpty|The wiki lets you write documentation for your project'), title: s_('WikiEmpty|The wiki lets you write documentation for your project'),
body: s_("WikiEmpty|A wiki is where you can store all the details about your project. This can include why you've created it, its principles, how to use it, and so on.") body: writable_body
}, },
issuable: { issuable: {
title: s_('WikiEmpty|This project has no wiki pages'), title: s_('WikiEmpty|This project has no wiki pages'),
...@@ -137,4 +140,10 @@ module WikiHelper ...@@ -137,4 +140,10 @@ module WikiHelper
'wiki-directory-nest-level' => page.path.scan('/').count 'wiki-directory-nest-level' => page.path.scan('/').count
} }
end end
def show_enable_confluence_integration?(container)
container.is_a?(Project) &&
current_user&.can?(:admin_project, container) &&
!container.has_confluence?
end
end end
...@@ -11,6 +11,10 @@ ...@@ -11,6 +11,10 @@
%p.text-left %p.text-left
= messages.dig(:writable, :body) = messages.dig(:writable, :body)
= create_link = create_link
- if show_enable_confluence_integration?(@wiki.container)
= link_to s_('WikiEmpty|Enable the Confluence Wiki integration'),
edit_project_service_path(@project, :confluence),
class: 'btn', title: s_('WikiEmpty|Enable the Confluence Wiki integration')
- elsif @project && can?(current_user, :read_issue, @project) - elsif @project && can?(current_user, :read_issue, @project)
- issues_link = link_to s_('WikiEmptyIssueMessage|issue tracker'), project_issues_path(@project) - issues_link = link_to s_('WikiEmptyIssueMessage|issue tracker'), project_issues_path(@project)
......
.row.empty-state .row.empty-state.empty-state-wiki
.col-12 .col-12
.svg-content.qa-svg-content .svg-content.qa-svg-content
= image_tag image_path = image_tag image_path
......
...@@ -26396,6 +26396,9 @@ msgstr "" ...@@ -26396,6 +26396,9 @@ msgstr ""
msgid "WikiEmptyIssueMessage|issue tracker" msgid "WikiEmptyIssueMessage|issue tracker"
msgstr "" msgstr ""
msgid "WikiEmpty| Have a Confluence wiki already? Use that instead."
msgstr ""
msgid "WikiEmpty|A wiki is where you can store all the details about your group. This can include why you've created it, its principles, how to use it, and so on." msgid "WikiEmpty|A wiki is where you can store all the details about your group. This can include why you've created it, its principles, how to use it, and so on."
msgstr "" msgstr ""
...@@ -26405,6 +26408,9 @@ msgstr "" ...@@ -26405,6 +26408,9 @@ msgstr ""
msgid "WikiEmpty|Create your first page" msgid "WikiEmpty|Create your first page"
msgstr "" msgstr ""
msgid "WikiEmpty|Enable the Confluence Wiki integration"
msgstr ""
msgid "WikiEmpty|Suggest wiki improvement" msgid "WikiEmpty|Suggest wiki improvement"
msgstr "" msgstr ""
......
...@@ -4,18 +4,19 @@ require 'spec_helper' ...@@ -4,18 +4,19 @@ require 'spec_helper'
RSpec.describe 'User views empty wiki' do RSpec.describe 'User views empty wiki' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:confluence_link) { 'Enable the Confluence Wiki integration' }
let(:element) { page.find('.row.empty-state') }
shared_examples 'empty wiki and accessible issues' do shared_examples 'empty wiki and accessible issues' do
it 'show "issue tracker" message' do it 'show "issue tracker" message' do
visit(project_wikis_path(project)) visit(project_wikis_path(project))
element = page.find('.row.empty-state')
expect(element).to have_content('This project has no wiki pages') expect(element).to have_content('This project has no wiki pages')
expect(element).to have_content('You must be a project member') expect(element).to have_content('You must be a project member')
expect(element).to have_content('improve the wiki for this project') expect(element).to have_content('improve the wiki for this project')
expect(element).to have_link("issue tracker", href: project_issues_path(project)) expect(element).to have_link("issue tracker", href: project_issues_path(project))
expect(element).to have_link("Suggest wiki improvement", href: new_project_issue_path(project)) expect(element).to have_link("Suggest wiki improvement", href: new_project_issue_path(project))
expect(element).to have_no_link(confluence_link)
end end
end end
...@@ -23,11 +24,10 @@ RSpec.describe 'User views empty wiki' do ...@@ -23,11 +24,10 @@ RSpec.describe 'User views empty wiki' do
it 'does not show "issue tracker" message' do it 'does not show "issue tracker" message' do
visit(project_wikis_path(project)) visit(project_wikis_path(project))
element = page.find('.row.empty-state')
expect(element).to have_content('This project has no wiki pages') expect(element).to have_content('This project has no wiki pages')
expect(element).to have_content('You must be a project member') expect(element).to have_content('You must be a project member')
expect(element).to have_no_link('Suggest wiki improvement') expect(element).to have_no_link('Suggest wiki improvement')
expect(element).to have_no_link(confluence_link)
end end
end end
...@@ -60,16 +60,15 @@ RSpec.describe 'User views empty wiki' do ...@@ -60,16 +60,15 @@ RSpec.describe 'User views empty wiki' do
end end
context 'when user is logged in and a member' do context 'when user is logged in and a member' do
let(:project) { create(:project, :public, :wiki_repo) } let(:project) { create(:project, :public) }
before do before do
sign_in(user) sign_in(user)
project.add_developer(user) project.add_developer(user)
end end
it 'show "create first page" message' do it 'shows "create first page" message' do
visit(project_wikis_path(project)) visit(project_wikis_path(project))
element = page.find('.row.empty-state')
expect(element).to have_content('your project', count: 2) expect(element).to have_content('your project', count: 2)
...@@ -77,5 +76,34 @@ RSpec.describe 'User views empty wiki' do ...@@ -77,5 +76,34 @@ RSpec.describe 'User views empty wiki' do
expect(page).to have_button('Create page') expect(page).to have_button('Create page')
end end
it 'does not show the "enable confluence" button' do
visit(project_wikis_path(project))
expect(element).to have_no_link(confluence_link)
end
end
context 'when user is logged in and an admin' do
let(:project) { create(:project, :public, :wiki_repo) }
before do
sign_in(user)
project.add_maintainer(user)
end
it 'shows the "enable confluence" button' do
visit(project_wikis_path(project))
expect(element).to have_link(confluence_link)
end
it 'does not show "enable confluence" button if confluence is already enabled' do
create(:confluence_service, project: project)
visit(project_wikis_path(project))
expect(element).to have_no_link(confluence_link)
end
end 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