Bug 29020 - Missing Background jobs link in admin-home
Summary: Missing Background jobs link in admin-home
Status: REOPENED
Alias: None
Product: Koha
Classification: Unclassified
Component: System Administration (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Tomás Cohen Arazi
URL:
Keywords: Manual
: 29141 29178 (view as bug list)
Depends on: 22417
Blocks: 29178
  Show dependency treegraph
 
Reported: 2021-09-14 17:27 UTC by Caroline Cyr La Rose
Modified: 2021-12-01 03:15 UTC (History)
8 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Text to go in the release notes:
Version(s) released in:
21.11.00


Attachments
Bug 29020: Add link on the mainpage for users without admin access (6.35 KB, patch)
2021-10-08 13:58 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29020: Add link on the admin module (2.14 KB, patch)
2021-10-08 13:58 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29020: Add link on the mainpage for users without admin access (6.34 KB, patch)
2021-10-08 16:01 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 29020: Add link on the mainpage for users without admin access (6.34 KB, patch)
2021-10-08 16:03 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 29020: Add link on the admin module (2.40 KB, patch)
2021-10-08 16:03 UTC, Caroline Cyr La Rose
Details | Diff | Splinter Review
Bug 29020: Add link on the mainpage for users without admin access (6.40 KB, patch)
2021-10-18 15:06 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review
Bug 29020: Add link on the admin module (2.46 KB, patch)
2021-10-18 15:06 UTC, Tomás Cohen Arazi
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Caroline Cyr La Rose 2021-09-14 17:27:49 UTC
Hello!

There is currently no way to access the Background jobs page other than typing in the URL in the address bar of the navigator.

Caroline
Comment 1 David Cook 2021-09-30 03:29:18 UTC
*** Bug 29141 has been marked as a duplicate of this bug. ***
Comment 2 Jonathan Druart 2021-10-04 14:48:19 UTC
I haven't done it in the first iteration because it's a bit tricky.

A user who enqueued a job should be able to access to page, and view their jobs.

Should we have the view available for any staff users? Only those with admin access?

Otherwise we need to list the permissions of the different pages that allow background jobs. But I don't like this solution.
Comment 3 Caroline Cyr La Rose 2021-10-04 15:19:52 UTC
I think superlibrarians should be able to see all background jobs.

As for other users, could it be a permission? The other links in the Administration page or Tools page are all linked to permissions.

We could maybe emulate the items_batchmod and items_batchmod_restricted permissions?

background_jobs : access to all background jobs

background_jobs_restricted : access to background jobs limited to jobs started by user

? 

I'm not sure what appears in that page and what are the implications of having access to it (I don't even remember in what context I had to have access to it when I wrote this bug lol!). Can we stop background jobs from there? If that is the case, should we also have a permission to stop jobs? Or is that ability implied when having access to the page?
Comment 4 Jonathan Druart 2021-10-05 15:15:24 UTC
Tools that allow you to batch delete/edit/create will use the "background jobs" (also "task queue" sometimes) feature in a near (hopefully) future.

The goal is to process the job when the server can do it (and to not block the user, the job is enqueued and they don't need to care about it).


So any users with access to those tools (listed is short now, but will be extended later, even to plugins certainly) should have access to the list of jobs THEY enqueued (at the minimum).

I don't think it should be a permission, neither it should be linked to the permissions of the tools using the task queue (it's a list that we will need to keep up-to-date, and it will be tricky when it will be extended to plugins).

> Can we stop background jobs from there?

Yes, you can cancel a job, but only those you started (or you have the manage_background_jobs permission).

