-
Notifications
You must be signed in to change notification settings - Fork 357
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 Ansible related inputs to GOD haml #5166
Conversation
@ZitaNemeckova Cannot apply the following label because they are not recognized: automation/ |
@miq-bot add_label pending core |
12e13f4
to
e8f8885
Compare
@miq-bot remove_label wip, pending core |
if (vm.customButtonRecordId) { | ||
vm.newRecord = false; | ||
miqService.sparkleOn(); | ||
dataPromise = API.get('/api/custom_buttons/' + vm.customButtonRecordId + '?attributes=resource_action,uri_attributes') |
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.
this won't work - you're setting dataPromise
after you use it in $q.all
, so we never wait for this one.
But.. looks like no part of this request depends on anything from the options request, right? (I mean to make the request, not to process the response.)
So, maybe something like...
var optionsPromise = API.options('/api/custom_buttons')
.then(function(response) {
_.forEach(response.data.custom_button_types, function(name, id) {
vm.button_types.push({id: id, name: name});
});
});
if (vm.customButtonRecordId) {
vm.newRecord = false;
//miqService.sparkleOn(); - see second coment
var dataPromise = API.get('/api/custom_buttons/' + vm.customButtonRecordId + '?attributes=resource_action,uri_attributes');
.then(getCustomButtonFormData) // getCustomButtonFormData already waits for optionsPromise inside
.catch(miqService.handleFailure);
} else {
vm.newRecord = true;
vm.modelCopy = angular.copy( vm.customButtonModel );
}
?
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, since we're always waiting for some responses,
we should probably sparkleOn
every time (not only with id), and sparkleOff
in the big $q.all
block.
@@ -258,8 +283,14 @@ function mainCustomButtonFormController(API, miqService, $q, $http) { | |||
vm.customButtonModel.attribute_names, | |||
vm.customButtonModel.attribute_values); | |||
|
|||
if(vm.customButtonModel.uri_attributes.hosts == undefined || vm.customButtonModel.uri_attributes.hosts === "localhost" || vm.customButtonModel.uri_attributes.hosts == null) { |
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.
missing spaces after if, and before { on line 288
also, no point testing both vm.customButtonModel.uri_attributes.hosts == undefined
and vm.customButtonModel.uri_attributes.hosts == null
. Those are exactly the same thing without ===
.
(And this should really be just if (!vm.customButtonModel.uri_attributes.hosts || vm.customButtonModel.uri_attributes.hosts === 'localhost')
.. comparing against null or undefined is usually not what you want :).
@@ -243,7 +267,8 @@ function mainCustomButtonFormController(API, miqService, $q, $http) { | |||
|
|||
vm.genericObjectDefinitionRecordId = response.applies_to_id; | |||
|
|||
optionsPromise.then(function() { | |||
vm.customButtonModel.uri_attributes = response.uri_attributes; | |||
|
|||
if (vm.customButtonModel.current_visibility === 'role') { |
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.
bad indent for this whole block? (246..262 in original)
app/views/static/generic_object/main_custom_button_form.html.haml
Outdated
Show resolved
Hide resolved
5d52a94
to
9c82507
Compare
@miq-bot add_label changelog/yes |
@himdel please re-review, thanks :) |
Sure, but fix the miq-bot error please? :) |
app/assets/javascripts/components/generic_object/main-custom-button-form.js
Outdated
Show resolved
Hide resolved
%label.control-label.col-md-2 | ||
= _("Inventory") | ||
.col-md-8 | ||
%input{:type => "radio", :id => "inventory_localhost", :value => "localhost", 'ng-model' => 'vm.inventory'} |
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 now have those 3 options in:
app/views/static/generic_object/main_custom_button_form.html.haml
44: = label_tag('inventory_localhost', _("Localhost"), "title" => _('Run on localhost'))
47: = label_tag('inventory_event_target', _("Target Machine"), "title" => _('Run on the target of the Policy Event'))
50: = label_tag(_("Specific Hosts"))
app/views/shared/_playbook_options.html.haml
24: = label_tag('inventory_localhost', _("Localhost"), "title" => _('Run on localhost'))
29: = label_tag('inventory_event_target', _("Target Machine"), "title" => _('Run on the target of the Policy Event'))
34: = label_tag('inventory_manual', _("Specific Hosts"), "title" => _('Enter a comma separated list of IP or DNS names'))
app/views/miq_policy/_action_options.html.haml
341: = label_tag('inventory_localhost', _("Localhost"), "title" => _('Run on localhost'))
347: = label_tag('inventory_event_target', _("Target Machine"), "title" => _('Run on the target of the Policy Event'))
353: = label_tag('inventory_manual', _("Specific Hosts"), "title" => _('Enter a comma separated list of IP or DNS names'))
Time for a partial, I think ;)
EDIT: never mind, the other 2 are non-angular ..
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, the inputs are missing name="inventory"
. Otherwise, you have 3 unrelated radio buttons, instead of one radio button group (it probably works anyway because they do share the same ng-model).
app/views/static/generic_object/main_custom_button_form.html.haml
Outdated
Show resolved
Hide resolved
app/views/static/generic_object/main_custom_button_form.html.haml
Outdated
Show resolved
Hide resolved
9c82507
to
abda080
Compare
abda080
to
285c611
Compare
Checked commits ZitaNemeckova/manageiq-ui-classic@38e6ad7~...285c611 with ruby 2.3.3, rubocop 0.69.0, haml-lint 0.20.0, and yamllint 1.10.0 **
|
Remove unused id Fix bad ids and bad intent Move dataPromise out of OptionsPromise because they don't depend on each other
@himdel This is ready for another review :) |
@romanblanco could you test/have a look at this one, please? |
@miq-bot assign @romanblanco |
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.
Tested, works 👍
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1650559
Go to Automation -> Automate -> Generic Object -> create or edit a button -> select Button type to be Ansible Playbook
Depends on ManageIQ/manageiq#18379
Before:
After:
Ansible Catalog Item is required!
@miq-bot add_label wip, bug, hammer/yes, gaprindashvili/yes, generic objects, automation/
automate