import * as React from "react"; import * as moment from "moment"; interface tag { image_id: string; last_modified: string; name: string; size: number; } interface ISidebar { isPublic: string, tags: Array, repository: Object } /** * The Component for the sidebar of the repo page * @param {string} isPublic - A string that states whether the repository is private or public * @param {tag} tags - The list of tags for the repository * @param {object} repository - The list of properties for the repository */ class repoSidebar extends React.Component { static propTypes = { isPublic: React.PropTypes.string.isRequired, tags: React.PropTypes.array.isRequired, repository: React.PropTypes.object.isRequired } render () { let isPublic: string = (this.props.isPublic) ? "Public" : "Private"; let sortedTags: Array = []; let tagRows: Array = []; let badgeIcon: string = (this.props.isPublic) ? "rp-badge__icon--public" : "rp-badge__icon--private"; let repository: any = this.props.repository; let sharing: string = repository.company || repository.namespace; for (let tagObject in this.props.tags) { sortedTags.push({ name: this.props.tags[tagObject].name, lastModified: Date.parse(this.props.tags[tagObject].last_modified) }); } sortedTags = sortedTags.sort(function(a, b) { return a.lastModified - b.lastModified; }); sortedTags.forEach(function(el, i){ tagRows.push( {el.name} {moment(el.lastModified).fromNow()} ); }); return(
{isPublic}
{sharing} is sharing this container {this.props.isPublic ? "publically" : "privately"}
Latest Images
{tagRows}
NAME LAST MODIFIED
); } } export default repoSidebar;