Skip to content
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

Image upload in creating issue #6962

Closed
wants to merge 3 commits into from

Conversation

erbunao
Copy link
Contributor

@erbunao erbunao commented May 13, 2014

[WIP] Expecting for feedback. We have already implemented:

  1. Multiple image upload
  2. Drag and Drop UI
  3. Display the image according to the markdown syntax
  4. File type filtering

Looking for feedback.

links = []
params['issue-imgs'].each do |img|
uploader.store!(img)
links << File.join(root_url,uploader.url)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.

@dzaporozhets
Copy link
Member

Can you please attach screenshot or gif animation so we can see how UI looks?

def upload_image
uploader = AttachmentUploader.new(@project.namespace.path, @project.path)
links = []
params['issue-imgs'].each do |img|
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wouldn't it be simpler to limit the upload API to a single image (rather than several images at once), and let the javascript/browser send one request per image to upload?

IMHO it would make the error handling easier on the browser side: each upload would receive its own success or error. If several files can be uploaded at once the error handling must deal with partial errors.

@erbunao
Copy link
Contributor Author

erbunao commented May 14, 2014

@randx, here are the print screens:

Attaching image:
attach_image1

Result:
attach_image_result

With invalid file type:
attach_image_error1

def upload_image
@upload_path = File.join(project.namespace.path, @project.path)
@accepted_types = %w(png jpg jpeg gif)
uploader = FileUploader.new('uploads/'+@upload_path,@accepted_types)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space missing after comma.
Surrounding space missing for operator '+'.

@@ -300,9 +299,10 @@
end
end

resources :issues, constraints: {id: /\d+/}, except: [:destroy] do
resources :issues, constraints: {id: /\d+/}, except: [:destroy] do=

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Space inside { missing.
Space inside } missing.

@@ -77,7 +80,7 @@ def update
@issue = Issues::UpdateService.new(project, current_user, params[:issue]).execute(issue)

respond_to do |format|
format.js
format.js

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Trailing whitespace detected.

@erbunao erbunao changed the title Issue file upload Image upload in creating issue May 15, 2014
links = []
params['issue-imgs'].each do |img|
alt = uploader.store!(img)
links << {'alt' => File.basename(alt,'.*'), 'url' => File.join(root_url, uploader.url)}

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Line is too long. [93/80]
Space missing after comma.
Space inside { missing.
Space inside } missing.

@erbunao
Copy link
Contributor Author

erbunao commented May 15, 2014

@kemenaran:
As I understand, this PR allows attachments to be uploaded for an issue - but not for Merge Requests, wiki projects, etc.

How about putting the upload API at the Project level? The project_controller would handle uploading and deleting images. And the same browser code could be used to upload an image from anywhere in a project: issues, MR, wiki, wall, all the same code.

@kemenaran, we have considered your point and started working on it. So far we are done with issue, comment, and wiki forms.

@randx, do we need to submit a separate pull request for the feature mentioned by @kemenaran or just maintain this PR.

@@ -13,5 +13,4 @@ def download
redirect_to uploader.url
end
end
end

end

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Final newline missing.

@mbrgm
Copy link

mbrgm commented May 16, 2014

+1!

@dblessing
Copy link
Member

@erbunao I would think you want to implement within projects up front. It will be a better user experience. It seems like it would also be advantageous to have this new behavior in notes/comments as some point. Anything that can unify the experience.

Things seem to be looking good so far. From a UI standpoint I'm not sure I like the location of the invalid file type alert. It would probably be best to have it red so it matches the normal bootstrap alert/danger scheme. It may be more appropriate to have the bar appear above or below the description field or at the bottom of the screen like other error banners do. I understand it may be helpful to have the error message appear more in context so the user notices it easily.

@dblessing
Copy link
Member

Also, be careful with your editor to ensure you don't have trailing whitespace and you don't remove new lines at the end of files. It'll make review and merging easier later on. :)

if issue.save
notification_service.new_issue(issue, current_user)
event_service.open_issue(issue, current_user)
issue.create_cross_references!(issue.project, current_user)
execute_hooks(issue)
end

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please avoid changes like this in files where you're not adding/changing code.

@dblessing
Copy link
Member

favicon.ico file seems to have been removed in this PR, also.

@@ -69,7 +68,11 @@ def create
render :new
end
end
format.js
format.js do |format|
# issue = Issues.create()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What does this comment try to explain?

@erbunao
Copy link
Contributor Author

erbunao commented May 19, 2014

@dblessing, @jvanbaarsen, we're already refactoring the code for the feature and we're planning to submit another PR for a more generic markdown area (maybe we can incorporate this feature to the notes (comments) section and/or wiki). Thanks for the feedback!

@Wachiwi
Copy link

Wachiwi commented May 20, 2014

very nice feature! 👍

@erbunao
Copy link
Contributor Author

erbunao commented May 23, 2014

@randx, @dosire, @dblessing. We submitted a new pull request which applies this feature to other markdown area. Please take a look at #7011. Thanks!

@erbunao erbunao closed this May 23, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
8 participants