From 7eee6cd2d5c66d543fcc14e9a87b8b6b411d0794 Mon Sep 17 00:00:00 2001 From: Alexis Reigel Date: Tue, 17 Jul 2018 09:59:45 +0200 Subject: [PATCH] convert admin runners table to responsive table --- app/views/admin/runners/_runner.html.haml | 127 +++++++++++++--------- app/views/admin/runners/index.html.haml | 29 +++-- spec/features/admin/admin_runners_spec.rb | 24 ++-- 3 files changed, 100 insertions(+), 80 deletions(-) diff --git a/app/views/admin/runners/_runner.html.haml b/app/views/admin/runners/_runner.html.haml index 43937b01339..7d4cf4d32c3 100644 --- a/app/views/admin/runners/_runner.html.haml +++ b/app/views/admin/runners/_runner.html.haml @@ -1,51 +1,78 @@ -%tr{ id: dom_id(runner) } - %td - - if runner.instance_type? - %span.badge.badge-success shared - - elsif runner.group_type? - %span.badge.badge-success group - - else - %span.badge.badge-info specific - - if runner.locked? - %span.badge.badge-warning locked - - unless runner.active? - %span.badge.badge-danger paused - - %td - = link_to admin_runner_path(runner) do - = runner.short_sha - %td - = runner.description - %td - = runner.version - %td - = runner.ip_address - %td - - if runner.instance_type? || runner.group_type? - n/a - - else - = runner.projects.count(:all) - %td - #{runner.builds.count(:all)} - %td - - runner.tag_list.sort.each do |tag| - %span.badge.badge-primary - = tag - %td - - if runner.contacted_at - = time_ago_with_tooltip runner.contacted_at - - else - Never - %td.admin-runner-btn-group-cell - .float-right.btn-group - = link_to admin_runner_path(runner), class: 'btn btn-sm btn-default has-tooltip', title: 'Edit', ref: 'tooltip', aria: { label: 'Edit' }, data: { placement: 'top', container: 'body'} do - = icon('pencil') -   - - if runner.active? - = link_to [:pause, :admin, runner], method: :get, class: 'btn btn-sm btn-default has-tooltip', title: 'Pause', ref: 'tooltip', aria: { label: 'Pause' }, data: { placement: 'top', container: 'body', confirm: "Are you sure?" } do - = icon('pause') +.gl-responsive-table-row{ id: dom_id(runner) } + .table-section.section-10 + .table-mobile-header{ role: "rowheader" } Type + .table-mobile-content + - if runner.instance_type? + %span.badge.badge-success shared + - elsif runner.group_type? + %span.badge.badge-success group - else - = link_to [:resume, :admin, runner], method: :get, class: 'btn btn-default btn-sm has-tooltip', title: 'Resume', ref: 'tooltip', aria: { label: 'Resume' }, data: { placement: 'top', container: 'body'} do - = icon('play') - = link_to [:admin, runner], method: :delete, class: 'btn btn-danger btn-sm has-tooltip', title: 'Remove', ref: 'tooltip', aria: { label: 'Remove' }, data: { placement: 'top', container: 'body', confirm: "Are you sure?" } do - = icon('remove') + %span.badge.badge-info specific + - if runner.locked? + %span.badge.badge-warning locked + - unless runner.active? + %span.badge.badge-danger paused + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Runner token + .table-mobile-content + = link_to runner.short_sha, admin_runner_path(runner) + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Description + .table-mobile-content + = runner.description + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Version + .table-mobile-content + = runner.version + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } IP Address + .table-mobile-content + = runner.ip_address + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Projects + .table-mobile-content + - if runner.instance_type? || runner.group_type? + n/a + - else + = runner.projects.count(:all) + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Jobs + .table-mobile-content + = runner.builds.count(:all) + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Tags + .table-mobile-content + - runner.tag_list.sort.each do |tag| + %span.badge.badge-primary + = tag + + .table-section.section-10 + .table-mobile-header{ role: 'rowheader' } Last contact + .table-mobile-content + - if runner.contacted_at + = time_ago_with_tooltip runner.contacted_at + - else + Never + + .table-section.table-button-footer.section-10 + .btn-group.table-action-buttons + .btn-group + = link_to admin_runner_path(runner), class: 'btn btn-default has-tooltip', title: 'Edit', ref: 'tooltip', aria: { label: 'Edit' }, data: { placement: 'top', container: 'body'} do + = icon('pencil') + .btn-group + - if runner.active? + = link_to [:pause, :admin, runner], method: :get, class: 'btn btn-default has-tooltip', title: 'Pause', ref: 'tooltip', aria: { label: 'Pause' }, data: { placement: 'top', container: 'body', confirm: "Are you sure?" } do + = icon('pause') + - else + = link_to [:resume, :admin, runner], method: :get, class: 'btn btn-default has-tooltip', title: 'Resume', ref: 'tooltip', aria: { label: 'Resume' }, data: { placement: 'top', container: 'body'} do + = icon('play') + .btn-group + = link_to [:admin, runner], method: :delete, class: 'btn btn-danger has-tooltip', title: 'Remove', ref: 'tooltip', aria: { label: 'Remove' }, data: { placement: 'top', container: 'body', confirm: "Are you sure?" } do + = icon('remove') diff --git a/app/views/admin/runners/index.html.haml b/app/views/admin/runners/index.html.haml index e3d2587b8e5..de2ebd595db 100644 --- a/app/views/admin/runners/index.html.haml +++ b/app/views/admin/runners/index.html.haml @@ -92,24 +92,21 @@ %br - if @runners.any? - .runners-content + .runners-content.content-list .table-holder - %table.table - %thead - %tr - %th Type - %th Runner token - %th Description - %th Version - %th IP Address - %th Projects - %th Jobs - %th Tags - %th Last contact - %th + .gl-responsive-table-row.table-row-header{ role: 'row' } + .table-section.section-10{ role: 'rowheader' } Type + .table-section.section-10{ role: 'rowheader' } Runner token + .table-section.section-10{ role: 'rowheader' } Description + .table-section.section-10{ role: 'rowheader' } Version + .table-section.section-10{ role: 'rowheader' } IP Address + .table-section.section-10{ role: 'rowheader' } Projects + .table-section.section-10{ role: 'rowheader' } Jobs + .table-section.section-10{ role: 'rowheader' } Tags + .table-section.section-10{ role: 'rowheader' } Last contact - - @runners.each do |runner| - = render "admin/runners/runner", runner: runner + - @runners.each do |runner| + = render "admin/runners/runner", runner: runner = paginate @runners, theme: "gitlab" - else .nothing-here-block No runners found diff --git a/spec/features/admin/admin_runners_spec.rb b/spec/features/admin/admin_runners_spec.rb index de530eea10a..1363228cac3 100644 --- a/spec/features/admin/admin_runners_spec.rb +++ b/spec/features/admin/admin_runners_spec.rb @@ -99,26 +99,22 @@ describe "Admin Runners", :js do visit admin_runners_path - within '.runners-content tbody' do - within('tr:nth-child(1)') do - expect(page).to have_content 'runner-2' - end + within '.runners-content .gl-responsive-table-row:nth-child(2)' do + expect(page).to have_content 'runner-2' + end - within('tr:nth-child(2)') do - expect(page).to have_content 'runner-1' - end + within '.runners-content .gl-responsive-table-row:nth-child(3)' do + expect(page).to have_content 'runner-1' end sorting_by 'Last Contact' - within '.runners-content tbody' do - within('tr:nth-child(1)') do - expect(page).to have_content 'runner-1' - end + within '.runners-content .gl-responsive-table-row:nth-child(2)' do + expect(page).to have_content 'runner-1' + end - within('tr:nth-child(2)') do - expect(page).to have_content 'runner-2' - end + within '.runners-content .gl-responsive-table-row:nth-child(3)' do + expect(page).to have_content 'runner-2' end end end