Commit 0e1948fb authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'refactor-blob-upload-locals' into 'master'

Move partial locals out of controller

Some minor cleanup for upload/replace functionality: move controller variables into partial locals.

See merge request !1331
parents b75e4d71 ac855e5e
......@@ -18,12 +18,6 @@ class Projects::BlobController < Projects::ApplicationController
before_action :after_edit_path, only: [:edit, :update]
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?
end
......@@ -46,11 +40,6 @@ class Projects::BlobController < Projects::ApplicationController
end
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
def edit
......
......@@ -3,12 +3,12 @@
.modal-content
.modal-header
%a.close{href: "#", "data-dismiss" => "modal"} ×
%h3.page-title #{@title}
%h3.page-title #{title}
%p.light
From branch
%strong= @ref
.modal-body
= form_tag @form_path, method: @method, 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-previews.blob-upload-dropzone-previews
%p.dz-message.light
......@@ -17,12 +17,12 @@
%br
.dropzone-alerts{class: "alert alert-danger data", style: "display:none"}
= render 'shared/commit_message_container', params: params,
placeholder: @placeholder
placeholder: placeholder
.form-group
.col-sm-offset-2.col-sm-10
= button_tag @button_title, 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"
:coffeescript
disableButtonIfEmptyField $('.blob-file-upload-form-js').find('#commit_message'), '.btn-upload-file'
new BlobFileDropzone($('.blob-file-upload-form-js'), '#{@method}')
new BlobFileDropzone($('.blob-file-upload-form-js'), '#{method}')
......@@ -4,7 +4,7 @@
{ class: 'upload-link', 'data-target' => '#modal-upload-blob', 'data-toggle' => 'modal'}
an existing one
= render 'projects/blob/upload'
= render 'projects/blob/upload', title: 'Upload', placeholder: 'Upload new file', button_title: 'Upload file', form_path: namespace_project_create_blob_path(@project.namespace, @project, @id), method: :post
.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
......
......@@ -10,4 +10,8 @@
- if allowed_tree_edit?
= render 'projects/blob/remove'
= render 'projects/blob/upload'
- title = "Replace #{@blob.name}"
= render 'projects/blob/upload', title: title, placeholder: title,
button_title: 'Replace file', form_path: namespace_project_update_blob_path(@project.namespace, @project, @id),
method: :put
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment