Commit 04af2a59 authored by Marin Jankovski's avatar Marin Jankovski

Show asterisks if jira service user password is set. Create server url from...

Show asterisks if jira service user password is set. Create server url from project_url to connect to jira instance.
parent ef03be7b
...@@ -265,4 +265,14 @@ module ProjectsHelper ...@@ -265,4 +265,14 @@ module ProjectsHelper
false false
end end
end end
def service_field_value(type, value)
return value unless type == 'password'
if value.present?
"***********"
else
nil
end
end
end end
...@@ -90,12 +90,19 @@ class JiraService < IssueTrackerService ...@@ -90,12 +90,19 @@ class JiraService < IssueTrackerService
end end
def close_issue_url(issue_name) def close_issue_url(issue_name)
"#{self.project_url.chomp("/")}/rest/api/#{self.api_version}/issue/#{issue_name}/transitions" "#{server_url}/rest/api/#{self.api_version}/issue/#{issue_name}/transitions"
end end
def auth def auth
require 'base64' require 'base64'
Base64.urlsafe_encode64("#{self.username}:#{self.password}") Base64.urlsafe_encode64("#{self.username}:#{self.password}")
end end
def server_url
server = URI(project_url)
default_ports = [80, 443].include?(server.port)
server_url = "#{server.scheme}://#{server.host}"
server_url.concat(":#{server.port}") unless default_ports
return server_url
end
end end
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
- @service.fields.each do |field| - @service.fields.each do |field|
- name = field[:name] - name = field[:name]
- value = @service.send(name) unless field[:type] == 'password' - value = service_field_value(field[:type], @service.send(name))
- type = field[:type] - type = field[:type]
- placeholder = field[:placeholder] - placeholder = field[:placeholder]
- choices = field[:choices] - choices = field[:choices]
...@@ -43,12 +43,10 @@ ...@@ -43,12 +43,10 @@
= f.text_area name, rows: 5, class: "form-control", placeholder: placeholder = f.text_area name, rows: 5, class: "form-control", placeholder: placeholder
- elsif type == 'checkbox' - elsif type == 'checkbox'
= f.check_box name = f.check_box name
- elsif type == 'password'
= f.password_field name, class: "form-control"
- elsif type == 'select' - elsif type == 'select'
= f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" } = f.select name, options_for_select(choices, value ? value : default_choice), {}, { class: "form-control" }
- elsif type == 'password' - elsif type == 'password'
= f.password_field name, class: 'form-control' = f.password_field name, value: value, class: 'form-control'
.form-actions .form-actions
= f.submit 'Save', class: 'btn btn-save' = f.submit 'Save', class: 'btn btn-save'
......
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