-
-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft: Extend react app #320
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suggest to wrap it in content for
<% content_for(:javascripts) do %>
<%= webpacked_plugins_js_for :foreman_fog_proxmox %>
<%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm', "data-turbolinks-track" => true %>
<%= react_component('ProxmoxVmType', { vm_attributes: object_to_attributes_hash(f.object), nodes: nodes, images: images, pools: compute_resource.pools, from_profile: true, new_vm: new_vm, paramsScope: "#{f.object_name}"}) %>
<% end %>
@@ -14,6 +14,9 @@ GNU General Public License for more details. | |||
|
|||
You should have received a copy of the GNU General Public License | |||
along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |||
<%= webpacked_plugins_js_for :foreman_fog_proxmox %> | |||
<%= webpacked_plugins_css_for :foreman_fog_proxmox %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
webpacked_plugins_css_for is deprecated: webpacked_plugins_css_for
is deprecated, plugin css is already loaded.
<%= f.fields_for :config, compute_resource.new_typed_vm(object_to_config_hash(f.object, 'qemu'), 'qemu').config, include_id: false do |server_config|%> | ||
<%= render :partial => "compute_resources_vms/form/proxmox/server/config", :locals => { :f => server_config, :cloudinit => f.object.cloud_init?, :compute_resource => compute_resource, :host => @host, :new_vm => new_vm, :item_layout => 'removable', :type => f.object.type, :node_id => f.object.node_id } %> | ||
<%= webpacked_plugins_js_for :foreman_fog_proxmox %> | ||
<%= webpacked_plugins_css_for :foreman_fog_proxmox %> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also webpacked_plugins_css_for
is deprecated, plugin css is already loaded.
aa2fc47
to
b87d960
Compare
vm_h.merge!({key => {:name => "#{paramScope}[#{key}]", :value => value}}) | ||
end | ||
logger.warn("*********************8 interfaces #{vm.interfaces}") | ||
logger.warn("******************* net attrs #{network_attrs(paramScope, vm.interfaces)}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging?
vm_h.merge!({ :interfaces => network_attrs(paramScope, vm.interfaces) }) | ||
vm_h.merge!({:pool => {:name => "#{paramScope}[pool]", :value => vm.pool}}) | ||
vm_h.merge!({:cpu_type => {:name => "#{paramScope}[config_attributes][cpu_type]", :value => vm.config.cpu_type}}) | ||
vm_h.merge!({ :disks => volumes_attrs(paramScope, vm.volumes) }) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Would it be more readable to use []
instead of merge!()
(also for the other occurrences)?
vm_h.merge!({ :interfaces => network_attrs(paramScope, vm.interfaces) }) | |
vm_h.merge!({:pool => {:name => "#{paramScope}[pool]", :value => vm.pool}}) | |
vm_h.merge!({:cpu_type => {:name => "#{paramScope}[config_attributes][cpu_type]", :value => vm.config.cpu_type}}) | |
vm_h.merge!({ :disks => volumes_attrs(paramScope, vm.volumes) }) | |
vm_h[:interfaces] = network_attrs(paramScope, vm.interfaces) | |
vm_h[:pool] = { | |
name: "#{paramScope}[pool]", | |
value: vm.pool, | |
} | |
vm_h[:cpu_type] = { | |
name: "#{paramScope}[config_attributes][cpu_type]", | |
value: vm.config.cpu_type, | |
} | |
vm_h[:disks] = volumes_attrs(paramScope, vm.volumes) |
If not, we could reduce this to one bigger merge!()
since the keys do not seem to collide.
include ForemanFogProxmox::ProxmoxComputeAttributes | ||
# Convert a foreman form server hash into a fog-proxmox server attributes hash |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would expect rubocop to request at least one newline between require/include and the actual code.
interfaces = Hash[vm.config.interfaces.each_with_index.map do |interface, idx| | ||
[idx.to_s, interface_compute_attributes(interface.attributes)] | ||
end ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout looks off; probably because there is a tab on line 35 🤔
if vol.rootfs? | ||
keys = ['volid', 'storage', 'size'] | ||
type = 'rootfs' | ||
elsif vol.hard_disk? | ||
keys = ['id', 'volid', 'storage_type', 'storage', 'controller', 'device', 'cache', 'size'] | ||
type = 'hard_disk' | ||
elsif vol.cdrom? | ||
keys = ['id', 'storage_type', 'cdrom', 'storage', 'volid'] | ||
type = 'cdrom' | ||
elsif vol.cloudinit? | ||
keys = ['id', 'volid', 'storage_type', 'storage', 'controller', 'device'] | ||
type = 'cloudinit' | ||
elsif vol.mount_point? | ||
keys = ['id', 'volid', 'storage', 'device', 'mp', 'size'] | ||
type = 'mount_point' | ||
end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if this is nicer, but you should be able to do this in a case
-statement:
case vol
when :rootfs?.to_proc
keys = ['volid', 'storage', 'size']
type = 'rootfs'
when :hard_disk?.to_proc
...
@@ -15,9 +15,10 @@ GNU General Public License for more details. | |||
You should have received a copy of the GNU General Public License | |||
along with ForemanFogProxmox. If not, see <http://www.gnu.org/licenses/>. %> | |||
<% if @set.compute_resource.class == ForemanFogProxmox::Proxmox %> | |||
<% logger.warn("****************** compute attribute form #{f2} #{f2.object}")%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging!?
eslint.config.mjs
Outdated
export default [ | ||
{files: ["**/*.{js,mjs,cjs,jsx}"]}, | ||
{ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } }, | ||
{languageOptions: { globals: globals.browser }}, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
some inconsistent whitespaces around []
and {}
😉
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
do we have linting for this foreman_fog_proxmox project?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Had a look at the ruby-code, which looks good overall (though I had some minor nitpicks 😁 ).
@@ -0,0 +1,58 @@ | |||
import React, { useState, useEffect } from 'react'; | |||
import PropTypes from 'prop-types'; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You may drop that, if you are not defining the component's Parameter-types and -defaults.
I am not sure if it is strictly necessary, but I guess it is best-practice.
Defining it helps with finding unexpected property-types/-formats coming in 😁
setHdStorage(hdStorage); | ||
}; | ||
|
||
console.log('hdd key', { id }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should get rid of all debug output (console.log)
<%= webpacked_plugins_js_for :foreman_fog_proxmox %> | ||
<%= javascript_include_tag 'foreman_fog_proxmox/proxmox_vm', "data-turbolinks-track" => true %> | ||
<% end %> | ||
<%logger.warn("***********************8 i am here with host compute resource #{@host.compute_resource}")%> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
get rid of debug output
isDisabled={cloudInit} | ||
> | ||
{' '} | ||
Add Cloud-init{' '} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about translations?
<Table aria-label="Simple table" variant="compact"> | ||
<Thead> | ||
<Tr> | ||
<Th>Name</Th> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Translation
value: bridge.iface, | ||
label: bridge.iface, | ||
})); | ||
console.log('******************8 interface', network); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
debugging
cc180d3
to
8f86f79
Compare
No description provided.