Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
1
Merge Requests
1
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
nexedi
gitlab-ce
Commits
59857938
Commit
59857938
authored
Apr 07, 2021
by
Francisco Javier López
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Ci/CD menu to new sidebar refactor
This commits move the CI/CD menu from the HAML view to the new refactor.
parent
23675d9d
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
349 additions
and
102 deletions
+349
-102
app/helpers/sidebars_helper.rb
app/helpers/sidebars_helper.rb
+2
-1
app/views/layouts/nav/sidebar/_project_menus.html.haml
app/views/layouts/nav/sidebar/_project_menus.html.haml
+0
-46
ee/app/views/layouts/nav/_test_cases_link.html.haml
ee/app/views/layouts/nav/_test_cases_link.html.haml
+0
-8
ee/lib/ee/sidebars/projects/menus/ci_cd_menu.rb
ee/lib/ee/sidebars/projects/menus/ci_cd_menu.rb
+37
-0
ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb
ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb
+43
-0
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+27
-0
lib/sidebars/projects/menus/ci_cd_menu.rb
lib/sidebars/projects/menus/ci_cd_menu.rb
+114
-0
lib/sidebars/projects/panel.rb
lib/sidebars/projects/panel.rb
+1
-0
qa/qa/page/project/sub_menus/ci_cd.rb
qa/qa/page/project/sub_menus/ci_cd.rb
+1
-5
spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb
spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb
+66
-0
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
+58
-42
No files found.
app/helpers/sidebars_helper.rb
View file @
59857938
...
...
@@ -40,7 +40,8 @@ module SidebarsHelper
container:
project
,
learn_gitlab_experiment_enabled:
learn_gitlab_experiment_enabled?
(
project
),
current_ref:
current_ref
,
jira_issues_integration:
project_jira_issues_integration?
jira_issues_integration:
project_jira_issues_integration?
,
can_view_pipeline_editor:
can_view_pipeline_editor?
(
project
)
}
end
end
app/views/layouts/nav/sidebar/_project_menus.html.haml
View file @
59857938
-
if
project_nav_tab?
:pipelines
=
nav_link
(
controller:
[
:pipelines
,
:builds
,
:jobs
,
:pipeline_schedules
,
:artifacts
,
:test_cases
,
:pipeline_editor
],
unless:
->
{
current_path?
(
'projects/pipelines#charts'
)
})
do
=
link_to
project_pipelines_path
(
@project
),
class:
'shortcuts-pipelines qa-link-pipelines rspec-link-pipelines'
,
data:
{
qa_selector:
'ci_cd_link'
}
do
.nav-icon-container
=
sprite_icon
(
'rocket'
)
%span
.nav-item-name
#js-onboarding-pipelines-link
=
_
(
'CI/CD'
)
%ul
.sidebar-sub-level-items
=
nav_link
(
controller:
[
:pipelines
,
:builds
,
:jobs
,
:pipeline_schedules
,
:artifacts
,
:test_cases
,
:pipeline_editor
],
html_options:
{
class:
"fly-out-top-item"
})
do
=
link_to
project_pipelines_path
(
@project
)
do
%strong
.fly-out-top-item-name
=
_
(
'CI/CD'
)
%li
.divider.fly-out-top-item
-
if
project_nav_tab?
:pipelines
=
nav_link
(
path:
[
'pipelines#index'
,
'pipelines#show'
])
do
=
link_to
project_pipelines_path
(
@project
),
title:
_
(
'Pipelines'
),
class:
'shortcuts-pipelines'
do
%span
=
_
(
'Pipelines'
)
-
if
can_view_pipeline_editor?
(
@project
)
=
nav_link
(
controller: :pipeline_editor
,
action: :show
)
do
=
link_to
project_ci_pipeline_editor_path
(
@project
),
title:
s_
(
'Pipelines|Editor'
)
do
%span
=
s_
(
'Pipelines|Editor'
)
-
if
project_nav_tab?
:builds
=
nav_link
(
controller: :jobs
)
do
=
link_to
project_jobs_path
(
@project
),
title:
_
(
'Jobs'
),
class:
'shortcuts-builds'
do
%span
=
_
(
'Jobs'
)
-
if
Feature
.
enabled?
(
:artifacts_management_page
,
@project
)
=
nav_link
(
controller: :artifacts
,
action: :index
)
do
=
link_to
project_artifacts_path
(
@project
),
title:
_
(
'Artifacts'
),
class:
'shortcuts-builds'
do
%span
=
_
(
'Artifacts'
)
-
if
project_nav_tab?
(
:pipelines
)
=
nav_link
(
controller: :pipeline_schedules
)
do
=
link_to
pipeline_schedules_path
(
@project
),
title:
_
(
'Schedules'
),
class:
'shortcuts-builds'
do
%span
=
_
(
'Schedules'
)
=
render_if_exists
"layouts/nav/test_cases_link"
,
project:
@project
-
if
project_nav_tab?
:security_and_compliance
=
render_if_exists
'layouts/nav/sidebar/project_security_link'
# EE-specific
...
...
ee/app/views/layouts/nav/_test_cases_link.html.haml
deleted
100644 → 0
View file @
23675d9d
-
return
unless
project
.
feature_available?
(
:quality_management
)
-
return
unless
can?
(
current_user
,
:read_issue
,
project
)
-
if
project_nav_tab?
(
:pipelines
)
=
nav_link
(
controller: :test_cases
)
do
=
link_to
project_quality_test_cases_path
(
project
),
title:
_
(
'Test Cases'
),
class:
'shortcuts-test-cases'
do
%span
=
_
(
'Test Cases'
)
ee/lib/ee/sidebars/projects/menus/ci_cd_menu.rb
0 → 100644
View file @
59857938
# frozen_string_literal: true
module
EE
module
Sidebars
module
Projects
module
Menus
module
CiCdMenu
extend
::
Gitlab
::
Utils
::
Override
override
:configure_menu_items
def
configure_menu_items
return
false
unless
super
add_item
(
test_cases_menu_item
)
true
end
private
def
test_cases_menu_item
return
unless
context
.
project
.
licensed_feature_available?
(
:quality_management
)
return
unless
can?
(
context
.
current_user
,
:read_issue
,
context
.
project
)
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Test Cases'
),
link:
project_quality_test_cases_path
(
context
.
project
),
container_html_options:
{
class:
'shortcuts-test-cases'
},
active_routes:
{
controller: :test_cases
},
item_id: :test_cases
)
end
end
end
end
end
end
ee/spec/lib/ee/sidebars/projects/menus/ci_cd_menu_spec.rb
0 → 100644
View file @
59857938
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Sidebars
::
Projects
::
Menus
::
CiCdMenu
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:user
)
{
project
.
owner
}
let
(
:context
)
{
Sidebars
::
Projects
::
Context
.
new
(
current_user:
user
,
container:
project
,
can_view_pipeline_editor:
true
)
}
describe
'Test Cases'
do
subject
{
described_class
.
new
(
context
).
items
.
index
{
|
e
|
e
.
item_id
==
:test_cases
}
}
context
'when licensed feature quality_management is not enabled'
do
before
do
stub_licensed_features
(
quality_management:
false
)
end
it
'does not include test cases menu item'
do
is_expected
.
to
be_nil
end
end
context
'when licensed feature quality_management is enabled'
do
before
do
stub_licensed_features
(
quality_management:
true
)
end
context
'when user can read issues'
do
it
'includes test cases menu item'
do
is_expected
.
to
be_present
end
end
context
'when user cannot read issues'
do
let
(
:user
)
{
nil
}
it
'does not include test cases menu item'
do
is_expected
.
to
be_nil
end
end
end
end
end
ee/spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
View file @
59857938
...
...
@@ -122,6 +122,33 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe
'CI/CD'
do
describe
'Test Cases'
do
let
(
:license_feature_status
)
{
true
}
before
do
stub_licensed_features
(
quality_management:
license_feature_status
)
allow
(
view
).
to
receive
(
:current_user
).
and_return
(
user
)
end
it
'has a link to the test cases page'
do
render
expect
(
rendered
).
to
have_link
(
'Test Cases'
,
href:
project_quality_test_cases_path
(
project
))
end
context
'when license feature :quality_management is not enabled'
do
let
(
:license_feature_status
)
{
false
}
it
'does not have a link to the test cases page'
do
render
expect
(
rendered
).
not_to
have_link
(
'Test Cases'
,
href:
project_quality_test_cases_path
(
project
))
end
end
end
end
describe
'Operations main link'
do
let
(
:user
)
{
create
(
:user
)
}
...
...
lib/sidebars/projects/menus/ci_cd_menu.rb
0 → 100644
View file @
59857938
# frozen_string_literal: true
module
Sidebars
module
Projects
module
Menus
class
CiCdMenu
<
::
Sidebars
::
Menu
override
:configure_menu_items
def
configure_menu_items
return
unless
can?
(
context
.
current_user
,
:read_build
,
context
.
project
)
add_item
(
pipelines_menu_item
)
add_item
(
pipelines_editor_menu_item
)
add_item
(
jobs_menu_item
)
add_item
(
artifacts_menu_item
)
add_item
(
pipeline_schedules_menu_item
)
end
override
:link
def
link
project_pipelines_path
(
context
.
project
)
end
override
:extra_container_html_options
def
extra_container_html_options
{
class:
'shortcuts-pipelines rspec-link-pipelines'
}
end
override
:title
def
title
_
(
'CI/CD'
)
end
override
:title_html_options
def
title_html_options
{
id:
'js-onboarding-pipelines-link'
}
end
override
:sprite_icon
def
sprite_icon
'rocket'
end
private
def
pipelines_menu_item
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Pipelines'
),
link:
project_pipelines_path
(
context
.
project
),
container_html_options:
{
class:
'shortcuts-pipelines'
},
active_routes:
{
path:
pipelines_routes
},
item_id: :pipelines
)
end
def
pipelines_routes
%w[
pipelines#index
pipelines#show
pipelines#new
]
end
def
pipelines_editor_menu_item
return
unless
context
.
can_view_pipeline_editor
::
Sidebars
::
MenuItem
.
new
(
title:
s_
(
'Pipelines|Editor'
),
link:
project_ci_pipeline_editor_path
(
context
.
project
),
active_routes:
{
path:
'projects/ci/pipeline_editor#show'
},
item_id: :pipelines_editor
)
end
def
jobs_menu_item
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Jobs'
),
link:
project_jobs_path
(
context
.
project
),
container_html_options:
{
class:
'shortcuts-builds'
},
active_routes:
{
controller: :jobs
},
item_id: :jobs
)
end
def
artifacts_menu_item
return
unless
Feature
.
enabled?
(
:artifacts_management_page
,
context
.
project
)
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Artifacts'
),
link:
project_artifacts_path
(
context
.
project
),
container_html_options:
{
class:
'shortcuts-builds'
},
active_routes:
{
path:
'artifacts#index'
},
item_id: :artifacts
)
end
def
pipeline_schedules_menu_item
::
Sidebars
::
MenuItem
.
new
(
title:
_
(
'Schedules'
),
link:
pipeline_schedules_path
(
context
.
project
),
container_html_options:
{
class:
'shortcuts-builds'
},
active_routes:
{
controller: :pipeline_schedules
},
item_id: :pipeline_schedules
)
end
end
end
end
end
Sidebars
::
Projects
::
Menus
::
CiCdMenu
.
prepend_if_ee
(
'EE::Sidebars::Projects::Menus::CiCdMenu'
)
lib/sidebars/projects/panel.rb
View file @
59857938
...
...
@@ -14,6 +14,7 @@ module Sidebars
add_menu
(
Sidebars
::
Projects
::
Menus
::
ExternalIssueTrackerMenu
.
new
(
context
))
add_menu
(
Sidebars
::
Projects
::
Menus
::
LabelsMenu
.
new
(
context
))
add_menu
(
Sidebars
::
Projects
::
Menus
::
MergeRequestsMenu
.
new
(
context
))
add_menu
(
Sidebars
::
Projects
::
Menus
::
CiCdMenu
.
new
(
context
))
end
override
:render_raw_menus_partial
...
...
qa/qa/page/project/sub_menus/ci_cd.rb
View file @
59857938
...
...
@@ -12,16 +12,12 @@ module QA
base
.
class_eval
do
include
QA
::
Page
::
Project
::
SubMenus
::
Common
view
'app/views/layouts/nav/sidebar/_project_menus.html.haml'
do
element
:link_pipelines
end
end
end
def
click_ci_cd_pipelines
within_sidebar
do
click_element
:link_pipelines
click_element
(
:sidebar_menu_link
,
menu_item:
'CI/CD'
)
end
end
end
...
...
spec/lib/sidebars/projects/menus/ci_cd_menu_spec.rb
0 → 100644
View file @
59857938
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Sidebars
::
Projects
::
Menus
::
CiCdMenu
do
let
(
:project
)
{
build
(
:project
)
}
let
(
:user
)
{
project
.
owner
}
let
(
:can_view_pipeline_editor
)
{
true
}
let
(
:context
)
{
Sidebars
::
Projects
::
Context
.
new
(
current_user:
user
,
container:
project
,
current_ref:
'master'
,
can_view_pipeline_editor:
can_view_pipeline_editor
)
}
subject
{
described_class
.
new
(
context
)
}
describe
'#render?'
do
context
'when user cannot read builds'
do
let
(
:user
)
{
nil
}
it
'returns false'
do
expect
(
subject
.
render?
).
to
eq
false
end
end
context
'when user can read builds'
do
it
'returns true'
do
expect
(
subject
.
render?
).
to
eq
true
end
end
end
describe
'Pipelines Editor'
do
subject
{
described_class
.
new
(
context
).
items
.
index
{
|
e
|
e
.
item_id
==
:pipelines_editor
}
}
context
'when user cannot view pipeline editor'
do
let
(
:can_view_pipeline_editor
)
{
false
}
it
'does not include pipeline editor menu item'
do
is_expected
.
to
be_nil
end
end
context
'when user can view pipeline editor'
do
it
'includes pipeline editor menu item'
do
is_expected
.
not_to
be_nil
end
end
end
describe
'Artifacts'
do
subject
{
described_class
.
new
(
context
).
items
.
index
{
|
e
|
e
.
item_id
==
:artifacts
}
}
context
'when feature flag :artifacts_management_page is disabled'
do
it
'does not include artifacts menu item'
do
stub_feature_flags
(
artifacts_management_page:
false
)
is_expected
.
to
be_nil
end
end
context
'when feature flag :artifacts_management_page is enabled'
do
it
'includes artifacts menu item'
do
stub_feature_flags
(
artifacts_management_page:
true
)
is_expected
.
not_to
be_nil
end
end
end
end
spec/views/layouts/nav/sidebar/_project.html.haml_spec.rb
View file @
59857938
...
...
@@ -257,6 +257,64 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe
'CI/CD'
do
it
'has a link to pipelines page'
do
render
expect
(
rendered
).
to
have_link
(
'CI/CD'
,
href:
project_pipelines_path
(
project
))
end
describe
'Artifacts'
do
it
'has a link to the artifacts page'
do
render
expect
(
rendered
).
to
have_link
(
'Artifacts'
,
href:
project_artifacts_path
(
project
))
end
end
describe
'Jobs'
do
it
'has a link to the jobs page'
do
render
expect
(
rendered
).
to
have_link
(
'Jobs'
,
href:
project_jobs_path
(
project
))
end
end
describe
'Pipeline Schedules'
do
it
'has a link to the pipeline schedules page'
do
render
expect
(
rendered
).
to
have_link
(
'Schedules'
,
href:
pipeline_schedules_path
(
project
))
end
end
describe
'Pipelines'
do
it
'has a link to the pipelines page'
do
render
expect
(
rendered
).
to
have_link
(
'Pipelines'
,
href:
project_pipelines_path
(
project
))
end
end
describe
'Pipeline Editor'
do
it
'has a link to the pipeline editor'
do
render
expect
(
rendered
).
to
have_link
(
'Editor'
,
href:
project_ci_pipeline_editor_path
(
project
))
end
context
'when user cannot access pipeline editor'
do
it
'does not has a link to the pipeline editor'
do
allow
(
view
).
to
receive
(
:can_view_pipeline_editor?
).
and_return
(
false
)
render
expect
(
rendered
).
not_to
have_link
(
'Editor'
,
href:
project_ci_pipeline_editor_path
(
project
))
end
end
end
end
describe
'packages tab'
do
before
do
stub_container_registry_config
(
enabled:
true
)
...
...
@@ -419,48 +477,6 @@ RSpec.describe 'layouts/nav/sidebar/_project' do
end
end
describe
'ci/cd settings tab'
do
before
do
project
.
update!
(
archived:
project_archived
)
end
context
'when project is archived'
do
let
(
:project_archived
)
{
true
}
it
'does not show the ci/cd settings tab'
do
render
expect
(
rendered
).
not_to
have_link
(
'CI/CD'
,
href:
project_settings_ci_cd_path
(
project
))
end
end
context
'when project is active'
do
let
(
:project_archived
)
{
false
}
it
'shows the ci/cd settings tab'
do
render
expect
(
rendered
).
to
have_link
(
'CI/CD'
,
href:
project_settings_ci_cd_path
(
project
))
end
end
end
describe
'pipeline editor link'
do
it
'shows the pipeline editor link'
do
render
expect
(
rendered
).
to
have_link
(
'Editor'
,
href:
project_ci_pipeline_editor_path
(
project
))
end
it
'does not show the pipeline editor link'
do
allow
(
view
).
to
receive
(
:can_view_pipeline_editor?
).
and_return
(
false
)
render
expect
(
rendered
).
not_to
have_link
(
'Editor'
,
href:
project_ci_pipeline_editor_path
(
project
))
end
end
describe
'operations settings tab'
do
describe
'archive projects'
do
before
do
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment