-
Notifications
You must be signed in to change notification settings - Fork 360
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
feat(VncConsole): More possibilities to customize component #1402
Conversation
a4d81f7
to
9f1014b
Compare
this.disconnect(); | ||
this.removeEventListeners(); | ||
this.rfb = undefined; |
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.
With this change, the RFB.disconnect()
is skipped. Can you please explain reason for that?
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.
But no, it doesn't skipped. Line 66 perform disconnecting. And previously onDisconnected
event doesn't work, because it removed all listeners before it disconnected.
} | ||
|
||
disconnect() { | ||
disconnect = () => { |
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 this change, please?
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.
Because otherwise method doesn't get this
context.
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.
+1
textDisconnect, | ||
onCtrlAltDel, | ||
onDisconnect, | ||
portalToolbarTo |
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.
The name is too specific for the oVirt VM Portal
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.
Well, it calling portalToolbarTo
, because if it set it do portal toolbar to some element, not because this is from VM Portal. But yeah, it better to rename.
return toolbar; | ||
} | ||
return ( | ||
document.getElementById(portalToolbarTo) && ReactDOM.createPortal(toolbar, document.getElementById(portalToolbarTo)) |
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 don't think we should perform such manipulations. I believe change in the component composition should be preferred over this approach.
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.
Yes, but in that case appear problem with customization. For example, in VM Portal we need only one toolbar not two and we can't Send Key
dropdown move to our toolbar, because console is fully under control of VncConsole
component.
And I think this is most suitable solution.
}; | ||
|
||
VncActions.defaultProps = { | ||
onCtrlAltDel: noop, | ||
onDisconnect: noop, |
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 is a breaking change.
The consuming application is silently required to add implementation. Otherwise the button just appears there without any function.
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.
Ok, I'll do onDisconnect
props required, but this is was just copy from onCtlAltDel
. So why in this case onCtrlAltDel: noop
not required too?
@@ -95,11 +96,11 @@ class VncConsole extends React.Component { | |||
this.props.onSecurityFailure(e); | |||
}; | |||
|
|||
removeEventListeners() { | |||
removeEventListeners = () => { |
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.
likewise
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.
Because of context.
{status} | ||
{this.novncStaticComponent} | ||
</Toolbar.Results> | ||
{portalToolbarTo ? ( |
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.
as commented above
9f1014b
to
223e582
Compare
@mareklibra please, review. |
@mareklibra Could you please take another look? |
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. |
@priley86 could you, please, look at this PR? |
like other VncConsole PRs, this is hard to visualize. Can you possibly share an environment this is running w/ me? Or maybe it is easier to record a gif from your machine.. Also, do you plan to add PF4 variation? This is still using PF3 menus/buttons/etc.. |
Yes, but in separate PR. |
@priley86 Could you, please, take another look? |
return toolbar; | ||
} | ||
return ( | ||
document.getElementById(insertToolbarTo) && ReactDOM.createPortal(toolbar, document.getElementById(insertToolbarTo)) |
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.
does this need to be a portal? We don't typically use portals for elements that will render in the typical DOM/page content area (they are more often used for appending modals/popovers/etc.).
I'm not currently using this downstream, so I can't say for sure, but you may be able to just expose it as a simple stateless component... we always break the JSX down into smaller reusable components if possible.
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.
does this need to be a portal?
Yes, this component is depend on VncConsole component and for correct work should only be used inside of VncConsole. So from my point of view portals are the best solution.
> | ||
<MenuItem | ||
bsClass="dropdown" | ||
<div> |
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.
additional div?
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.
No, div
should be there.
patternfly-react/packages/patternfly-3/react-console/src/VncConsole/VncActions.js
Lines 17 to 28 in 223e582
const toolbar = ( | |
<div> | |
<Dropdown bsStyle="default" title={textSendShortcut} id="console-send-shortcut" onClick={noop}> | |
<MenuItem eventKey="1" onClick={onCtrlAltDel}> | |
{textCtrlAltDel} | |
</MenuItem> | |
</Dropdown> | |
<Button bsStyle="default" onClick={onDisconnect}> | |
{textDisconnect} | |
</Button> | |
</div> | |
); |
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.
Conditionally approving. I don't want to block this effort since it is a 3rd party component being used w/ PF3. Added some comments above though.
All of this markup/CSS should be revisited w/ PF4 layouts/classes eventually if being put into a PF4 app. It seems like we are applying some additional divs/layout CSS which shouldn't be necessary in a PF4 context.
cc: @jeff-phillips-18 @mareklibra
thanks for the contribution @bond95 !
textSendShortcut: PropTypes.string, | ||
textDisconnect: PropTypes.string, | ||
|
||
insertToolbarTo: PropTypes.string |
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 would this be used? I don't see it being used here at all.
These propTypes should all be commented.
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 would this be used? I don't see it being used here at all.
It is used in VncActions.
patternfly-react/packages/patternfly-3/react-console/src/VncConsole/VncActions.js
Lines 30 to 35 in 223e582
if (!insertToolbarTo) { | |
return toolbar; | |
} | |
return ( | |
document.getElementById(insertToolbarTo) && ReactDOM.createPortal(toolbar, document.getElementById(insertToolbarTo)) | |
); |
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.
These propTypes should all be commented.
Added comment.
223e582
to
c57707d
Compare
PatternFly-React preview: https://patternfly-react-pr-1402.surge.sh |
…traction toolbar and console sc Added possibility to extract toolbar to any other component. Added scaling prop to VncConsole, and enhance `textConnecting` props to use node type as well. And fixed disconnecting.
c57707d
to
65fa453
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.
Approving but agree with @priley86's comments.
Also, most of the console components do not show examples and while that is OK since they can't be demo'd without a backend, the components' properties should all be commented correctly for storybook info documentation and the components force included in the stories so that the docs for each component is provided.
This is not specific to this change as this is all pre-existing.
@priley86 could you, please, look one more? |
merging - please be sure to file any follow up issues after testing downstream further. thanks @bond95 ! |
What:
Added possibility to extract toolbar to any other component. Added scaling prop to VncConsole, and
enhance
textConnecting
props to use node type as well. And fixed disconnecting.We need this features for console page in oVirt VM Portal: oVirt/ovirt-web-ui#956
Example from oVirt VM Portal:

@mareklibra please, review