Link to single files from the list table
This commit is contained in:
parent
06aaed23d9
commit
e17654226a
|
@ -61,6 +61,15 @@ class File {
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the name of the file, with extension, but without full path.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_basename() {
|
||||
return basename( $this->path );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the file's source property.
|
||||
*
|
||||
|
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
namespace Automattic\WooCommerce\Internal\Admin\Logging\FileV2;
|
||||
|
||||
use Automattic\WooCommerce\Internal\Admin\Logging\PageController;
|
||||
|
||||
use WP_List_Table;
|
||||
|
||||
/**
|
||||
|
@ -18,11 +20,17 @@ class ListTable extends WP_List_Table {
|
|||
*/
|
||||
private $file_controller;
|
||||
|
||||
/**
|
||||
* @var PageController
|
||||
*/
|
||||
private $page_controller;
|
||||
|
||||
/**
|
||||
* ListTable class.
|
||||
*/
|
||||
public function __construct( FileController $file_controller ) {
|
||||
public function __construct( FileController $file_controller, PageController $page_controller ) {
|
||||
$this->file_controller = $file_controller;
|
||||
$this->page_controller = $page_controller;
|
||||
|
||||
parent::__construct(
|
||||
array(
|
||||
|
@ -170,7 +178,20 @@ class ListTable extends WP_List_Table {
|
|||
* @return string
|
||||
*/
|
||||
public function column_source( $item ) {
|
||||
return $item->get_source();
|
||||
$log_file = sanitize_title( $item->get_basename() );
|
||||
$single_file_url = add_query_arg(
|
||||
array(
|
||||
'view' => 'single_file',
|
||||
'log_file' => $log_file,
|
||||
),
|
||||
$this->page_controller->get_logs_tab_url()
|
||||
);
|
||||
|
||||
return sprintf(
|
||||
'<a href="%1$s">%2$s</a>',
|
||||
$single_file_url,
|
||||
$item->get_source()
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -183,7 +204,7 @@ class ListTable extends WP_List_Table {
|
|||
public function column_created( $item ) {
|
||||
$timestamp = $item->get_created_timestamp();
|
||||
|
||||
return date( 'Y-m-d H:i:s', $timestamp );
|
||||
return date( 'Y-m-d', $timestamp );
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -48,6 +48,21 @@ class PageController {
|
|||
self::add_action( 'load-woocommerce_page_wc-status', array( $this, 'setup_screen_options' ) );
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the canonical URL for the Logs tab of the Status admin page.
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function get_logs_tab_url() {
|
||||
return add_query_arg(
|
||||
array(
|
||||
'page' => 'wc-status',
|
||||
'tab' => 'logs',
|
||||
),
|
||||
admin_url( 'admin.php' )
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine the default log handler.
|
||||
*
|
||||
|
@ -144,7 +159,7 @@ class PageController {
|
|||
return $this->list_table;
|
||||
}
|
||||
|
||||
$this->list_table = new ListTable( $this->file_controller );
|
||||
$this->list_table = new ListTable( $this->file_controller, $this );
|
||||
|
||||
return $this->list_table;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue