Commit 5640345d authored by Justin Ho Tuan Duong's avatar Justin Ho Tuan Duong Committed by charlie ablett

Add Jira issues to sidebar navigation

- Add links for "Jira Issues" and "Open Jira"
- Make existing link to external issue tracker open in a new
tab
- Update translations
parent d925aae1
...@@ -166,7 +166,7 @@ ...@@ -166,7 +166,7 @@
color: $sidebar-text; color: $sidebar-text;
} }
svg { .nav-icon-container svg {
fill: $sidebar-text; fill: $sidebar-text;
} }
} }
......
...@@ -131,6 +131,10 @@ module ServicesHelper ...@@ -131,6 +131,10 @@ module ServicesHelper
integration.configurable_events.present? integration.configurable_events.present?
end end
def project_jira_issues_integration?
false
end
extend self extend self
end end
......
...@@ -80,7 +80,7 @@ ...@@ -80,7 +80,7 @@
= render_if_exists 'projects/sidebar/repository_locked_files' = render_if_exists 'projects/sidebar/repository_locked_files'
- if project_nav_tab? :issues - if project_nav_tab? :issues
= nav_link(controller: @project.issues_enabled? ? [:issues, :labels, :milestones, :boards] : :issues) do = nav_link(controller: @project.issues_enabled? ? ['projects/issues', :labels, :milestones, :boards] : 'projects/issues') do
= link_to project_issues_path(@project), class: 'shortcuts-issues qa-issues-item' do = link_to project_issues_path(@project), class: 'shortcuts-issues qa-issues-item' do
.nav-icon-container .nav-icon-container
= sprite_icon('issues') = sprite_icon('issues')
...@@ -91,7 +91,7 @@ ...@@ -91,7 +91,7 @@
= number_with_delimiter(@project.open_issues_count(current_user)) = number_with_delimiter(@project.open_issues_count(current_user))
%ul.sidebar-sub-level-items %ul.sidebar-sub-level-items
= nav_link(controller: :issues, action: :index, html_options: { class: "fly-out-top-item" } ) do = nav_link(controller: 'projects/issues', action: :index, html_options: { class: "fly-out-top-item" } ) do
= link_to project_issues_path(@project) do = link_to project_issues_path(@project) do
%strong.fly-out-top-item-name %strong.fly-out-top-item-name
= _('Issues') = _('Issues')
...@@ -120,19 +120,23 @@ ...@@ -120,19 +120,23 @@
= link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do = link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do
%span %span
= _('Milestones') = _('Milestones')
- if project_nav_tab? :external_issue_tracker
= nav_link do - if project_nav_tab?(:external_issue_tracker)
- issue_tracker = @project.external_issue_tracker - issue_tracker = @project.external_issue_tracker
= link_to issue_tracker.issue_tracker_path, class: 'shortcuts-external_tracker' do - if issue_tracker.is_a?(JiraService) && project_jira_issues_integration?
.nav-icon-container = render_if_exists 'layouts/nav/sidebar/project_jira_issues_link', issue_tracker: issue_tracker
= sprite_icon('external-link') - else
%span.nav-item-name = nav_link do
= issue_tracker.title = link_to issue_tracker.issue_tracker_path, target: '_blank', rel: 'noopener noreferrer', class: 'shortcuts-external_tracker' do
%ul.sidebar-sub-level-items.is-fly-out-only .nav-icon-container
= nav_link(html_options: { class: "fly-out-top-item" } ) do = sprite_icon('external-link')
= link_to issue_tracker.issue_tracker_path do %span.nav-item-name
%strong.fly-out-top-item-name = issue_tracker.title
= issue_tracker.title %ul.sidebar-sub-level-items.is-fly-out-only
= nav_link(html_options: { class: "fly-out-top-item" } ) do
= link_to issue_tracker.issue_tracker_path, target: '_blank', rel: 'noopener noreferrer' do
%strong.fly-out-top-item-name
= issue_tracker.title
- if (project_nav_tab? :labels) && !@project.issues_enabled? - if (project_nav_tab? :labels) && !@project.issues_enabled?
= nav_link(controller: [:labels]) do = nav_link(controller: [:labels]) do
......
...@@ -154,6 +154,12 @@ module EE ...@@ -154,6 +154,12 @@ module EE
] ]
end end
def sidebar_external_tracker_paths
%w[
projects/integrations/jira/issues#index
]
end
def size_limit_message(project) def size_limit_message(project)
show_lfs = project.lfs_enabled? ? 'including files in LFS' : '' show_lfs = project.lfs_enabled? ? 'including files in LFS' : ''
......
...@@ -2,6 +2,13 @@ ...@@ -2,6 +2,13 @@
module EE module EE
module ServicesHelper module ServicesHelper
extend ::Gitlab::Utils::Override
override :project_jira_issues_integration?
def project_jira_issues_integration?
::Feature.enabled?(:jira_integration, @project) && @project.jira_service.issues_enabled
end
def add_to_slack_link(project, slack_app_id) def add_to_slack_link(project, slack_app_id)
"https://slack.com/oauth/authorize?scope=commands&client_id=#{slack_app_id}&redirect_uri=#{slack_auth_project_settings_slack_url(project)}&state=#{escaped_form_authenticity_token}" "https://slack.com/oauth/authorize?scope=commands&client_id=#{slack_app_id}&redirect_uri=#{slack_auth_project_settings_slack_url(project)}&state=#{escaped_form_authenticity_token}"
end end
......
= nav_link(path: sidebar_external_tracker_paths) do
= link_to project_integrations_jira_issues_path(@project), class: 'shortcuts-tree' do
.nav-icon-container
= sprite_icon('issues')
%span.nav-item-name.qa-settings-item#js-onboarding-settings-link
= s_('JiraService|Jira Issues')
%ul.sidebar-sub-level-items
= nav_link(path: sidebar_external_tracker_paths, html_options: { class: 'fly-out-top-item' } ) do
= link_to project_integrations_jira_issues_path(@project) do
%strong.fly-out-top-item-name
= s_('JiraService|Jira Issues')
%li.divider.fly-out-top-item
= nav_link(path: sidebar_external_tracker_paths[0]) do
= link_to project_integrations_jira_issues_path(@project), title: s_('JiraService|Issue List') do
%span
= s_('JiraService|Issue List')
= nav_link do
= link_to issue_tracker.issue_tracker_path, target: '_blank', rel: 'noopener noreferrer' do
%span
= s_('JiraService|Open Jira')
= sprite_icon('external-link', css_class: 'gl-vertical-align-text-bottom')
# frozen_string_literal: true
require 'spec_helper'
RSpec.describe 'User activates Jira', :js do
include_context 'project service activation'
include_context 'project service Jira context'
describe 'user sets and activates Jira Service' do
context 'when Jira connection test succeeds' do
before do
allow_any_instance_of(JiraService).to receive(:issues_enabled) { true }
server_info = { key: 'value' }.to_json
stub_request(:get, test_url).with(basic_auth: %w(username password)).to_return(body: server_info)
visit_project_integration('Jira')
fill_form
click_test_integration
end
it 'adds Jira links to sidebar menu' do
page.within('.nav-sidebar') do
expect(page).to have_link('Jira Issues', href: project_integrations_jira_issues_path(project))
expect(page).to have_link('Issue List', href: project_integrations_jira_issues_path(project), visible: false)
expect(page).to have_link('Open Jira', href: url, visible: false)
expect(page).not_to have_link('Jira', href: url)
end
end
end
end
end
...@@ -12874,9 +12874,15 @@ msgstr "" ...@@ -12874,9 +12874,15 @@ msgstr ""
msgid "JiraService|If different from Web URL" msgid "JiraService|If different from Web URL"
msgstr "" msgstr ""
msgid "JiraService|Issue List"
msgstr ""
msgid "JiraService|Jira API URL" msgid "JiraService|Jira API URL"
msgstr "" msgstr ""
msgid "JiraService|Jira Issues"
msgstr ""
msgid "JiraService|Jira comments will be created when an issue gets referenced in a commit." msgid "JiraService|Jira comments will be created when an issue gets referenced in a commit."
msgstr "" msgstr ""
...@@ -12886,6 +12892,9 @@ msgstr "" ...@@ -12886,6 +12892,9 @@ msgstr ""
msgid "JiraService|Jira issue tracker" msgid "JiraService|Jira issue tracker"
msgstr "" msgstr ""
msgid "JiraService|Open Jira"
msgstr ""
msgid "JiraService|Password or API token" msgid "JiraService|Password or API token"
msgstr "" msgstr ""
......
...@@ -4,18 +4,7 @@ require 'spec_helper' ...@@ -4,18 +4,7 @@ require 'spec_helper'
RSpec.describe 'User activates Jira', :js do RSpec.describe 'User activates Jira', :js do
include_context 'project service activation' include_context 'project service activation'
include_context 'project service Jira context'
let(:url) { 'http://jira.example.com' }
let(:test_url) { 'http://jira.example.com/rest/api/2/serverInfo' }
def fill_form(disable: false)
click_active_toggle if disable
fill_in 'service_url', with: url
fill_in 'service_username', with: 'username'
fill_in 'service_password', with: 'password'
fill_in 'service_jira_issue_transition_id', with: '25'
end
describe 'user sets and activates Jira Service' do describe 'user sets and activates Jira Service' do
context 'when Jira connection test succeeds' do context 'when Jira connection test succeeds' do
...@@ -33,9 +22,14 @@ RSpec.describe 'User activates Jira', :js do ...@@ -33,9 +22,14 @@ RSpec.describe 'User activates Jira', :js do
expect(current_path).to eq(edit_project_service_path(project, :jira)) expect(current_path).to eq(edit_project_service_path(project, :jira))
end end
it 'shows the Jira link in the menu' do unless Gitlab.ee?
page.within('.nav-sidebar') do it 'adds Jira link to sidebar menu' do
expect(page).to have_link('Jira', href: url) page.within('.nav-sidebar') do
expect(page).not_to have_link('Jira Issues')
expect(page).not_to have_link('Issue List', visible: false)
expect(page).not_to have_link('Open Jira', href: url, visible: false)
expect(page).to have_link('Jira', href: url)
end
end end
end end
end end
......
# frozen_string_literal: true
RSpec.shared_context 'project service Jira context' do
let(:url) { 'http://jira.example.com' }
let(:test_url) { 'http://jira.example.com/rest/api/2/serverInfo' }
def fill_form(disable: false)
click_active_toggle if disable
fill_in 'service_url', with: url
fill_in 'service_username', with: 'username'
fill_in 'service_password', with: 'password'
fill_in 'service_jira_issue_transition_id', with: '25'
end
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