-
Notifications
You must be signed in to change notification settings - Fork 900
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
Add dynamic dropdown list support for orchestration service dialog #12693
Add dynamic dropdown list support for orchestration service dialog #12693
Conversation
@bzwei This is the change that I need in order to continue #12273. Although I thought I resolved the blocking issue in #12570, it turned out that the latter actually filled the values at the time of dialog creation. This means that if the underlying networks have changed in VMware vCloud, the list of networks available in the dropdown would not be updated. That's why I introduced another constraint type that only sets the automate method which will then dynamically fill the dropdown, when shown. I understand this kind of change might be difficult to accept, but I hope we can do it somehow. Let me know if improvements are needed. /cc @agrare This is the one I mentioned yesterday in the call. |
dropdown = parameter.constraints.detect { |c| c.kind_of? OrchestrationTemplate::OrchestrationParameterAllowed } | ||
checkbox = parameter.constraints.detect { |c| c.kind_of? OrchestrationTemplate::OrchestrationParameterBoolean } unless dropdown | ||
end | ||
if dropdown | ||
if dynamic_dropdown |
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.
we may write something like
if parameter.contrains
dynamic_dropdown = parameter.constaints.detect ...
return create_parameter_dynamic_dropdown_list(...) if dynamic_dropdown
dropdown = ...
return create_parameter_dropdown_list(...) if dropdown
checkbox = ...
return create_parameter_checkbox(...) if checkbox
end
create_parameter_text_field(...)
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.
Thanks for the suggestion @bzwei!
b1674ab
to
bb28408
Compare
<pr_mergeability_checker />This pull request is not mergeable. Please rebase and repush. |
bb28408
to
4e32ab1
Compare
@miq-bot add_label euwe/no |
@@ -0,0 +1,5 @@ | |||
class OrchestrationTemplate | |||
class OrchestrationParameterFqname < OrchestrationParameterConstraint |
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.
OrchestrationParameterAllowedDynamic
is a better name. There are other dynamic types of controls that we may add in the future.
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 you think the attr_accessor fqname
should also be renamed? I had a bit of a problem with choosing the proper name. fqname
is used in the resource_action
of the dialog field.
Patch is updated with the suggested name change.
This patchs adds a new orchestration template parameter constraint referencing the required method from the automate. Contrary to stack parameters of the orchestration template service dialog where dynamic dropdowns are supported via `resource_actions`. However, for additional template parameters, the values for the presented dropdowns are created using a static list of values (static at the time of dialog creation). With this patch, it is possible to construct a parameter whose allowed values are retrieved when the dialog is opened, i.e. when the user wants to order the orchestration service. The patch is required in order to allow the VMware vCloud provider to create dropdowns for the available networks that can be set for each VM that is part of the vApp template (orchestration template). Signed-off-by: Gregor Berginc <[email protected]>
4e32ab1
to
788d12f
Compare
Checked commit xlab-si@788d12f with ruby 2.2.5, rubocop 0.37.2, and haml-lint 0.16.1 app/services/orchestration_template_dialog_service.rb
spec/services/orchestration_template_dialog_service_spec.rb
|
@@ -0,0 +1,5 @@ | |||
class OrchestrationTemplate | |||
class OrchestrationParameterAllowedDynamic < OrchestrationParameterConstraint | |||
attr_accessor :fqname |
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.
fqname
is fine to me.
@bzwei ready to merge? |
👍 |
Great job @gberginc |
This patchs adds a new orchestration template parameter constraint
referencing the required method from the automate. Contrary to stack
parameters of the orchestration template service dialog where dynamic
dropdowns are supported via
resource_actions
. However, for additionaltemplate parameters, the values for the presented dropdowns are created
using a static list of values (static at the time of dialog creation).
With this patch, it is possible to construct a parameter whose allowed
values are retrieved when the dialog is opened, i.e. when the user wants
to order the orchestration service.
The patch is required in order to allow the VMware vCloud provider to
create dropdowns for the available networks that can be set for each VM
that is part of the vApp template (orchestration template).
@miq-bot add_label orchestration, ui, enhancement