-
Notifications
You must be signed in to change notification settings - Fork 1k
Fixes #21737 - move about page to react #5024
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| module AboutHelper | ||
| def plugins | ||
| @plugins.map do |plugin| | ||
| {:name => {name: plugin.name, url: plugin.url}, :description => plugin.description, | ||
| :author => plugin.author, :version => plugin.version } | ||
| end | ||
| end | ||
|
|
||
| def proxies | ||
| @smart_proxies.map do |proxy| | ||
| {:id => {:name => proxy.name, :id => proxy.id}, | ||
| :features => proxy.features.map(&:name).to_sentence} | ||
| end | ||
| end | ||
|
|
||
| def providers | ||
| nil unless SETTINGS[:unattended] | ||
| @providers.map do |provider| | ||
| {:provider => provider[:friendly_name], | ||
| :status => provider[:status] == :installed} | ||
| end | ||
| end | ||
|
|
||
| def compute_resources | ||
| nil unless SETTINGS[:unattended] | ||
| @compute_resources.map do |compute| | ||
| {:id => {:name => compute.name, :id => compute.id}, | ||
| :type => compute.provider_friendly_name} | ||
| end | ||
| end | ||
|
|
||
| def about_data | ||
| {:compute => compute_resources, :proxy => proxies, :plugin => plugins, :provider => providers } | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,122 +1,12 @@ | ||
| <% title _("About") %> | ||
| <%= javascript 'proxy_status', 'charts', 'about' %> | ||
|
|
||
| <div class="row" id="about"> | ||
| <div class="col-md-7"> | ||
|
|
||
| <div class="stats-well"> | ||
| <h4><%=_("System Status")%></h4> | ||
| <ul class="nav nav-tabs" data-tabs="tabs"> | ||
| <li class="active"><a href="#smart_proxies" data-toggle="tab"><%= _('Smart Proxies') %></a></li> | ||
| <% if SETTINGS[:unattended] %> | ||
| <li><a href="#available_providers" data-toggle="tab"><%= _('Available Providers') %></a></li> | ||
| <li><a href="#compute_resources" data-toggle="tab"><%= _('Compute Resources') %></a></li> | ||
| <% end %> | ||
| <li><a href="#plugins" data-toggle="tab"><%= _('Plugins') %></a></li> | ||
| </ul> | ||
| <div class="tab-content"> | ||
| <div class="tab-pane active" id="smart_proxies"> | ||
| <% if @smart_proxies.empty? %> | ||
| <p class="ca"><%= _("No smart proxies to show") %></p> | ||
| <% else %> | ||
| <table class="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th><%= _("Name") %></th> | ||
| <th><%= _("Features") %></th> | ||
| <th><%= _("Status") %></th> | ||
| <th><%= _("Version") %></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @smart_proxies.each do |proxy| %> | ||
| <tr class="proxy-show" data-url="<%= ping_smart_proxy_path(proxy) %>"> | ||
| <td><%= link_to_if_authorized proxy.name, hash_for_smart_proxy_path(proxy) %></td> | ||
| <td><%=h proxy.features.map(&:name).to_sentence %></td> | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I wonder how translation worked here before? |
||
| <td><div class="proxy-show-status"><%= spinner %></div></td> | ||
| <td><div class="proxy-version"><%= spinner %></div></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| </table> | ||
| <% end %> | ||
| </div> | ||
| <% if SETTINGS[:unattended] %> | ||
| <div class="tab-pane" id="available_providers"> | ||
| <table class="table table-striped"> | ||
| <thead> | ||
| <tr> | ||
| <th><%= _("Provider") %></th> | ||
| <th><%= _("Status") %></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @providers.sort_by { |prov| prov[:friendly_name].downcase }.each do |provider| %> | ||
| <tr> | ||
| <td><%= provider[:friendly_name] %></td> | ||
| <% if provider[:status] == :installed %> | ||
| <td><div class="label label-success"><%= _('Installed') %></div></td> | ||
| <% else %> | ||
| <td><div class="label label-default"><%= _('Not Installed') %></div></td> | ||
| <% end %> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| </table> | ||
| <%= _('To enable a provider, either install the OS package (e.g. foreman-libvirt) or enable the bundler group for development setup (e.g. ovirt).') %> | ||
| </div> | ||
| <div class="tab-pane" id="compute_resources"> | ||
| <% if @compute_resources.empty? %> | ||
| <p class="ca"><%= _("No compute resource to show") %></p> | ||
| <% else %> | ||
| <table class="table table-striped table-fixed"> | ||
| <thead> | ||
| <tr> | ||
| <th class="col-md-4"><%= _("Name") %></th> | ||
| <th class="col-md-4"><%= _("Type") %></th> | ||
| <th class="col-md-4"><%= _("Status") %></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @compute_resources.each do |compute| %> | ||
| <tr> | ||
| <td class="ellipsis"><%= link_to(compute.name, compute) %></td> | ||
| <td><%= compute.provider_friendly_name %></td> | ||
| <td><div class="compute-status" data-url=<%= ping_compute_resource_path(compute) %>><%= spinner %></div></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| </table> | ||
| <% end %> | ||
| </div> | ||
| <% end %> | ||
| <div class="tab-pane" id="plugins"> | ||
| <% if @plugins.empty? %> | ||
| <p class="ca"><%= _("No plugins found") %></p> | ||
| <% else %> | ||
| <table class="table table-striped table-fixed"> | ||
| <thead> | ||
| <tr> | ||
| <th class="col-md-4"><%= _("Name") %></th> | ||
| <th class="col-md-6"><%= _("Description") %></th> | ||
| <th class="col-md-2"><%= _("Author") %></th> | ||
| <th class="col-md-2"><%= _("Version") %></th> | ||
| </tr> | ||
| </thead> | ||
| <tbody> | ||
| <% @plugins.each do |plugin| %> | ||
| <tr> | ||
| <td><%= plugin.url.blank? ? plugin.name : link_to(plugin.name, plugin.url, :rel=>'external')%></td> | ||
| <td class="ellipsis"><%= _(plugin.description) %></td> | ||
| <td class="ellipsis"><%= plugin.author_url.blank? ? plugin.author : link_to(plugin.author, plugin.author_url)%></td> | ||
| <td><%= plugin.version %></td> | ||
| </tr> | ||
| <% end %> | ||
| </tbody> | ||
| </table> | ||
| <% end %> | ||
| </div> | ||
| </div> | ||
| <div id="tabs"></div> | ||
| <%= mount_react_component('About', '#tabs', about_data.compact.to_json) %> | ||
| </div> | ||
| </div> | ||
| <div class="col-md-5"> | ||
|
|
@@ -144,5 +34,4 @@ | |
| <p id="copyright-p"><%= (_("Version %{version} %{copyright} 2009-%{year} Paul Kelly and %{author}") % {:version => SETTINGS[:version], :copyright => "©", :year=>DateTime.now.year, :author=>mail_to("ohadlevy@gmail.com", "Ohad Levy" )}).html_safe %></p> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| </div> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -17,27 +17,12 @@ class AboutIntegrationTest < IntegrationTestWithJavascript | |
| assert page.has_selector?('h4', :text => "System Status"), "System Status was expected in the <h4> tag, but was not found" | ||
| assert page.has_selector?('h4', :text => "Support"), "Support was expected in the <h4> tag, but was not found" | ||
| assert page.has_selector?('h4', :text => "System Information"), "System Information was expected in the <h4> tag, but was not found" | ||
| assert page.has_link?("Smart Proxies", :href => "#smart_proxies") | ||
| assert page.has_link?("Compute Resources", :href => "#compute_resources") | ||
| assert page.has_link?("Smart Proxies", :href => "#") | ||
| assert page.has_link?("Compute Resources", :href => "#") | ||
| assert page.has_link?("Foreman Users", :href => "http://groups.google.com/group/foreman-users") | ||
| assert page.has_link?("Foreman Developers", :href => "http://groups.google.com/group/foreman-dev") | ||
| assert page.has_link?("issue tracker", :href => "http://projects.theforeman.org/projects/foreman/issues") | ||
| assert page.has_link?("Wiki", :href => "http://projects.theforeman.org") | ||
| assert page.has_link?("Ohad Levy", :href => "mailto:ohadlevy@gmail.com") | ||
| assert page.has_content?("Version") | ||
| end | ||
|
|
||
| test "about page proxies should have version" do | ||
|
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. already tested here |
||
| visit about_index_path | ||
| wait_for_ajax | ||
| assert page.has_selector?('th', :text => "Version") | ||
| assert page.has_selector?('div.proxy-version', :text => '1.13.0') | ||
| end | ||
|
|
||
| private | ||
|
|
||
| def wait_for_ajax | ||
| super | ||
| assert page.has_no_selector?('div.spinner'), 'AJAX spinners still active' | ||
| end | ||
| end | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,38 @@ | ||
| export const computeResource = () => ({ | ||
| header: __('Compute Resource'), | ||
| description: __('Foreman supports creating and managing hosts on a number of virtualization and cloud services - referred to as “compute resources” - as well as bare metal hosts.'), | ||
| documentation: { | ||
| // eslint-disable-next-line no-undef | ||
| url: `https://www.theforeman.org/manuals/${VERSION}/index.html#5.2ComputeResources`, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found out that the docs link (and the other too) leads to 404. |
||
| }, | ||
| action: { | ||
| title: __('Create a compute resource'), | ||
| url: '/compute_resources/new', | ||
| }, | ||
| }); | ||
|
|
||
| export const plugin = () => ({ | ||
| header: __('Plugin'), | ||
| description: __('Plugins are tools to extend and modify the functionality of Foreman. Plugins offer custom functions and features so that each user can tailor their environment to their specific needs.'), | ||
| documentation: { | ||
| // eslint-disable-next-line no-undef | ||
| url: `https://www.theforeman.org/manuals/${VERSION}/index.html#Plugins`, | ||
| }, | ||
| action: { | ||
| title: __('Get a plugin'), | ||
| url: 'https://projects.theforeman.org/projects/foreman/wiki/List_of_Plugins', | ||
| }, | ||
| }); | ||
|
|
||
| export const smartProxy = () => ({ | ||
| header: __('Smart Proxy'), | ||
| description: __('The Smart Proxy provides an easy way to add or extended existing subsystems, via DHCP, DNS, Puppet, etc.'), | ||
| documentation: { | ||
| // eslint-disable-next-line no-undef | ||
| url: `https://www.theforeman.org/manuals/${VERSION}/index.html#Smart-Proxy`, | ||
| }, | ||
| action: { | ||
| title: __('Create a smart proxy'), | ||
| url: '/smart_proxies/new', | ||
| }, | ||
| }); | ||
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.
if you are creating a controller per action, then I would expect AboutPluginController with only index action.
having said that, I would default to use the API first and only if it doesnt fit create a UI end point
Uh oh!
There was an error while loading. Please reload this page.
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've created About controller namespace, inspired by this post.
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.
in that case why do you need the helper than?
also.. can't we simply use the existing api?
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.
Using an api endpoint would definitely be more systemic. Such endpoint doesn't exist at the moment. We can only list proxies and compute profiles separately. How about moving it to a new api endpoint? It would help with http://projects.theforeman.org/issues/3036.
But I understand it's adds some work and there are probably issues with higher priority. So if you don't have space for moving it to API, I can live with the current state ;)