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
880cf60b
Commit
880cf60b
authored
Nov 03, 2017
by
Eric Eastwood
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'master' into 38464-k8s-apps
parents
1bbeafc3
f580e497
Changes
13
Show whitespace changes
Inline
Side-by-side
Showing
13 changed files
with
85 additions
and
34 deletions
+85
-34
app/assets/javascripts/clusters.js
app/assets/javascripts/clusters.js
+2
-0
app/assets/javascripts/lib/utils/axios_utils.js
app/assets/javascripts/lib/utils/axios_utils.js
+6
-0
app/assets/stylesheets/pages/boards.scss
app/assets/stylesheets/pages/boards.scss
+7
-3
app/controllers/admin/applications_controller.rb
app/controllers/admin/applications_controller.rb
+5
-10
app/controllers/oauth/applications_controller.rb
app/controllers/oauth/applications_controller.rb
+10
-11
app/controllers/profiles/keys_controller.rb
app/controllers/profiles/keys_controller.rb
+2
-8
app/models/environment.rb
app/models/environment.rb
+5
-1
app/services/applications/create_service.rb
app/services/applications/create_service.rb
+13
-0
app/services/keys/base_service.rb
app/services/keys/base_service.rb
+1
-0
changelogs/unreleased/sh-fix-environment-slug-generation.yml
changelogs/unreleased/sh-fix-environment-slug-generation.yml
+5
-0
config/gitlab.yml.example
config/gitlab.yml.example
+1
-1
spec/models/environment_spec.rb
spec/models/environment_spec.rb
+15
-0
spec/services/applications/create_service_spec.rb
spec/services/applications/create_service_spec.rb
+13
-0
No files found.
app/assets/javascripts/clusters.js
View file @
880cf60b
/* globals Flash */
/* globals Flash */
import
Visibility
from
'
visibilityjs
'
;
import
Visibility
from
'
visibilityjs
'
;
import
axios
from
'
axios
'
;
import
axios
from
'
axios
'
;
import
setAxiosCsrfToken
from
'
./lib/utils/axios_utils
'
;
import
Poll
from
'
./lib/utils/poll
'
;
import
Poll
from
'
./lib/utils/poll
'
;
import
{
s__
}
from
'
./locale
'
;
import
{
s__
}
from
'
./locale
'
;
import
initSettingsPanels
from
'
./settings_panels
'
;
import
initSettingsPanels
from
'
./settings_panels
'
;
...
@@ -17,6 +18,7 @@ import Flash from './flash';
...
@@ -17,6 +18,7 @@ import Flash from './flash';
class
ClusterService
{
class
ClusterService
{
constructor
(
options
=
{})
{
constructor
(
options
=
{})
{
this
.
options
=
options
;
this
.
options
=
options
;
setAxiosCsrfToken
();
}
}
fetchData
()
{
fetchData
()
{
return
axios
.
get
(
this
.
options
.
endpoint
);
return
axios
.
get
(
this
.
options
.
endpoint
);
...
...
app/assets/javascripts/lib/utils/axios_utils.js
0 → 100644
View file @
880cf60b
import
axios
from
'
axios
'
;
import
csrf
from
'
./csrf
'
;
export
default
function
setAxiosCsrfToken
()
{
axios
.
defaults
.
headers
.
common
[
csrf
.
headerKey
]
=
csrf
.
token
;
}
app/assets/stylesheets/pages/boards.scss
View file @
880cf60b
...
@@ -72,7 +72,7 @@
...
@@ -72,7 +72,7 @@
}
}
.boards-list
{
.boards-list
{
height
:
calc
(
100vh
-
1
52
px
);
height
:
calc
(
100vh
-
1
05
px
);
width
:
100%
;
width
:
100%
;
padding-top
:
25px
;
padding-top
:
25px
;
padding-bottom
:
25px
;
padding-bottom
:
25px
;
...
@@ -81,10 +81,14 @@
...
@@ -81,10 +81,14 @@
overflow-x
:
scroll
;
overflow-x
:
scroll
;
white-space
:
nowrap
;
white-space
:
nowrap
;
@media
(
min-width
:
$screen-sm-min
)
{
@media
(
min-width
:
$screen-sm-min
)
and
(
max-width
:
$screen-sm-max
)
{
height
:
calc
(
100vh
-
90px
);
}
@media
(
min-width
:
$screen-md-min
)
{
height
:
475px
;
// Needed for PhantomJS
height
:
475px
;
// Needed for PhantomJS
// scss-lint:disable DuplicateProperty
// scss-lint:disable DuplicateProperty
height
:
calc
(
100vh
-
222
px
);
height
:
calc
(
100vh
-
160
px
);
// scss-lint:enable DuplicateProperty
// scss-lint:enable DuplicateProperty
min-height
:
475px
;
min-height
:
475px
;
}
}
...
...
app/controllers/admin/applications_controller.rb
View file @
880cf60b
...
@@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
...
@@ -19,10 +19,12 @@ class Admin::ApplicationsController < Admin::ApplicationController
end
end
def
create
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
application_params
).
execute
(
request
)
if
@application
.
save
if
@application
.
persisted?
redirect_to_admin_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
else
else
render
:new
render
:new
end
end
...
@@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
...
@@ -41,13 +43,6 @@ class Admin::ApplicationsController < Admin::ApplicationController
redirect_to
admin_applications_url
,
status:
302
,
notice:
'Application was successfully destroyed.'
redirect_to
admin_applications_url
,
status:
302
,
notice:
'Application was successfully destroyed.'
end
end
protected
def
redirect_to_admin_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
admin_application_url
(
@application
)
end
private
private
def
set_application
def
set_application
...
...
app/controllers/oauth/applications_controller.rb
View file @
880cf60b
...
@@ -16,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -16,25 +16,18 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
end
end
def
create
def
create
@application
=
Doorkeeper
::
Application
.
new
(
application_params
)
@application
=
Applications
::
CreateService
.
new
(
current_user
,
create_application_params
).
execute
(
request
)
@application
.
owner
=
current_user
if
@application
.
persisted?
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
if
@application
.
save
redirect_to
oauth_application_url
(
@application
)
redirect_to_oauth_application_page
else
else
set_index_vars
set_index_vars
render
:index
render
:index
end
end
end
end
protected
def
redirect_to_oauth_application_page
flash
[
:notice
]
=
I18n
.
t
(
:notice
,
scope:
[
:doorkeeper
,
:flash
,
:applications
,
:create
])
redirect_to
oauth_application_url
(
@application
)
end
private
private
def
verify_user_oauth_applications_enabled
def
verify_user_oauth_applications_enabled
...
@@ -61,4 +54,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
...
@@ -61,4 +54,10 @@ class Oauth::ApplicationsController < Doorkeeper::ApplicationsController
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
rescue_from
ActiveRecord
::
RecordNotFound
do
|
exception
|
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
render
"errors/not_found"
,
layout:
"errors"
,
status:
404
end
end
def
create_application_params
application_params
.
tap
do
|
params
|
params
[
:owner
]
=
current_user
end
end
end
end
app/controllers/profiles/keys_controller.rb
View file @
880cf60b
...
@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
...
@@ -11,10 +11,10 @@ class Profiles::KeysController < Profiles::ApplicationController
end
end
def
create
def
create
@key
=
Keys
::
CreateService
.
new
(
current_user
,
key_params
).
execute
@key
=
Keys
::
CreateService
.
new
(
current_user
,
key_params
.
merge
(
ip_address:
request
.
remote_ip
)
).
execute
if
@key
.
persisted?
if
@key
.
persisted?
redirect_to
_profile_key_path
redirect_to
profile_key_path
(
@key
)
else
else
@keys
=
current_user
.
keys
.
select
(
&
:persisted?
)
@keys
=
current_user
.
keys
.
select
(
&
:persisted?
)
render
:index
render
:index
...
@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
...
@@ -50,12 +50,6 @@ class Profiles::KeysController < Profiles::ApplicationController
end
end
end
end
protected
def
redirect_to_profile_key_path
redirect_to
profile_key_path
(
@key
)
end
private
private
def
key_params
def
key_params
...
...
app/models/environment.rb
View file @
880cf60b
...
@@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base
...
@@ -110,7 +110,7 @@ class Environment < ActiveRecord::Base
end
end
def
ref_path
def
ref_path
"refs/
#{
Repository
::
REF_ENVIRONMENTS
}
/
#{
generate_
slug
}
"
"refs/
#{
Repository
::
REF_ENVIRONMENTS
}
/
#{
slug
}
"
end
end
def
formatted_external_url
def
formatted_external_url
...
@@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base
...
@@ -164,6 +164,10 @@ class Environment < ActiveRecord::Base
end
end
end
end
def
slug
super
.
presence
||
generate_slug
end
# An environment name is not necessarily suitable for use in URLs, DNS
# An environment name is not necessarily suitable for use in URLs, DNS
# or other third-party contexts, so provide a slugified version. A slug has
# or other third-party contexts, so provide a slugified version. A slug has
# the following properties:
# the following properties:
...
...
app/services/applications/create_service.rb
0 → 100644
View file @
880cf60b
module
Applications
class
CreateService
def
initialize
(
current_user
,
params
)
@current_user
=
current_user
@params
=
params
@ip_address
=
@params
.
delete
(
:ip_address
)
end
def
execute
(
request
=
nil
)
Doorkeeper
::
Application
.
create
(
@params
)
end
end
end
app/services/keys/base_service.rb
View file @
880cf60b
...
@@ -4,6 +4,7 @@ module Keys
...
@@ -4,6 +4,7 @@ module Keys
def
initialize
(
user
,
params
)
def
initialize
(
user
,
params
)
@user
,
@params
=
user
,
params
@user
,
@params
=
user
,
params
@ip_address
=
@params
.
delete
(
:ip_address
)
end
end
def
notification_service
def
notification_service
...
...
changelogs/unreleased/sh-fix-environment-slug-generation.yml
0 → 100644
View file @
880cf60b
---
title
:
Avoid regenerating the ref path for the environment
merge_request
:
author
:
type
:
fixed
config/gitlab.yml.example
View file @
880cf60b
...
@@ -501,7 +501,7 @@ production: &base
...
@@ -501,7 +501,7 @@ production: &base
# Gitaly settings
# Gitaly settings
gitaly:
gitaly:
# Path to the directory containing Gitaly client executables.
# Path to the directory containing Gitaly client executables.
client_path: /home/git/gitaly
client_path: /home/git/gitaly
/bin
# Default Gitaly authentication token. Can be overriden per storage. Can
# Default Gitaly authentication token. Can be overriden per storage. Can
# be left blank when Gitaly is running locally on a Unix socket, which
# be left blank when Gitaly is running locally on a Unix socket, which
# is the normal way to deploy Gitaly.
# is the normal way to deploy Gitaly.
...
...
spec/models/environment_spec.rb
View file @
880cf60b
...
@@ -547,6 +547,15 @@ describe Environment do
...
@@ -547,6 +547,15 @@ describe Environment do
expect
(
environment
.
slug
).
to
eq
(
original_slug
)
expect
(
environment
.
slug
).
to
eq
(
original_slug
)
end
end
it
"regenerates the slug if nil"
do
environment
=
build
(
:environment
,
slug:
nil
)
new_slug
=
environment
.
slug
expect
(
new_slug
).
not_to
be_nil
expect
(
environment
.
slug
).
to
eq
(
new_slug
)
end
end
end
describe
'#generate_slug'
do
describe
'#generate_slug'
do
...
@@ -583,6 +592,12 @@ describe Environment do
...
@@ -583,6 +592,12 @@ describe Environment do
it
'returns a path that uses the slug and does not have spaces'
do
it
'returns a path that uses the slug and does not have spaces'
do
expect
(
environment
.
ref_path
).
to
start_with
(
'refs/environments/staging-review-1-'
)
expect
(
environment
.
ref_path
).
to
start_with
(
'refs/environments/staging-review-1-'
)
end
end
it
"doesn't change when the slug is nil initially"
do
environment
.
slug
=
nil
expect
(
environment
.
ref_path
).
to
eq
(
environment
.
ref_path
)
end
end
end
describe
'#external_url_for'
do
describe
'#external_url_for'
do
...
...
spec/services/applications/create_service_spec.rb
0 → 100644
View file @
880cf60b
require
'spec_helper'
describe
::
Applications
::
CreateService
do
let
(
:user
)
{
create
(
:user
)
}
let
(
:params
)
{
attributes_for
(
:application
)
}
let
(
:request
)
{
ActionController
::
TestRequest
.
new
(
remote_ip:
'127.0.0.1'
)
}
subject
{
described_class
.
new
(
user
,
params
)
}
it
'creates an application'
do
expect
{
subject
.
execute
(
request
)
}.
to
change
{
Doorkeeper
::
Application
.
count
}.
by
(
1
)
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