New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Generalizes image upload in drag and drop in markdown to all files. #7078
Conversation
def upload_image | ||
link_to_image = ::Projects::ImageService.new(repository, params, root_url).execute | ||
def upload_file | ||
link_to_file = ::Projects::FileService.new(repository, params, root_url).execute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Any tips to solve this warning? :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
if you really want to:
def upload_file
link_to_file = ::Projects::FileService.
new(repository, params, root_url).execute
end
or
def upload_file
::Projects::FileService.new(repository, params, root_url).execute
end
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Where I can find ::Projects::FileService
class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I made a git error. Sorry :(
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can just do:
link_to_file = ::Projects::FileService.new(repository, params, root_url).
execute
Thanks @nmcalabroso ! We would really like this functionality and I hope @jvanbaarsen and @randx can give you feedback on the code and possible security issues. |
end | ||
end | ||
|
||
protected |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Indent access modifiers like protected
.
Keep a blank line before and after protected
.
@nmcalabroso squash it to 1 commit if its final :) |
def upload_image | ||
link_to_image = ::Projects::ImageService.new(repository, params, root_url).execute | ||
def upload_file | ||
link_to_file = ::Projects::FileService.new(repository, params, root_url).execute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
@erbunao, done, but we should also wait for @jvanbaarsen's feedbacks before finalising this PR. |
@jvanbaarsen, I just saw the failed test by Travis. Will fix the tests immediately. |
@@ -13,12 +13,14 @@ | |||
context 'for valid gif file' do | |||
before do | |||
gif = fixture_file_upload(Rails.root + 'spec/fixtures/banana_sample.gif', 'image/gif') | |||
@link_to_image = upload_image(@project.repository, { 'markdown_img' => gif }, "http://test.example/") | |||
@link_to_image = upload_image(@project.repository, { 'markdown_file' => gif }, "http://test.example/") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [110/80]
Prefer single-quoted strings when you don't need string interpolation or special symbols.
end | ||
end | ||
|
||
context "with valid file" do | ||
context "with valid non-image file" do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer single-quoted strings when you don't need string interpolation or special symbols.
def upload_image | ||
link_to_image = ::Projects::ImageService.new(repository, params, root_url).execute | ||
def upload_file | ||
link_to_file = ::Projects::FileService.new(repository, params, root_url).execute |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Line is too long. [84/80]
@nmcalabroso Please fix tests and code style and ping me after so I can do a review and merge it if ok |
This merge request has been closed because a request for more information has not been reacted to for more than 2 weeks. If you respond and conform to the merge request guidelines in our contributing guidelines we will reopen this merge request. |
@nmcalabroso If you want to fix this please let us know and we can reopen. |
(w/ @erbunao)
This is our attempt to generalize the drag-and-drop upload in markdown areas. UI is still the same as #7011. Note that only the images have valid preview.
@dosire, this PR doesn't have any blacklisted file types so we need suggestions from you. Thanks!