From 7d6dafef6d3cf938cfa8976cec9ad49079b4cd21 Mon Sep 17 00:00:00 2001 From: Nick Clemens Date: Wed, 20 May 2026 17:24:17 +0000 Subject: [PATCH] Bug 42656: Improve file transport test display This patch displays the directory tested in the background jobs results It updates the language when test results are not stored for the transport and links to the job when results are stored To test: 1 - Setup an ftp file transport with good credentials 2 - Enter non-existent directories in incoming/outgoing 3 - Save 4 - Verify on save 'Never used' shows for status 5 - Refresh the page, status now: Connection ok Change directory ok Change directory failed Change directory ok Change directory failed 6 - Apply patch, restart all 7 - Edit/save the transport again, change nothing 8 - Confirm the page says 'No test results stored' 9 - Reload the page 10 - Confirm results are now: Connection ok Change directory ok Change directory failed Change directory ok Change directory failed Test job details 11 - Click on the job details link 12 - Confirm actual directory and errors are shown 13 - Edit the transport, use existing directories 14 - Save, reload 15 - Confirm the success results and link t background job Signed-off-by: John Vinke Signed-off-by: Martin Renvoize Signed-off-by: Pedro Amorim --- Koha/BackgroundJob/TestTransport.pm | 5 +++- Koha/File/Transport/FTP.pm | 9 +++--- .../background_jobs/file_transport_test.inc | 30 +++++++++++-------- .../prog/en/modules/admin/file_transports.tt | 12 +++++--- 4 files changed, 34 insertions(+), 22 deletions(-) diff --git a/Koha/BackgroundJob/TestTransport.pm b/Koha/BackgroundJob/TestTransport.pm index 72e67314e7..54b5b720bb 100644 --- a/Koha/BackgroundJob/TestTransport.pm +++ b/Koha/BackgroundJob/TestTransport.pm @@ -53,7 +53,10 @@ sub process { my $transport = Koha::File::Transports->find( $args->{transport_id} ); $transport->test_connection; - my $status = { status => 'ok' }; + my $status = { + status => 'ok', transport_id => $transport->id, transport_name => $transport->name, + background_job_id => $self->id + }; my $messages = $transport->object_messages; for my $message (@$messages) { $status->{status} = 'errors' if $message->{type} eq 'error'; diff --git a/Koha/File/Transport/FTP.pm b/Koha/File/Transport/FTP.pm index 6a5e775f63..b045977954 100644 --- a/Koha/File/Transport/FTP.pm +++ b/Koha/File/Transport/FTP.pm @@ -157,7 +157,7 @@ sub _change_directory { my ( $self, $remote_directory ) = @_; my $operation = "change_directory"; - $self->{connection}->cwd($remote_directory) or return $self->_abort_operation($operation); + $self->{connection}->cwd($remote_directory) or return $self->_abort_operation( $operation, $remote_directory ); $self->add_message( { @@ -396,15 +396,16 @@ C_abort_operation($operation)> on failure. =cut sub _abort_operation { - my ( $self, $operation ) = @_; + my ( $self, $operation, $operation_params ) = @_; $self->add_message( { message => $operation || 'operation', type => 'error', payload => { - detail => $self->{connection} ? $self->{connection}->status : '', - error => $self->{connection} ? $self->{connection}->message : $@ + detail => $self->{connection} ? $self->{connection}->status : '', + error => $self->{connection} ? $self->{connection}->message : $@, + operation_params => $operation_params } } ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/file_transport_test.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/file_transport_test.inc index 02940554f0..4ed7f7beaa 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/file_transport_test.inc +++ b/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/file_transport_test.inc @@ -3,29 +3,30 @@ [%- BLOCK operation_description -%] [%- SWITCH operation.code -%] + [%- IF operation.error %][% SET status = " failed. " %][% ELSE %][% SET status = " passed. " %][% END -%] [%- CASE 'connection' -%] - Connection + Connection[% status | html %] [%- CASE 'upload' -%] - Upload + Upload[% status | html %] [%- CASE 'download' -%] - Download + Download[% status | html %] [%- CASE 'list' -%] - List files + List files[% status | html %] [%- CASE 'change_directory' -%] - Change directory + Change directory ([% operation.detail.directory | html %][% operation.detail.operation_params | html %])[% status | html %] [%- CASE -%] - [% operation.code | html %] + [% operation.code | html %][% status | html %] [%- END -%] [%- END -%] [% SET report = job.decoded_data %] [% BLOCK report %] [% IF job.status == 'finished' %] - [% IF report.status == 'errors' %] -
Connection test completed with errors
- [% ELSE %] -
Connection test completed without errors
- [% END %] + [%- IF report.status == 'errors' -%] +
Connection test for [% report.transport_name | html %]([% report.transport_id | html %]) completed with errors
+ [%- ELSE -%] +
Connection test for [% report.transport_name | html %]([% report.transport_id | html %]) completed without errors
+ [%- END -%] [% ELSIF job.status == 'cancelled' %] The connection test was cancelled before it finished. [% END %] @@ -34,9 +35,12 @@ [% BLOCK detail %] [% FOREACH operation IN report.operations %] [% IF operation.status == 'error' %] -
[% PROCESS operation_description %] failed.
+
+ [% PROCESS operation_description %] + [%- IF operation.detail.error %]- error:[% operation.detail.error | html %][% END -%]
[% ELSE %] -
[% PROCESS operation_description %] passed.
+
[% PROCESS operation_description %]
[% END %] [% END %] [% IF job.status == 'cancelled' %] diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/file_transports.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/file_transports.tt index 6dab8dbcb3..f7e914709b 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/file_transports.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/file_transports.tt @@ -567,10 +567,10 @@ let render = ""; if (data) { if (data.status == "ok") { - render += ' '; + render += '
'; render += ''; render += _("Tests passing"); - render += ""; + render += "
"; } else if (data.status == "errors") { data.operations.forEach(operation => { render += "
"; @@ -590,10 +590,14 @@ render += "
"; }); } else { - render += "" + _("Never used") + ""; + render += "" + _("No test results stored") + ""; + } + if (data.background_job_id) { + render += ' '; + render += '' + _("Test job details") + ""; } } else { - render += "" + _("Never used") + ""; + render += "" + _("No test results stored") + ""; } return render; },