Add gitlab internal issue tracker service.
This commit is contained in:
parent
8eb365c0a0
commit
537cd66d7e
5 changed files with 37 additions and 11 deletions
|
@ -181,7 +181,7 @@ class ApplicationController < ActionController::Base
|
|||
end
|
||||
|
||||
def add_gon_variables
|
||||
gon.default_issues_tracker = Project.issues_tracker.default_value
|
||||
gon.default_issues_tracker = Project.new.default_issue_tracker.to_param
|
||||
gon.api_version = API::API.version
|
||||
gon.relative_url_root = Gitlab.config.gitlab.relative_url_root
|
||||
gon.default_avatar_url = URI::join(Gitlab.config.gitlab.url, ActionController::Base.helpers.image_path('no_avatar.png')).to_s
|
||||
|
|
|
@ -9,7 +9,7 @@ class Projects::ServicesController < Projects::ApplicationController
|
|||
|
||||
def index
|
||||
@project.build_missing_services
|
||||
@services = @project.services.reload
|
||||
@services = @project.services.where.not(type: 'GitlabIssueTrackerService').reload
|
||||
end
|
||||
|
||||
def edit
|
||||
|
@ -17,9 +17,6 @@ class Projects::ServicesController < Projects::ApplicationController
|
|||
|
||||
def update
|
||||
if @service.update_attributes(service_params)
|
||||
if @service.activated? && @service.issue_tracker?
|
||||
@project.update_attributes(issues_tracker: @service.to_param)
|
||||
end
|
||||
redirect_to edit_project_service_path(@project, @service.to_param),
|
||||
notice: 'Successfully updated.'
|
||||
else
|
||||
|
|
|
@ -77,6 +77,7 @@ class Project < ActiveRecord::Base
|
|||
has_one :jira_service, dependent: :destroy
|
||||
has_one :redmine_service, dependent: :destroy
|
||||
has_one :custom_issue_tracker_service, dependent: :destroy
|
||||
has_one :gitlab_issue_tracker_service, dependent: :destroy
|
||||
|
||||
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
|
||||
|
||||
|
@ -149,8 +150,6 @@ class Project < ActiveRecord::Base
|
|||
scope :public_and_internal_only, -> { where(visibility_level: Project.public_and_internal_levels) }
|
||||
scope :non_archived, -> { where(archived: false) }
|
||||
|
||||
enumerize :issues_tracker, in: (Service.issue_tracker_service_list).append(:gitlab), default: :gitlab
|
||||
|
||||
state_machine :import_status, initial: :none do
|
||||
event :import_start do
|
||||
transition [:none, :finished] => :started
|
||||
|
@ -317,19 +316,32 @@ class Project < ActiveRecord::Base
|
|||
end
|
||||
end
|
||||
|
||||
def default_issue_tracker
|
||||
unless gitlab_issue_tracker_service
|
||||
create_gitlab_issue_tracker_service
|
||||
end
|
||||
|
||||
gitlab_issue_tracker_service
|
||||
end
|
||||
|
||||
def issues_tracker
|
||||
if external_issue_tracker
|
||||
external_issue_tracker
|
||||
else
|
||||
default_issue_tracker
|
||||
end
|
||||
end
|
||||
|
||||
def default_issues_tracker?
|
||||
if external_issue_tracker
|
||||
false
|
||||
else
|
||||
unless self.issues_tracker == Project.issues_tracker.default_value
|
||||
self.update_attributes(issues_tracker: Project.issues_tracker.default_value)
|
||||
end
|
||||
true
|
||||
end
|
||||
end
|
||||
|
||||
def external_issues_trackers
|
||||
services.select { |service| service.issue_tracker? }
|
||||
services.select(&:issue_tracker?).reject(&:default?)
|
||||
end
|
||||
|
||||
def external_issue_tracker
|
||||
|
|
13
app/models/project_services/gitlab_issue_tracker_service.rb
Normal file
13
app/models/project_services/gitlab_issue_tracker_service.rb
Normal file
|
@ -0,0 +1,13 @@
|
|||
class GitlabIssueTrackerService < IssueTrackerService
|
||||
|
||||
prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url
|
||||
|
||||
|
||||
def default?
|
||||
true
|
||||
end
|
||||
|
||||
def to_param
|
||||
'gitlab'
|
||||
end
|
||||
end
|
|
@ -6,6 +6,10 @@ class IssueTrackerService < Service
|
|||
:issue_tracker
|
||||
end
|
||||
|
||||
def default?
|
||||
false
|
||||
end
|
||||
|
||||
def project_url
|
||||
# implement inside child
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue