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

Add Physical Server relationship for Host summary page #1440

Merged
merged 1 commit into from
Jun 6, 2017

Conversation

gabrielsvinha
Copy link
Contributor

Adds physical server link to Host summary page in relationship label.

captura de tela de 2017-05-25 17-06-26

@gabrielsvinha
Copy link
Contributor Author

@miq-bot add_labels compute/physical infrastructure, enhancement, textual summaries

@@ -235,6 +235,10 @@ def textual_cluster
h
end

def textual_physical_server
{:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)}
Copy link
Contributor

Choose a reason for hiding this comment

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

@gabrielsvinha Not all hosts are expected to have a Physical Server associated with them, therefore, I recommend adding a conditional here.

{:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)} if @record.physical_server_id

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done it.

@AparnaKarve
Copy link
Contributor

screen shot 2017-05-25 at 2 48 41 pm

Could you also add the Physical server relationship in the left navigation view?

@gabrielsvinha
Copy link
Contributor Author

Sure. But there is no point adding a count for physical servers in the listnav, their relationship is one-to-one. @AparnaKarve

@AparnaKarve
Copy link
Contributor

Ok, makes sense.
Listnav is good as is.

@gabrielsvinha gabrielsvinha force-pushed the host_relationship branch 2 times, most recently from 76ddf16 to e9d1e51 Compare May 26, 2017 13:16
@AparnaKarve
Copy link
Contributor

LGTM.

@dclarizio Good to go.

@dclarizio
Copy link

@gabrielsvinha I'm pretty sure we try to make the listnav match the summary screen contents and have seen links to single relationships, such as Host to Provider, in the listnav. @AparnaKarve is checking to see what we would do in the listnav if there is no relationship to an entity.

@AparnaKarve
Copy link
Contributor

@gabrielsvinha Let's revisit the discussion #1440 (comment) and #1440 (comment).

So, for 1:1 Relationships, the listnav should display the Relationship and the link to that should land on the Summary page of the item.
Meaning, let's display the Physical Server relationship in the Hosts listnav with a link pointing to the Physical Server show page (Summary page)

Please take a look at the screenshot below -
screen shot 2017-05-30 at 11 46 27 am

Two things to note here.

  • Notice how Providers:SCVMM (which has a 1:1 with the Host) is shown in the listnav, so we want something similar for Physical Server
  • Notice Cluster: None on the right.
    Maybe we should take this approach too. i.e. display Physical Server: None when a host does not have a Physical server associated with it. And also display it in the listnav as purely an info item with no links (since a link is not possible in this case)

Let me know if I can assist in any way. Thanks.

@gabrielsvinha
Copy link
Contributor Author

@AparnaKarve @dclarizio Got it, working on it right now.

@gabrielsvinha
Copy link
Contributor Author

@AparnaKarve Done it:
captura de tela de 2017-06-01 12-56-22
captura de tela de 2017-06-01 12-56-41

@AparnaKarve
Copy link
Contributor

Can you add Physical Server as the last entry in the listnav, that way we maintain the same order like in the Summary page?

{:label => _("Physical Server"), :value => "None", :icon => "pficon pficon-server"}
end
end

Copy link
Contributor

Choose a reason for hiding this comment

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

Flip the order here that way we do not have to use ! (negative conditional)
Also note the use of _("None") which takes care of i18n.

if @record.physical_server_id.nil?
  {:label => _("Physical Server"), :value => _("None"), :icon => "pficon pficon-server"}
else
  {:label => _("Physical Server"), :value => @record.physical_server.try(:name), :icon => "pficon pficon-server", :link => url_for(:controller => 'physical_server', :action => 'show', :id => @record.physical_server_id)}
end

@@ -77,6 +77,12 @@
ems_infra_path(@record.ext_management_system),
:title => _("Show this parent %{provider} for this %{host}") % {:host => host_title, :provider => ui_lookup(:table => "ems_infra")})

