-
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
For middleware UI, only allow operations on mutable servers. #636
Conversation
@miq-bot add_label middleware, enhancement, ui |
@mtho11 unrecognized command 'middleware', ignoring... Accepted commands are: add_label, assign, close_issue, move_issue, remove_label, rm_label, set_milestone |
@miq-bot add_label middleware, enhancement, ui |
Does the hawkular server ("the provider") also have this flag? |
[email protected]? || | ||
(@record.try(:product) != 'Hawkular' && @record.try(:middleware_server).try(:product) != 'Hawkular') | ||
if @record.present? | ||
hawkular_product? ? false : !immutable? |
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.
Can this part be simplified?
perhaps something like "return record.present? && hawkular_product? && immutable?"
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.
ok thank for the tip, this works: @record.present? && !hawkular_product? && !immutable?
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.
The case for when the record is a hawkular instance should be tested accordingly. The other changes I suggested are more code-quality related, so while they are completely optional in my view, they would increase the code quality by making stuff more encapsulated.
@@ -1,7 +1,18 @@ | |||
class ApplicationHelper::Button::MiddlewareServerAction < ApplicationHelper::Button::Basic | |||
|
|||
def visible? | |||
[email protected]? || | |||
(@record.try(:product) != 'Hawkular' && @record.try(:middleware_server).try(:product) != 'Hawkular') | |||
@record.present? && !hawkular_product? && !immutable? |
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 think this class would be better written as:
class ApplicationHelper::Button::MiddlewareServerAction < ApplicationHelper::Button::Basic
def NullableRecord
delegate :present?, to: :@record
def initialize(record)
@record = record
end
def properties
@record.try(:properties)
end
def product
@record.try(:product).presence ||
@record.try(:middleware_server).try(:product)
end
end
def visible?
nullable_record = NullableRecord.new(@record)
@record.present?
&& !nullable_record.properties['Immutable']
&& nullable_record.product != 'Hawkular'
end
end
That way you gain a more testable interface and make the visible?
method clearer about its implementation.
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, wouldn't EAP non-immutable servers have the Hawkular product if they are registered into miq by Hawkular? Also, what happens if the created provider for Hawkular is not called Hawkular
, but something else? Does this field is unrelated to the created name?
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.
@cfcosta I agree with all of your changes, just not sure it should be part of this PR. I'm just adding an immutable field to existing infrastructure. And we need to get this merged quickly as this is a blocker issue for this release that the window is closing rapidly. Changing more lines of code will subject the PR to more scrutiny which could cause it to miss the release window. You or I can add these changes to a follow-on refactoring PR immediately after this is merged. Besides the fact that, these changes need to be applied consistently to all of the middleware application helper classes and tests.
end | ||
|
||
context 'when server.properties.immutable? == true' do | ||
let(:immutable_server) { FactoryGirl.create(:middleware_server, :properties => create_immutable(true)) } |
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.
For those tests you can do something like this:
let(:record) { double(:properties => create_immutable(true)) }
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'll have to read more about double, I'm not familiar.
end | ||
|
||
context 'when server.properties.immutable? == false' do | ||
let(:mutable_server) { FactoryGirl.create(:middleware_server, :properties => create_immutable(false)) } |
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.
let(:record) { double(:properties => create_immutable(false) }
subject { described_class.new(setup_view_context_with_sandbox({}), {}, {'record' => record}, {}) } | ||
it { expect(subject).not_to be_visible } | ||
end | ||
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.
These test cases are not testing if the product is hawkular.
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 @cfcosta, I'm done for the night, will address tomorrow.
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 did think about the not testing 'Hawkular' product but it was already not part of the test suite and I didn't want to add permutation explosion. Not sure how we should handle this?
Sure, I'd be up for that. I'll create a follow-up today then.
…On Mar 17, 2017 14:39, "Mike Thompson" ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In app/helpers/application_helper/button/middleware_server_action.rb
<#636 (comment)>
:
> @@ -1,7 +1,18 @@
class ApplicationHelper::Button::MiddlewareServerAction < ApplicationHelper::Button::Basic
def visible?
- ***@***.***? ||
- ***@***.***(:product) != 'Hawkular' && @record.try(:middleware_server).try(:product) != 'Hawkular')
+ @record.present? && !hawkular_product? && !immutable?
@cfcosta <https://github.com/cfcosta> I agree with all of your changes,
just not sure it should be part of this PR. I'm just adding an immutable
field to existing infrastructure. And we need to get this merged quickly as
this is a blocker issue for this release that the window is closing
rapidly. Changing more lines of code will subject the PR to more scrutiny
which could cause it to miss the release window. You or I can add these
changes to a follow-on refactoring PR immediately after this is merged.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#636 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAA5oGdE-IAEPXuabiZu0GfWbwxgVbQBks5rmsVNgaJpZM4MXeIG>
.
|
Checked commits https://github.com/mtho11/manageiq-ui-classic/compare/768982921884e69ad47a8ac324f89f9ab3597db6~...2e48b198305e19f602d11c1de0c1f9551a26b603 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0 |
@abonas is this good to go? |
@miq-bot assign @martinpovolny |
@martinpovolny @bronaghs @chessbyte can someone please merge it ? thank you |
|
||
def hawkular? | ||
@record.try(:product) == 'Hawkular' || | ||
@record.try(:middleware_server).try(:product) == 'Hawkular' |
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 has been already merged, but it may be handy to have those methods also on the server entity itself
@Jiri-Kremser check ManageIQ/manageiq#14565 and #839 |
The Hawkular agent now reads the properties from managed servers. These properties can be used to indicate the immutability of the environment (such as an EAP server running in OpenShift). The property being set here is: -Dhawkular.agent.immutable=true
An Immutable server:
A mutable server:
Testing
Links