Skip to content
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

Physical infra pages #196

Merged
merged 23 commits into from
Mar 6, 2017
Merged

Physical infra pages #196

merged 23 commits into from
Mar 6, 2017

Conversation

juliancheal
Copy link
Member

@juliancheal juliancheal commented Jan 19, 2017

Adds the Physical Infra pages.

There are still issues.

  • Missing toolbar at the top

screen shot 2017-01-19 at 17 50 27

  • Such as on the add page, need to add types of physical infra

screen shot 2017-01-19 at 17 49 51

  • Discover page issue

screen shot 2017-01-19 at 17 50 39

This PR links to ManageIQ/manageiq#13587

@AparnaKarve
Copy link
Contributor

Need the Gemfile changes in ManageIQ/manageiq#11846 for tests to pass.

@miq-bot
Copy link
Member

miq-bot commented Feb 13, 2017

This pull request is not mergeable. Please rebase and repush.

@juliancheal
Copy link
Member Author

screen shot 2017-02-14 at 22 08 27

@juliancheal juliancheal changed the title [WIP] Physical infra pages Physical infra pages Feb 15, 2017
@juliancheal
Copy link
Member Author

@miq-bot remove_label wip

@miq-bot miq-bot removed the wip label Feb 15, 2017
@juliancheal
Copy link
Member Author

@miq-bot assign @dclarizio

@juliancheal
Copy link
Member Author

Hey @dclarizio could you see about getting this merged. It's all working technically and been reviewed by both @AparnaKarve and myself.

@dclarizio
Copy link

@juliancheal will look at this today and discuss with @AparnaKarve

@dclarizio
Copy link

@juliancheal asking @himdel and @mzazrivec to review this to make sure we're following some of the latest UI guidelines.

@martinpovolny
Copy link
Member

There's exactly 0 tests in this PR. And there are new controllers. Please include at least one test for every new screen.

@himdel
Copy link
Contributor

himdel commented Feb 20, 2017

This introduces another copy of angular topology controler - won't force you to do the refactoring now (since we already have 5 of them), but.. created https://www.pivotaltracker.com/story/show/140220953

:default_userid => @ems.authentication_userid ? @ems.authentication_userid : "",
:ems_controller => controller_name,
:default_auth_status => default_auth_status,
} if controller_name == "ems_physical_infra"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Uh, and here I thought mixins are supposed to be for shared code.

The pattern of having controllers A and B include mixin M, which checks controller name and does something based on it .. feels silly (and more importantly, wrong). Can we just call a method that's defined in all those controllers?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agree, there is a good scope for a refactor here, but just not in this PR.
Note that most of the code here is adhering to the existing code pattern, which has gotten crazy over the last few months when folks keep adding more and more controllers here.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if we keep saying that and postponing cleanups then we are doomed.

The need to add new code that follows a bad pattern should be the trigger for refactoring :-(

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The need to add new code that follows a bad pattern should be the trigger for refactoring :-(

@martinpovolny Could not agree more.
However, it goes without saying that the refactoring effort should not be part of this (already gigantic) PR. That said, what I can offer here is this commit that I just pushed:
1dd3e43
It renders the ems_physical_infra-specific json using it's own controller method, making sure it does not add to the mess in the mixin.
Does that work?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well if we keep saying that and postponing cleanups then we are doomed.

This is a fine sentiment, but this ems_common has been bad for a very very long time. Pinning this level of cleanup on this PR is a mistake, imo.

Refactoring ems_common to be what it really should be (common code used by multiple controllers) is a monumental effort. Best suited for a separate dedicated PR that can be reviewed in that specific context.

@@ -200,6 +200,10 @@ def url_for_db(db, action = "show", item = nil) # Default action is show
)
elsif @host && ["Patch", "GuestApplication"].include?(db)
return url_for(:controller => "host", :action => @lastaction, :id => @host, :show => @id)
elsif db == "MiqCimInstance" && @db && @db == "snia_local_file_system"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got spot, tried to find all of these.


def textual_group_topology
items = %w(topology)
i = items.collect { |m| send("textual_#{m}") }.flatten.compact
Copy link
Contributor

@himdel himdel Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Really? Can't we just do i = [ textual_topology ]?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure? Until there's more than one...

In reality, this should be a private method somewhere hiding the details of building this "textual_" prefixed items since there's already 17[1] other occurrences of this exact line. And, if you want to optimize on whether there's only one item, then the private method would be a fantastic place to do that.

$ git grep -Ii "items.collect { |m| send(\"textual_#{m}" 
app/helpers/container_build_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_group_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_image_helper/textual_summary.rb:      items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_image_registry_helper/textual_summary.rb:      items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_node_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_project_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_replicator_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_route_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_service_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/container_template_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/ems_cloud_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/ems_container_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/ems_infra_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/ems_middleware_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/ems_network_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact
app/helpers/persistent_volume_helper/textual_summary.rb:    items.collect { |m| send("textual_#{m}") }.flatten.compact

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Leaving this as-is for now unless this is absolutely an issue.

end

def textual_physical_infrastructure_folders
return nil if @record.kind_of?(ManageIQ::Providers::PhysicalInfraManager)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So... what is the @record that this deals with?

Seems like this is just copy-pasted from ems_infra, where the condition dealt specifically with openstack (introduced in ManageIQ/manageiq#3556) - and makes little sense here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@record is a record of the new provider type -- ManageIQ::Providers::PhysicalInfraManager.
Not really sure if we can draw a connection here with Openstack or not or how closely this Provider type is related to ems_infra.
@juliancheal Any idea?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@himdel It looks like it's copy-pasta, because it is :) Ems Infra has been a good start to base Physical Infra on, but sometimes we do have unneeded code.

Didn't realise that's what @record here was used for, as there weren't any comments 😌

end

def textual_folders
return nil if @record.kind_of?(ManageIQ::Providers::PhysicalInfraManager)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here

def entity_status(entity)
case entity
when ManageIQ::Providers::PhysicalInfraManager
entity.authentications.blank? ? 'Unknown' : entity.authentications.first.status.try(:capitalize)
Copy link
Contributor

@himdel himdel Feb 20, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Unknown .. missing translation (2 other occurences in this function)

@@ -0,0 +1,11 @@
= render :partial => "layouts/flash_msg"
.row
.col-md-12.col-lg-6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is obsolete and doesn't work anymore. Please see #274 on how to fix this.

Also, @juliancheal .. clearly this screen is not being tested since it doesn't work and the tests pass ;).

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe the Lenovo guys did test the Textual Summary page, and AFAIK, everything seemed to work OK.
But we'll address the obsolete part.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tests are still WIP :)

Julian Cheal and others added 2 commits March 2, 2017 08:30
@juliancheal juliancheal closed this Mar 2, 2017
@juliancheal juliancheal reopened this Mar 2, 2017
@juliancheal
Copy link
Member Author

@martinpovolny @AparnaKarve yay finally green!

@Fryguy
Copy link
Member

Fryguy commented Mar 2, 2017

Any possibility to clean up all/most of the rubocops?

@juliancheal
Copy link
Member Author

Any possibility to clean up all/most of the rubocops?

The current broken cops are in style with the rest of the UI. I think it would be best to leave those for now and fix in a later PR with other classes that are also wrong with this style.

@AparnaKarve
Copy link
Contributor

Folks, we have been through many many rounds of rebasing and resolving merge conflicts.

Can someone please do the needful? Thanks.

return false;
}

topologyService.addContextMenuOption(popup, "Go to summary page", data, self.dblclick);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing i18n

container_template
ems_block_storage
ems_object_storage
timeline usage).include?(@layout)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this be timeline_usage or 2 lines?

@dclarizio dclarizio removed the request for review from mzazrivec March 6, 2017 18:11
@miq-bot
Copy link
Member

miq-bot commented Mar 6, 2017

Some comments on commits https://github.com/juliancheal/manageiq-ui-classic/compare/219131e374178987571ed9b2b85959cabab51175~...3d7e8df215c9b57389d01ccbc81313aeca63f478

spec/controllers/ems_physical_infra_controller_spec.rb

  • ⚠️ - 12 - Detected allow_any_instance_of. This RSpec method is highly discouraged, please only use when absolutely necessary.

@miq-bot
Copy link
Member

miq-bot commented Mar 6, 2017

Checked commits https://github.com/juliancheal/manageiq-ui-classic/compare/219131e374178987571ed9b2b85959cabab51175~...3d7e8df215c9b57389d01ccbc81313aeca63f478 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
25 files checked, 92 offenses detected

