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

feat(VncConsole): More possibilities to customize component #1402

Merged
merged 1 commit into from
Aug 8, 2019

Conversation

bond95
Copy link
Contributor

@bond95 bond95 commented Feb 18, 2019

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:
image

@mareklibra please, review

@bond95 bond95 force-pushed the vnc-console-enhacement branch from a4d81f7 to 9f1014b Compare February 19, 2019 09:59
this.disconnect();
this.removeEventListeners();
this.rfb = undefined;
Copy link
Contributor

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?

Copy link
Contributor Author

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 = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why this change, please?

Copy link
Contributor Author

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.

Copy link
Member

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
Copy link
Contributor

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

Copy link
Contributor Author

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))
Copy link
Contributor

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.

Copy link
Contributor Author

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,
Copy link
Contributor

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.

Copy link
Contributor Author

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 = () => {
Copy link
Contributor

Choose a reason for hiding this comment

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

likewise

Copy link
Contributor Author

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 ? (
Copy link
Contributor

Choose a reason for hiding this comment

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

as commented above

@bond95
Copy link
Contributor Author

bond95 commented Mar 22, 2019

@mareklibra please, review.

@jeff-phillips-18
Copy link
Member

@mareklibra Could you please take another look?

@stale
Copy link

stale bot commented Jul 16, 2019

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the wontfix label Jul 16, 2019
@bond95
Copy link
Contributor Author

bond95 commented Jul 18, 2019

@priley86 could you, please, look at this PR?

@stale stale bot removed the wontfix label Jul 18, 2019
@priley86
Copy link
Member

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..

@bond95
Copy link
Contributor Author

bond95 commented Jul 24, 2019

@priley86

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..

captured (4)

Also, do you plan to add PF4 variation? This is still using PF3 menus/buttons/etc..

Yes, but in separate PR.

@bond95
Copy link
Contributor Author

bond95 commented Jul 26, 2019

@priley86 Could you, please, take another look?

return toolbar;
}
return (
document.getElementById(insertToolbarTo) && ReactDOM.createPortal(toolbar, document.getElementById(insertToolbarTo))
Copy link
Member

@priley86 priley86 Jul 26, 2019

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.

Copy link
Contributor Author

@bond95 bond95 Aug 1, 2019

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>
Copy link
Member

Choose a reason for hiding this comment

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

additional div?

Copy link
Contributor Author

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.

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

priley86
priley86 previously approved these changes Jul 26, 2019
Copy link
Member

@priley86 priley86 left a 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
Copy link
Member

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.

Copy link
Contributor Author

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.

if (!insertToolbarTo) {
return toolbar;
}
return (
document.getElementById(insertToolbarTo) && ReactDOM.createPortal(toolbar, document.getElementById(insertToolbarTo))
);

Copy link
Contributor Author

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.

@patternfly-build
Copy link
Contributor

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.
@bond95 bond95 force-pushed the vnc-console-enhacement branch from c57707d to 65fa453 Compare August 1, 2019 13:19
Copy link
Member

@jeff-phillips-18 jeff-phillips-18 left a 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.

@bond95
Copy link
Contributor Author

bond95 commented Aug 8, 2019

@priley86 could you, please, look one more?

@priley86
Copy link
Member

priley86 commented Aug 8, 2019

merging - please be sure to file any follow up issues after testing downstream further.

thanks @bond95 !

@priley86 priley86 merged commit 122d68a into patternfly:master Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants