import _ from 'underscore'; import moment from 'moment'; import React from 'react'; import { QualityProfileLink } from './../../components/shared/quality-profile-link'; import { QualityGateLink } from './../../components/shared/quality-gate-link'; import { getEvents } from '../../api/events'; import { EventsList } from './components/events-list'; export default React.createClass({ componentDidMount() { this.requestEvents(); }, requestEvents () { return getEvents(this.props.component.key).then(events => { const nextEvents = events.map(event => { return { id: event.id, date: moment(event.dt).toDate(), type: event.c, name: event.n, text: event.ds }; }); this.setState({ events: nextEvents }); }); }, isView() { return this.props.component.qualifier === 'VW' || this.props.component.qualifier === 'SVW'; }, isDeveloper() { return this.props.component.qualifier === 'DEV'; }, renderEvents() { if (this.state && this.state.events) { return ; } else { return null; } }, render() { let profiles = (this.props.component.profiles || []).map(profile => { return (
  • ({profile.language}) {profile.name}
  • ); }); let links = (this.props.component.links || []).map(link => { let iconClassName = `spacer-right icon-color-link icon-${link.type}`; return (
  • {link.name}
  • ); }); let descriptionCard = this.props.component.description ? (
    {this.props.component.description}
    ) : null; let linksCard = _.size(this.props.component.links) > 0 ? (
      {links}
    ) : null; let profilesCard = !this.isView() && !this.isDeveloper() && _.size(this.props.component.profiles) > 0 ? (

    {window.t('overview.quality_profiles')}

      {profiles}
    ) : null; let gateCard = !this.isView() && !this.isDeveloper() && this.props.component.gate ? (

    {window.t('overview.quality_gate')}

    • {this.props.component.gate.isDefault ? (Default) : null} {this.props.component.gate.name}
    ) : null; return (
    {descriptionCard} {linksCard} {gateCard} {profilesCard} {this.renderEvents()}
    ); } });