Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
G
gitlab-ce
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Boxiang Sun
gitlab-ce
Commits
9f33898f
Commit
9f33898f
authored
Feb 12, 2015
by
Marin Jankovski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
All services can have templates.
parent
f7e90245
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
26 additions
and
14 deletions
+26
-14
app/controllers/admin/services_controller.rb
app/controllers/admin/services_controller.rb
+7
-7
app/models/project.rb
app/models/project.rb
+1
-6
app/models/service.rb
app/models/service.rb
+5
-0
app/views/admin/services/_form.html.haml
app/views/admin/services/_form.html.haml
+13
-1
No files found.
app/controllers/admin/services_controller.rb
View file @
9f33898f
...
@@ -26,18 +26,14 @@ class Admin::ServicesController < Admin::ApplicationController
...
@@ -26,18 +26,14 @@ class Admin::ServicesController < Admin::ApplicationController
def
services_templates
def
services_templates
templates
=
[]
templates
=
[]
allowed_templat
es
.
each
do
|
service
|
Service
.
available_services_nam
es
.
each
do
|
service
|
service_template
=
service
.
constantize
service_template
=
service
.
con
cat
(
"_service"
).
camelize
.
con
stantize
templates
<<
service_template
.
where
(
template:
true
).
first_or_create
templates
<<
service_template
.
where
(
template:
true
).
first_or_create
end
end
templates
templates
end
end
def
allowed_templates
%w( JiraService RedmineService CustomIssueTrackerService )
end
def
service
def
service
@service
||=
Service
.
where
(
id:
params
[
:id
],
template:
true
).
first
@service
||=
Service
.
where
(
id:
params
[
:id
],
template:
true
).
first
end
end
...
@@ -45,7 +41,11 @@ class Admin::ServicesController < Admin::ApplicationController
...
@@ -45,7 +41,11 @@ class Admin::ServicesController < Admin::ApplicationController
def
application_services_params
def
application_services_params
params
.
permit
(
:id
,
params
.
permit
(
:id
,
service:
[
service:
[
:title
,
:project_url
,
:description
,
:issues_url
,
:new_issue_url
:title
,
:token
,
:type
,
:active
,
:api_key
,
:subdomain
,
:room
,
:recipients
,
:project_url
,
:webhook
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:build_key
,
:server
,
:teamcity_url
,
:build_type
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
])
])
end
end
end
end
app/models/project.rb
View file @
9f33898f
...
@@ -355,7 +355,7 @@ class Project < ActiveRecord::Base
...
@@ -355,7 +355,7 @@ class Project < ActiveRecord::Base
def
build_missing_services
def
build_missing_services
services_templates
=
Service
.
where
(
template:
true
)
services_templates
=
Service
.
where
(
template:
true
)
available_services_names
.
each
do
|
service_name
|
Service
.
available_services_names
.
each
do
|
service_name
|
service
=
find_service
(
services
,
service_name
)
service
=
find_service
(
services
,
service_name
)
# If service is available but missing in db
# If service is available but missing in db
...
@@ -377,11 +377,6 @@ class Project < ActiveRecord::Base
...
@@ -377,11 +377,6 @@ class Project < ActiveRecord::Base
list
.
find
{
|
service
|
service
.
to_param
==
name
}
list
.
find
{
|
service
|
service
.
to_param
==
name
}
end
end
def
available_services_names
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla asana
emails_on_push gemnasium slack pushover buildbox bamboo teamcity jira redmine custom_issue_tracker)
end
def
gitlab_ci?
def
gitlab_ci?
gitlab_ci_service
&&
gitlab_ci_service
.
active
gitlab_ci_service
&&
gitlab_ci_service
.
active
end
end
...
...
app/models/service.rb
View file @
9f33898f
...
@@ -98,6 +98,11 @@ class Service < ActiveRecord::Base
...
@@ -98,6 +98,11 @@ class Service < ActiveRecord::Base
self
.
category
==
:issue_tracker
self
.
category
==
:issue_tracker
end
end
def
self
.
available_services_names
%w(gitlab_ci campfire hipchat pivotaltracker flowdock assembla asana
emails_on_push gemnasium slack pushover buildbox bamboo teamcity jira redmine custom_issue_tracker)
end
def
self
.
create_from_template
(
project_id
,
template
)
def
self
.
create_from_template
(
project_id
,
template
)
service
=
template
.
dup
service
=
template
.
dup
service
.
template
=
false
service
.
template
=
false
...
...
app/views/admin/services/_form.html.haml
View file @
9f33898f
...
@@ -12,13 +12,25 @@
...
@@ -12,13 +12,25 @@
-
@service
.
fields
.
each
do
|
field
|
-
@service
.
fields
.
each
do
|
field
|
-
name
=
field
[
:name
]
-
name
=
field
[
:name
]
-
value
=
@service
.
send
(
name
)
unless
field
[
:type
]
==
'password'
-
type
=
field
[
:type
]
-
type
=
field
[
:type
]
-
placeholder
=
field
[
:placeholder
]
-
placeholder
=
field
[
:placeholder
]
-
choices
=
field
[
:choices
]
-
default_choice
=
field
[
:default_choice
]
.form-group
.form-group
=
f
.
label
name
,
class:
"control-label"
=
f
.
label
name
,
class:
"control-label"
.col-sm-10
.col-sm-10
=
f
.
text_field
name
,
class:
"form-control"
,
placeholder:
placeholder
-
if
type
==
'text'
=
f
.
text_field
name
,
class:
"form-control"
,
placeholder:
placeholder
-
elsif
type
==
'textarea'
=
f
.
text_area
name
,
rows:
5
,
class:
"form-control"
,
placeholder:
placeholder
-
elsif
type
==
'checkbox'
=
f
.
check_box
name
-
elsif
type
==
'select'
=
f
.
select
name
,
options_for_select
(
choices
,
value
?
value
:
default_choice
),
{},
{
class:
"form-control"
}
-
elsif
type
==
'password'
=
f
.
password_field
name
,
class:
'form-control'
.form-actions
.form-actions
=
f
.
submit
'Save'
,
class:
'btn btn-save'
=
f
.
submit
'Save'
,
class:
'btn btn-save'
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment