Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions app/assets/javascripts/about.js

This file was deleted.

35 changes: 35 additions & 0 deletions app/helpers/about_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
module AboutHelper
def plugins
Copy link
Member

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

Copy link
Member Author

@amirfefer amirfefer Dec 5, 2017

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.

Copy link
Member

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?

Copy link
Member

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 ;)

@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
117 changes: 3 additions & 114 deletions app/views/about/index.html.erb
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>
Copy link
Member

Choose a reason for hiding this comment

The 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">
Expand Down Expand Up @@ -144,5 +34,4 @@
<p id="copyright-p"><%= (_("Version %{version} %{copyright} 2009-%{year} Paul Kelly and %{author}") % {:version => SETTINGS[:version], :copyright => "&copy;", :year=>DateTime.now.year, :author=>mail_to("ohadlevy@gmail.com", "Ohad Levy" )}).html_safe %></p>
</div>
</div>
</div>
</div>
</div>
1 change: 0 additions & 1 deletion config/initializers/assets.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ class << self
subnets
hidden_values
proxy_status
about
parameter_override)

javascript += FastGettext.default_available_locales.map { |loc| "locale/#{loc}/app" }
Expand Down
2 changes: 1 addition & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -405,7 +405,7 @@
post 'instance_type_selected'
post 'cluster_selected'
get 'resource_pools'
post 'ping'
get 'ping'
put 'associate'
put 'refresh_cache'
end
Expand Down
6 changes: 4 additions & 2 deletions config/webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ var LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
var pluginUtils = require('../script/plugin_webpack_directories');
var vendorEntry = require('./webpack.vendor');
var SimpleNamedModulesPlugin = require('../webpack/simple_named_modules');
const { version } = require('../package.json')

module.exports = env => {
// must match config.webpack.dev_server.port
Expand Down Expand Up @@ -142,8 +143,9 @@ module.exports = env => {
new webpack.DefinePlugin({
'process.env': {
NODE_ENV: JSON.stringify(production ? 'production' : 'development'),
NOTIFICATIONS_POLLING: process.env.NOTIFICATIONS_POLLING
}
NOTIFICATIONS_POLLING: process.env.NOTIFICATIONS_POLLING,
},
VERSION: JSON.stringify(version),
}),
]
};
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,8 @@
"^.+\\.(png|gif|css|scss)$": "identity-obj-proxy"
},
"globals": {
"__testing__": true
"__testing__": true,
"VERSION": "1.19"
},
"transform": {
"^.+\\.js$": "babel-jest"
Expand Down
19 changes: 2 additions & 17 deletions test/integration/about_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Member Author

Choose a reason for hiding this comment

The 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
38 changes: 38 additions & 0 deletions webpack/assets/javascripts/react_app/common/EmptyStates.js
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`,
Copy link
Member

Choose a reason for hiding this comment

The 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. VERSION is 1.19.0 but the manual url has to contain only 1.19. We probably need both VERSION and VERSION_MAJOR or something similar, maybe an object containing multiple version formats and with toString() defined.

},
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',
},
});
3 changes: 3 additions & 0 deletions webpack/assets/javascripts/react_app/common/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,7 @@ export default {
});
},
noop,
urlBuilder(controller, action, id = undefined) {
return `/${controller}/${id ? `${id}/` : ''}${action}`;
},
};
Loading