-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
CNV-48466: Changing apperance of console - part 1
Signed-off-by: Matan Schatzman <[email protected]>
- Loading branch information
Showing
12 changed files
with
131 additions
and
295 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
95 changes: 33 additions & 62 deletions
95
src/utils/components/Consoles/components/AccessConsoles/AccessConsoles.tsx
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
47 changes: 17 additions & 30 deletions
47
src/utils/components/Consoles/components/AccessConsoles/utils/accessConsoles.tsx
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 |
---|---|---|
@@ -1,34 +1,21 @@ | ||
import * as React from 'react'; | ||
import { Dispatch, SetStateAction } from 'react'; | ||
|
||
export type AccessConsolesProps = { | ||
/** | ||
* Child element can be either | ||
* - <SerialConsole>, <VncConsole> or <DesktopViewer> | ||
* - or has a property "type" of value either SERIAL_CONSOLE_TYPE or VNC_CONSOLE_TYPE (useful when wrapping (composing) basic console components | ||
*/ | ||
children?: React.ReactElement[] | React.ReactNode; | ||
/** Initial selection of the Select */ | ||
preselectedType?: string; // NONE_TYPE | SERIAL_CONSOLE_TYPE | VNC_CONSOLE_TYPE | DESKTOP_VIEWER_CONSOLE_TYPE; | ||
/** The value for the Desktop Viewer Console option. This can be overriden by the type property of the child component */ | ||
textDesktopViewerConsole?: string; | ||
/** Placeholder text for the console selection */ | ||
textSelectConsoleType?: string; | ||
/** The value for the Serial Console option. This can be overriden by the type property of the child component */ | ||
textSerialConsole?: string; | ||
/** The value for the VNC Console option. This can be overriden by the type property of the child component */ | ||
textVncConsole?: string; | ||
}; | ||
import { t } from '@kubevirt-utils/hooks/useKubevirtTranslation'; | ||
|
||
export const getChildTypeName = (child: any) => | ||
child && child.props && child.props.type | ||
? child.props.type | ||
: (child && child.type && child.type.displayName) || null; | ||
import { | ||
DESKTOP_VIEWER_CONSOLE_TYPE, | ||
SERIAL_CONSOLE_TYPE, | ||
VNC_CONSOLE_TYPE, | ||
} from '../../utils/ConsoleConsts'; | ||
|
||
export const getConsoleForType = (consoleType: string, children) => | ||
React.Children.map(children as React.ReactElement[], (child: any) => { | ||
if (getChildTypeName(child) === consoleType) { | ||
return <React.Fragment key={getChildTypeName(child)}>{child}</React.Fragment>; | ||
} | ||
export type AccessConsolesProps = { | ||
isWindowsVM: boolean; | ||
setType: Dispatch<SetStateAction<string>>; | ||
type: string; | ||
}; | ||
|
||
return null; | ||
}); | ||
export const typeMap = (isWindowsVM: boolean) => ({ | ||
...(isWindowsVM && { [DESKTOP_VIEWER_CONSOLE_TYPE]: t('Desktop viewer') }), | ||
[SERIAL_CONSOLE_TYPE]: t('Serial console'), | ||
[VNC_CONSOLE_TYPE]: t('VNC console'), | ||
}); |
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
Oops, something went wrong.