/* eslint-disable react/jsx-max-depth */
/**
* @prettier
*/
import React, { Component } from 'react';
import { DetailContextConsumer } from '../../pages/version/index';
import List from '@material-ui/core/List/index';
import DownloadIcon from '@material-ui/icons/CloudDownload';
import BugReportIcon from '@material-ui/icons/BugReport';
import HomeIcon from '@material-ui/icons/Home';
import Tooltip from '@material-ui/core/Tooltip/index';
import { Fab, ActionListItem } from './styles';
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) {
if (!link) {
return null;
}
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) {
const fab = (
{ACTIONS[value]['icon']}
);
component.push(
{this.renderIconsWithLink(link, fab)}
);
}
return component;
}, []);
return (
<>
{renderList}
>
);
};
renderActionBar = ({ packageMeta = {} }) => {
return (
{this.renderActionBarListItems(packageMeta)}
);
};
}
export default ActionBar;