Move BodyDelete into func node menu

pull/10616/head
Alex P 2018-06-15 16:24:37 -07:00
parent 394fe281f3
commit d58f06b232
3 changed files with 12 additions and 18 deletions

View File

@ -26,13 +26,10 @@ class BodyBuilder extends PureComponent<Props> {
const bodybuilder = body.map((b, i) => { const bodybuilder = body.map((b, i) => {
if (b.declarations.length) { if (b.declarations.length) {
return b.declarations.map((d, dIndex) => { return b.declarations.map(d => {
if (d.funcs) { if (d.funcs) {
return ( return (
<div className="declaration" key={i}> <div className="declaration" key={i}>
{!dIndex && (
<BodyDelete bodyID={b.id} onDeleteBody={onDeleteBody} />
)}
<VariableNode name={d.name} assignedToQuery={true} /> <VariableNode name={d.name} assignedToQuery={true} />
<ExpressionNode <ExpressionNode
bodyID={b.id} bodyID={b.id}
@ -41,6 +38,7 @@ class BodyBuilder extends PureComponent<Props> {
funcs={d.funcs} funcs={d.funcs}
declarationsFromBody={this.declarationsFromBody} declarationsFromBody={this.declarationsFromBody}
isLastBody={this.isLastBody(i)} isLastBody={this.isLastBody(i)}
onDeleteBody={onDeleteBody}
/> />
</div> </div>
) )
@ -65,13 +63,13 @@ class BodyBuilder extends PureComponent<Props> {
return ( return (
<div className="declaration" key={i}> <div className="declaration" key={i}>
<BodyDelete bodyID={b.id} onDeleteBody={onDeleteBody} />
<ExpressionNode <ExpressionNode
bodyID={b.id} bodyID={b.id}
funcs={b.funcs} funcs={b.funcs}
funcNames={this.funcNames} funcNames={this.funcNames}
declarationsFromBody={this.declarationsFromBody} declarationsFromBody={this.declarationsFromBody}
isLastBody={this.isLastBody(i)} isLastBody={this.isLastBody(i)}
onDeleteBody={onDeleteBody}
/> />
</div> </div>
) )

View File

@ -15,6 +15,7 @@ interface Props {
declarationID?: string declarationID?: string
declarationsFromBody: string[] declarationsFromBody: string[]
isLastBody: boolean isLastBody: boolean
onDeleteBody: (bodyID: string) => void
} }
interface State { interface State {
@ -42,6 +43,7 @@ class ExpressionNode extends PureComponent<Props, State> {
funcNames, funcNames,
funcs, funcs,
declarationsFromBody, declarationsFromBody,
onDeleteBody,
} = this.props } = this.props
const {nonYieldableIndexesToggled} = this.state const {nonYieldableIndexesToggled} = this.state
@ -106,6 +108,7 @@ class ExpressionNode extends PureComponent<Props, State> {
onGenerateScript={onGenerateScript} onGenerateScript={onGenerateScript}
declarationsFromBody={declarationsFromBody} declarationsFromBody={declarationsFromBody}
onToggleYieldWithLast={this.handleToggleYieldWithLast} onToggleYieldWithLast={this.handleToggleYieldWithLast}
onDeleteBody={onDeleteBody}
/> />
) )
@ -152,6 +155,7 @@ class ExpressionNode extends PureComponent<Props, State> {
onGenerateScript={onGenerateScript} onGenerateScript={onGenerateScript}
declarationsFromBody={declarationsFromBody} declarationsFromBody={declarationsFromBody}
onToggleYieldWithLast={this.handleToggleYieldWithLast} onToggleYieldWithLast={this.handleToggleYieldWithLast}
onDeleteBody={onDeleteBody}
/> />
<YieldFuncNode <YieldFuncNode
index={i} index={i}

View File

@ -2,7 +2,7 @@ import React, {PureComponent, MouseEvent} from 'react'
import classnames from 'classnames' import classnames from 'classnames'
import _ from 'lodash' import _ from 'lodash'
import ConfirmButton from 'src/shared/components/ConfirmButton' import BodyDelete from 'src/flux/components/BodyDelete'
import FuncArgs from 'src/flux/components/FuncArgs' import FuncArgs from 'src/flux/components/FuncArgs'
import FuncArgsPreview from 'src/flux/components/FuncArgsPreview' import FuncArgsPreview from 'src/flux/components/FuncArgsPreview'
import { import {
@ -29,6 +29,7 @@ interface Props {
declarationsFromBody: string[] declarationsFromBody: string[]
isYielding: boolean isYielding: boolean
isYieldable: boolean isYieldable: boolean
onDeleteBody: (bodyID: string) => void
} }
interface State { interface State {
@ -138,19 +139,10 @@ export default class FuncNode extends PureComponent<Props, State> {
} }
private get deleteButton(): JSX.Element { private get deleteButton(): JSX.Element {
const {name} = this.props.func const {func, bodyID, onDeleteBody} = this.props
if (name === 'from') { if (func.name === 'from') {
return ( return <BodyDelete onDeleteBody={onDeleteBody} bodyID={bodyID} />
<ConfirmButton
icon="trash"
type="btn-danger"
confirmText="Delete this query"
square={true}
confirmAction={this.handleDelete}
position="right"
/>
)
} }
return ( return (