Skip to content
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

Closed
wants to merge 0 commits into from
Closed

Conversation

Manisha15
Copy link
Contributor

No description provided.

@Manisha15 Manisha15 marked this pull request as draft May 6, 2024 08:10
@Manisha15 Manisha15 changed the title Extend react app Draft: Extend react app May 6, 2024
Copy link
Member

@MariaAga MariaAga left a 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 %>
Copy link
Member

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 %>
Copy link
Member

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.

@Manisha15 Manisha15 force-pushed the extend_react_app branch 2 times, most recently from aa2fc47 to b87d960 Compare June 21, 2024 12:55
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)}")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging?

Comment on lines 47 to 50
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) })
Copy link
Contributor

@m-bucher m-bucher Jul 11, 2024

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)?

Suggested change
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.

Comment on lines 25 to 26
include ForemanFogProxmox::ProxmoxComputeAttributes
# Convert a foreman form server hash into a fog-proxmox server attributes hash
Copy link
Contributor

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.

Comment on lines 34 to 36
interfaces = Hash[vm.config.interfaces.each_with_index.map do |interface, idx|
[idx.to_s, interface_compute_attributes(interface.attributes)]
end ]
Copy link
Contributor

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 🤔

Comment on lines 67 to 82
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
Copy link
Contributor

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}")%>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging!?

export default [
{files: ["**/*.{js,mjs,cjs,jsx}"]},
{ languageOptions: { parserOptions: { ecmaFeatures: { jsx: true } } } },
{languageOptions: { globals: globals.browser }},
Copy link
Contributor

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 {} 😉

Copy link
Contributor

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?

Copy link
Contributor

@m-bucher m-bucher left a 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';
Copy link
Contributor

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 });
Copy link
Contributor

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}")%>
Copy link
Contributor

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{' '}
Copy link
Contributor

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>
Copy link
Contributor

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);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants