debian-mirror-gitlab/app/models/integrations/zentao.rb

97 lines
2.6 KiB
Ruby
Raw Normal View History

2021-11-11 11:23:49 +05:30
# frozen_string_literal: true
module Integrations
class Zentao < Integration
2021-12-11 22:18:48 +05:30
include Gitlab::Routing
2021-11-11 11:23:49 +05:30
data_field :url, :api_url, :api_token, :zentao_product_xid
validates :url, public_url: true, presence: true, if: :activated?
validates :api_url, public_url: true, allow_blank: true
validates :api_token, presence: true, if: :activated?
validates :zentao_product_xid, presence: true, if: :activated?
2021-12-11 22:18:48 +05:30
# License Level: EEP_FEATURES
def self.issues_license_available?(project)
project&.licensed_feature_available?(:zentao_issues_integration)
end
2021-11-11 11:23:49 +05:30
def data_fields
zentao_tracker_data || self.build_zentao_tracker_data
end
def title
2021-12-11 22:18:48 +05:30
'ZenTao'
2021-11-11 11:23:49 +05:30
end
def description
2021-12-11 22:18:48 +05:30
s_("ZentaoIntegration|Use ZenTao as this project's issue tracker.")
end
def help
s_("ZentaoIntegration|Before you enable this integration, you must configure ZenTao. For more details, read the %{link_start}ZenTao integration documentation%{link_end}.") % {
link_start: '<a href="%{url}" target="_blank" rel="noopener noreferrer">'
.html_safe % { url: help_page_url('user/project/integrations/zentao') },
link_end: '</a>'.html_safe
}
2021-11-11 11:23:49 +05:30
end
def self.to_param
name.demodulize.downcase
end
def test(*_args)
client.ping
end
def self.supported_events
%w()
end
def self.supported_event_actions
%w()
end
def fields
[
{
type: 'text',
name: 'url',
2021-12-11 22:18:48 +05:30
title: s_('ZentaoIntegration|ZenTao Web URL'),
2021-11-11 11:23:49 +05:30
placeholder: 'https://www.zentao.net',
2021-12-11 22:18:48 +05:30
help: s_('ZentaoIntegration|Base URL of the ZenTao instance.'),
2021-11-11 11:23:49 +05:30
required: true
},
{
type: 'text',
name: 'api_url',
2021-12-11 22:18:48 +05:30
title: s_('ZentaoIntegration|ZenTao API URL (optional)'),
2021-11-11 11:23:49 +05:30
help: s_('ZentaoIntegration|If different from Web URL.')
},
{
type: 'password',
name: 'api_token',
2021-12-11 22:18:48 +05:30
title: s_('ZentaoIntegration|ZenTao API token'),
non_empty_password_title: s_('ZentaoIntegration|Enter new ZenTao API token'),
non_empty_password_help: s_('ProjectService|Leave blank to use your current token.'),
2021-11-11 11:23:49 +05:30
required: true
},
{
type: 'text',
name: 'zentao_product_xid',
2021-12-11 22:18:48 +05:30
title: s_('ZentaoIntegration|ZenTao Product ID'),
2021-11-11 11:23:49 +05:30
required: true
}
]
end
private
def client
@client ||= ::Gitlab::Zentao::Client.new(self)
end
end
end
2021-12-11 22:18:48 +05:30
::Integrations::Zentao.prepend_mod