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
iv
gitlab-ce
Commits
55dca86b
Commit
55dca86b
authored
Aug 12, 2015
by
Artem Sidorenko
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Import sources: settings in the admin interface
parent
55fc58bd
Changes
9
Hide whitespace changes
Inline
Side-by-side
Showing
9 changed files
with
100 additions
and
3 deletions
+100
-3
app/controllers/admin/application_settings_controller.rb
app/controllers/admin/application_settings_controller.rb
+10
-0
app/helpers/application_settings_helper.rb
app/helpers/application_settings_helper.rb
+17
-0
app/models/application_setting.rb
app/models/application_setting.rb
+14
-1
app/views/admin/application_settings/_form.html.haml
app/views/admin/application_settings/_form.html.haml
+14
-0
config/initializers/1_settings.rb
config/initializers/1_settings.rb
+1
-0
db/migrate/20150812080800_add_settings_import_sources.rb
db/migrate/20150812080800_add_settings_import_sources.rb
+11
-0
db/schema.rb
db/schema.rb
+2
-1
lib/gitlab/current_settings.rb
lib/gitlab/current_settings.rb
+2
-1
lib/gitlab/import_sources.rb
lib/gitlab/import_sources.rb
+29
-0
No files found.
app/controllers/admin/application_settings_controller.rb
View file @
55dca86b
...
...
@@ -29,6 +29,15 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
end
end
import_sources
=
params
[
:application_setting
][
:import_sources
]
if
import_sources
.
nil?
params
[
:application_setting
][
:import_sources
]
=
[]
else
import_sources
.
map!
do
|
source
|
source
.
to_str
end
end
params
.
require
(
:application_setting
).
permit
(
:default_projects_limit
,
:default_branch_protection
,
...
...
@@ -47,6 +56,7 @@ class Admin::ApplicationSettingsController < Admin::ApplicationController
:version_check_enabled
,
:user_oauth_applications
,
restricted_visibility_levels:
[],
import_sources:
[]
)
end
end
app/helpers/application_settings_helper.rb
View file @
55dca86b
...
...
@@ -39,4 +39,21 @@ module ApplicationSettingsHelper
end
end
end
# Return a group of checkboxes that use Bootstrap's button plugin for a
# toggle button effect.
def
import_sources_checkboxes
(
help_block_id
)
Gitlab
::
ImportSources
.
options
.
map
do
|
name
,
source
|
checked
=
current_application_settings
.
import_sources
.
include?
(
source
)
css_class
=
'btn'
css_class
+=
' active'
if
checked
checkbox_name
=
'application_setting[import_sources][]'
label_tag
(
checkbox_name
,
class:
css_class
)
do
check_box_tag
(
checkbox_name
,
source
,
checked
,
autocomplete:
'off'
,
'aria-describedby'
=>
help_block_id
)
+
name
end
end
end
end
app/models/application_setting.rb
View file @
55dca86b
...
...
@@ -22,10 +22,12 @@
# user_oauth_applications :boolean default(TRUE)
# after_sign_out_path :string(255)
# session_expire_delay :integer default(10080), not null
# import_sources :text
#
class
ApplicationSetting
<
ActiveRecord
::
Base
serialize
:restricted_visibility_levels
serialize
:import_sources
serialize
:restricted_signup_domains
,
Array
attr_accessor
:restricted_signup_domains_raw
...
...
@@ -52,6 +54,16 @@ class ApplicationSetting < ActiveRecord::Base
end
end
validates_each
:import_sources
do
|
record
,
attr
,
value
|
unless
value
.
nil?
value
.
each
do
|
source
|
unless
Gitlab
::
ImportSources
.
options
.
has_value?
(
source
)
record
.
errors
.
add
(
attr
,
"'
#{
source
}
' is not a import source"
)
end
end
end
end
def
self
.
current
ApplicationSetting
.
last
end
...
...
@@ -70,7 +82,8 @@ class ApplicationSetting < ActiveRecord::Base
session_expire_delay:
Settings
.
gitlab
[
'session_expire_delay'
],
default_project_visibility:
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
default_snippet_visibility:
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
restricted_signup_domains:
Settings
.
gitlab
[
'restricted_signup_domains'
]
restricted_signup_domains:
Settings
.
gitlab
[
'restricted_signup_domains'
],
import_sources:
[
'github'
,
'bitbucket'
,
'gitlab'
,
'gitorious'
,
'google_code'
,
'git'
]
)
end
...
...
app/views/admin/application_settings/_form.html.haml
View file @
55dca86b
...
...
@@ -27,6 +27,20 @@
-
restricted_level_checkboxes
(
'restricted-visibility-help'
).
each
do
|
level
|
=
level
%span
.help-block
#restricted-visibility-help
Selected levels cannot be used by non-admin users for projects or snippets
.form-group
=
f
.
label
:import_sources
,
class:
'control-label col-sm-2'
.col-sm-10
-
data_attrs
=
{
toggle:
'buttons'
}
.btn-group
{
data:
data_attrs
}
-
import_sources_checkboxes
(
'import-sources-help'
).
each
do
|
source
|
=
source
%span
.help-block
#import-sources-help
Enabled sources for code import during project creation. OmniAuth must be configured for GitHub
=
link_to
"(?)"
,
help_page_path
(
"integration"
,
"github"
)
, Bitbucket
=
link_to
"(?)"
,
help_page_path
(
"integration"
,
"bitbucket"
)
and GitLab.com
=
link_to
"(?)"
,
help_page_path
(
"integration"
,
"gitlab"
)
.form-group
.col-sm-offset-2.col-sm-10
.checkbox
...
...
config/initializers/1_settings.rb
View file @
55dca86b
...
...
@@ -148,6 +148,7 @@ Settings.gitlab.default_projects_features['snippets'] = false if Settings.
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
]
=
Settings
.
send
(
:verify_constant
,
Gitlab
::
VisibilityLevel
,
Settings
.
gitlab
.
default_projects_features
[
'visibility_level'
],
Gitlab
::
VisibilityLevel
::
PRIVATE
)
Settings
.
gitlab
[
'repository_downloads_path'
]
=
File
.
absolute_path
(
Settings
.
gitlab
[
'repository_downloads_path'
]
||
'tmp/repositories'
,
Rails
.
root
)
Settings
.
gitlab
[
'restricted_signup_domains'
]
||=
[]
Settings
.
gitlab
[
'import_sources'
]
||=
[
'github'
,
'bitbucket'
,
'gitlab'
,
'gitorious'
,
'google_code'
,
'git'
]
#
# Gravatar
...
...
db/migrate/20150812080800_add_settings_import_sources.rb
0 → 100644
View file @
55dca86b
require
'yaml'
class
AddSettingsImportSources
<
ActiveRecord
::
Migration
def
change
unless
column_exists?
(
:application_settings
,
:import_sources
)
add_column
:application_settings
,
:import_sources
,
:text
import_sources
=
YAML
::
dump
(
Settings
.
gitlab
[
'import_sources'
])
execute
(
"update application_settings set import_sources = '
#{
import_sources
}
'"
)
end
end
end
db/schema.rb
View file @
55dca86b
...
...
@@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.
ActiveRecord
::
Schema
.
define
(
version:
201508
06104937
)
do
ActiveRecord
::
Schema
.
define
(
version:
201508
12080800
)
do
# These are extensions that must be enabled in order to support this database
enable_extension
"plpgsql"
...
...
@@ -44,6 +44,7 @@ ActiveRecord::Schema.define(version: 20150806104937) do
t
.
boolean
"user_oauth_applications"
,
default:
true
t
.
string
"after_sign_out_path"
t
.
integer
"session_expire_delay"
,
default:
10080
,
null:
false
t
.
text
"import_sources"
end
create_table
"audit_events"
,
force:
true
do
|
t
|
...
...
lib/gitlab/current_settings.rb
View file @
55dca86b
...
...
@@ -22,7 +22,8 @@ module Gitlab
sign_in_text:
Settings
.
extra
[
'sign_in_text'
],
restricted_visibility_levels:
Settings
.
gitlab
[
'restricted_visibility_levels'
],
max_attachment_size:
Settings
.
gitlab
[
'max_attachment_size'
],
session_expire_delay:
Settings
.
gitlab
[
'session_expire_delay'
]
session_expire_delay:
Settings
.
gitlab
[
'session_expire_delay'
],
import_sources:
Settings
.
gitlab
[
'import_sources'
]
)
end
end
...
...
lib/gitlab/import_sources.rb
0 → 100644
View file @
55dca86b
# Gitlab::ImportSources module
#
# Define import sources that can be used
# during the creation of new project
#
module
Gitlab
module
ImportSources
extend
CurrentSettings
class
<<
self
def
values
options
.
values
end
def
options
{
'GitHub'
=>
'github'
,
'Bitbucket'
=>
'bitbucket'
,
'GitLab.com'
=>
'gitlab'
,
'Gitorious.org'
=>
'gitorious'
,
'Google Code'
=>
'google_code'
,
'Any repo by URL'
=>
'git'
,
}
end
end
end
end
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