-
Notifications
You must be signed in to change notification settings - Fork 205
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
WIP Evaluate viability of using HTMX #5913
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -46,21 +46,21 @@ function updateNumerOfComments() { | |
} | ||
} | ||
|
||
function deleteComment(deleteButton) { | ||
const author = deleteButton.dataset.author; | ||
if (!window.confirm('Do you really want to delete the comment written by ' + author + '?')) { | ||
return; | ||
} | ||
$.ajax({ | ||
url: deleteButton.dataset.deleteUrl, | ||
method: 'DELETE', | ||
success: () => { | ||
$(deleteButton).parents('.comment-row, .pinned-comment-row').remove(); | ||
updateNumerOfComments(); | ||
}, | ||
error: showXhrError.bind(undefined, "The comment couldn't be deleted: ") | ||
}); | ||
} | ||
//function deleteComment(deleteButton) { | ||
// const author = deleteButton.dataset.author; | ||
// if (!window.confirm('Do you really want to delete the comment written by ' + author + '?')) { | ||
// return; | ||
// } | ||
// $.ajax({ | ||
// url: deleteButton.dataset.deleteUrl, | ||
// method: 'DELETE', | ||
// success: () => { | ||
// $(deleteButton).parents('.comment-row, .pinned-comment-row').remove(); | ||
// updateNumerOfComments(); | ||
// }, | ||
// error: showXhrError.bind(undefined, "The comment couldn't be deleted: ") | ||
// }); | ||
//} | ||
Comment on lines
+49
to
+63
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Feel free to delete the code completely. This way the diff statistics tell use how many lines of custom code we avoided. |
||
|
||
function updateComment(form) { | ||
const textElement = form.text; | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ use Test::Most; | |
use FindBin; | ||
use lib "$FindBin::Bin/lib", "$FindBin::Bin/../external/os-autoinst-common/lib"; | ||
require OpenQA::Test::Database; | ||
use OpenQA::Test::TimeLimit '5'; | ||
use OpenQA::Test::TimeLimit '25'; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. As you bumped the timeout without any other changes it might be worth checking if/why the test is slow for you. Generally it should work unmodified |
||
use OpenQA::VcsProvider; | ||
use Test::Mojo; | ||
use Test::Warnings ':report_warnings'; | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,27 +15,33 @@ | |
<div class="well well-lg"> | ||
<form onsubmit="updateComment(this); return false;" onreset="hideCommentEditor(this); return true;" data-put-url="<%= url_for($put_action => ($context->{type}.'_id' => $context->{id}, comment_id => $comment_id)) %>"> | ||
% if (current_user && current_user->is_admin) { | ||
<button class="btn btn-danger btn-circle btn-sm remove-edit-button" type="button" name="removeComment" onclick="deleteComment(this);" data-author="<%= $user->name %>" data-delete-url="<%= url_for($delete_action => ($context->{type}.'_id' => $context->{id}, comment_id => $comment_id)) %>"> | ||
<i class="fa fa-fw fa-trash"></i> | ||
</button> | ||
% } | ||
% if (current_user && (current_user->id eq $user->id)) { | ||
<button class="btn btn-primary btn-circle btn-sm trigger-edit-button" type="button" name="editComment" onclick="showCommentEditor(this.form);"> | ||
<i class="fa fa-fw fa-pencil"></i> | ||
</button> | ||
% } | ||
<h4 class="media-heading"> | ||
% if($comment) { | ||
<%= $user->name %> wrote | ||
<a href="#comment-<%= $comment_id %>" class="comment-anchor"><abbr class="timeago" title="<%= $comment->t_created->datetime() %>Z"><%= format_time($comment->t_created) %></abbr></a> | ||
% if ($comment->t_updated->subtract(seconds => OpenQA::Constants::DB_TIMESTAMP_ACCURACY) >= $comment->t_created) { | ||
(last edited <abbr class="timeago" title="<%= $comment->t_updated->datetime() %>Z"><%= format_time($comment->t_updated) %></abbr>) | ||
% } | ||
<button | ||
class="btn btn-danger btn-circle btn-sm remove-edit-button" | ||
hx-delete="<%= url_for($delete_action => ($context->{type}.'_id' => $context->{id}, comment_id => $comment_id)) %>" | ||
hx-confirm="Do you really want to delete the comment written by <%= $user->name %>?" | ||
hx-target="closest .comment-row, .pinned-comment-row" | ||
hx-swap="outerHTML" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think we want to replace the target element with the response. We want to delete the target element - but of course only if the response was a 200 return code. We also need to decrement the number of comments shown in the tab header (if the comment is part of the test details page). I guess you've chosen a good example here. That is the case kind of simple case we might be able to use htmx for. However, if it turns out that even this simple case it too complicated we know that we probably don't want to use htmx. |
||
> | ||
<i class="fa fa-fw fa-trash"></i> | ||
</button> | ||
% } | ||
% if (current_user && (current_user->id eq $user->id)) { | ||
<button class="btn btn-primary btn-circle btn-sm trigger-edit-button" type="button" name="editComment" onclick="showCommentEditor(this.form);"> | ||
<i class="fa fa-fw fa-pencil"></i> | ||
</button> | ||
% } | ||
</h4> | ||
<div class="media-comment markdown"> | ||
% if($comment) { | ||
%= $comment->rendered_markdown | ||
<h4 class="media-heading"> | ||
% if($comment) { | ||
<%= $user->name %> wrote | ||
<a href="#comment-<%= $comment_id %>" class="comment-anchor"><abbr class="timeago" title="<%= $comment->t_created->datetime() %>Z"><%= format_time($comment->t_created) %></abbr></a> | ||
% if ($comment->t_updated->subtract(seconds => OpenQA::Constants::DB_TIMESTAMP_ACCURACY) >= $comment->t_created) { | ||
(last edited <abbr class="timeago" title="<%= $comment->t_updated->datetime() %>Z"><%= format_time($comment->t_updated) %></abbr>) | ||
% } | ||
% } | ||
</h4> | ||
<div class="media-comment markdown"> | ||
% if($comment) { | ||
%= $comment->rendered_markdown | ||
% } | ||
</div> | ||
% if (current_user && ((current_user->id eq $user->id))) { | ||
|
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.
What's the size of that file?
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.