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

WIP Evaluate viability of using HTMX #5913

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

r-richardson
Copy link
Contributor

@r-richardson r-richardson changed the title WIP WIP Evaluate viability of using HTMX Sep 9, 2024
@r-richardson r-richardson reopened this Sep 9, 2024
Copy link
Contributor

@Martchus Martchus left a comment

Choose a reason for hiding this comment

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

I guess this is a good showcase. We can discuss it in one of the next meetings.

@@ -164,6 +164,9 @@
! job_next_previous.js
< javascripts/job_next_previous.js

! htmx.js
< ../node_modules/htmx.org/dist/htmx.js
Copy link
Contributor

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?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

160K	./htmx.js
52K	./htmx.min.js
16K	./htmx.min.js.gz

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"
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

Comment on lines +49 to +63
//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: ")
// });
//}
Copy link
Contributor

Choose a reason for hiding this comment

The 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.

@@ -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';
Copy link
Member

Choose a reason for hiding this comment

The 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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants