Skip to content

Commit

Permalink
UI optimization and VMware model cleanup
Browse files Browse the repository at this point in the history
Hide SB & TPM options from the UI when they aren't relevant
and remove unnecessary methods from the VMware model.
  • Loading branch information
nofaralfasi committed Jul 18, 2024
1 parent adc3bc1 commit f15676b
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 25 deletions.
16 changes: 0 additions & 16 deletions app/models/compute_resources/foreman/model/vmware.rb
Original file line number Diff line number Diff line change
Expand Up @@ -761,22 +761,6 @@ def normalize_vm_attrs(vm_attrs)
normalized
end

def secure_boot
attrs[:secure_boot] ||= false
end

def secure_boot=(enabled)
attrs[:secure_boot] = ActiveRecord::Type::Boolean.new.cast(enabled)
end

def virtual_tpm
attrs[:virtual_tpm] ||= false
end

def virtual_tpm=(enabled)
attrs[:virtual_tpm] = ActiveRecord::Type::Boolean.new.cast(enabled)
end

private

def dc
Expand Down
19 changes: 10 additions & 9 deletions app/views/compute_resources_vms/form/vmware/_base.html.erb
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<%= text_f f, :memory_mb, :class => "col-md-2", :label => _("Memory (MB)") %>
<%= field(f, :firmware, :label => _('Firmware'), :label_size => "col-md-2") do
compute_resource.firmware_types.collect do |type, name|
radio_button_f f, :firmware, {:disabled => !new_vm, :value => type, :text => _(name)}
radio_button_f f, :firmware, {:disabled => !new_vm, :value => type, :text => _(name), :onchange => 'tfm.computeResource.vmware.onFirmwareChange(this)'}
end.join(' ').html_safe
end %>
<%= selectable_f f, :cluster, compute_resource.clusters, { :include_blank => _('Please select a cluster') },
Expand Down Expand Up @@ -49,15 +49,16 @@ end %>
{ :disabled => images.empty?, :label => _('Image'), :label_size => "col-md-2" } %>
</div>

<%= checkbox_f f, :secure_boot, { :help_inline => _("Enable Secure Bott for provisioning."),
:label => _('Secure Boot'),
:label_size => "col-md-2",
:disabled => !new_vm } %>
<!-- # Only EFI firmware supports Secure Boot and virtual TPM. -->
<div id='efi_features' <%= 'class=hide' unless new_vm && f.object.firmware == 'efi' %>>
<%= checkbox_f f, :secure_boot, { :help_inline => _("Enable Secure Boot for provisioning."),
:label => _('Secure Boot'),
:label_size => "col-md-2" } %>
<%= checkbox_f f, :virtual_tpm, { :help_inline => _("Add Virtual TPM module to the VM."),
:label => _('Virtual TPM'),
:label_size => "col-md-2",
:disabled => !new_vm } %>
<%= checkbox_f f, :virtual_tpm, { :help_inline => _("Add Virtual TPM module to the VM."),
:label => _('Virtual TPM'),
:label_size => "col-md-2" } %>
</div>

<%= compute_specific_js(compute_resource, "nic_info") %>
Expand Down
7 changes: 7 additions & 0 deletions webpack/assets/javascripts/compute_resource/vmware.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,3 +83,10 @@ function fetchNetworks(url, clusterId) {
},
});
}

export function onFirmwareChange(item) {
const selected = $(item).val();
const inputs = $('#efi_features');

Check warning on line 89 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 14)

You have a misspelled word: efi on String

Check warning on line 89 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 18)

You have a misspelled word: efi on String

Check warning on line 89 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 14)

You have a misspelled word: efi on String

Check warning on line 89 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 18)

You have a misspelled word: efi on String

inputs.toggleClass('hide', selected !== 'efi');

Check warning on line 91 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 14)

You have a misspelled word: efi on String

Check warning on line 91 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 2.7, 18)

You have a misspelled word: efi on String

Check warning on line 91 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 14)

You have a misspelled word: efi on String

Check warning on line 91 in webpack/assets/javascripts/compute_resource/vmware.js

View workflow job for this annotation

GitHub Actions / test (13, 3.0, 18)

You have a misspelled word: efi on String
}

0 comments on commit f15676b

Please sign in to comment.