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

Add option to restart jobs upon comment submission #5971

Merged
merged 2 commits into from
Nov 7, 2024

Conversation

b10n1k
Copy link
Contributor

@b10n1k b10n1k commented Oct 2, 2024

Refactor restartJob in order to make sure that is able to handle request for
multiple restarts. This follows up with some changes to the form and the
javascript part of the overview.html.ep, which triggers the restart with the
use of restartJob, as opposed of reimplement the logic.
The advantage is that we have one common behavior and error handling on the
restart operation.

  • An optional comment can be passed not to restartJob, which is included to
    the request.

  • restartJob handles both single and multible job restarts.

  • The form is designed to handle each occasion in separate functions making
    the code becomes more modular and easier to maintain.

  • The overvies's restartJobs function will restart only jobs with valid id.- Renamed addComments to bulkJobsAction to handle both commenting and restarting jobs.

  • Updated HTML to include "Restart and Comment" and "Comment" buttons with individual data URLs.

These updates enhance the user experience by allowing users to either comment on jobs, or perform restart with a comment simultaneously from the overview page. Comments always add to the original job of the overview page. By integrating this functionality we provide a workflow for users managing multiple jobs on the overview page.

https://progress.opensuse.org/issues/166559

@b10n1k

This comment was marked as outdated.

@okurz

This comment was marked as resolved.

okurz

This comment was marked as resolved.

@b10n1k b10n1k force-pushed the batch_restart_with_comment branch 2 times, most recently from 7d7f709 to e886fd5 Compare October 3, 2024 12:12
Copy link

codecov bot commented Oct 3, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.98%. Comparing base (ebe44db) to head (29fdf01).
Report is 15 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #5971   +/-   ##
=======================================
  Coverage   98.98%   98.98%           
=======================================
  Files         395      395           
  Lines       39417    39428   +11     
=======================================
+ Hits        39017    39028   +11     
  Misses        400      400           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

okurz

This comment was marked as resolved.

@b10n1k

This comment was marked as resolved.

assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
@b10n1k
Copy link
Contributor Author

b10n1k commented Oct 7, 2024

please describe the relation to

The difference between this PR and the previews is that the old PR solves the problem integrating the logic in the Comments.pm passing parameters in the underline function.
It was requested to implement the solution using the Job.pm. This is not the case in this PR though.

@Martchus
Copy link
Contributor

Martchus commented Oct 7, 2024

You could base your PR on #5981 but it looks like I'll have to put a little bit more work into it (as CI checks are currently failing).

@b10n1k b10n1k force-pushed the batch_restart_with_comment branch 2 times, most recently from dd44e25 to e188f9e Compare October 14, 2024 10:03
@b10n1k
Copy link
Contributor Author

b10n1k commented Oct 14, 2024

UPDATED screenshot

**
image
**

okurz

This comment was marked as resolved.

@b10n1k b10n1k force-pushed the batch_restart_with_comment branch 2 times, most recently from 7577c7e to c07da9d Compare October 14, 2024 19:21
@b10n1k

This comment was marked as resolved.

okurz

This comment was marked as resolved.

t/ui/10-tests_overview.t Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
@b10n1k
Copy link
Contributor Author

b10n1k commented Oct 23, 2024

Some comments on 717e152

  • Review commit message for main changes
  • not sure if we prefer to rename the restartJob in openqa.js
  • not sure if we prefer to provide a link for reload as it is for comments submittion. I went with auto reload for now
  • I havent writen any additional tests as for now, other than the ones from the previous commit

@kalikiana

This comment was marked as resolved.

@b10n1k b10n1k removed the not-ready label Oct 24, 2024
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/openqa.js Outdated Show resolved Hide resolved
assets/javascripts/openqa.js Outdated Show resolved Hide resolved
assets/javascripts/openqa.js Outdated Show resolved Hide resolved
Comment on lines 291 to 290
setTimeout(() => {
window.location.reload();
}, 2000);
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
setTimeout(() => {
window.location.reload();
}, 2000);
setTimeout(() => window.location.reload(), 2000);

Although I don't like this whole approach of first adding an info to only reload the whole page 2 seconds later anyway. I would rather not reload the page automatically and change the info to "Changes have been applied. You may reload the page." where "reload" is a link that will reload the page. This way the info contains more useful information and one has more than 2 seconds to read it.

Copy link
Member

Choose a reason for hiding this comment

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

What's the benefit of having time to read that a reload is required? Why not just reload right away?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I changed to the manual reload with a similar text as it is for comments

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 see that this has been updated. As-is it looks like you still can't decide whether to reload the page or show a notification.

