-
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
Added support to delete Generic Object Definitions using REST API DELETE #2262
Conversation
cd827d7
to
9d92678
Compare
to block the Delete operation in the `show` screen if there are instances associated with a record
The observable in the toolbar listens for `delete` and then deletes a single record (i.e. applicable from the `show` screen only) using API
Only records with 0 instances would be deleted For records with > 0 instances a warning message would be displayed indicating why they could not be deleted
post a delete operation
9d92678
to
a86f34c
Compare
@martinpovolny Please take a look at the codeclimate report here. IMO, the We should definitely disable these errors by tweaking the mass value in CC settings if we can. Are you able to understand how CC came up with those mass value numbers - /cc @dclarizio |
@lfu Please review |
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.
Working as expected for me. 👍
LGTM 👍 |
@@ -0,0 +1,17 @@ | |||
class ApplicationHelper::Button::GenericObjectDefinitionDeleteButton < ApplicationHelper::Button::Basic | |||
def visible? |
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.
def visible?
@display != 'generic_objects'
end
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.
Done in 446f7c4
end | ||
|
||
def disabled? | ||
if @record.generic_objects.count > 0 |
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.
def disabled?
@record.generic_objects.count.zero?
end
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.
Done in 446f7c4
%generic-object-definition-toolbar#generic_object_definition_show_list_form | ||
|
||
:javascript | ||
miq_bootstrap('#generic_object_definition_show_list_form'); |
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.
@himdel : we discussed this as an anti-pattern. Do we have a replacement yet?
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.
Why would miq_bootstrap
on the angular component be an anti-pattern?
@himdel Pray tell me how.
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 an anti-pattern simply because a GTL show-list should not have any other components .. what is this generic-object-definition-toolbar
actually for? Should it not be an actual toolbar?
Also, it's a component without a template - sounds like something is very wrong there :).
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.
Aah.. and it is an invisible toolbar because you're actuall trying to do things right and call the API for all the toolbar actions, am I right? :)
Sounds maybe we could just move this outside the DOM, since it has no effect on any actual html...
And we can actually listen for Rx
messages even outside Angular code.. so maybe this should be a simple file that just starts listening for messages wherever - it means we would have the listeners on every screen but... so what :).
We just need the messages to be discoverable - but genericObjectDefinitionToolbarController
pretty much solves that.
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 mean.. instead of using a component (and having a non-standard show_list
), this could just be a js file which just starts the listeners directly, without anything angulary.
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.
GTL show-list should not have any other components
Seems very restrictive for no real reason.
Why wouldn't be more components allowed?
generic-object-definition-toolbar
generic-object-definition-toolbar
is the controller for the toolbar commands.
BTW, there are no groundbreaking changes here.
Something similar has already been implemented for Physical Servers - #1380
Also, it's a component without a template - sounds like something is very wrong there
I have one simple answer to that - Delete operation does not need a form/template. A flash message is good enough
Nothing went wrong ;)
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 mean.. instead of using a component (and having a non-standard show_list), this could just be a js file which just starts the listeners directly, without anything angulary.
(Looks like I missed this message since I did not refresh the page as I was typing mine)
- It cannot be non-angulary because I'm using the
API
service, which is available only if you use angular. - Also there is some advantage to using the the controller/component approach that I see.
All messages that are triggered by the Generic Object Definition toolbar would only be directed to the observable in thegeneric-object-definition-toolbar
component.
It's like I'm channeling the messages in a particular area of interest and not going in the common application-wide listeners pool.
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.
@AparnaKarve : You are correct, there's no other way to do this right now. It is 100% ok for this PR.
The comment was ment more as a note that this is something we have to deal with and ping to @himdel to look for a solution ;-)
I am looking at all the "extra" content in the "show" partials because I would like to delete all the "show" partials on our way towards more declarative and client-side UI.
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.
@martinpovolny Thanks for that clarification.
%generic-object-definition-toolbar#generic_object_definition_show_form{'generic-object-definition-id' => @record.id, | ||
'redirect-url' => "/#{controller_name}/show_list",} | ||
:javascript | ||
miq_bootstrap('#generic_object_definition_show_form'); |
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.
And here.. I'll say fine for this PR :)...
So just FYI Aparna..
we're trying to remove all those specific things from these show
partials, so that miq_bootstrap
will have to go as well..
but the idea is that instead, the controllers would have a method which gets called from all the show partials, and can create that miq_bootstrap
in a declarative way, maybe ideally with the option to create that component element as well.
But that's really just an idea for now, without any specifics worked out.
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.
It's in the TODO list that is growing...
@AparnaKarve : will you, please, replace the 2 methods with corresponding one-liners so that we can merge this? |
Checked commits AparnaKarve/manageiq-ui-classic@7fd40c9~...446f7c4 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@martinpovolny I have simplified the 2 methods with simple one-liners as you suggested. Thanks. |
The C-R-U for
Generic Object Definitions
was implemented in #2137.This PR implements the D (Delete) using REST API.
https://www.pivotaltracker.com/n/projects/1613907/stories/147627789