ManageIQ / manageiq-providers-cisco_intersight

ManageIQ provider for Cisco Intersight
Apache License 2.0
2 stars 15 forks source link

[WIP]: Added SupportsFeatures functionality to the overridden toolbar #65

Closed ghost closed 1 year ago

ghost commented 2 years ago

This PR is going to add SupportFeatures functionality for Decommission and Recommission buttons when viewing a specific physical server; meaning: If a server doesn't fulfill a criteria for either being decommissioned or recommissioned, the user should not have the ability to press it (it shouldn't be enabled).

With the current changes of this PR, the button still looks like this:

image

as you can see, Recommission as well as Decommission buttons may be pressed, which is not what I want.

I've written the "supports" sentences for server's recommission and decommission (with the first commit in this PR: https://github.com/ManageIQ/manageiq-providers-cisco_intersight/commit/2bbb626adaefc8aef716bacf0c81111f40c91244) but got stuck at actually using this functionality in the actual button - I want to use this changes in this file; more specifically, in this file, changes should most likely come in the following two places:

more precisely, I assume buttons' values :enabled and :options should have been changes, but I don't know how.

Any help would be greatly appreciated. Thanks.

ghost commented 2 years ago

@kavyanekkalapu, would you maybe know why the button mentioned above does not consider SuportFeature-s and still lets the user click on both Recommission and Decommission fields?

miq-bot commented 2 years ago

Checked commit https://github.com/tjazsch/manageiq-providers-cisco_intersight/commit/2bbb626adaefc8aef716bacf0c81111f40c91244 with ruby 2.6.9, rubocop 1.19.1, haml-lint 0.35.0, and yamllint 1 file checked, 1 offense detected

app/models/manageiq/providers/cisco_intersight/physical_infra_manager/physical_server.rb

agrare commented 2 years ago

@jeffibm can you help @tjazsch with getting the buttons mentioned above to use supports feature? Thanks!

And @tjazsch you'll want to add supports_not :decommission to the base class (https://github.com/ManageIQ/manageiq/blob/master/app/models/physical_server.rb) so that we can ask supports?(:decommission) of any type of physical_server

jeffibm commented 2 years ago

@tjazsch , For buttons I found something like this - For example, in manageiq-ui-classic - app/helpers/application_helper/toolbar/service_center.rb, we have a helper method specified in :Klass which also decides to enable/disable this button based on its return value. Its definitions can be found in app/helpers/application_helper/button/service_retire_now.rb

button(
           :service_retire_now,
           'fa fa-clock-o fa-lg',
           t = N_('Retire this Service'),
           t,
           :confirm => N_("Retire this Service?"),
           :klass   => ApplicationHelper::Button::ServiceRetireNow
         ),
agrare commented 2 years ago

@jeffibm I don't think that button class is right for this case

agrare commented 2 years ago

@tjazsch take a look at https://github.com/ManageIQ/manageiq-ui-classic/blob/master/app/helpers/application_helper/button/volume_attach.rb as an example of a button using supports?(:feature)

jeffibm commented 2 years ago

As i understand, to check if decommission / recommission methods are supported, we need to use like below in corresponding classes. I am also not sure if this is related to db/fixtures/miq_product_features.yml in manageiq(core).

def disabled?
    if !@record.supports?(:decommission)
      @error_message = _("Error message")
    end
    @error_message.present?
  end
miq-bot commented 1 year ago

This pull request has been automatically marked as stale because it has not been updated for at least 3 months.

If these changes are still valid, please remove the stale label, make any changes requested by reviewers (if any), and ensure that this issue is being looked at by the assigned/reviewer(s)

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.

miq-bot commented 1 year ago

This pull request has been automatically closed because it has not been updated for at least 3 months.

Feel free to reopen this pull request if these changes are still valid.

Thank you for all your contributions! More information about the ManageIQ triage process can be found in the triage process documentation.