- if role_allows?(:feature => "physical_server_show") && [email protected]_server.nil?
%li
= link_to("#{ui_lookup({:table => "physical_servers"})}: #{@record.physical_server.name}",
Copy link
Contributor

Choose a reason for hiding this comment

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

Currently the text is being shown as plural Physical Servers... we need it to be singular.
I have created ManageIQ/manageiq#15275 with which ui_lookup should work correctly and show the singular text.

Copy link
Contributor

@AparnaKarve AparnaKarve Jun 1, 2017

Choose a reason for hiding this comment

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

In addition to this, you will also need to consider a case when a host does not have a Physical Server associated with it and then display Physical Server: None in the listnav without a link.

- if role_allows?(:feature => "physical_server_show") && @record.physical_server.nil?
  = li_link(:if => false, :text => "#{ui_lookup({:table => "physical_servers"})}: #{_('None')}")

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done it.

@gabrielsvinha gabrielsvinha force-pushed the host_relationship branch 5 times, most recently from 8bf5f58 to 33e51b5 Compare June 5, 2017 12:50
@@ -235,6 +235,14 @@ def textual_cluster
h
end

def textual_physical_server
if @record.physical_server_id.nil?
{:label => _("Physical Server"), :value => "None", :icon => "pficon pficon-server"}
Copy link
Contributor

Choose a reason for hiding this comment

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

Change "None" to _("None")

@@ -119,6 +119,15 @@
:record_id => @record.id,
:title => _("Show %{host} drift history") % {:host => host_title})

- if role_allows?(:feature => "physical_server_show") && [email protected]_server.nil?
%li
= link_to("#{ui_lookup(:table => "physical_servers")}: #{@record.physical_server.name}",
Copy link
Contributor

Choose a reason for hiding this comment

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

For this ui_lookup(:table => "physical_servers") (note the singular use of :table as opposed to :tables), I was expecting to see a singular Physical Server, but instead seeing a plural (Physical Servers)
screen shot 2017-06-05 at 11 37 54 am

@mzazrivec Any idea why?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it's the :table => physical _servers, I tested :table => physical _server and it looked good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

captura de tela de 2017-06-05 18-39-18

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, I'm aware that :table => physical _server seems to work but the table name is physical_servers and not physical_server. Hence, it does not seem right to use physical_server

The other option would be to go with :model => 'PhysicalServer', which works perfectly well for singular and plural cases
:model => 'PhysicalServer' gives Physical Server
:models => 'PhysicalServer' gives Physical Servers

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know which one is the best.

Copy link
Contributor

@AparnaKarve AparnaKarve Jun 5, 2017

Choose a reason for hiding this comment

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

I'm inclined to use :model => 'PhysicalServer'since it is working the way it's supposed to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it. Doing it.

@AparnaKarve
Copy link
Contributor

@gabrielsvinha Other than the few minor things above, everything else looks good.

@AparnaKarve
Copy link
Contributor

In the next iteration can you address the rubocop issue?

@gabrielsvinha
Copy link
Contributor Author

@AparnaKarve Any idea what is this rubocop issue about?

@AparnaKarve
Copy link
Contributor

The haml-lint issue gets resolved if you write the link_to method like this:

%li
  - physical_server_show = {:controller => "physical_server", :action => 'show', :id => @record.physical_server.id}
  = link_to("#{ui_lookup(:table => "physical_servers")}: #{@record.physical_server.name}",
              physical_server_show,
              :title => _("Show Physical Server"))

On second thoughts, don't worry about fixing this lint error. Leave it as is. Thanks.

@gabrielsvinha
Copy link
Contributor Author

Do not worry, it will not be a problem.

@miq-bot
Copy link
Member

miq-bot commented Jun 6, 2017

Checked commit gabrielsvinha@a605548 with ruby 2.2.6, rubocop 0.47.1, and haml-lint 0.20.0
2 files checked, 0 offenses detected
Everything looks fine. 👍

 - Adds physical server to host summary page in relationships label
@AparnaKarve
Copy link
Contributor

@dclarizio This can be merged now. Thanks.

@dclarizio dclarizio merged commit 03ea79c into ManageIQ:master Jun 6, 2017
@dclarizio dclarizio added this to the Sprint 63 Ending Jun 19, 2017 milestone Jun 6, 2017
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.

4 participants