Commit 25af6bd3 authored by charlie ablett's avatar charlie ablett

Merge branch '223912-add-jira-links-on-the-left-sidebar' into 'master'

Add Jira issues to sidebar navigation

See merge request gitlab-org/gitlab!35414
parents 8384aeab 5640345d
......@@ -166,7 +166,7 @@
color: $sidebar-text;
}
svg {
.nav-icon-container svg {
fill: $sidebar-text;
}
}
......
......@@ -131,6 +131,10 @@ module ServicesHelper
integration.configurable_events.present?
end
def project_jira_issues_integration?
false
end
extend self
end
......
......@@ -80,7 +80,7 @@
= render_if_exists 'projects/sidebar/repository_locked_files'
- 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
.nav-icon-container
= sprite_icon('issues')
......@@ -91,7 +91,7 @@
= number_with_delimiter(@project.open_issues_count(current_user))
%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
%strong.fly-out-top-item-name
= _('Issues')
......@@ -120,19 +120,23 @@
= link_to project_milestones_path(@project), title: _('Milestones'), class: 'qa-milestones-link' do
%span
= _('Milestones')
- if project_nav_tab? :external_issue_tracker
= nav_link do
- issue_tracker = @project.external_issue_tracker
= link_to issue_tracker.issue_tracker_path, class: 'shortcuts-external_tracker' do
.nav-icon-container
= sprite_icon('external-link')
%span.nav-item-name
= 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 do
%strong.fly-out-top-item-name
= issue_tracker.title
- if project_nav_tab?(:external_issue_tracker)
- issue_tracker = @project.external_issue_tracker
- if issue_tracker.is_a?(JiraService) && project_jira_issues_integration?
= render_if_exists 'layouts/nav/sidebar/project_jira_issues_link', issue_tracker: issue_tracker
- else
= nav_link do
= link_to issue_tracker.issue_tracker_path, target: '_blank', rel: 'noopener noreferrer', class: 'shortcuts-external_tracker' do
.nav-icon-container
= sprite_icon('external-link')
%span.nav-item-name
= 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?
= nav_link(controller: [:labels]) do
......
......@@ -154,6 +154,12 @@ module EE
]
end
def sidebar_external_tracker_paths
%w[
projects/integrations/jira/issues#index
]
end
def size_limit_message(project)
show_lfs = project.lfs_enabled? ? 'including files in LFS' : ''
......
......@@ -2,6 +2,13 @@
module EE
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)
"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
......
= 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
......@@ -12877,9 +12877,15 @@ msgstr ""
msgid "JiraService|If different from Web URL"
msgstr ""
msgid "JiraService|Issue List"
msgstr ""
msgid "JiraService|Jira API URL"
msgstr ""
msgid "JiraService|Jira Issues"
msgstr ""
msgid "JiraService|Jira comments will be created when an issue gets referenced in a commit."
msgstr ""
......@@ -12889,6 +12895,9 @@ msgstr ""
msgid "JiraService|Jira issue tracker"
msgstr ""
msgid "JiraService|Open Jira"
msgstr ""
msgid "JiraService|Password or API token"
msgstr ""
......
......@@ -4,18 +4,7 @@ require 'spec_helper'
RSpec.describe 'User activates Jira', :js do
include_context 'project service activation'
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
include_context 'project service Jira context'
describe 'user sets and activates Jira Service' do
context 'when Jira connection test succeeds' do
......@@ -33,9 +22,14 @@ RSpec.describe 'User activates Jira', :js do
expect(current_path).to eq(edit_project_service_path(project, :jira))
end
it 'shows the Jira link in the menu' do
page.within('.nav-sidebar') do
expect(page).to have_link('Jira', href: url)
unless Gitlab.ee?
it 'adds Jira link to sidebar menu' do
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
......
# 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