I am in favor of displaying a link to that page for any users with access to the staff interface.
Comment 5 Jonathan Druart 2021-10-05 15:16:12 UTC
(In reply to Jonathan Druart from comment #4)
> > Can we stop background jobs from there?
> 
> Yes, you can cancel a job, but only those you started (or you have the
> manage_background_jobs permission).

This is the theory, the code is wrong!

 64     if ( my $job = Koha::BackgroundJobs->find($id) ) { # FIXME Make sure logged in user can cancel this job
 65         $job->cancel;
 66     }

will fix separately.
Comment 6 Tomás Cohen Arazi 2021-10-08 13:32:46 UTC
I think we could have a 'Server status' entry in the main page, that could contain some information currently in the about.pl page about the running processes (e.g. ES/ status, indexed records, etc).

And that page could have some sections, one of them (the only one for now until we migrate things there) the background jobs. Displaying only the tasks the user is allowed to see, if any.
Comment 7 Jonathan Druart 2021-10-08 13:58:31 UTC
Created attachment 125964 [details] [review]
Bug 29020: Add link on the mainpage for users without admin access
Comment 8 Jonathan Druart 2021-10-08 13:58:35 UTC
Created attachment 125965 [details] [review]
Bug 29020: Add link on the admin module
Comment 9 Jonathan Druart 2021-10-08 14:01:30 UTC
I think those patches provide a good ergonomic to the two type of users.
Those with admin access will have the link in the admin module, the others will see a "background jobs" on the mainpage.

Test plan:
Have 2 users, one P1 with parameters > manage background jobs, the other P2 without.

Log in with P1: no link on the main page

Create a job with P1 (batch delete biblio records for instance).

Go to the main page => You see the link

Click => you have access to your jobs

Log in with P2, create a job

=> Nothing on the main page, P2 has access to the job from the admin module.
Comment 10 Jonathan Druart 2021-10-08 14:01:50 UTC
Feel free to provide an alternative patch.

Note that this patch also fixes bug 29178.
Comment 11 Caroline Cyr La Rose 2021-10-08 16:01:12 UTC
Created attachment 125980 [details] [review]
Bug 29020: Add link on the mainpage for users without admin access
Comment 12 Caroline Cyr La Rose 2021-10-08 16:03:50 UTC
Created attachment 125981 [details] [review]
Bug 29020: Add link on the mainpage for users without admin access
Comment 13 Caroline Cyr La Rose 2021-10-08 16:03:59 UTC
Created attachment 125982 [details] [review]
Bug 29020: Add link on the admin module

It works! P1 and P2 are inverted in the test plan, but
the principle that user with manage permission accesses
bg jobs from the admin page and user who do not only
have access through main page is there.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Comment 14 Jonathan Druart 2021-10-18 12:59:38 UTC
*** Bug 29178 has been marked as a duplicate of this bug. ***
Comment 15 Tomás Cohen Arazi 2021-10-18 15:06:33 UTC
Created attachment 126439 [details] [review]
Bug 29020: Add link on the mainpage for users without admin access

Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 16 Tomás Cohen Arazi 2021-10-18 15:06:40 UTC
Created attachment 126440 [details] [review]
Bug 29020: Add link on the admin module

It works! P1 and P2 are inverted in the test plan, but
the principle that user with manage permission accesses
bg jobs from the admin page and user who do not only
have access through main page is there.

Signed-off-by: Caroline Cyr La Rose <caroline.cyr-la-rose@inlibro.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Comment 17 Tomás Cohen Arazi 2021-10-18 15:11:55 UTC
This patches work as advertised and should be added to Koha.

I still think we need to polish the area a bit:
- If you ever run any 'background job' ("what are they? I just used the batch delete tool") you will see the link forever, in an area that is usually reserved for notifying required actions, forever.
- One posible placement could be the user account dropdown at the top, and always display. Showing an empty table if never ran any background job.
- Another option could be in the Tools area, same behavior of the empty table if never ran anything.

Those are my thoughts. That should be worked somewhere else. Passing QA. If I manage to provide alternate patches, it will be follow-ups to this.
Comment 18 David Cook 2021-10-18 22:15:11 UTC
(In reply to Tomás Cohen Arazi from comment #17)
> I still think we need to polish the area a bit:
> - If you ever run any 'background job' ("what are they? I just used the
> batch delete tool") 

Agreed. I think calling them "background jobs" is too developer focused and not user-friendly.
Comment 19 Jonathan Druart 2021-10-19 05:59:53 UTC
(In reply to David Cook from comment #18)
> (In reply to Tomás Cohen Arazi from comment #17)
> > I still think we need to polish the area a bit:
> > - If you ever run any 'background job' ("what are they? I just used the
> > batch delete tool") 
> 
> Agreed. I think calling them "background jobs" is too developer focused and
> not user-friendly.

Suggest then please. What about the placement?
We have a bug to rename it "tasks/task queue", is that  what you have in mind?
Comment 20 Jonathan Druart 2021-10-19 07:44:56 UTC
Pushed to master for 21.11, thanks to everybody involved!
Comment 21 Tomás Cohen Arazi 2021-10-19 11:50:39 UTC
(In reply to Jonathan Druart from comment #20)
> Pushed to master for 21.11, thanks to everybody involved!

Thank you for your hard work on the area. And sorry for the delays in the testing phase.
Comment 22 Liz Rea 2021-11-29 18:38:56 UTC
Hi, 

May we have this in the stable branches please?

Liz
Comment 23 Liz Rea 2021-11-29 18:39:21 UTC
or at least 20.05
Comment 24 David Cook 2021-12-01 03:15:29 UTC
(This is an aside not directly related to Koha, but I was thinking about this a little bit the other day, while working with Discourse. It uses Sidekiq (https://en.wikipedia.org/wiki/Sidekiq) for running it's background tasks. A top level administrator can just go to http://<discourse>/sidekiq to see everything related to background tasks. As far as I can tell, there's no link to sidekiq from Discourse, but it is handy for the administrators to be able to trigger and review jobs from there.)