-
Notifications
You must be signed in to change notification settings - Fork 993
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
Fixes #21737 - move about page to react #5024
Conversation
Issues: #21737 |
5ed7f4c
to
22e7fec
Compare
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.
nice @amirfefer - first review round..
app/views/about/index.html.erb
Outdated
</table> | ||
<% end %> | ||
<%= data = @smart_proxies.map {|proxy| {:id => {:name => proxy.name, :id => proxy.id}, | ||
:features => h(proxy.features.map(&:name).to_sentence)}} %> |
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.
h
is probably no longer required (it's the default).
app/views/about/index.html.erb
Outdated
</tbody> | ||
</table> | ||
<% end %> | ||
<%= data = @compute_resources.map {|compute| {:id => {:name => compute.name, :id => compute.id}, |
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.
when there are none, you get a generic message ````No data found``` - we should use the PF empty state instead.
config/routes.rb
Outdated
@@ -404,7 +404,7 @@ | |||
post 'template_selected' | |||
post 'cluster_selected' | |||
get 'resource_pools' | |||
post 'ping' | |||
get 'ping' |
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.
doesnt this break CR test connection?
return `/${controller}/${id ? `${id}/` : ''}${action}`; | ||
}, | ||
getQueryParam(query) { | ||
const urlParams = new URLSearchParams(window.location.search); |
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.
how is this different from the urijs lib that we currently use? - also does this work across browsers?
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 becomes a standard interface, most of the browsers support it, and there's a polyfill
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.
should we replace than the urijs?
render() { | ||
const columns = [ | ||
{ | ||
Header: '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.
please extract all strings
? rowData | ||
: undefined, | ||
style: { | ||
textAlign: 'center', |
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.
why pass style here?
@@ -8,6 +8,10 @@ import PowerStatus from './hosts/powerStatus/'; | |||
import NotificationContainer from './notifications/'; | |||
import ToastsList from './toastNotifications/'; | |||
import StorageContainer from './hosts/storage/vmware/'; | |||
import AboutComputeTable from './about/compute'; |
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.
TBH: I am not too happy about having so many entry level components, is there any chance we can take over multiple tabs in one hoc ? this will allow to have all of the "logic" in one place vs across multiple components
@@ -0,0 +1,12 @@ | |||
import { STATUS_REQUEST, STATUS_SUCCESS, STATUS_FAILURE } from '../../consts'; |
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.
shouldnt these const be more specific? e.g. HOST_STATUS or COMPUTE_RESOURCE_STATUS?
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 extracted it out of the tree, something like this:
STATUS
-COMPUTE_RESOURCE
[-X...]
-SMART_PROXY
[-Y...]
|
||
switch (action.type) { | ||
case STATUS_REQUEST: | ||
return state; |
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.
why? shouldn't this set the state so that the request has started?
case STATUS_REQUEST: | ||
return state; | ||
case STATUS_SUCCESS: | ||
return state.set(payload.id, { ...payload }); |
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'm a bit worried that ID's can override each other, while I've seen you've prefixed it, the fact is that these actions are used for multiple objects, can confuse a future developer?
@amirfefer also note the lack of tests + current failing tests. |
@amirfefer It's is great to see more and more code moving to react. You can use The row and col can be replaced with: Those components will be apart of |
<% @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> |
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 wonder how translation worked here before?
@ohadlevy |
@amirfefer i think you forgot to push your new implementation. regardless, I would suggest to send PR's to patternfly-react repo with all of pf related components (tabs, emptystate etc) |
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 ran out of time, but here is some feedback
app/assets/stylesheets/base.scss
Outdated
@@ -250,7 +250,7 @@ select { | |||
|
|||
table { | |||
clear: both; | |||
margin-bottom: 6px !important; | |||
//margin-bottom: 6px !important; |
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.
?
app/assets/stylesheets/base.scss
Outdated
@@ -335,7 +335,7 @@ table { | |||
} | |||
|
|||
#pagination { | |||
margin-top: -6px; | |||
margin-top: -19px !important; |
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.
why change style for all pagination?
@@ -0,0 +1,31 @@ | |||
module AboutHelper | |||
def plugins |
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
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 ;)
app/views/about/index.html.erb
Outdated
</div> | ||
</div> | ||
<div id="tabs"></div> | ||
<%= mount_react_component('About', '#tabs', {:compute => compute_resources, :proxy => proxies, |
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.
probably makes sense to combine it under a method, so in theory we can expand it later vs hard code it. e.g.
def about_data
{:compute => compute_resources, :proxy => proxies,...
end
package.json
Outdated
@@ -68,12 +68,13 @@ | |||
"lodash": "~4.15.0", | |||
"multiselect": "~0.9.12", | |||
"patternfly": "^3.29.5", | |||
"patternfly-react": "^0.8.1", | |||
"patternfly-react": "^0.11.0", |
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.
all package upgrades seems not related?
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 upgraded in order to use Icon component
return `/${controller}/${id ? `${id}/` : ''}${action}`; | ||
}, | ||
getQueryParam(query) { | ||
const urlParams = new URLSearchParams(window.location.search); |
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.
should we replace than the urijs?
render() { | ||
const columns = [ | ||
{ | ||
header: '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.
string not extracted?
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.
extracted already in <Table>
component
} = this.props.data; | ||
const tabs = [__('Smart Proxies'), __('Available Providers'), __('Compute Resources'), __('Plugins')]; | ||
|
||
return <ForemanTabs id='about_tabs' tabs={tabs} > |
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.
this looks really close to how react-router works.. I wonder if we should combine the two? (so if you refresh you come back to the same tab)
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.
sounds great, though this PR becomes too large, maybe should we combine react-router in a different PR?
</p> | ||
<div className="blank-slate-pf-main-action"> | ||
<button | ||
onClick={e => window.Turbolinks.visit(action.url)} |
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.
wouldnt turbolink catch these regardless?
<h1>{header}</h1> | ||
<p>{description}</p> | ||
<p> | ||
Learn more about this{' '} |
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.
not extracted..
|
||
<<<<<<< HEAD |
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.
Parsing error: Unexpected token
app/assets/stylesheets/base.scss
Outdated
@@ -655,3 +655,7 @@ code.transparent { | |||
padding: 0; | |||
margin-bottom: 0; | |||
} | |||
|
|||
.react-bs-table table { | |||
margin-bottom: 0px !important |
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.
Unexpected unit length-zero-no-unit
Unexpected missing end-of-source newline no-missing-end-of-source-newline
Expected a trailing semicolon declaration-block-trailing-semicolon
app/assets/stylesheets/base.scss
Outdated
@@ -239,7 +239,7 @@ select { | |||
|
|||
table { | |||
clear: both; | |||
margin-bottom: 6px !important; | |||
margin-bottom: 6px !important; |
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.
Expected newline after ";" in a multi-line declaration block declaration-block-semicolon-newline-after
Unexpected whitespace at end of line no-eol-whitespace
app/assets/stylesheets/base.scss
Outdated
@@ -655,3 +655,7 @@ code.transparent { | |||
padding: 0; | |||
margin-bottom: 0; | |||
} | |||
|
|||
.react-bs-table table { | |||
margin-bottom: 0 !important; |
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.
Unexpected missing end-of-source newline no-missing-end-of-source-newline
@amirfefer ping, could you rebase, please? |
@amirfefer, could you rebase please? |
@amirfefer ping |
It was among the latter in the priority tasks list, |
@tstrachota , @waldenraines |
return this.isEmpty() ? ( | ||
<EmptyState {...emptyState} /> | ||
) : ( | ||
<PfTable.PfProvider |
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.
Hi @amirfefer, this looks good but what if I want to use components
in <PfTable.PfProvider>
- I am not sure I can do that through Table
. In Hardware Models
I am using it to set how the heading and cells will look like.
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.
This has been solved in Katello: https://github.com/Katello/katello/blob/master/webpack/move_to_foreman/components/common/table/components/Table.js That component is based on @amirfefer 's solution and is going to be moved to foreman soon. AFAIR the interfaces should be compatible.
So, if you don't mind @ripcurld, I wouldn't block merging this PR by that. It contains lot of other good stuff, has been open for quite some time and is quite ready to be merged.
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.
@tstrachota I didn't mean to block 😃 but just to raise a concern I have in Hardware Models
.
There's minor conflict again. I wasn't fast enough with the final review:( I'm sorry for that. Please rebase @amirfefer |
@tstrachota - rebased :) |
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 found two more issues on the empty states. Hopefully they'll be easy to fix.
The rest looks good and worked fine for me.
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`, |
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 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.
{url && | ||
<PfEmptyState.Help> | ||
{label} | ||
<a href={url}> {buttonLabel} </a> |
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.
@amirfefer could you rebase and fix the last two small comments from @tstrachota? :) |
what's the status here? |
This needs a rebase again. |
@amirfefer any updates on this? |
@waldenraines - basically i'd like to use table from this PR, will re-prioritize this soon :) |
@amirfefer what's the status here? |
any news here? :) |
@amirfefer this needs a bigger rebase now, could you please let us know if you plan to look at this soon? If there's no activity before next triage (2 weeks), we'd lean towards closing this. It would be unfrotunate as there were just 2 small things to finish this, but of course it can be reopened later if your availability for this PR changes. |
Unfortunatelly there was no reply for 2 weeks so we are closing this PR now. Please reopen if you're still interested in getting this in. |
About page uses 3 different old js files in order to check the status of compute resources and smart proxies.
I've extracted this status rendering to a react component
<About>
, in addition, I've united the UI style (by using Icons instead of labels).new components from pf-react:
Todoupdated gif (March) :
before: