-
Notifications
You must be signed in to change notification settings - Fork 356
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
UI for create and delete flavors #1818
Conversation
09521f3
to
ed37d81
Compare
%span.help-block{"ng-show" => "angularForm.rxtx_factor.$error.floatGreaterThanZero"} | ||
= _("RXTX factor must be greater than or equal to 0") | ||
|
||
= render :partial => "layouts/angular/x_edit_buttons_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.
You want generic_form_buttons
here instead .. those x_edit are for non-controllerAs controllers.
app/controllers/flavor_controller.rb
Outdated
assert_privileges('flavor_delete') | ||
checked = find_checked_items | ||
checked[0] = params[:id] if checked.blank? && params[:id] | ||
FlavorController.model.where(:id => checked).each do |flavor| |
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 should be find_records_with_rbac(model, checked_or_params)
, and you don't need to do the checked[0] = params[:id]
etc..
app/controllers/flavor_controller.rb
Outdated
end | ||
|
||
private | ||
|
||
def textual_group_list | ||
[%i(properties relationships), %i(tags)] | ||
[%i[properties relationships], %i[tags]] |
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.
Please change back to how it was.
app/controllers/flavor_controller.rb
Outdated
@@ -10,15 +10,59 @@ class FlavorController < ApplicationController | |||
include Mixins::GenericSessionMixin | |||
|
|||
def self.display_methods | |||
%w(instances) | |||
%w[instances] |
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.
Please change back to how it was.
var getBack = function(response) { | ||
var message = ''; | ||
var err = false; | ||
if (response.hasOwnProperty('results')) { |
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.
I guess the API really returns a 200 on error?
Can you perhaps separate this function into 2? (error and non-error) .. looks like this has too many if (! err)
all around, and could be more readable as 2 functions.
miqService.sparkleOff(); | ||
}; | ||
|
||
function getEmsFormDataComplete(response) { |
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.
You're changing the model here, but setForm
can already have been called in getManagerResource
.. I guess you want to wait for both requests to suceed before calling setForm
and sparkleOff
.
($q.all
is your friend :))
.then(getManagerResource) | ||
.catch(miqService.handleFailure); | ||
}; | ||
|
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 looks like you may be missing resetClicked
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.
Reset button is enabled when record is not new, flavor updating is not possible, for now I don`t need it.
return { | ||
require: 'ngModel', | ||
link: function(_scope, _elem, _attrs, ctrl) { | ||
ctrl.$validators.intGreaterThanZero = function(modelValue, viewValue) { |
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 should probably split these directives differently..
Right now, you have..
- is float && >0
- is int && >0
- is int && >= 0
This looks like it could better split as..
- is int
- is float
- is >0
- is >=0
.. and since we're using angular.validators
(https://github.com/gkaimakas/angular.validators) ...
- We already have
is-float
- We already have
is-int
input type=number min=0
already validates >= 0, but the only way to test a float for >0 would be step="0.01" + min="0.01", which may be undesirable .. but we can have agreaterThanZero
directive..input type=number min=0
already validates >= 0, unless you can't use an input type number, in which case we'd need a greaterOrZero as well.
@@ -1,4 +1,30 @@ | |||
class ApplicationHelper::Toolbar::FlavorsCenter < ApplicationHelper::Toolbar::Basic | |||
button_group('flavor_configuration', [ | |||
select( | |||
:aflavor_configuration_choice, |
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.
Atypo? :) Guessing this should be :flavor_configuration_choice
:)
ed37d81
to
d9f94cc
Compare
Thank you for review, @himdel ! Does it look better now? |
68921cd
to
e7d7bd2
Compare
@@ -0,0 +1,21 @@ | |||
ManageIQ.angular.app.directive('isFloat', function() { |
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 is a duplicate of angular validator's is-float
.
So I think you can just remove this file and it will work equally well ;)
@@ -0,0 +1,22 @@ | |||
ManageIQ.angular.app.directive('isInteger', function() { |
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.
Same here, is-integer
already exists in angular-validators ... except it is called is-int
;)
e7d7bd2
to
f0e5254
Compare
@alexander-demichev The code looks fine now (EDIT: except for |
Aah... indeed it does.. ManageIQ/manageiq#15552. @alexander-demichev for future reference, in such cases, you need to mention the PR in the description, and add a (I've also added info on where to look for those screens.) |
@himdel can you please review the cc issues, perhaps a few more can be addressed. |
b242cad
to
0b8e291
Compare
Changes look good to me, thanks! |
@himdel Martin, we need your help here.. thanks |
flavors = find_records_with_rbac(Flavor, checked_or_params) | ||
flavors.each do |flavor| | ||
begin | ||
flavor.delete_flavor_queue(User.current_user.id) |
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 shoud be done through the API, not here :-(
Oh, I see that @himdel agreed to get this fixed later... But we really need to stop doing that! |
Guys, these CC issues are easy to fix:
|
108e01b
to
2e771b5
Compare
The style issues seem okay to me - I think a few of the CC issues are still fixable though? |
ecd495b
to
1af8de3
Compare
1af8de3
to
f64713b
Compare
Checked commit alexander-demicev@f64713b with ruby 2.3.3, rubocop 0.47.1, and haml-lint 0.20.0 app/helpers/application_helper/toolbar/flavors_center.rb
|
@h-kataria Hi, can you take a look to this PR, it's close to be resolved. |
@alexander-demichev is the chaining issue in cc fixable? |
@tzumainn I don't know, didn't find any examples in other controllers/directives. |
@alexander-demichev you're right, this does seem to match the existing code. Okay, nevermind! |
looks like most comments/concerns have been addressed, merging. |
Oh my! Gentleman and ladies, https://github.com/ManageIQ/manageiq-ui-classic/pull/1818/files#diff-3dcd700167653275bbf7873cfa7fa7c7R23 The delete in the else branch. That is like when one shoots himself in the leg with a mortar. Now when I try to tag a flavor I delete it. We need to aproach things (especially the destructive ones) with care! We are reviewing and merging in too much hurry :-( |
add_flash(_("Delete of Flavor \"%{name}\" was successfully initiated.") % {:name => flavor.name}) | ||
rescue => error | ||
add_flash(_("Unable to delete Flavor \"%{name}\": %{details}") % {:name => flavor.name, | ||
:details => error}, |
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.
error
is an exception, not a message. What do you expect to get displayed here?
Compute > Clouds > Flavors
Depends on: ManageIQ/manageiq#15552.
Add UI for create and delete flavors
Adding flavor:
Removing flavor: