Skip to content

Commit

Permalink
Memory checkbox will not show when VM is not up
Browse files Browse the repository at this point in the history
When creating a snapshot there is not reason to show
the option to save runtime memory if the VM is down.

https://bugzilla.redhat.com/show_bug.cgi?id=1375850
  • Loading branch information
borod108 committed Nov 21, 2016
1 parent eaf5abc commit de813a1
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,7 @@ def snap
@name = @description = ""
@in_a_form = true
@button_group = "snap"
@show_snapshot_memory_checkbox = show_snapshot_memory_checkbox?(@vm)
drop_breadcrumb(:name => _("Snapshot VM '%{name}''") % {:name => @record.name},
:url => "/vm_common/snap",
:display => "snapshot_info")
Expand All @@ -566,6 +567,11 @@ def render_missing_field(session, missing_field_name)
end
end

def show_snapshot_memory_checkbox?(vm)
return true unless vm.respond_to?(:snapshotting_memory_allowed?)
vm.snapshotting_memory_allowed?
end

def snap_vm
@vm = @record = identify_record(params[:id], VmOrTemplate)
if params["cancel"] || params[:button] == "cancel"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ def allowed_to_revert?
current_state == 'off'
end

def snapshotting_memory_allowed?
current_state == 'on'
end

private

def with_snapshots_service(vm_uid_ems)
Expand Down
2 changes: 1 addition & 1 deletion app/views/vm_common/_snap.html.haml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
= _('Description')
.col-md-8
= text_area_tag("description", @description, :size => "50x4")
.form-group
%div{:class => "form-group #{@show_snapshot_memory_checkbox ? "" : "hidden"}"}
%label.control-label.col-md-2
= _('Snapshot VM memory')
.col-md-8
Expand Down

0 comments on commit de813a1

Please sign in to comment.