app/controllers/ems_physical_infra_controller.rb

app/helpers/application_helper/toolbar/ems_physical_infra_center.rb

app/helpers/application_helper/toolbar/ems_physical_infras_center.rb

app/helpers/ems_physical_infra_helper/textual_summary.rb

app/presenters/menu/default_menu.rb

app/services/physical_infra_topology_service.rb

app/views/ems_physical_infra/_form.html.haml

  • ⚠️ - Line 10 - Prefer to_s over string interpolation.
  • ⚠️ - Line 26 - Use hash rockets syntax.

app/views/ems_physical_infra/edit.html.haml

  • ⚠️ - Line 1 - Prefer to_s over string interpolation.

app/views/ems_physical_infra/new.html.haml

  • ⚠️ - Line 2 - Prefer to_s over string interpolation.

app/views/layouts/listnav/_ems_physical_infra.html.haml

  • ⚠️ - Line 17 - Use @record.number_of(:physical_servers).zero? instead of @record.number_of(:physical_servers) == 0.

app/views/physical_infra_topology/show.html.haml

  • ⚠️ - Line 1 - Use snake_case for variable names.

spec/controllers/ems_physical_infra_controller_spec.rb

spec/routing/ems_physical_infra_routing_spec.rb

@dclarizio dclarizio merged commit d304589 into ManageIQ:master Mar 6, 2017
@dclarizio dclarizio added this to the Sprint 56 Ending Mar 13, 2017 milestone Mar 6, 2017
ems_block_storage
ems_object_storage
timeline
usage).include?(@layout)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@dclarizio @martinpovolny 2 requests here for future PRs:

  • Please alphabetize this list
  • Please move the list to a well-named constant so code is more readable

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@chessbyte : Toolbar chooser was extracted but not yet refactored :-(

@martinpovolny
Copy link
Member

For the record: I don't think we should merge new code that has so many Rubocop issues. No matter it might match other places in the code. It's not the way forward and someone will have to fix it sooner or later anyway.

@himdel
Copy link
Contributor

himdel commented Mar 7, 2017

@juliancheal Not sure if that's a know problem or not but...

Clicking on "Validate" when adding an phinfra provider just returns success, without even trying. (Added the provider with 127.0.0.1 and port 80 and it didn't even show up in my access.log.)

@himdel
Copy link
Contributor

himdel commented Mar 9, 2017

@juliancheal , @AparnaKarve the textual summary still has a link to Topology, it even seems like there is a PhysicalInfraTopology controller, but the topology itself is not available from the menu, and, perhaps more importantly, completely broken right now :).

FYI ;)

phitop

@AparnaKarve
Copy link
Contributor

the textual summary still has a link to Topology, it even seems like there is a PhysicalInfraTopology controller, but the topology itself is not available from the menu, and, perhaps more importantly, completely broken right now :).

@himdel The only way to get to Physical Infra Topology is via the summary screen -- so that's a known thing.

As far as the Topology itself goes, do you have enough data to get a decent Topology graph?
I never got a chance to play with this because I never had access to an actual Physical infra provider.

Can you also post a screenshot of your summary screen...I'm curious to know what Relationships you're seeing. Thanks.

@himdel
Copy link
Contributor

himdel commented Mar 9, 2017

only way to get to Physical Infra Topology is via the summary screen

OK, cool .. because all the others have a Topology entry in the menu too..

do you have enough data to get a decent Topology graph?

Not really, I just have that one provider, without any additional data :). (I just used the bug that you can just add it without validation, so... I have a provider, but that's it.)

@himdel
Copy link
Contributor

himdel commented Mar 9, 2017

@AparnaKarve this is my summary screen.. but not sure it helps :)

summary

TomasKohoutek pushed a commit to TomasKohoutek/manageiq-ui-classic that referenced this pull request Apr 7, 2017
skateman pushed a commit to ManageIQ/manageiq-decorators that referenced this pull request Jul 17, 2018
skateman pushed a commit to ManageIQ/manageiq-decorators that referenced this pull request Jan 14, 2019
relates to: ManageIQ/manageiq-ui-classic#196


(transferred from manageiq-ui-classic@c57b49eaa709046958493ce47cd4621736858764)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants