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
Tatuya Kamada
gitlab-ce
Commits
fb9cb3f0
Commit
fb9cb3f0
authored
Sep 15, 2015
by
Kamil Trzcinski
Browse files
Options
Browse Files
Download
Plain Diff
Merge remote-tracking branch 'origin/master' into ci-and-ce-sitting-in-a-tree-k-i-s-s-i-n-g
parents
2d8c4273
61737af5
Changes
11
Hide whitespace changes
Inline
Side-by-side
Showing
11 changed files
with
80 additions
and
73 deletions
+80
-73
app/assets/javascripts/blob/blob_file_dropzone.js.coffee
app/assets/javascripts/blob/blob_file_dropzone.js.coffee
+31
-16
app/assets/stylesheets/generic/common.scss
app/assets/stylesheets/generic/common.scss
+8
-0
app/assets/stylesheets/pages/tree.scss
app/assets/stylesheets/pages/tree.scss
+2
-1
app/controllers/projects/blob_controller.rb
app/controllers/projects/blob_controller.rb
+11
-0
app/views/projects/blob/_actions.html.haml
app/views/projects/blob/_actions.html.haml
+3
-3
app/views/projects/blob/_replace.html.haml
app/views/projects/blob/_replace.html.haml
+0
-28
app/views/projects/blob/_upload.html.haml
app/views/projects/blob/_upload.html.haml
+10
-10
app/views/projects/blob/new.html.haml
app/views/projects/blob/new.html.haml
+6
-6
app/views/projects/blob/show.html.haml
app/views/projects/blob/show.html.haml
+1
-1
features/project/source/browse_files.feature
features/project/source/browse_files.feature
+3
-3
features/steps/project/source/browse_files.rb
features/steps/project/source/browse_files.rb
+5
-5
No files found.
app/assets/javascripts/blob/blob_file_dropzone.js.coffee
View file @
fb9cb3f0
...
@@ -20,26 +20,41 @@ class @BlobFileDropzone
...
@@ -20,26 +20,41 @@ class @BlobFileDropzone
headers
:
headers
:
"X-CSRF-Token"
:
$
(
"meta[name=
\"
csrf-token
\"
]"
).
attr
(
"content"
)
"X-CSRF-Token"
:
$
(
"meta[name=
\"
csrf-token
\"
]"
).
attr
(
"content"
)
success
:
(
header
,
response
)
->
init
:
->
window
.
location
.
href
=
response
.
filePath
this
.
on
'addedfile'
,
(
file
)
->
return
$
(
'.dropzone-alerts'
).
html
(
''
).
hide
()
commit_message
=
form
.
find
(
'#commit_message'
)[
0
]
error
:
(
temp
,
errorMessage
)
->
if
/^Upload/
.
test
(
commit_message
.
placeholder
)
stripped
=
$
(
"<div/>"
).
html
(
errorMessage
).
text
();
commit_message
.
placeholder
=
'Upload '
+
file
.
name
$
(
'.dropzone-alerts'
).
html
(
'Error uploading file:
\"
'
+
stripped
+
'
\"
'
).
show
()
return
maxfilesexceeded
:
(
file
)
->
return
@
removeFile
file
return
this
.
on
'removedfile'
,
(
file
)
->
commit_message
=
form
.
find
(
'#commit_message'
)[
0
]
removedfile
:
(
file
)
->
if
/^Upload/
.
test
(
commit_message
.
placeholder
)
$
(
'.dropzone-previews'
)[
0
].
removeChild
(
file
.
previewTemplate
)
commit_message
.
placeholder
=
'Upload new file'
$
(
'.dropzone-alerts'
).
html
(
''
).
hide
()
return
true
sending
:
(
file
,
xhr
,
formData
)
->
return
formData
.
append
(
'commit_message'
,
form
.
find
(
'#commit_message'
).
val
())
this
.
on
'success'
,
(
header
,
response
)
->
window
.
location
.
href
=
response
.
filePath
return
this
.
on
'maxfilesexceeded'
,
(
file
)
->
@
removeFile
file
return
this
.
on
'sending'
,
(
file
,
xhr
,
formData
)
->
formData
.
append
(
'commit_message'
,
form
.
find
(
'#commit_message'
).
val
())
return
# Override behavior of adding error underneath preview
error
:
(
file
,
errorMessage
)
->
stripped
=
$
(
"<div/>"
).
html
(
errorMessage
).
text
();
$
(
'.dropzone-alerts'
).
html
(
'Error uploading file:
\"
'
+
stripped
+
'
\"
'
).
show
()
@
removeFile
file
return
return
)
)
...
...
app/assets/stylesheets/generic/common.scss
View file @
fb9cb3f0
...
@@ -382,3 +382,11 @@ table {
...
@@ -382,3 +382,11 @@ table {
margin-bottom
:
0
;
margin-bottom
:
0
;
}
}
}
}
.dropzone
.dz-preview
.dz-progress
{
border-color
:
$border-color
!
important
;
}
.dropzone
.dz-preview
.dz-progress
.dz-upload
{
background
:
$gl-success
!
important
;
}
app/assets/stylesheets/pages/tree.scss
View file @
fb9cb3f0
...
@@ -121,10 +121,11 @@
...
@@ -121,10 +121,11 @@
text-align
:
center
;
text-align
:
center
;
border
:
2px
;
border
:
2px
;
border-style
:
dashed
;
border-style
:
dashed
;
border-color
:
$border-color
;
min-height
:
200px
;
min-height
:
200px
;
}
}
.upload-link
{
.upload-link
{
font-weight
:
normal
;
font-weight
:
normal
;
color
:
#0000EE
;
color
:
$md-link-color
;
}
}
app/controllers/projects/blob_controller.rb
View file @
fb9cb3f0
...
@@ -18,6 +18,12 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -18,6 +18,12 @@ class Projects::BlobController < Projects::ApplicationController
before_action
:after_edit_path
,
only:
[
:edit
,
:update
]
before_action
:after_edit_path
,
only:
[
:edit
,
:update
]
def
new
def
new
@title
=
'Upload'
@placeholder
=
'Upload new file'
@button_title
=
'Upload file'
@form_path
=
namespace_project_create_blob_path
(
@project
.
namespace
,
@project
,
@id
)
@method
=
:post
commit
unless
@repository
.
empty?
commit
unless
@repository
.
empty?
end
end
...
@@ -40,6 +46,11 @@ class Projects::BlobController < Projects::ApplicationController
...
@@ -40,6 +46,11 @@ class Projects::BlobController < Projects::ApplicationController
end
end
def
show
def
show
@title
=
"Replace
#{
@blob
.
name
}
"
@placeholder
=
@title
@button_title
=
'Replace file'
@form_path
=
namespace_project_update_blob_path
(
@project
.
namespace
,
@project
,
@id
)
@method
=
:put
end
end
def
edit
def
edit
...
...
app/views/projects/blob/_actions.html.haml
View file @
fb9cb3f0
...
@@ -17,6 +17,6 @@
...
@@ -17,6 +17,6 @@
tree_join
(
@commit
.
sha
,
@path
)),
class:
'btn btn-sm'
tree_join
(
@commit
.
sha
,
@path
)),
class:
'btn btn-sm'
-
if
allowed_tree_edit?
-
if
allowed_tree_edit?
.btn-group
{
:role
=>
"group"
}
.btn-group
{
role:
"group"
}
%button
.btn.btn-default
{
class:
'btn-primary'
,
href:
'#modal-replace-blob'
,
'data-target'
=>
'#modal-replace-blob'
,
'data-toggle'
=>
'modal'
}
Replace
%button
.btn.btn-default
{
'data-target'
=>
'#modal-upload-blob'
,
'data-toggle'
=>
'modal'
}
Replace
%button
.btn.btn-
default
{
class:
'btn-remove'
,
href:
'#modal-remove-blob'
,
'data-target'
=>
'#modal-remove-blob'
,
'data-toggle'
=>
'modal'
}
Remove
%button
.btn.btn-
remove
{
'data-target'
=>
'#modal-remove-blob'
,
'data-toggle'
=>
'modal'
}
Remove
app/views/projects/blob/_replace.html.haml
deleted
100644 → 0
View file @
2d8c4273
#modal-replace-blob
.modal
.modal-dialog
.modal-content
.modal-header
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%h3
.page-title
Replace
#{
@blob
.
name
}
%p
.light
From branch
%strong
=
@ref
.modal-body
=
form_tag
namespace_project_update_blob_path
(
@project
.
namespace
,
@project
,
@id
),
method: :put
,
class:
'blob-file-upload-form-js form-horizontal'
do
.dropzone
.dropzone-previews
{
class:
"blob-upload-dropzone-previews"
}
%p
.dz-message
{
class:
"hint"
}
<
Attach
files
by
dragging
&
dropping
or
&
nbsp
;
%a
{
href:
'#'
,
class:
"markdown-selector"
}
>
click to upload
%br
.dropzone-alerts
{
class:
"alert alert-danger data"
,
"data-dismiss"
=>
"alert"
,
style:
"display:none"
}
=
render
'shared/commit_message_container'
,
params:
params
,
placeholder:
'Replace this file because...'
.form-group
.col-sm-offset-2.col-sm-10
=
button_tag
'Replace file'
,
class:
'btn btn-small btn-primary btn-replace-file'
,
id:
'submit-all'
=
link_to
"Cancel"
,
'#'
,
class:
"btn btn-cancel"
,
"data-dismiss"
=>
"modal"
:coffeescript
disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-replace-file'
new BlobFileDropzone($('.blob-file-upload-form-js'), 'put')
app/views/projects/blob/_upload.html.haml
View file @
fb9cb3f0
...
@@ -3,26 +3,26 @@
...
@@ -3,26 +3,26 @@
.modal-content
.modal-content
.modal-header
.modal-header
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%a
.close
{
href:
"#"
,
"data-dismiss"
=>
"modal"
}
×
%h3
.page-title
Upload
%h3
.page-title
#{
@title
}
%p
.light
%p
.light
From branch
From branch
%strong
=
@ref
%strong
=
@ref
.modal-body
.modal-body
=
form_tag
namespace_project_create_blob_path
(
@project
.
namespace
,
@project
,
@id
),
method: :post
,
class:
'blob-file-upload-form-js form-horizontal'
do
=
form_tag
@form_path
,
method:
@method
,
class:
'blob-file-upload-form-js form-horizontal'
do
.dropzone
.dropzone
.dropzone-previews
{
class:
"blob-upload-dropzone-previews"
}
.dropzone-previews
.blob-upload-dropzone-previews
%p
.dz-message
{
class:
"hint"
}
<
%p
.dz-message
.light
Attach
files
by
dragging
&
dropping
or
&
nbsp
;
Attach
a file by drag
&
drop or
%a
{
href:
'#'
,
class:
"markdown-selector"
}
>
click to upload
=
link_to
'click to upload'
,
'#'
,
class:
"markdown-selector"
%br
%br
.dropzone-alerts
{
class:
"alert alert-danger data"
,
"data-dismiss"
=>
"alert"
,
style:
"display:none"
}
.dropzone-alerts
{
class:
"alert alert-danger data"
,
style:
"display:none"
}
=
render
'shared/commit_message_container'
,
params:
params
,
=
render
'shared/commit_message_container'
,
params:
params
,
placeholder:
'Upload this file because...'
placeholder:
@placeholder
.form-group
.form-group
.col-sm-offset-2.col-sm-10
.col-sm-offset-2.col-sm-10
=
button_tag
'Upload file'
,
class:
'btn btn-small btn-primary btn-upload-file'
,
id:
'submit-all'
=
button_tag
@button_title
,
class:
'btn btn-small btn-primary btn-upload-file'
,
id:
'submit-all'
=
link_to
"Cancel"
,
'#'
,
class:
"btn btn-cancel"
,
"data-dismiss"
=>
"modal"
=
link_to
"Cancel"
,
'#'
,
class:
"btn btn-cancel"
,
"data-dismiss"
=>
"modal"
:coffeescript
:coffeescript
disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file'
disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file'
new BlobFileDropzone($('.blob-file-upload-form-js'), '
post
')
new BlobFileDropzone($('.blob-file-upload-form-js'), '
#{
@method
}
')
app/views/projects/blob/new.html.haml
View file @
fb9cb3f0
%h3
.page-title
<
.gray-content-block.top-block
Create
new
file
or
&
nbsp
;
Create a new file or
%a
.upload-link
{
href:
'#modal-upload-blob'
,
'data-target'
=>
'#modal-upload-blob'
,
'data-toggle'
=>
'modal'
}
>
upload existing one
=
link_to
'upload'
,
'#modal-upload-blob'
,
{
class:
'upload-link'
,
'data-target'
=>
'#modal-upload-blob'
,
'data-toggle'
=>
'modal'
}
an existing one
.file-title
=
render
'projects/blob/upload'
=
render
'projects/blob/upload'
%br
.file-editor
.file-editor
=
form_tag
(
namespace_project_create_blob_path
(
@project
.
namespace
,
@project
,
@id
),
method: :post
,
class:
'form-horizontal form-new-file js-requires-input'
)
do
=
form_tag
(
namespace_project_create_blob_path
(
@project
.
namespace
,
@project
,
@id
),
method: :post
,
class:
'form-horizontal form-new-file js-requires-input'
)
do
...
...
app/views/projects/blob/show.html.haml
View file @
fb9cb3f0
...
@@ -10,4 +10,4 @@
...
@@ -10,4 +10,4 @@
-
if
allowed_tree_edit?
-
if
allowed_tree_edit?
=
render
'projects/blob/remove'
=
render
'projects/blob/remove'
=
render
'projects/blob/
replace
'
=
render
'projects/blob/
upload
'
features/project/source/browse_files.feature
View file @
fb9cb3f0
...
@@ -33,13 +33,13 @@ Feature: Project Source Browse Files
...
@@ -33,13 +33,13 @@ Feature: Project Source Browse Files
And
I click on
"Commit Changes"
And
I click on
"Commit Changes"
Then
I am redirected to the new file
Then
I am redirected to the new file
And
I should see its new content
And
I should see its new content
@javascript
@javascript
Scenario
:
I
can upload file and commit
Scenario
:
I
can upload file and commit
Given
I click on
"new file"
link in repo
Given
I click on
"new file"
link in repo
Then
I can see new file page
Then
I can see new file page
And
I can see
"upload existing one"
And
I can see
"upload
an
existing one"
And
I click on
"upload
existing one
"
And
I click on
"upload"
And
I upload a new text file
And
I upload a new text file
And
I fill the upload file commit message
And
I fill the upload file commit message
And
I click on
"Upload file"
And
I click on
"Upload file"
...
...
features/steps/project/source/browse_files.rb
View file @
fb9cb3f0
...
@@ -119,12 +119,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
...
@@ -119,12 +119,12 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
expect
(
page
).
to
have_content
"Commit message"
expect
(
page
).
to
have_content
"Commit message"
end
end
step
'I can see "upload existing one"'
do
step
'I can see "upload
an
existing one"'
do
expect
(
page
).
to
have_content
"upload existing one"
expect
(
page
).
to
have_content
"upload
an
existing one"
end
end
step
'I click on "upload
existing one
"'
do
step
'I click on "upload"'
do
click_link
'upload
existing one
'
click_link
'upload'
end
end
step
'I click on "Upload file"'
do
step
'I click on "Upload file"'
do
...
@@ -150,7 +150,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
...
@@ -150,7 +150,7 @@ class Spinach::Features::ProjectSourceBrowseFiles < Spinach::FeatureSteps
end
end
step
'I fill the replace file commit message'
do
step
'I fill the replace file commit message'
do
page
.
within
(
'#modal-
replace
-blob'
)
do
page
.
within
(
'#modal-
upload
-blob'
)
do
fill_in
:commit_message
,
with:
'Replacement file commit message'
fill_in
:commit_message
,
with:
'Replacement file commit message'
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