Skip to content

Commit

Permalink
Remove dialog and support fullscreen
Browse files Browse the repository at this point in the history
  • Loading branch information
OskarDamkjaer committed Apr 10, 2021
1 parent d4d722d commit e66b02b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 101 deletions.
63 changes: 0 additions & 63 deletions src/browser/components/ConfirmationDialog.tsx

This file was deleted.

39 changes: 12 additions & 27 deletions src/browser/modules/Frame/FrameTitlebar.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ import {
} from 'shared/modules/stream/streamDuck'
import { sleep } from 'shared/services/utils'
import { FrameButton } from 'browser-components/buttons'
import ConfirmationDialog from 'browser-components/ConfirmationDialog'
import Render from 'browser-components/Render'
import { CSVSerializer } from 'services/serializer'
import {
Expand Down Expand Up @@ -133,7 +132,6 @@ function FrameTitlebar(props: FrameTitleBarProps) {
// makes sure the frame is updated as links in frame is followed
editorRef.current?.setValue(props.frame.cmd)
}, [props.frame.cmd])
const [confirmationDialogOpen, setConfirmationDialogOpen] = useState(false)
const editorRef = useRef<MonacoHandles>(null)

/* When the frametype is changed the titlebar is unmounted
Expand Down Expand Up @@ -163,6 +161,17 @@ function FrameTitlebar(props: FrameTitleBarProps) {
}, [props.frame.isRerun])
useEffect(gainFocusCallback, [gainFocusCallback])

useEffect(() => {
if (props.bus && props.fullscreen) {
return props.bus.take(editor.SET_CONTENT, ({ message }) => {
setRenderEditor(true)
// timeout needed for editor to mount if not yet mounted.
setTimeout(() => editorRef.current?.setValue(message), 0)
})
}
return undefined
}, [props.bus, props.fullscreen])

function hasData() {
return props.numRecords > 0
}
Expand Down Expand Up @@ -400,34 +409,10 @@ function FrameTitlebar(props: FrameTitleBarProps) {
<SVGInline svg={controlsPlay} width="12px" />
</FrameButton>
</Render>
<ConfirmationDialog
confirmLabel="Yes, close frame"
onClose={() => {
setConfirmationDialogOpen(false)
}}
onConfirm={() => {
setConfirmationDialogOpen(false)
props.onCloseClick(frame.id, frame.requestId, props.request)
}}
open={confirmationDialogOpen}
>
<h2 style={{ fontWeight: 'normal' }}>Close frame?</h2>
<p>
Closing the frame cannot be undone.
<br />
You can access you query history by running <code>
:history
</code>{' '}
command.
</p>
<p>Do you want to close the frame anyway?</p>
</ConfirmationDialog>
<FrameButton
title="Close"
onClick={() => {
frame.isRerun
? setConfirmationDialogOpen(true)
: props.onCloseClick(frame.id, frame.requestId, props.request)
props.onCloseClick(frame.id, frame.requestId, props.request)
}}
>
<CloseIcon />
Expand Down
15 changes: 8 additions & 7 deletions src/browser/modules/Frame/styled.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,12 +31,13 @@ export const StyledFrame = styled.article<FullscreenProps>`
${props =>
props.fullscreen
? `margin: 0;
position: fixed;
left: 0;
position: absolute;
left: -9px;
top: 0;
bottom: 0;
right: 0;
z-index: 130;`
bottom: 0px;
right: -10px;
z-index: 130;
`
: 'margin 0 0 10px 0;'}
&:hover .carousel-intro-animation {
Expand Down Expand Up @@ -105,9 +106,9 @@ export const StyledFrameContents = styled.div<FullscreenProps>`
min-height: ${dim.frameBodyHeight / 2}px;
max-height: ${props =>
props.fullscreen
? '100vh'
? 'auto'
: dim.frameBodyHeight - dim.frameStatusbarHeight * 2 + 'px'};
${props => (props.fullscreen ? 'height: 100vh' : null)};
${props => (props.fullscreen ? 'height: calc(100vh - 40px)' : null)};
flex: auto;
display: flex;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,12 @@
import styled from 'styled-components'
import { dim } from 'browser-styles/constants'

export const StyledVisContainer: any = styled.div`
export const StyledVisContainer = styled.div<{ fullscreen: boolean }>`
width: 100%;
overflow: hidden;
${(props: any) => (props.fullscreen ? 'padding-bottom: 39px' : null)};
height: ${(props: any) =>
height: ${props =>
props.fullscreen
? '100vh'
? 'calc(100vh - 40px)'
: dim.frameBodyHeight - dim.frameTitlebarHeight * 2 + 'px'};
> svg {
width: 100%;
Expand Down

0 comments on commit e66b02b

Please sign in to comment.