|
|
@ -1,12 +1,9 @@ |
|
|
|
|
|
|
|
import { FC, ReactNode, useEffect, useState } from 'react'; |
|
|
|
import { |
|
|
|
import { |
|
|
|
Dispatch, |
|
|
|
Box, |
|
|
|
FC, |
|
|
|
IconButton as MUIIconButton, |
|
|
|
ReactNode, |
|
|
|
IconButtonProps as MUIIconButtonProps, |
|
|
|
SetStateAction, |
|
|
|
} from '@mui/material'; |
|
|
|
useEffect, |
|
|
|
|
|
|
|
useState, |
|
|
|
|
|
|
|
} from 'react'; |
|
|
|
|
|
|
|
import { Box, IconButton as MUIIconButton } from '@mui/material'; |
|
|
|
|
|
|
|
import { |
|
|
|
import { |
|
|
|
DesktopWindows as DesktopWindowsIcon, |
|
|
|
DesktopWindows as DesktopWindowsIcon, |
|
|
|
PowerOffOutlined as PowerOffOutlinedIcon, |
|
|
|
PowerOffOutlined as PowerOffOutlinedIcon, |
|
|
@ -15,7 +12,7 @@ import { |
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; |
|
|
|
import API_BASE_URL from '../../lib/consts/API_BASE_URL'; |
|
|
|
import { BORDER_RADIUS, GREY } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
import { BORDER_RADIUS, GREY } from '../../lib/consts/DEFAULT_THEME'; |
|
|
|
|
|
|
|
|
|
|
|
import IconButton from '../IconButton'; |
|
|
|
import IconButton, { IconButtonProps } from '../IconButton'; |
|
|
|
import { InnerPanel, InnerPanelHeader, Panel, PanelHeader } from '../Panels'; |
|
|
|
import { InnerPanel, InnerPanelHeader, Panel, PanelHeader } from '../Panels'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
import { BodyText, HeaderText } from '../Text'; |
|
|
|
|
|
|
|
|
|
|
@ -26,23 +23,28 @@ type PreviewOptionalProps = { |
|
|
|
isFetchPreview?: boolean; |
|
|
|
isFetchPreview?: boolean; |
|
|
|
isShowControls?: boolean; |
|
|
|
isShowControls?: boolean; |
|
|
|
isUseInnerPanel?: boolean; |
|
|
|
isUseInnerPanel?: boolean; |
|
|
|
|
|
|
|
onClickConnectButton?: IconButtonProps['onClick']; |
|
|
|
|
|
|
|
onClickPreview?: MUIIconButtonProps['onClick']; |
|
|
|
serverName?: string; |
|
|
|
serverName?: string; |
|
|
|
setMode?: Dispatch<SetStateAction<boolean>> | null; |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
type PreviewProps = PreviewOptionalProps & { |
|
|
|
type PreviewProps = PreviewOptionalProps & { |
|
|
|
serverUUID: string; |
|
|
|
serverUUID: string; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const PREVIEW_DEFAULT_PROPS: Required<PreviewOptionalProps> = { |
|
|
|
const PREVIEW_DEFAULT_PROPS: Required< |
|
|
|
|
|
|
|
Omit<PreviewOptionalProps, 'onClickConnectButton' | 'onClickPreview'> |
|
|
|
|
|
|
|
> & |
|
|
|
|
|
|
|
Pick<PreviewOptionalProps, 'onClickConnectButton' | 'onClickPreview'> = { |
|
|
|
externalPreview: '', |
|
|
|
externalPreview: '', |
|
|
|
headerEndAdornment: null, |
|
|
|
headerEndAdornment: null, |
|
|
|
isExternalPreviewStale: false, |
|
|
|
isExternalPreviewStale: false, |
|
|
|
isFetchPreview: true, |
|
|
|
isFetchPreview: true, |
|
|
|
isShowControls: true, |
|
|
|
isShowControls: true, |
|
|
|
isUseInnerPanel: false, |
|
|
|
isUseInnerPanel: false, |
|
|
|
|
|
|
|
onClickConnectButton: undefined, |
|
|
|
|
|
|
|
onClickPreview: undefined, |
|
|
|
serverName: '', |
|
|
|
serverName: '', |
|
|
|
setMode: null, |
|
|
|
|
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const PreviewPanel: FC<{ isUseInnerPanel: boolean }> = ({ |
|
|
|
const PreviewPanel: FC<{ isUseInnerPanel: boolean }> = ({ |
|
|
@ -78,9 +80,10 @@ const Preview: FC<PreviewProps> = ({ |
|
|
|
isFetchPreview = PREVIEW_DEFAULT_PROPS.isFetchPreview, |
|
|
|
isFetchPreview = PREVIEW_DEFAULT_PROPS.isFetchPreview, |
|
|
|
isShowControls = PREVIEW_DEFAULT_PROPS.isShowControls, |
|
|
|
isShowControls = PREVIEW_DEFAULT_PROPS.isShowControls, |
|
|
|
isUseInnerPanel = PREVIEW_DEFAULT_PROPS.isUseInnerPanel, |
|
|
|
isUseInnerPanel = PREVIEW_DEFAULT_PROPS.isUseInnerPanel, |
|
|
|
|
|
|
|
onClickPreview: previewClickHandler, |
|
|
|
serverName, |
|
|
|
serverName, |
|
|
|
serverUUID, |
|
|
|
serverUUID, |
|
|
|
setMode, |
|
|
|
onClickConnectButton: connectButtonClickHandle = previewClickHandler, |
|
|
|
}) => { |
|
|
|
}) => { |
|
|
|
const [isPreviewStale, setIsPreviewStale] = useState<boolean>(false); |
|
|
|
const [isPreviewStale, setIsPreviewStale] = useState<boolean>(false); |
|
|
|
const [preview, setPreview] = useState<string>(''); |
|
|
|
const [preview, setPreview] = useState<string>(''); |
|
|
@ -130,7 +133,7 @@ const Preview: FC<PreviewProps> = ({ |
|
|
|
<Box> |
|
|
|
<Box> |
|
|
|
<MUIIconButton |
|
|
|
<MUIIconButton |
|
|
|
component="span" |
|
|
|
component="span" |
|
|
|
onClick={() => setMode?.call(null, false)} |
|
|
|
onClick={previewClickHandler} |
|
|
|
sx={{ |
|
|
|
sx={{ |
|
|
|
borderRadius: BORDER_RADIUS, |
|
|
|
borderRadius: BORDER_RADIUS, |
|
|
|
color: GREY, |
|
|
|
color: GREY, |
|
|
@ -161,7 +164,7 @@ const Preview: FC<PreviewProps> = ({ |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|
{isShowControls && ( |
|
|
|
{isShowControls && ( |
|
|
|
<Box> |
|
|
|
<Box> |
|
|
|
<IconButton onClick={() => setMode?.call(null, false)}> |
|
|
|
<IconButton onClick={connectButtonClickHandle}> |
|
|
|
<DesktopWindowsIcon /> |
|
|
|
<DesktopWindowsIcon /> |
|
|
|
</IconButton> |
|
|
|
</IconButton> |
|
|
|
</Box> |
|
|
|
</Box> |
|
|
|