text: import React, { Component } from 'react';
  import PropTypes from 'prop-types';
  import { Route, withRouter } from 'react-router-dom';
  import { compose } from 'ramda';
  import { createFragmentContainer } from 'react-relay';
  import graphql from 'babel-plugin-relay/macro';
  import { withStyles } from '@material-ui/core/styles';
  import inject18n from '../../../../components/i18n';
  import EntityStixRelations from '../../common/stix_relations/EntityStixRelations';
  import StixDomainEntityThreatKnowledge from '../../common/stix_domain_entities/StixDomainEntityThreatKnowledge';
  import StixRelation from '../../common/stix_relations/StixRelation';
  import MalwarePopover from './MalwarePopover';
  import MalwareKnowledgeBar from './MalwareKnowledgeBar';
  import StixDomainEntityHeader from '../../common/stix_domain_entities/StixDomainEntityHeader';
  import StixDomainEntityKillChain from '../../common/stix_domain_entities/StixDomainEntityKillChain';
  import StixDomainEntityVictimology from '../../common/stix_domain_entities/StixDomainEntityVictimology';
  
  const styles = () => ({
    container: {
      margin: 0,
      padding: '0 260px 0 0',
    },
  });
  
  class MalwareKnowledgeComponent extends Component {
    render() {
      const { classes, malware } = this.props;
      const link = `/dashboard/threats/malwares/${malware.id}/knowledge`;
      return (
        <div className={classes.container}>
          <StixDomainEntityHeader
            stixDomainEntity={malware}
            PopoverComponent={<MalwarePopover />}
          />
          <MalwareKnowledgeBar malwareId={malware.id} />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/relations/:relationId"
            render={(routeProps) => (
              <StixRelation
                entityId={malware.id}
                paddingRight={true}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/overview"
            render={(routeProps) => (
              <StixDomainEntityThreatKnowledge
                stixDomainEntityId={malware.id}
                stixDomainEntityType="malware"
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/attribution"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="attributed-to"
                targetEntityTypes={['Threat-Actor', 'Organization', 'User']}
                entityLink={link}
                creationIsFrom={true}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/usage"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="uses"
                targetEntityTypes={['Threat-Actor', 'Intrusion-Set']}
                entityLink={link}
                creationIsFrom={false}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/variants"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="variant-of"
                targetEntityTypes={['Malware']}
                entityLink={link}
                creationIsFrom={true}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/campaigns"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="uses"
                targetEntityTypes={['Campaign']}
                entityLink={link}
                creationIsFrom={false}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/incidents"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="uses"
                targetEntityTypes={['Incident']}
                entityLink={link}
                creationIsFrom={false}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/victimology"
            render={(routeProps) => (
              <StixDomainEntityVictimology
                stixDomainEntityId={malware.id}
                entityLink={link}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/ttp"
            render={(routeProps) => (
              <StixDomainEntityKillChain
                stixDomainEntityId={malware.id}
                entityLink={link}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/tools"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="uses"
                targetEntityTypes={['Tool']}
                entityLink={link}
                creationIsFrom={true}
                {...routeProps}
              />
            )}
          />
          <Route
            exact
            path="/dashboard/threats/malwares/:malwareId/knowledge/vulnerabilities"
            render={(routeProps) => (
              <EntityStixRelations
                entityId={malware.id}
                relationType="targets"
                targetEntityTypes={['Vulnerability']}
                entityLink={link}
                creationIsFrom={true}
                {...routeProps}
              />
            )}
          />
        </div>
      );
    }
  }
  
  MalwareKnowledgeComponent.propTypes = {
    malware: PropTypes.object,
    classes: PropTypes.object,
    t: PropTypes.func,
  };
  
  const MalwareKnowledge = createFragmentContainer(MalwareKnowledgeComponent, {
    malware: graphql`
      fragment MalwareKnowledge_malware on Malware {
        id
        name
        alias
      }
    `,
  });
  
  export default compose(
    inject18n,
    withRouter,
    withStyles(styles),
  )(MalwareKnowledge);
  