From 1db5de72d1c26c6db4f045850424203aeb6222f9 Mon Sep 17 00:00:00 2001 From: Del Date: Thu, 7 Jun 2018 18:04:05 -0700 Subject: [PATCH] Move time machine visualization from bottom division to yield func node component Co-authored-by: Iris Scholten Co-authored-by: Delmer Reed --- ui/src/flux/components/ExpressionNode.tsx | 47 +++++++++----- ui/src/flux/components/TimeMachine.tsx | 63 +++++++++---------- ui/src/flux/components/YieldFuncNode.tsx | 32 ++++++++++ ui/src/flux/containers/FluxPage.tsx | 5 +- .../shared/components/threesizer/Division.tsx | 5 +- .../components/threesizer/Threesizer.tsx | 49 ++++++++------- ui/src/types/flux.ts | 1 + 7 files changed, 126 insertions(+), 76 deletions(-) create mode 100644 ui/src/flux/components/YieldFuncNode.tsx diff --git a/ui/src/flux/components/ExpressionNode.tsx b/ui/src/flux/components/ExpressionNode.tsx index dbdb50e26..f83dea1c0 100644 --- a/ui/src/flux/components/ExpressionNode.tsx +++ b/ui/src/flux/components/ExpressionNode.tsx @@ -3,6 +3,7 @@ import React, {PureComponent} from 'react' import {FluxContext} from 'src/flux/containers/FluxPage' import FuncSelector from 'src/flux/components/FuncSelector' import FuncNode from 'src/flux/components/FuncNode' +import YieldFuncNode from 'src/flux/components/YieldFuncNode' import {Func} from 'src/types/flux' @@ -24,6 +25,7 @@ class ExpressionNode extends PureComponent { funcs, declarationsFromBody, } = this.props + return ( {({ @@ -33,24 +35,39 @@ class ExpressionNode extends PureComponent { onGenerateScript, onToggleYield, service, + data, }) => { return ( <> - {funcs.map((func, i) => ( - - ))} + {funcs.map((func, i) => { + if (func.name === 'yield') { + return ( + + ) + } + return ( + + ) + })} { public render() { return ( ) } - private get mainSplit() { - const {data} = this.props + private get verticals() { return [ { handleDisplay: 'none', @@ -56,31 +52,40 @@ class TimeMachine extends PureComponent { headerButtons: [], render: () => ( ), }, - { - handlePixels: 8, - menuOptions: [], - headerButtons: [], - style: {overflow: 'visible'} as CSSProperties, - render: () => , - }, + this.builder, ] } - private get divisions() { + private get builder() { + const {body, service, suggestions, onAppendFrom, onAppendJoin} = this.props + + return { + name: 'Build', + headerButtons: [], + menuOptions: [], + render: () => ( + + ), + } + } + private get scriptAndExplorer() { const { - body, script, status, service, onAnalyze, suggestions, - onAppendFrom, - onAppendJoin, onChangeScript, onSubmitScript, } = this.props @@ -91,9 +96,11 @@ class TimeMachine extends PureComponent { headerButtons: [], menuOptions: [], render: () => , + headerOrientation: HANDLE_VERTICAL, }, { name: 'Script', + headerOrientation: HANDLE_VERTICAL, headerButtons: [
{ /> ), }, - { - name: 'Build', - headerButtons: [], - menuOptions: [], - render: () => ( - - ), - }, ] } } diff --git a/ui/src/flux/components/YieldFuncNode.tsx b/ui/src/flux/components/YieldFuncNode.tsx new file mode 100644 index 000000000..0542b0241 --- /dev/null +++ b/ui/src/flux/components/YieldFuncNode.tsx @@ -0,0 +1,32 @@ +import React, {PureComponent} from 'react' +import _ from 'lodash' + +import {ErrorHandling} from '../../shared/decorators/errors' + +import {FluxTable} from 'src/types' +import {Func} from 'src/types/flux' +import TimeMachineVis from './TimeMachineVis' + +interface Props { + data: FluxTable[] + index: number + bodyID: string + func: Func + declarationID?: string +} + +@ErrorHandling +class YieldFuncNode extends PureComponent { + public render() { + const {data, func} = this.props + const yieldName = _.get(func, 'args.0.value', 'result') + return ( +
+ {yieldName} + +
+ ) + } +} + +export default YieldFuncNode diff --git a/ui/src/flux/containers/FluxPage.tsx b/ui/src/flux/containers/FluxPage.tsx index 97e391662..f02776481 100644 --- a/ui/src/flux/containers/FluxPage.tsx +++ b/ui/src/flux/containers/FluxPage.tsx @@ -95,7 +95,7 @@ export class FluxPage extends PureComponent { } public render() { - const {suggestions, data, body, status} = this.state + const {suggestions, body, status} = this.state const {script} = this.props return ( @@ -104,7 +104,6 @@ export class FluxPage extends PureComponent {
{this.header} { onGenerateScript: this.handleGenerateScript, onToggleYield: this.handleToggleYield, service: this.service, + data: this.state.data, } } @@ -366,6 +366,7 @@ export class FluxPage extends PureComponent { const {funcs: bodyFuncs, declarations} = body let funcs = bodyFuncs + if (!_.isEmpty(declarations)) { funcs = _.flatMap(declarations, d => d.funcs) } diff --git a/ui/src/shared/components/threesizer/Division.tsx b/ui/src/shared/components/threesizer/Division.tsx index e1c0ff783..2534e7e64 100644 --- a/ui/src/shared/components/threesizer/Division.tsx +++ b/ui/src/shared/components/threesizer/Division.tsx @@ -25,6 +25,7 @@ interface Props { draggable: boolean orientation: string activeHandleID: string + headerOrientation: string render: (visibility: string) => ReactElement onHandleStartDrag: (id: string, e: MouseEvent) => void onDoubleClick: (id: string) => void @@ -191,8 +192,8 @@ class Division extends PureComponent { } private get contentsClass(): string { - const {orientation, size} = this.props - return classnames(`threesizer--contents ${orientation}`, { + const {headerOrientation, size} = this.props + return classnames(`threesizer--contents ${headerOrientation}`, { 'no-shadows': !size, }) } diff --git a/ui/src/shared/components/threesizer/Threesizer.tsx b/ui/src/shared/components/threesizer/Threesizer.tsx index cc8a6bb32..47e01b039 100644 --- a/ui/src/shared/components/threesizer/Threesizer.tsx +++ b/ui/src/shared/components/threesizer/Threesizer.tsx @@ -133,28 +133,33 @@ class Threesizer extends Component { onMouseMove={this.handleDrag} ref={r => (this.containerRef = r)} > - {divisions.map((d, i) => ( - 0} - orientation={orientation} - handlePixels={d.handlePixels} - handleDisplay={d.handleDisplay} - activeHandleID={activeHandleID} - onMaximize={this.handleMaximize} - onMinimize={this.handleMinimize} - onDoubleClick={this.handleDoubleClick} - render={this.props.divisions[i].render} - onHandleStartDrag={this.handleStartDrag} - menuOptions={this.props.divisions[i].menuOptions} - headerButtons={this.props.divisions[i].headerButtons} - /> - ))} + {divisions.map((d, i) => { + const headerOrientation = _.get(d, 'headerOrientation', orientation) + + return ( + 0} + orientation={orientation} + handlePixels={d.handlePixels} + handleDisplay={d.handleDisplay} + activeHandleID={activeHandleID} + onMaximize={this.handleMaximize} + onMinimize={this.handleMinimize} + headerOrientation={headerOrientation} + onDoubleClick={this.handleDoubleClick} + render={this.props.divisions[i].render} + onHandleStartDrag={this.handleStartDrag} + menuOptions={this.props.divisions[i].menuOptions} + headerButtons={this.props.divisions[i].headerButtons} + /> + ) + })}
) } diff --git a/ui/src/types/flux.ts b/ui/src/types/flux.ts index 39488be4e..9cbce4a1a 100644 --- a/ui/src/types/flux.ts +++ b/ui/src/types/flux.ts @@ -30,6 +30,7 @@ export interface Context { onGenerateScript: OnGenerateScript onToggleYield: OnToggleYield service: Service + data: FluxTable[] } export interface DeleteFuncNodeArgs {