/* global $ */ import React, { PropTypes, Component } from 'react' import MetacodeSelect from '../MetacodeSelect' import Permission from './Permission' // TODO use a callback instead of an import import Visualize from '../../Metamaps/Visualize' class Links extends Component { constructor(props) { super(props) this.state = { showMetacodeTitle: false, showMetacodeSelect: false, showInMaps: false, showMoreMaps: false, hoveringMapCount: false, hoveringSynapseCount: false } } handleMetacodeSelect = metacodeId => { this.setState({ showMetacodeSelect: false }) this.props.updateTopic({ metacode_id: metacodeId }) Visualize.mGraph.plot() } toggleShowMoreMaps = e => { e.stopPropagation() e.preventDefault() this.setState({ showMoreMaps: !this.state.showMoreMaps }) } updateState = (key, value) => () => { this.setState({ [key]: value }) } inMaps = (topic) => { const inmapsArray = topic.get('inmaps') || [] const inmapsLinks = topic.get('inmapsLinks') || [] let firstFiveLinks = [] let extraLinks = [] for (let i = 0; i < inmapsArray.length; i ++) { if (i < 5) { firstFiveLinks.push({ mapName: inmapsArray[i], mapId: inmapsLinks[i] }) } else { extraLinks.push({ mapName: inmapsArray[i], mapId: inmapsLinks[i] }) } } let output = [] firstFiveLinks.forEach(obj => { output.push(