/** * @prettier */ import React, { Component } from 'react'; import BugReportIcon from '@material-ui/icons/BugReport'; import DownloadIcon from '@material-ui/icons/CloudDownload'; import HomeIcon from '@material-ui/icons/Home'; import List from '@material-ui/core/List/index'; import Tooltip from '@material-ui/core/Tooltip/index'; import { DetailContextConsumer } from '../../pages/version/index'; import { Fab, ActionListItem } from './styles'; import { isURL } from '../../utils/url'; const ACTIONS = { homepage: { icon: , title: 'Visit homepage', }, issue: { icon: , title: 'Open an issue', }, tarball: { icon: , title: 'Download tarball', }, }; class ActionBar extends Component { render() { return ( {context => { return this.renderActionBar(context); }} ); } renderIconsWithLink(link, component) { return ( {component} ); } renderActionBarListItems = packageMeta => { const { latest: { bugs: { url: issue } = {}, homepage, dist: { tarball } = {} } = {} } = packageMeta; const actionsMap = { homepage, issue, tarball, }; const renderList = Object.keys(actionsMap).reduce((component, value, key) => { const link = actionsMap[value]; if (link && isURL(link)) { const fab = {ACTIONS[value]['icon']}; component.push( {this.renderIconsWithLink(link, fab)} ); } return component; }, []); return ( <> {renderList} ); }; renderActionBar = ({ packageMeta = {} }) => { return {this.renderActionBarListItems(packageMeta)}; }; } export default ActionBar;