diff --git a/app/views/dashboard/index.html.erb b/app/views/dashboard/index.html.erb index 07028728..93559880 100644 --- a/app/views/dashboard/index.html.erb +++ b/app/views/dashboard/index.html.erb @@ -5,9 +5,9 @@
- <%= render 'widget', {vms: @vms, id: 'vms_active', header: 'Active machines', buttons: nil} %> - <%= render 'widget', {vms: @archivable, id: 'vms_to_be_archived', header: 'Archivable Machines', buttons: 'vms/archive_buttons'} %> - <%= render 'widget', {vms: @revivable, id: 'vms_to_be_revived', header: 'Revivable Machines', buttons: 'vms/to_revive_buttons'} %> + <%= render 'widget', {vms: @vms, id: 'vms_active', header: 'Active VMs', buttons: nil} %> + <%= render 'widget', {vms: @archivable, id: 'vms_to_be_archived', header: 'Archivable VMs', buttons: nil} %> + <%= render 'widget', {vms: @revivable, id: 'vms_to_be_revived', header: 'Revivable VMs', buttons: nil} %>
diff --git a/app/views/vms/_vm_status.html.erb b/app/views/vms/_running_vm_buttons.erb similarity index 51% rename from app/views/vms/_vm_status.html.erb rename to app/views/vms/_running_vm_buttons.erb index d62ca254..8ef0ea29 100644 --- a/app/views/vms/_vm_status.html.erb +++ b/app/views/vms/_running_vm_buttons.erb @@ -1,17 +1,16 @@ -
<% if current_user.admin? || vm.sudo_users.include?(current_user) %> <% if vm.vm_ware_tools? %> <%= link_to '', {controller: :vms, action: 'change_power_state', id: vm.name}, method: :post, - data: { confirm: 'Are you sure?' }, - class: "btn-manage float-right #{ vm.powered_on? ? 'stop' : 'play' }" %> + data: {confirm: "Are you sure you want to #{ vm.powered_on? ? 'stop' : 'start' } '#{vm.name}'?"}, + class: "btn-manage float-right fa #{ vm.powered_on? ? 'fa-stop' : 'fa-play' }" %> <% if vm.powered_on? %> <%= link_to '', {controller: :vms, action: 'reboot_guest_os', id: vm.name}, method: :post, - data: { confirm: 'Are you sure?' }, - class: "btn-manage float-right replay" %> + data: {confirm: "Are you sure you want to reboot the guest OS of '#{vm.name}'?"}, + class: "btn-manage float-right fa fa-repeat" %> <% end %> <% end %> -<% end %> +<% end %> \ No newline at end of file diff --git a/app/views/vms/_table.erb b/app/views/vms/_table.erb index aefde473..f43c82f1 100644 --- a/app/views/vms/_table.erb +++ b/app/views/vms/_table.erb @@ -1,9 +1,13 @@ > - + + - + + <% unless buttons.nil? %> + + <% end %> @@ -11,10 +15,14 @@ <% vms&.slice(0...10)&.each do |vm| %> + + <% unless buttons.nil? %> + + <% end %> diff --git a/app/views/vms/_vm_confirmations.erb b/app/views/vms/_vm_confirmations.erb new file mode 100644 index 00000000..e69de29b diff --git a/app/views/vms/index.html.erb b/app/views/vms/index.html.erb index f2e6d14d..82d2fa6e 100644 --- a/app/views/vms/index.html.erb +++ b/app/views/vms/index.html.erb @@ -9,7 +9,7 @@ -<%= render 'section', {header: 'Active vms', id: 'active', vms: @vms, buttons: nil} %> -<%= render 'section', {header: 'To be archived vms', id: 'to_be_archived', vms: @pending_archivation_vms, buttons: 'archive_buttons'} %> -<%= render 'section', {header: 'To be revived vms', id: 'to_be_revived', vms: @pending_reviving_vms, buttons: 'to_revive_buttons'} %> -<%= render 'section', {header: 'Archived vms', id: 'archived', vms: @archived_vms, buttons: 'revive_buttons'} %> \ No newline at end of file +<%= render 'section', {header: 'Active VMs', id: 'active', vms: @vms, buttons: 'running_vm_buttons'} %> +<%= render 'section', {header: 'Archivable VMs', id: 'to_be_archived', vms: @pending_archivation_vms, buttons: 'archive_buttons'} %> +<%= render 'section', {header: 'Revivable VMs', id: 'to_be_revived', vms: @pending_reviving_vms, buttons: 'to_revive_buttons'} %> +<%= render 'section', {header: 'Archived VMs', id: 'archived', vms: @archived_vms, buttons: 'revive_buttons'} %> \ No newline at end of file diff --git a/spec/views/vms/index.html.erb_spec.rb b/spec/views/vms/index.html.erb_spec.rb index abc9c8df..c77f2db0 100644 --- a/spec/views/vms/index.html.erb_spec.rb +++ b/spec/views/vms/index.html.erb_spec.rb @@ -51,11 +51,11 @@ end it 'shows correct power on / off button' do - expect(rendered).to have_css('a.btn-manage.play') + expect(rendered).to have_css('a.fa-play') end it 'demands confirmation on shutdown' do - expect(rendered).to have_css('a.btn-manage[data-confirm="Are you sure?"]') + expect(rendered).to have_css 'a.btn-manage[data-confirm]' end context 'when vmwaretools are not installed' do @@ -65,16 +65,16 @@ it 'shows no power buttons' do rendered = render - expect(rendered).not_to have_css('a.btn-manage.play') - expect(rendered).not_to have_css('a.btn-manage.stop') + expect(rendered).not_to have_css('a.fa-play') + expect(rendered).not_to have_css('a.fa-stop') end end end context 'when the user is not a root user for the vms' do it 'does not show any manage buttons' do - expect(rendered).not_to have_css('a.btn-manage.play') - expect(rendered).not_to have_css('a.btn-manage.stop') + expect(rendered).not_to have_css('a.fa-play') + expect(rendered).not_to have_css('a.fa-stop') end end @@ -98,24 +98,18 @@ let(:current_user) { FactoryBot.create :admin } it 'shows correct power on / off button' do - expect(rendered).to have_css('a.btn-manage.play') + expect(rendered).to have_css('a.fa-play') end it 'demands confirmation on shutdown' do - expect(rendered).to have_css('a.btn-manage[data-confirm="Are you sure?"]') + expect(rendered).to have_css('a.btn-manage[data-confirm]') end - context 'when vmwaretools are not installed' do - before do - assign(:vms, mock_vms_without_tools) - render - end - - it 'shows no power buttons' do - rendered = render - expect(rendered).not_to have_css('a.btn-manage.play') - expect(rendered).not_to have_css('a.btn-manage.stop') - end + it 'shows no power buttons when vmwaretools are not installed' do + assign(:vms, mock_vms_without_tools) + rendered = render + expect(rendered).not_to have_css('a.fa-play') + expect(rendered).not_to have_css('a.fa-stop') end it 'links to new vm page' do
NameStatusName ProjectResponsibleResponsibleActionsDescription
- <%= render 'vms/vm_status', vm: vm %> + <% vm.powered_on? %> +

<%= vm.archived? ? 'archived' : vm.powered_on? ? 'online' : 'offline' %>

+
+
<%= link_to vm.name, {controller: :vms, action: 'show', id: vm.name}, - method: :get, class: "btn btn-link" %> + method: :get, class: "btn btn-link" %> <% if vm.project.nil? %> @@ -33,11 +41,12 @@ <% end %> <% end %> - - <% unless buttons.nil? %> - <%= render buttons.to_s, vm: vm %> - <% end %> + <%= render buttons.to_s, vm: vm %> + <%= vm.config&.description %>