theforeman / foreman_column_view

A simple Foreman plugin showcasing Deface for altering the Hosts view
GNU General Public License v3.0
23 stars 15 forks source link

Failure: undefined method `drop' for :bmc_available?:Symbol #27

Open matt-cahill opened 6 years ago

matt-cahill commented 6 years ago

Trying to set up a button in the host view that only appears for Mac machines, however whatever condition statement I try I get the same error.

Failure: undefined method `drop' for :bmc_available?:Symbol

  :ssh_to:
    :title: Remote Control
    :after: 2
    :content: link_to(_("SSH"), "ssh://admin@#{host.facts_hash['ipaddress']}", { :class => "btn btn-info" } )
    :conditional: :bmc_available?
    :eval_content: true
    :view: :hosts_properties

Foreman 1.15.3

Also any help on what my conditional should look like would be greatly appreciated.

:conditional: :facts_hash['kernel'] = Darwin

Many thanks

Matt

matt-cahill commented 6 years ago

I assume it's this method call:

https://github.com/GregSutcliffe/foreman_column_view/blob/706a2e06b5b261ff1328acbfc92406b47ebed811/app/helpers/foreman_column_view/hosts_helper_extension.rb#L18

has drop been replaced by something else?

GregSutcliffe commented 6 years ago

Hey, sorry for the delay.

drop only operates on an array, which is what it's expecting (as you can see for the line above where it calls conditional[0]). I'm surprised the default doesn't work though - can you try it as an array? eg

:ssh_to:
  :conditional:
    - :bmc_available?
danquack commented 6 years ago

I appear to be running into the same issue. Placing the conditional into an array didn't fix anything. Would you be able to provide documentation for how to specify the conditional?

olifre commented 4 years ago

On my end, the array syntax worked (but I got the same error when not using the array syntax). Here's my full snippet:

  :console:
    :title: IPMI Console
    :after: 0
    :content: link_to(_("Console"), "https://#{host.interfaces.first.name}", { :class => "btn btn-info" } )
    :conditional:
      - :bmc_available?
    :eval_content: true
    :view: :hosts_properties

Hope that helps!