Commit bb89a15b authored by Arturo Herrero's avatar Arturo Herrero

Merge branch '327444-fj-add-learn-gitlab-menu' into 'master'

Add `Learn Gitlab` Menu to project sidebar refactor

See merge request gitlab-org/gitlab!59109
parents 69c37240 eefdc014
......@@ -35,7 +35,8 @@ module SidebarsHelper
def project_sidebar_context_data(project, user)
{
current_user: user,
container: project
container: project,
learn_gitlab_experiment_enabled: learn_gitlab_experiment_enabled?(project)
}
end
end
# frozen_string_literal: true
module Sidebars
module Projects
module Menus
module LearnGitlab
class Menu < ::Sidebars::Menu
override :link
def link
project_learn_gitlab_path(context.project)
end
override :active_routes
def active_routes
{ controller: :learn_gitlab }
end
override :title
def title
_('Learn GitLab')
end
override :extra_container_html_options
def nav_link_html_options
{ class: 'home' }
end
override :sprite_icon
def sprite_icon
'home'
end
override :render?
def render?
context.learn_gitlab_experiment_enabled
end
end
end
end
end
end
......@@ -8,6 +8,7 @@ module Sidebars
set_scope_menu(Sidebars::Projects::Menus::Scope::Menu.new(context))
add_menu(Sidebars::Projects::Menus::ProjectOverview::Menu.new(context))
add_menu(Sidebars::Projects::Menus::LearnGitlab::Menu.new(context))
end
override :render_raw_menus_partial
......
- if project_nav_tab? :learn_gitlab
= nav_link(controller: :learn_gitlab, html_options: { class: 'home' }) do
= link_to project_learn_gitlab_path(@project) do
.nav-icon-container
= sprite_icon('home')
%span.nav-item-name
= _('Learn GitLab')
- if project_nav_tab? :files
= nav_link(controller: sidebar_repository_paths, unless: -> { current_path?('projects/graphs#charts') }) do
= link_to project_tree_path(@project), class: 'shortcuts-tree', data: { qa_selector: "repository_link" } do
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Projects::Menus::LearnGitlab::Menu do
let(:project) { build(:project) }
let(:experiment_enabled) { true }
let(:context) { Sidebars::Projects::Context.new(current_user: nil, container: project, learn_gitlab_experiment_enabled: experiment_enabled) }
subject { described_class.new(context) }
it 'does not contain any sub menu' do
expect(subject.instance_variable_get(:@items)).to be_empty
end
describe '#render?' do
context 'when learn gitlab experiment is enabled' do
it 'returns true' do
expect(subject.render?).to eq true
end
end
context 'when learn gitlab experiment is disabled' do
let(:experiment_enabled) { false }
it 'returns false' do
expect(subject.render?).to eq false
end
end
end
end
......@@ -50,6 +50,16 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe 'Learn GitLab' do
it 'has a link to the learn GitLab experiment' do
allow(view).to receive(:learn_gitlab_experiment_enabled?).and_return(true)
render
expect(rendered).to have_link('Learn GitLab', href: project_learn_gitlab_path(project))
end
end
describe 'issue boards' do
it 'has board tab' do
render
......
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