All files / owid-grapher/grapher/controls AddEntityButton.tsx

97.78% Statements 44/45
50% Branches 1/2
50% Functions 1/2
97.78% Lines 44/45

Press n or j to go to the next uncovered block, b, p or k for the previous block.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 371x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 1x 14x 14x 14x 14x   14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 14x 1x 1x
import * as React from "react"
import { observer } from "mobx-react"
import { runInAction } from "mobx"
 
export interface AddEntityButtonManager {
    isSelectingData?: boolean
    entityType?: string
}
 
@observer
export class AddEntityButton extends React.Component<{
    manager: AddEntityButtonManager
}> {
    render(): JSX.Element {
        return (
            <button
                className="addEntityButton clickable"
                onClick={(): boolean =>
                    runInAction(
                        () => (this.props.manager.isSelectingData = true)
                    )
                }
                data-track-note="chart-add-entity"
            >
                <span className="icon">
                    <svg width={16} height={16}>
                        <path d="M3,8 h10 m-5,-5 v10" />
                    </svg>
                </span>
                <span className="label">{`Add ${
                    this.props.manager.entityType || "data"
                }`}</span>
            </button>
        )
    }
}