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
Jérome Perrin
gitlab-ce
Commits
6d010ebf
Commit
6d010ebf
authored
Jan 12, 2017
by
Robert Speicher
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'refactor-controller-params' into 'master'
Refactor controller params See merge request !8522
parents
e75b1f11
9e0d3906
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
66 additions
and
21 deletions
+66
-21
app/controllers/concerns/service_params.rb
app/controllers/concerns/service_params.rb
+60
-19
app/controllers/groups_controller.rb
app/controllers/groups_controller.rb
+6
-2
No files found.
app/controllers/concerns/service_params.rb
View file @
6d010ebf
module
ServiceParams
module
ServiceParams
extend
ActiveSupport
::
Concern
extend
ActiveSupport
::
Concern
ALLOWED_PARAMS
=
[
:title
,
:token
,
:type
,
:active
,
:api_key
,
:api_url
,
:api_version
,
:subdomain
,
ALLOWED_PARAMS_CE
=
[
:room
,
:recipients
,
:project_url
,
:webhook
,
:active
,
:user_key
,
:device
,
:priority
,
:sound
,
:bamboo_url
,
:username
,
:password
,
:add_pusher
,
:build_key
,
:server
,
:teamcity_url
,
:drone_url
,
:build_type
,
:api_key
,
:description
,
:issues_url
,
:new_issue_url
,
:restrict_to_branch
,
:channel
,
:api_url
,
:colorize_messages
,
:channels
,
:api_version
,
:bamboo_url
,
:build_key
,
:build_type
,
:ca_pem
,
:channel
,
:channels
,
:color
,
:colorize_messages
,
:confidential_issues_events
,
:default_irc_uri
,
:description
,
:device
,
:disable_diffs
,
:drone_url
,
:enable_ssl_verification
,
:external_wiki_url
,
# We're using `issues_events` and `merge_requests_events`
# We're using `issues_events` and `merge_requests_events`
# in the view so we still need to explicitly state them
# in the view so we still need to explicitly state them
# here. `Service#event_names` would only give
# here. `Service#event_names` would only give
# `issue_events` and `merge_request_events` (singular!)
# `issue_events` and `merge_request_events` (singular!)
# See app/helpers/services_helper.rb for how we
# See app/helpers/services_helper.rb for how we
# make those event names plural as special case.
# make those event names plural as special case.
:issues_events
,
:confidential_issues_events
,
:merge_requests_events
,
:issues_events
,
:notify_only_broken_builds
,
:notify_only_broken_pipelines
,
:issues_url
,
:add_pusher
,
:send_from_committer_email
,
:disable_diffs
,
:jira_issue_transition_id
,
:external_wiki_url
,
:notify
,
:color
,
:merge_requests_events
,
:server_host
,
:server_port
,
:default_irc_uri
,
:enable_ssl_verification
,
:namespace
,
:jira_issue_transition_id
,
:url
,
:project_key
,
:ca_pem
,
:namespace
]
:new_issue_url
,
:notify
,
:notify_only_broken_builds
,
:notify_only_broken_pipelines
,
:password
,
:priority
,
:project_key
,
:project_url
,
:recipients
,
:restrict_to_branch
,
:room
,
:send_from_committer_email
,
:server
,
:server_host
,
:server_port
,
:sound
,
:subdomain
,
:teamcity_url
,
:title
,
:token
,
:type
,
:url
,
:user_key
,
:username
,
:webhook
]
# Parameters to ignore if no value is specified
# Parameters to ignore if no value is specified
FILTER_BLANK_PARAMS
=
[
:password
]
FILTER_BLANK_PARAMS
=
[
:password
]
def
service_params
def
service_params
dynamic_params
=
@service
.
event_channel_names
+
@service
.
event_names
dynamic_params
=
@service
.
event_channel_names
+
@service
.
event_names
service_params
=
params
.
permit
(
:id
,
service:
ALLOWED_PARAMS
+
dynamic_params
)
service_params
=
params
.
permit
(
:id
,
service:
ALLOWED_PARAMS
_CE
+
dynamic_params
)
if
service_params
[
:service
].
is_a?
(
Hash
)
if
service_params
[
:service
].
is_a?
(
Hash
)
FILTER_BLANK_PARAMS
.
each
do
|
param
|
FILTER_BLANK_PARAMS
.
each
do
|
param
|
...
...
app/controllers/groups_controller.rb
View file @
6d010ebf
...
@@ -125,7 +125,11 @@ class GroupsController < Groups::ApplicationController
...
@@ -125,7 +125,11 @@ class GroupsController < Groups::ApplicationController
end
end
def
group_params
def
group_params
params
.
require
(
:group
).
permit
(
params
.
require
(
:group
).
permit
(
group_params_ce
)
end
def
group_params_ce
[
:avatar
,
:avatar
,
:description
,
:description
,
:lfs_enabled
,
:lfs_enabled
,
...
@@ -135,7 +139,7 @@ class GroupsController < Groups::ApplicationController
...
@@ -135,7 +139,7 @@ class GroupsController < Groups::ApplicationController
:request_access_enabled
,
:request_access_enabled
,
:share_with_group_lock
,
:share_with_group_lock
,
:visibility_level
:visibility_level
)
]
end
end
def
load_events
def
load_events
...
...
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