Commit 75e40a8e authored by Gabriel Mazetto's avatar Gabriel Mazetto

Merge branch 'group-wiki-link' into 'master'

Add Wiki link to Group sidebar

See merge request gitlab-org/gitlab!36409
parents c6567cbc 715d4afb
......@@ -176,6 +176,10 @@ module GroupsHelper
links << :settings
end
if can?(current_user, :read_wiki, @group)
links << :wiki
end
links
end
......
......@@ -123,6 +123,9 @@
= render 'layouts/nav/sidebar/analytics_links', links: group_analytics_navbar_links(@group, current_user)
- if group_sidebar_link?(:wiki)
= render 'layouts/nav/sidebar/wiki_link', wiki_url: @group.wiki.web_url
- if group_sidebar_link?(:group_members)
= nav_link(path: 'group_members#index') do
= link_to group_group_members_path(@group) do
......
......@@ -308,18 +308,7 @@
= _('Confluence')
- if project_nav_tab? :wiki
- wiki_url = wiki_path(@project.wiki)
= nav_link(controller: :wikis) do
= link_to wiki_url, class: 'shortcuts-wiki', data: { qa_selector: 'wiki_link' } do
.nav-icon-container
= sprite_icon('book')
%span.nav-item-name
= _('Wiki')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :wikis, html_options: { class: "fly-out-top-item" } ) do
= link_to wiki_url do
%strong.fly-out-top-item-name
= _('Wiki')
= render 'layouts/nav/sidebar/wiki_link', wiki_url: wiki_path(@project.wiki)
- if project_nav_tab?(:external_wiki)
- external_wiki_url = @project.external_wiki.external_wiki_url
......
= nav_link(controller: :wikis) do
= link_to wiki_url, class: 'shortcuts-wiki', data: { qa_selector: 'wiki_link' } do
.nav-icon-container
= sprite_icon('book')
%span.nav-item-name
= _('Wiki')
%ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(controller: :wikis, html_options: { class: "fly-out-top-item" } ) do
= link_to wiki_url do
%strong.fly-out-top-item-name
= _('Wiki')
......@@ -15,6 +15,7 @@ RSpec.describe 'Group navbar' do
group.add_maintainer(user)
stub_feature_flags(group_push_rules: false)
stub_feature_flags(group_iterations: false)
stub_feature_flags(group_wiki: false)
sign_in(user)
end
......@@ -217,4 +218,21 @@ RSpec.describe 'Group navbar' do
it_behaves_like 'verified navigation bar'
end
context 'when group wiki is available' do
before do
stub_feature_flags(group_wiki: true)
insert_after_nav_item(
_('Analytics'),
new_nav_item: {
nav_item: _('Wiki'),
nav_sub_items: []
}
)
visit group_path(group)
end
it_behaves_like 'verified navigation bar'
end
end
......@@ -200,6 +200,40 @@ RSpec.describe 'layouts/nav/sidebar/_group' do
end
end
describe 'wiki tab' do
let(:can_read_wiki) { true }
let_it_be(:current_user) { create(:user) }
before do
group.add_guest(current_user)
allow(view).to receive(:current_user).and_return(current_user)
allow(view).to receive(:can?).with(current_user, :read_wiki, group).and_return(can_read_wiki)
# TODO can be removed with https://gitlab.com/gitlab-org/gitlab/-/issues/207888
stub_feature_flags(group_wiki: true)
end
describe 'when wiki is available to user' do
it 'shows the wiki tab with the wiki internal link' do
render
expect(rendered).to have_link('Wiki', href: group.wiki.web_url)
end
end
describe 'when wiki is unavailable to user' do
let(:can_read_wiki) { false }
it 'does not show the wiki tab' do
render
expect(rendered).not_to have_link('Wiki', href: group.wiki.web_url)
end
end
end
describe 'iterations link' do
let_it_be(:current_user) { create(:user) }
......
......@@ -44,6 +44,10 @@ module QA
element :group_sidebar_submenu_content
element :group_saml_sso_link
end
view 'app/views/layouts/nav/sidebar/_wiki_link.html.haml' do
element :wiki_link
end
end
end
......@@ -114,6 +118,12 @@ module QA
end
end
end
def click_group_wiki_link
within_sidebar do
click_element(:wiki_link)
end
end
end
end
end
......
......@@ -15,11 +15,14 @@ module QA
view 'app/views/layouts/nav/sidebar/_project.html.haml' do
element :activity_link
element :merge_requests_link
element :wiki_link
element :snippets_link
element :members_link
end
view 'app/views/layouts/nav/sidebar/_wiki_link.html.haml' do
element :wiki_link
end
def click_merge_requests
within_sidebar do
click_element(:merge_requests_link)
......
......@@ -47,6 +47,7 @@ RSpec.describe 'Group navbar' do
before do
stub_feature_flags(group_push_rules: false)
stub_feature_flags(group_iterations: false)
stub_feature_flags(group_wiki: false)
group.add_maintainer(user)
sign_in(user)
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