forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(react-console): accept random children in AccessConsole component (
patternfly#6374) So far we were supporting children of three types, SerialConsole, DesktopViewer and VncConsole. This component is consumed by `cockpit machines` product and it's used for exposing consoles of Virtual Machines. A Virtual Machines however can have multiple consoles of one type; for example 2 different serial consoles, something which was not supported until this commit. For this reason we need to extend this component to accept also custom children apart from a single from each from the predefined types. Also start respecting the order of the children to display the options in the AccessConsoles dropdown.
- Loading branch information
Showing
6 changed files
with
87 additions
and
72 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/react-console/src/components/AccessConsoles/examples/SerialConsoleCustom.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
import React from 'react'; | ||
import { debounce } from '@patternfly/react-core'; | ||
import { SerialConsole } from '@patternfly/react-console'; | ||
|
||
export const SerialConsoleCustom = () => { | ||
const [status, setStatus] = React.useState('disconnected'); | ||
const setConnected = React.useRef(debounce(() => setStatus('connected'), 3000)).current; | ||
const ref2 = React.createRef(); | ||
|
||
return ( | ||
<SerialConsole | ||
onConnect={() => { | ||
setStatus('loading'); | ||
setConnected(); | ||
}} | ||
onDisconnect={() => setStatus('disconnected')} | ||
onData={data => { | ||
ref2.current.onDataReceived(data); | ||
}} | ||
status={status} | ||
ref={ref2} | ||
/> | ||
); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters