Commit ab59b333 authored by Enrique Alcántara's avatar Enrique Alcántara

Merge branch 'dc-remove-hierarchy-nav' into 'master'

Removed planning hierarchy from left nav

See merge request gitlab-org/gitlab!80935
parents 00415f09 19c42a20
# frozen_string_literal: true
# This module has the necessary methods to render
# work items hierarchy menu
module Sidebars
module Concerns
module WorkItemHierarchy
def hierarchy_menu_item(container, url, path)
unless show_hierarachy_menu_item?(container)
return ::Sidebars::NilMenuItem.new(item_id: :hierarchy)
end
::Sidebars::MenuItem.new(
title: _('Planning hierarchy'),
link: url,
active_routes: { path: path },
item_id: :hierarchy
)
end
def show_hierarachy_menu_item?(container)
can?(context.current_user, :read_planning_hierarchy, container)
end
end
end
end
...@@ -4,13 +4,10 @@ module Sidebars ...@@ -4,13 +4,10 @@ module Sidebars
module Projects module Projects
module Menus module Menus
class ProjectInformationMenu < ::Sidebars::Menu class ProjectInformationMenu < ::Sidebars::Menu
include ::Sidebars::Concerns::WorkItemHierarchy
override :configure_menu_items override :configure_menu_items
def configure_menu_items def configure_menu_items
add_item(activity_menu_item) add_item(activity_menu_item)
add_item(labels_menu_item) add_item(labels_menu_item)
add_item(hierarchy_menu_item(context.project, project_planning_hierarchy_path(context.project), 'projects#planning_hierarchy'))
add_item(members_menu_item) add_item(members_menu_item)
true true
......
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe Sidebars::Concerns::WorkItemHierarchy do
shared_examples 'hierarchy menu' do
let(:item_id) { :hierarchy }
specify { is_expected.not_to be_nil }
end
describe 'Project hierarchy menu item' do
let_it_be_with_reload(:project) { create(:project, :repository) }
let(:user) { project.owner }
let(:context) { Sidebars::Projects::Context.new(current_user: user, container: project) }
subject { Sidebars::Projects::Menus::ProjectInformationMenu.new(context).renderable_items.index { |e| e.item_id == item_id } }
it_behaves_like 'hierarchy menu'
end
end
...@@ -59,11 +59,5 @@ RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do ...@@ -59,11 +59,5 @@ RSpec.describe Sidebars::Projects::Menus::ProjectInformationMenu do
specify { is_expected.to be_nil } specify { is_expected.to be_nil }
end end
end end
describe 'Hierarchy' do
let(:item_id) { :hierarchy }
specify { is_expected.not_to be_nil }
end
end end
end end
...@@ -22,7 +22,6 @@ RSpec.shared_context 'project navbar structure' do ...@@ -22,7 +22,6 @@ RSpec.shared_context 'project navbar structure' do
nav_sub_items: [ nav_sub_items: [
_('Activity'), _('Activity'),
_('Labels'), _('Labels'),
_('Planning hierarchy'),
_('Members') _('Members')
] ]
}, },
......
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