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
132a3673
Commit
132a3673
authored
Apr 14, 2022
by
Martin Tan
Committed by
Alex Kalderimis
Apr 14, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Refactor/put zentao menu under issues
parent
9350dbd4
Changes
8
Show whitespace changes
Inline
Side-by-side
Showing
8 changed files
with
119 additions
and
128 deletions
+119
-128
ee/lib/ee/sidebars/projects/menus/issues_menu.rb
ee/lib/ee/sidebars/projects/menus/issues_menu.rb
+44
-1
ee/lib/ee/sidebars/projects/menus/zentao_menu.rb
ee/lib/ee/sidebars/projects/menus/zentao_menu.rb
+0
-41
ee/lib/ee/sidebars/projects/panel.rb
ee/lib/ee/sidebars/projects/panel.rb
+4
-0
ee/spec/lib/ee/sidebars/projects/menus/issues_menu_spec.rb
ee/spec/lib/ee/sidebars/projects/menus/issues_menu_spec.rb
+54
-0
ee/spec/lib/ee/sidebars/projects/menus/zentao_menu_spec.rb
ee/spec/lib/ee/sidebars/projects/menus/zentao_menu_spec.rb
+0
-54
lib/sidebars/projects/menus/zentao_menu.rb
lib/sidebars/projects/menus/zentao_menu.rb
+4
-27
locale/gitlab.pot
locale/gitlab.pot
+3
-3
spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb
...ib/sidebars/projects/menus/zentao_menu_shared_examples.rb
+10
-2
No files found.
ee/lib/ee/sidebars/projects/menus/issues_menu.rb
View file @
132a3673
...
@@ -9,12 +9,15 @@ module EE
...
@@ -9,12 +9,15 @@ module EE
override
:configure_menu_items
override
:configure_menu_items
def
configure_menu_items
def
configure_menu_items
return
false
unless
super
||
show_jira_menu_items?
return
false
unless
super
||
show_jira_menu_items?
\
||
show_zentao_menu_items?
add_item
(
iterations_menu_item
)
add_item
(
iterations_menu_item
)
add_item
(
requirements_menu_item
)
add_item
(
requirements_menu_item
)
add_item
(
jira_issue_list_menu_item
)
add_item
(
jira_issue_list_menu_item
)
add_item
(
jira_external_link_menu_item
)
add_item
(
jira_external_link_menu_item
)
add_item
(
zentao_issue_list_menu_item
)
add_item
(
zentao_external_link_menu_item
)
true
true
end
end
...
@@ -23,6 +26,11 @@ module EE
...
@@ -23,6 +26,11 @@ module EE
external_issue_tracker
.
is_a?
(
Integrations
::
Jira
)
&&
context
.
jira_issues_integration
external_issue_tracker
.
is_a?
(
Integrations
::
Jira
)
&&
context
.
jira_issues_integration
end
end
def
show_zentao_menu_items?
zentao_active?
&&
\
::
Integrations
::
Zentao
.
issues_license_available?
(
context
.
project
)
end
private
private
def
iterations_menu_item
def
iterations_menu_item
...
@@ -88,6 +96,41 @@ module EE
...
@@ -88,6 +96,41 @@ module EE
}
}
)
)
end
end
def
zentao_active?
!!
zentao_integration
&
.
active?
end
def
zentao_issue_list_menu_item
return
::
Sidebars
::
NilMenuItem
.
new
(
item_id: :zentao_issue_list
)
unless
show_zentao_menu_items?
::
Sidebars
::
MenuItem
.
new
(
title:
s_
(
'ZentaoIntegration|ZenTao issues'
),
link:
project_integrations_zentao_issues_path
(
context
.
project
),
active_routes:
{
controller:
'projects/integrations/zentao/issues'
},
item_id: :zentao_issue_list
)
end
def
zentao_integration
@zentao_integration
||=
context
.
project
.
zentao_integration
end
def
zentao_external_link_menu_item
return
::
Sidebars
::
NilMenuItem
.
new
(
item_id: :zentao_external_link
)
unless
show_zentao_menu_items?
::
Sidebars
::
MenuItem
.
new
(
title:
s_
(
'ZentaoIntegration|Open ZenTao'
),
link:
zentao_integration
.
url
,
active_routes:
{},
item_id: :zentao_external_link
,
sprite_icon:
'external-link'
,
container_html_options:
{
target:
'_blank'
,
rel:
'noopener noreferrer'
}
)
end
end
end
end
end
end
end
...
...
ee/lib/ee/sidebars/projects/menus/zentao_menu.rb
deleted
100644 → 0
View file @
9350dbd4
# frozen_string_literal: true
module
EE
module
Sidebars
module
Projects
module
Menus
module
ZentaoMenu
extend
::
Gitlab
::
Utils
::
Override
override
:link
def
link
return
super
unless
feature_available?
project_integrations_zentao_issues_path
(
context
.
project
)
end
override
:add_items
def
add_items
add_item
(
issue_list_menu_item
)
if
feature_available?
super
end
private
def
feature_available?
::
Integrations
::
Zentao
.
issues_license_available?
(
context
.
project
)
end
def
issue_list_menu_item
::
Sidebars
::
MenuItem
.
new
(
title:
s_
(
'ZentaoIntegration|Issue list'
),
link:
project_integrations_zentao_issues_path
(
context
.
project
),
active_routes:
{
controller:
'projects/integrations/zentao/issues'
},
item_id: :issue_list
)
end
end
end
end
end
end
ee/lib/ee/sidebars/projects/panel.rb
View file @
132a3673
...
@@ -16,6 +16,10 @@ module EE
...
@@ -16,6 +16,10 @@ module EE
if
::
Sidebars
::
Projects
::
Menus
::
IssuesMenu
.
new
(
context
).
show_jira_menu_items?
if
::
Sidebars
::
Projects
::
Menus
::
IssuesMenu
.
new
(
context
).
show_jira_menu_items?
remove_menu
(
::
Sidebars
::
Projects
::
Menus
::
ExternalIssueTrackerMenu
)
remove_menu
(
::
Sidebars
::
Projects
::
Menus
::
ExternalIssueTrackerMenu
)
end
end
if
::
Sidebars
::
Projects
::
Menus
::
IssuesMenu
.
new
(
context
).
show_zentao_menu_items?
remove_menu
(
::
Sidebars
::
Projects
::
Menus
::
ZentaoMenu
)
end
end
end
end
end
end
end
...
...
ee/spec/lib/ee/sidebars/projects/menus/issues_menu_spec.rb
View file @
132a3673
...
@@ -138,4 +138,58 @@ RSpec.describe Sidebars::Projects::Menus::IssuesMenu do
...
@@ -138,4 +138,58 @@ RSpec.describe Sidebars::Projects::Menus::IssuesMenu do
end
end
end
end
end
end
describe
'Zentao issues'
do
let
(
:project
)
{
create
(
:project
,
has_external_issue_tracker:
true
)
}
let
(
:context
)
{
Sidebars
::
Projects
::
Context
.
new
(
current_user:
user
,
container:
project
)
}
let
(
:zentao_integration
)
{
create
(
:zentao_integration
,
project:
project
)
}
subject
{
described_class
.
new
(
context
)
}
context
'when Zentao integration is enabled'
do
before
do
stub_licensed_features
(
zentao_issues_integration:
true
)
zentao_integration
.
update!
(
active:
true
)
end
context
'when Issues feature is enabled'
do
before
do
allow
(
project
).
to
receive
(
:issues_enabled?
).
and_return
(
true
)
end
it
'includes Zentao issues menu items'
do
expect
(
subject
.
show_zentao_menu_items?
).
to
eq
(
true
)
expect
(
subject
.
renderable_items
.
any?
{
|
e
|
e
.
item_id
==
:zentao_issue_list
}).
to
eq
(
true
)
end
end
context
'when Issues feature is disabled'
do
before
do
allow
(
project
).
to
receive
(
:issues_enabled?
).
and_return
(
false
)
end
it
'includes Zentao issues menu items'
do
expect
(
subject
.
show_zentao_menu_items?
).
to
eq
(
true
)
expect
(
subject
.
renderable_items
.
any?
{
|
e
|
e
.
item_id
==
:zentao_issue_list
}).
to
eq
(
true
)
end
end
end
context
'when Zentao integration is disabled'
do
before
do
stub_licensed_features
(
zentao_issues_integration:
false
)
end
context
'when Issues feature is disabled'
do
before
do
allow
(
project
).
to
receive
(
:issues_enabled?
).
and_return
(
false
)
end
it
'does not include Zentao issues menu items'
do
expect
(
subject
.
show_zentao_menu_items?
).
to
eq
(
false
)
expect
(
subject
.
renderable_items
.
any?
{
|
e
|
e
.
item_id
==
:zentao_issue_list
}).
to
eq
(
false
)
end
end
end
end
end
end
ee/spec/lib/ee/sidebars/projects/menus/zentao_menu_spec.rb
deleted
100644 → 0
View file @
9350dbd4
# frozen_string_literal: true
require
'spec_helper'
RSpec
.
describe
Sidebars
::
Projects
::
Menus
::
ZentaoMenu
do
let
(
:project
)
{
create
(
:project
,
has_external_issue_tracker:
true
)
}
let
(
:user
)
{
project
.
first_owner
}
let
(
:context
)
{
Sidebars
::
Projects
::
Context
.
new
(
current_user:
user
,
container:
project
)
}
let
(
:zentao_integration
)
{
create
(
:zentao_integration
,
project:
project
)
}
subject
{
described_class
.
new
(
context
)
}
describe
'when feature is not licensed'
do
before
do
stub_licensed_features
(
zentao_issues_integration:
false
)
end
it_behaves_like
'ZenTao menu with CE version'
end
describe
'when feature is licensed'
do
before
do
stub_licensed_features
(
zentao_issues_integration:
true
)
end
context
'when issues integration is disabled'
do
before
do
zentao_integration
.
update!
(
active:
false
)
end
it
'returns false'
do
expect
(
subject
.
render?
).
to
eq
false
end
end
context
'when issues integration is enabled'
do
before
do
zentao_integration
.
update!
(
active:
true
)
end
it
'returns true'
do
expect
(
subject
.
render?
).
to
eq
true
end
it
'renders menu link'
do
expect
(
subject
.
link
).
to
include
(
'/-/integrations/zentao/issues'
)
end
it
'contains issue list and open ZenTao menu items'
do
expect
(
subject
.
renderable_items
.
map
(
&
:item_id
)).
to
match_array
[
:issue_list
,
:open_zentao
]
end
end
end
end
lib/sidebars/projects/menus/zentao_menu.rb
View file @
132a3673
...
@@ -4,11 +4,6 @@ module Sidebars
...
@@ -4,11 +4,6 @@ module Sidebars
module
Projects
module
Projects
module
Menus
module
Menus
class
ZentaoMenu
<
::
Sidebars
::
Menu
class
ZentaoMenu
<
::
Sidebars
::
Menu
override
:configure_menu_items
def
configure_menu_items
render?
.
tap
{
|
render
|
add_items
if
render
}
end
override
:link
override
:link
def
link
def
link
zentao_integration
.
url
zentao_integration
.
url
...
@@ -16,7 +11,7 @@ module Sidebars
...
@@ -16,7 +11,7 @@ module Sidebars
override
:title
override
:title
def
title
def
title
s_
(
'ZentaoIntegration|ZenTao
issues
'
)
s_
(
'ZentaoIntegration|ZenTao'
)
end
end
override
:title_html_options
override
:title_html_options
...
@@ -26,9 +21,9 @@ module Sidebars
...
@@ -26,9 +21,9 @@ module Sidebars
}
}
end
end
override
:
image_path
override
:
sprite_icon
def
image_path
def
sprite_icon
'
logos/zentao.svg
'
'
external-link
'
end
end
# Hardcode sizes so image doesn't flash before CSS loads https://gitlab.com/gitlab-org/gitlab/-/issues/321022
# Hardcode sizes so image doesn't flash before CSS loads https://gitlab.com/gitlab-org/gitlab/-/issues/321022
...
@@ -46,29 +41,11 @@ module Sidebars
...
@@ -46,29 +41,11 @@ module Sidebars
zentao_integration
.
active?
zentao_integration
.
active?
end
end
def
add_items
add_item
(
open_zentao_menu_item
)
end
private
private
def
zentao_integration
def
zentao_integration
@zentao_integration
||=
context
.
project
.
zentao_integration
@zentao_integration
||=
context
.
project
.
zentao_integration
end
end
def
open_zentao_menu_item
::
Sidebars
::
MenuItem
.
new
(
title:
s_
(
'ZentaoIntegration|Open ZenTao'
),
link:
zentao_integration
.
url
,
active_routes:
{},
item_id: :open_zentao
,
sprite_icon:
'external-link'
,
container_html_options:
{
target:
'_blank'
,
rel:
'noopener noreferrer'
}
)
end
end
end
end
end
end
end
...
...
locale/gitlab.pot
View file @
132a3673
...
@@ -43863,15 +43863,15 @@ msgstr ""
...
@@ -43863,15 +43863,15 @@ msgstr ""
msgid "ZentaoIntegration|If different from Web URL."
msgid "ZentaoIntegration|If different from Web URL."
msgstr ""
msgstr ""
msgid "ZentaoIntegration|Issue list"
msgstr ""
msgid "ZentaoIntegration|Open ZenTao"
msgid "ZentaoIntegration|Open ZenTao"
msgstr ""
msgstr ""
msgid "ZentaoIntegration|Use ZenTao as this project's issue tracker."
msgid "ZentaoIntegration|Use ZenTao as this project's issue tracker."
msgstr ""
msgstr ""
msgid "ZentaoIntegration|ZenTao"
msgstr ""
msgid "ZentaoIntegration|ZenTao API URL (optional)"
msgid "ZentaoIntegration|ZenTao API URL (optional)"
msgstr ""
msgstr ""
...
...
spec/support/shared_examples/lib/sidebars/projects/menus/zentao_menu_shared_examples.rb
View file @
132a3673
...
@@ -34,8 +34,16 @@ RSpec.shared_examples 'ZenTao menu with CE version' do
...
@@ -34,8 +34,16 @@ RSpec.shared_examples 'ZenTao menu with CE version' do
expect
(
subject
.
link
).
to
eq
zentao_integration
.
url
expect
(
subject
.
link
).
to
eq
zentao_integration
.
url
end
end
it
'contains only open ZenTao item'
do
it
'renders external-link icon'
do
expect
(
subject
.
renderable_items
.
map
(
&
:item_id
)).
to
match_array
[
:open_zentao
]
expect
(
subject
.
sprite_icon
).
to
eq
'external-link'
end
it
'renders ZenTao menu'
do
expect
(
subject
.
title
).
to
eq
s_
(
'ZentaoIntegration|ZenTao'
)
end
it
'does not contain items'
do
expect
(
subject
.
renderable_items
.
count
).
to
eq
0
end
end
end
end
end
end
...
...
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