diff --git a/app/assets/javascripts/components/cloud_volume_backup/cloud-volume-backup-form.js b/app/assets/javascripts/components/cloud_volume_backup/cloud-volume-backup-form.js index 968421ff743..fd90b54d2ba 100644 --- a/app/assets/javascripts/components/cloud_volume_backup/cloud-volume-backup-form.js +++ b/app/assets/javascripts/components/cloud_volume_backup/cloud-volume-backup-form.js @@ -17,6 +17,7 @@ function cloudVolumeBackupFormController(miqService, $http) { vm.cloudVolumeBackupModel = { volume: '', + name: '', }; vm.model = 'cloudVolumeBackupModel'; diff --git a/app/controllers/cloud_volume_backup_controller.rb b/app/controllers/cloud_volume_backup_controller.rb index d4416e664d0..02111b7cbef 100644 --- a/app/controllers/cloud_volume_backup_controller.rb +++ b/app/controllers/cloud_volume_backup_controller.rb @@ -42,7 +42,10 @@ def backup_restore cancel_action(_("Restore to Cloud Volume \"%{name}\" was cancelled by the user") % {:name => @backup.name}) when "restore" - task_id = @backup.restore_queue(session[:userid], params[:volume][:ems_ref]) + # volume_id to restore to is optional + volume_id = params[:volume].try(:fetch, :ems_ref, nil) + new_volume_name = params[:name] + task_id = @backup.restore_queue(session[:userid], volume_id, new_volume_name) if task_id.kind_of?(Integer) initiate_wait_for_task(:task_id => task_id, :action => "backup_restore_finished") diff --git a/app/views/static/cloud_volume_backup/volume_select.html.haml b/app/views/static/cloud_volume_backup/volume_select.html.haml index ad85d45739c..b78482de6fc 100644 --- a/app/views/static/cloud_volume_backup/volume_select.html.haml +++ b/app/views/static/cloud_volume_backup/volume_select.html.haml @@ -11,11 +11,19 @@ %label.col-md-2.control-label = _('Volume') .col-md-8 - = select_tag('volume_id', - '', - 'ng-model' => 'vm.cloudVolumeBackupModel.volume', - 'ng-options' => 'volume.name for volume in vm.volume_choices track by volume.id', - :required => '', - 'miq-select' => true) + %select{"name" => "volume_id", + "ng-model" => "vm.cloudVolumeBackupModel.volume", + "ng-options" => "volume.name for volume in vm.volume_choices track by volume.id", + "miq-select" => true} + %option{"value" => ""} + = "<#{_('New Volume')}>" + .form-group{"ng-if" => "vm.cloudVolumeBackupModel.volume == null"} + %label.col-md-2.control-label + = _('New Volume Name') + .col-md-8 + %input.form-control{:type => "text", + :name => "name", + 'ng-model' => "vm.cloudVolumeBackupModel.name", + 'ng-maxlength' => 128} = render :partial => 'layouts/angular/generic_form_buttons' diff --git a/spec/javascripts/components/cloud_volume_backup/cloud_volume_backup_form_spec.js b/spec/javascripts/components/cloud_volume_backup/cloud_volume_backup_form_spec.js index 2ba40084ec8..3d151fc1446 100644 --- a/spec/javascripts/components/cloud_volume_backup/cloud_volume_backup_form_spec.js +++ b/spec/javascripts/components/cloud_volume_backup/cloud_volume_backup_form_spec.js @@ -24,6 +24,7 @@ describe('cloud-volume-backup-form', function() { describe('#init', function() { var expectedValue = { volume: { name: "original value" }, + name: '' }; it('sets model correctly', function() {