-
Notifications
You must be signed in to change notification settings - Fork 1.8k
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
Fix Rich-Text & Image Upload in FRESHLY Posted Comments #9162
Conversation
@@ -132,9 +132,6 @@ class Editor { | |||
this.textAreaElement.val(this.textAreaValue+'\n\n'+this.templates[template]) | |||
} | |||
} | |||
generate_preview(id,text) { | |||
$('#' + id)[0].innerHTML = marked(text) | |||
} |
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.
Unrelated changes in this file (sorry)! Deleted this unused code.
// used to create fileupload functionality for: | ||
// 1. existing comments at document.load | ||
// 2. dynamically inserted (freshly posted) comments, see /app/views/comments/create.js.erb | ||
function getFileUploadOptions(dropZone, isSmallDropzone = false) { |
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.
Function getFileUploadOptions
has a Cognitive Complexity of 9 (exceeds 5 allowed). Consider refactoring.
// used to create fileupload functionality for: | ||
// 1. existing comments at document.load | ||
// 2. dynamically inserted (freshly posted) comments, see /app/views/comments/create.js.erb | ||
function getFileUploadOptions(dropZone, isSmallDropzone = false) { |
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.
Function getFileUploadOptions
has 48 lines of code (exceeds 25 allowed). Consider refactoring.
Code Climate has analyzed commit b52e480 and detected 2 issues on this pull request. Here's the issue category breakdown:
View more on Code Climate. |
replyFormBody.fileupload(replyFormOptions); | ||
editFormBody.fileupload(editFormOptions); | ||
replyButton.fileupload(replyButtonOptions); | ||
editButton.fileupload(editButtonOptions); |
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 think create.js.erb
runs when comments/create
is called from the controller.
I had a choice between putting this code here, or in /app/assets/javascripts/comment.js
. The second choice (where ajax:success
is triggered on adding a comment) seemed more intuitive, but also more complicated to rewrite. Putting this here for now.
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.
That note on when/where it is run may be good to include in the file itself in a header comment, how does that sound? Just thinking to help future devs. Thanks!!!
<i class="fa fa-upload"></i> | ||
<a><%= translation('comments._form.upload_image') %></a> | ||
</span> | ||
</label> |
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.
This is an unrelated change (sorry again), for some reason the imagebar text ("Drag and drop an image, or choose one to upload") wasn't appearing in the legacy editor pages. It was just a blank grey spot.
Codecov Report
@@ Coverage Diff @@
## main #9162 +/- ##
=======================================
Coverage ? 81.94%
=======================================
Files ? 100
Lines ? 5939
Branches ? 0
=======================================
Hits ? 4867
Misses ? 1072
Partials ? 0 |
@jywarren Do you have the ability to override codeclimate? I can't do it. Would prefer not to take the suggestions in this case. Otherwise this is ready to merge! |
Yes i can do that tomorrow morning! Thanks!
…On Mon, Feb 8, 2021, 5:01 PM noi5e ***@***.***> wrote:
@jywarren <https://github.com/jywarren> Do you have the ability to
override codeclimate? I can't do it. Would prefer not to take the
suggestions in this case.
Otherwise this is ready to merge!
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#9162 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAAF6J57AN2AOHKA66ILWDLS6BNL3ANCNFSM4XJY2GCQ>
.
|
}); | ||
const isSmallDropzone = $(this).hasClass("dropzone-small"); | ||
const fileUploadOptions = getFileUploadOptions($(this), isSmallDropzone); | ||
$(this).fileupload(fileUploadOptions); |
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.
👍
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.
Thanks @noi5e and reviewers!!!!
* delete unused code; add semicolon publiclab#9072 * attach eventHandlers to #legacy-editor-container publiclab#9072 * add image upload functionality to new comments publiclab#9072 * add imagebar caption publiclab#9072 * add #legacy-editor-container class to attach eventHandlers publiclab#9072 * add system test for rich-text & image upload on fresh comments publiclab#9072
* delete unused code; add semicolon publiclab#9072 * attach eventHandlers to #legacy-editor-container publiclab#9072 * add image upload functionality to new comments publiclab#9072 * add imagebar caption publiclab#9072 * add #legacy-editor-container class to attach eventHandlers publiclab#9072 * add system test for rich-text & image upload on fresh comments publiclab#9072
* delete unused code; add semicolon publiclab#9072 * attach eventHandlers to #legacy-editor-container publiclab#9072 * add image upload functionality to new comments publiclab#9072 * add imagebar caption publiclab#9072 * add #legacy-editor-container class to attach eventHandlers publiclab#9072 * add system test for rich-text & image upload on fresh comments publiclab#9072
* delete unused code; add semicolon publiclab#9072 * attach eventHandlers to #legacy-editor-container publiclab#9072 * add image upload functionality to new comments publiclab#9072 * add imagebar caption publiclab#9072 * add #legacy-editor-container class to attach eventHandlers publiclab#9072 * add system test for rich-text & image upload on fresh comments publiclab#9072
Fixes #9072
(This issue is part of the larger Comment Editor Overhaul Project with Outreachy. Refer to Planning Issue #9069 for more context)