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
open the VNC console in a new window #5593
open the VNC console in a new window #5593
Conversation
@glekner: This pull request references Bugzilla bug 1837677, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
@glekner: This pull request references Bugzilla bug 1837677, which is invalid:
Comment In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
frontend/public/components/app.jsx
Outdated
@@ -229,6 +230,7 @@ render( | |||
<Provider store={store}> | |||
<Router history={history} basename={window.SERVER_FLAGS.basePath}> | |||
<Switch> | |||
<Route path="/vm-console" component={CloudVMConsole} /> |
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.
IMHO our route table is a better place for a route we use, see for example:
https://github.com/openshift/console/blob/master/frontend/packages/kubevirt-plugin/src/plugin.tsx#L158
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.
Mounting the route here will mount the layout aswell, we want to render the console alone
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.
Are we okay with rendering a kubevirt component here? Are we going to add an extension point for this in the future?
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.
Mounting the route here will mount the layout aswell, we want to render the console alone
With #5645 a plugin can add new page & route that is rendered outside the standard Console <App>
layout.
I think the CloudVMConsole
page fits this use case, so we shouldn't need to modify the core app.jsx
.
|
||
const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({ location, flags }) => { | ||
const params = new URLSearchParams(location.search); | ||
const consoleType = params.get('console'); |
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.
can we make the constants a bit simpler? like vnc | serial | rdp
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.
and maybe name it just type
?
return ( | ||
<ConnectedVMConsole | ||
isKubevirt={flags.KUBEVIRT} | ||
consoleType={consoleType === 'SerialConsole' ? 'SerialConsole' : 'VncConsole'} |
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.
Can we create an enum for this?
'', | ||
`width=1024,height=768,left=200,top=200`, | ||
); | ||
|
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.
IMHO we shouldn't create an additional logic for this. We should have the same behaviour when somebody opens the console in the new tab by themselves.
Can we just create a simple link with href="/vm-console" target="_blank" rel="noopener noreferrer"
?
Current console will get Disconnected
by default in the current window
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.
From my experience they interfere each other.
also having a variable for the window
helps us know if it got blocked by an Adblocker or not.
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.
What do you mean by interfering? You can still open a new tab with /vm-console
.
You don't have to care about adblock when you have link for a new tab
@@ -63,7 +65,13 @@ const VMConsoles: React.FC<VMConsolesProps> = ({ | |||
serial, | |||
rdp, | |||
LoadingComponent, |
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.
we could also add the url console type param for /k8s/ns/default/virtualmachines/vm-example/consoles
optional: true, | ||
}, | ||
{ | ||
kind: DataVolumeModel.kind, |
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 tagging resources are becoming quite a big pain. We should refactor how we use them.
ee498d0
to
6b41f7d
Compare
frontend/public/components/app.jsx
Outdated
@@ -229,6 +230,7 @@ render( | |||
<Provider store={store}> | |||
<Router history={history} basename={window.SERVER_FLAGS.basePath}> | |||
<Switch> | |||
<Route path="/vm-console" component={CloudVMConsole} /> |
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.
Mounting the route here will mount the layout aswell, we want to render the console alone
With #5645 a plugin can add new page & route that is rendered outside the standard Console <App>
layout.
I think the CloudVMConsole
page fits this use case, so we shouldn't need to modify the core app.jsx
.
@@ -0,0 +1,27 @@ | |||
import * as React from 'react'; | |||
import { connectToFlags, FlagsObject } from '@console/internal/reducers/features'; | |||
import ConnectedVMConsole from '@console/kubevirt-plugin/src/components/connected-vm-console/connected-vm-console'; |
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.
return ( | ||
<ConnectedVMConsole | ||
isKubevirt={flags.KUBEVIRT} | ||
type={type === ConsoleType.SERIAL ? ConsoleType.SERIAL : ConsoleType.VNC} |
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 not simply use value pass-through?
type={type === ConsoleType.SERIAL ? ConsoleType.SERIAL : ConsoleType.VNC} | |
type={type} |
The value should be already coerced via ConsoleType.fromString
logic.
location: Location; | ||
}; | ||
|
||
export default connectToFlags('KUBEVIRT')(CloudVMConsole); |
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.
Shouldn't we import & use the KubeVirt flag name as a constant?
}); | ||
|
||
return ( | ||
<VmConsolesWrapper |
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.
<VmConsolesWrapper | |
<VMConsolesWrapper |
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.
Also why "consoles" (plural) ?
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.
Patternfly's AccessConsoles
is plural, so I guess someone thought its in place. ( I didnt name the components)
<> | ||
<TextListItem component={TextListItemVariants.dt}>name</TextListItem> | ||
<TextListItem component={TextListItemVariants.dd}> | ||
Missing name of the VM/VMI |
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.
Nit: I'd omit the "Missing" prefix since it's already mentioned above ("Missing Required URL Parameters").
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.
Missing name of the VM/VMI | |
Name of the VM/VMI |
<> | ||
<TextListItem component={TextListItemVariants.dt}>namespace</TextListItem> | ||
<TextListItem component={TextListItemVariants.dd}> | ||
Missing namespace of the VM/VMI |
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.
Missing namespace of the VM/VMI | |
Namespace of the VM/VMI |
.vm-console-actions { | ||
padding: 0 30px; | ||
} | ||
.vm-console-bottom-gutter { |
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.
Nit: please separate CSS declarations with newline.
> | ||
<SerialConsoleConnector {...serial} /> | ||
<VncConsole {...vnc} /> | ||
{desktopViewverSelector} |
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.
{desktopViewverSelector} | |
{desktopViewerSelector} |
); | ||
}; | ||
|
||
const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => { | ||
const { vm: vmProp, vmi, pods, vmStatusBundle } = props; | ||
export const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => { |
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.
export const VmConsolesWrapper: React.FC<VmConsolesWrapperProps> = (props) => { | |
export const VMConsoleWrapper: React.FC<VmConsolesWrapperProps> = (props) => { |
@glekner: No Bugzilla bug is referenced in the title of this pull request. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
c09e6b6
to
111b73a
Compare
|
||
export class ConsoleType extends ObjectEnum<string> { | ||
static readonly VNC = new ConsoleType('VncConsole'); | ||
static readonly SERIAL = new ConsoleType('SerialConsole'); |
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.
Maybe we should allow navigating to DesktopViewer as well. And default to VNC when not available.
We also might select the vnc or serial if we detect one of them is not available.
thoughts?
cc @mareklibra
</Button> | ||
)} | ||
<AccessConsoles | ||
preselectedType={type?.toString() || VNC_CONSOLE_TYPE} |
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.
here select the right type if the desired one is not available
<Button | ||
className="vm-console-bottom-gutter" | ||
variant="secondary" | ||
onClick={() => window.open(`/vm-console?namespace=${namespace}&name=${vmName}`)} |
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.
can we use this here?
href={href}
target="_blank"
rel="noopener noreferrer"
|
||
const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({ location, flags }) => { | ||
const params = new URLSearchParams(location.search); | ||
const type = ConsoleType.fromString(params.get('console')); |
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.
Can we use a shorter name without uppercases for the URL?
console=vnc
instead of console=VncConsole
and console=serial
We could define both in ConsoleType
to have them together in one enum instance and use the second one for pf react-console
import { ConsoleEmptyState } from './vm-console-empty-state'; | ||
import { ConsoleType } from '../../constants/vm/console-type'; | ||
|
||
const CloudVMConsole: React.FC<CloudVMConsoleProps> = ({ |
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.
What is the reason for calling this Cloud
? ^^
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.
Just took inspiration from the CloudTerminal
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.
IMO it is better not to overuse words like this, because people will try to find meaning in them after they try to touch this code in one year
b927585
to
9f54dec
Compare
component="a" | ||
target="_blank" | ||
variant="secondary" | ||
href={`/k8s/ns/${namespace}/virtualmachineinstances/${vmName}/standaloneconsole?type=${consoleType.toString()}`} |
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.
NPE: consoleType could be null if no console is supported by VM
return null; | ||
}; | ||
|
||
const consoleType = typeNotSupported || type === undefined ? getAvailableType() : type; |
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.
nit: IMO it is always better to use type == null unless we have a special use case that has different behaviour for null vs 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.
fixed
d225b96
to
84579bc
Compare
/test e2e-gcp-console |
/lgtm |
/retest Please review the full test history for this PR and help us cut down flakes. |
3 similar comments
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/retest Please review the full test history for this PR and help us cut down flakes. |
/test analyze |
/retest Please review the full test history for this PR and help us cut down flakes. |
1 similar comment
/retest Please review the full test history for this PR and help us cut down flakes. |
/lgtm cancel Analyze is failing, probably because |
/retest |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: glekner, rawagner, suomiy The full list of commands accepted by this bot can be found here. The pull request process is described here
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
design: openshift/openshift-origin-design#425
JIRA: https://issues.redhat.com/browse/CNV-5111
This enables opening an independent new window for a VM/VMI console.
Opening a new window disables the main window's console as they can cause disconnects between each other. closing the new window returns the console to the main window.
closing the main window doesn't affect the new window :)
If the new window fails to open due to some Adblocker, an alert is shown.
We're introducing a new route
/vm-console
with 3 URL Parameters:name
,namespace
,console
if
console=SerialConsole
it will open the serial console, for every other string or missing parameter it will openVncConsole
If
name
ornamespace
or both are missing or misspelled, an error is shownVideo showing the new feature: