Make pencil menu into getter to remove ternary

pull/3458/head
Alex P 2018-05-17 11:04:46 -07:00
parent 7b32e68c14
commit 21fdf585c5
1 changed files with 18 additions and 14 deletions

View File

@ -69,13 +69,7 @@ class LayoutCellMenu extends Component<Props, State> {
}
private get renderMenu(): JSX.Element {
const {
isEditable,
mode,
cell,
onDismissEditingAnnotation,
queries,
} = this.props
const {isEditable, mode, cell, onDismissEditingAnnotation} = this.props
if (mode === EDITING && cellSupportsAnnotations(cell.type)) {
return (
@ -93,13 +87,7 @@ class LayoutCellMenu extends Component<Props, State> {
if (isEditable && mode !== EDITING) {
return (
<div className="dash-graph-context--buttons">
{queries.length ? (
<MenuTooltipButton
icon="pencil"
menuItems={this.editMenuItems}
informParent={this.handleToggleSubMenu}
/>
) : null}
{this.pencilMenu}
<Authorized requiredRole={EDITOR_ROLE}>
<MenuTooltipButton
icon="duplicate"
@ -118,6 +106,22 @@ class LayoutCellMenu extends Component<Props, State> {
}
}
private get pencilMenu(): JSX.Element {
const {queries} = this.props
if (!queries.length) {
return
}
return (
<MenuTooltipButton
icon="pencil"
menuItems={this.editMenuItems}
informParent={this.handleToggleSubMenu}
/>
)
}
private get contextMenuClassname(): string {
const {subMenuIsOpen} = this.state