I suggest to show a notification. Only this way it is apparent that the operation was actually successful. Otherwise the page is just reloading but the user has to interpret this behavior as success - which is not ideal in my opinion. The notification should also explicitly list of jobs that have actually been successfully restarted so one can easily go though the list to access them if wanted. It can of course also include a link for reloading the page.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My mistake. I did the changes but I revert the file in some point after experiment with the progress bar. I have to check again that your previews comments are also here.

assets/javascripts/overview.js Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
assets/javascripts/overview.js Outdated Show resolved Hide resolved
subtest "job template names displayed on 'Test result overview' page" => sub {
$driver->get('/group_overview/1002');
is($driver->find_element('.progress-bar-unfinished')->get_text(),
'1 unfinished', 'The number of unfinished jobs is right');
Copy link
Contributor

Choose a reason for hiding this comment

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

We normally start test names with lower case. You can also drop the "is right" in the end which is kind of a given for checks:

Suggested change
'1 unfinished', 'The number of unfinished jobs is right');
'1 unfinished', 'expected number of unfinished jobs');

EDIT: I now see that you're just moving this code. My suggestion would nevertheless be a good improvement.

Copy link
Member

Choose a reason for hiding this comment

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

@b10n1k How about this one?

Copy link
Member

Choose a reason for hiding this comment

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

Not changed in the latest diff. Ofc you can argue that you don't want to change it. Be explicit, though, rather than leaving questions unanswered.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

t/ui/10-tests_overview.t Outdated Show resolved Hide resolved
Copy link

Great PR! Please pay attention to the following items before merging:

Files matching assets/stylesheets/**:

  • Consider providing screenshots in a PR comment to show the difference visually

This is an automatically generated QA checklist based on modified files.

Comment on lines 291 to 290
setTimeout(() => {
window.location.reload();
}, 2000);
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 see that this has been updated. As-is it looks like you still can't decide whether to reload the page or show a notification.

I suggest to show a notification. Only this way it is apparent that the operation was actually successful. Otherwise the page is just reloading but the user has to interpret this behavior as success - which is not ideal in my opinion. The notification should also explicitly list of jobs that have actually been successfully restarted so one can easily go though the list to access them if wanted. It can of course also include a link for reloading the page.

assets/stylesheets/overview.scss Outdated Show resolved Hide resolved
t/ui/10-tests_overview.t Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
templates/webapi/test/overview.html.ep Outdated Show resolved Hide resolved
@b10n1k b10n1k force-pushed the batch_restart_with_comment branch 3 times, most recently from 9f9268d to 43d628b Compare November 1, 2024 07:15
@perlpunk

This comment was marked as resolved.

assets/javascripts/openqa.js Outdated Show resolved Hide resolved
@b10n1k b10n1k force-pushed the batch_restart_with_comment branch 2 times, most recently from 779a2fd to 2346d98 Compare November 1, 2024 13:04
- Renamed `addComments` to `restartOrCommentJobs` to handle both commenting and
restarting jobs.
- Added button-specific actions using `form.clickedButton`.
- Updated `fetchWithCSRF` logic to dynamically determine request URLs based on
the button clicked.
- Introduced separate success and error messages for restarting and commenting
actions.
- Updated HTML to include "Restart and Comment" and "Comment" buttons with
individual API endpoints via formaction. That removes action attribute from
the form element.
- Let "comments" be `btn-warning` and "restart" show more severe operation
using `btn-danger`.
- Adjusted modal to allow submission of comments or restarts through the
correct action handlers.
- Inform overview page with warning in case of errors in Response.
- Redesign `restartOrCommentJobs` (previews addComments) to reflect the new
features.

These updates enhance the user experience by allowing users to either comment
on jobs, or perform restart with a comment simultaneously from the
overview page. Comments always add to the original job of the overview
page. By integrating this functionality we provide a workflow for
users managing multiple jobs on the overview page using the already existing
API implementations.

https://progress.opensuse.org/issues/166559

Signed-off-by: Ioannis Bonatakis <[email protected]>
@okurz

This comment was marked as resolved.

@b10n1k

This comment was marked as resolved.

@perlpunk

This comment was marked as resolved.

assets/javascripts/overview.js Outdated Show resolved Hide resolved
Refactor restartJob in order to make sure that is able to handle request for
multiple restarts. This follows up with some changes to the form and the
javascript part of the overview.html.ep, which triggers the restart with the
use of restartJob, as opposed of reimplement the logic.
The advantage is that we have one common behavior and error handling on the
restart operation.

- An optional comment can be passed not to restartJob, which is included to
the request.
- restartJob handles both single and multible job restarts.
- The form is designed to handle each occasion in separate functions making
the code becomes more modular and easier to maintain.
- The overvies's restartJobs function will restart only jobs with valid id.

https://progress.opensuse.org/issues/166559

Signed-off-by: Ioannis Bonatakis <[email protected]>
@mergify mergify bot merged commit 25b7bc0 into os-autoinst:master Nov 7, 2024
46 checks passed
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.

5 participants