Skip to content

Commit

Permalink
Merge pull request ManageIQ#12637 from borod108/bugs/1384517snapshot_…
Browse files Browse the repository at this point in the history
…desc_req

Require a description when creating Snapshot
  • Loading branch information
agrare authored Nov 17, 2016
2 parents 1738663 + 06c8bc3 commit d643265
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
26 changes: 17 additions & 9 deletions app/controllers/vm_common.rb
Original file line number Diff line number Diff line change
Expand Up @@ -558,6 +558,20 @@ def snap
end
alias_method :vm_snapshot_add, :snap

def render_missing_field(session, missing_field_name)
add_flash(_("%{missing_field_name} is required") %
{:missing_field_name => missing_field_name}, :error)
@in_a_form = true
drop_breadcrumb(:name => _("Snapshot VM '%{name}'") % {:name => @record.name},
:url => "/vm_common/snap")
if session[:edit] && session[:edit][:explorer]
@edit = session[:edit] # saving it to use in next transaction
javascript_flash(:spinner_off => true)
else
render :action => "snap"
end
end

def snap_vm
@vm = @record = identify_record(params[:id], VmOrTemplate)
if params["cancel"] || params[:button] == "cancel"
Expand All @@ -573,15 +587,9 @@ def snap_vm
@name = params[:name]
@description = params[:description]
if params[:name].blank? && !@record.try(:snapshot_name_optional?)
add_flash(_("Name is required"), :error)
@in_a_form = true
drop_breadcrumb(:name => _("Snapshot VM '%{name}'") % {:name => @record.name}, :url => "/vm_common/snap")
if session[:edit] && session[:edit][:explorer]
@edit = session[:edit] # saving it to use in next transaction
javascript_flash(:spinner_off => true)
else
render :action => "snap"
end
render_missing_field(session, "Name")
elsif params[:description].blank? && @record.try(:snapshot_description_required?)
render_missing_field(session, "Description")
else
flash_error = false
# audit = {:event=>"vm_genealogy_change", :target_id=>@record.id, :target_class=>@record.class.base_class.name, :userid => session[:userid]}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,10 @@ def snapshot_name_optional?
true
end

def snapshot_description_required?
true
end

def validate_remove_all_snapshots
{:available => false, :message => _("Removing all snapshots is currently not supported")}
end
Expand Down

0 comments on commit d643265

Please sign in to comment.