'vrts-run-queue', 'plural' => 'vrts-run-queues', 'ajax' => false, ]); } /** * Get table classes. */ public function get_table_classes() { return [ 'vrts-test-runs-list-table', 'vrts-test-runs-list-queue-table', 'widefat', 'fixed', $this->_args['plural'] ]; } /** * Message to show if no designation found. * * @return void */ public function no_items() { printf( /* translators: %1$s, %2$s link wrapper. */ esc_html__( 'No Runs in the queue. %1$sAdd Tests%2$s to get started.', 'visual-regression-tests' ), '', '' ); } /** * Get the column names. * * @return array */ public function get_columns() { $columns = [ 'cb' => '', 'title' => esc_html__( 'Title', 'visual-regression-tests' ), 'trigger' => esc_html__( 'Trigger', 'visual-regression-tests' ), 'status' => esc_html__( 'Test Status', 'visual-regression-tests' ), ]; return $columns; } /** * Gets the list of views available on this table. * * @return array */ public function get_views() { $base_link = Url_Helpers::get_page_url( 'runs' ); $links = [ 'all' => [ 'title' => esc_html__( 'Queue', 'visual-regression-tests' ), 'link' => $base_link, 'count' => count( Test_Run::get_queued_items() ), ], ]; $status_links = []; // phpcs:ignore WordPress.Security.NonceVerification.Recommended -- It's status request. $filter_status_query = ( isset( $_REQUEST['status'] ) ? sanitize_text_field( wp_unslash( $_REQUEST['status'] ) ) : 'all' ); foreach ( $links as $key => $link ) { $current_class = ( $filter_status_query === $key ? 'class="current" ' : '' ); $link = sprintf( '%s (%s)', $current_class, $link['link'], $link['title'], $link['count'] ); $status_links[ $key ] = $link; } return $status_links; } /** * Prepare the class items * * @return void */ public function prepare_items() { $columns = $this->get_columns(); $hidden = []; $sortable = $this->get_sortable_columns(); $this->_column_headers = [ $columns, $hidden, $sortable ]; $this->items = Test_Run::get_queued_items(); } /** * Generates content for a single row of the table. * * @param object|array $item The current item. */ public function single_row( $item ) { $classes = 'iedit'; $status = Test_Run::get_calculated_status( $item ); ?>
%3$s
', esc_attr( $item->trigger ), esc_html( $trigger_title ), $trigger_note ); } /** * Render the status column. * * @param object $item column item. * * @return string */ public function column_status( $item ) { $test_run_status = Test_Run::get_calculated_status( $item ); $number_of_tests = count( maybe_unserialize( $item->tests ) ?? [] ); if ( 0 === $number_of_tests ) { $number_of_tests = Test::get_all_running( true ); } if ( 'running' === $test_run_status ) { $class = 'waiting'; $text = ''; $instructions = sprintf( '%s', sprintf( // translators: %1$s: link start to test runs page. %2$s: link end to test runs page. wp_kses( __( '%1$sRefresh page%2$s to see results', 'visual-regression-tests' ), [ 'a' => [ 'href' => [] ] ] ), '', '' ) ); } else { $class = 'waiting'; $text = esc_html__( 'Pending', 'visual-regression-tests' ); $instructions = sprintf( '%2$s | %4$s', // translators: %s: number of tests. esc_url( Url_Helpers::get_page_url( 'tests' ) ), sprintf( /* translators: %s Test. Test count */ esc_html( _n( '%s Test', '%s Tests', $number_of_tests, 'visual-regression-tests' ) ), $number_of_tests ), esc_url( Url_Helpers::get_page_url( 'settings' ) ), esc_html__( 'Edit configuration', 'visual-regression-tests' ) ); }//end if return sprintf( '