<commit_before>import React, { PropTypes } from "react";
import ReactDOM from "react-dom";
import {
  Modal,
  Grid,
  Row,
  Col,
  Button,
  Input,
  OverlayTrigger,
  Popover,
  Tooltip
} from "react-bootstrap";
import _ from "lodash";
import moment from "moment";
import DiscussionListContainer from "../containers/discussion_list_container";
import CommentFormContainer from "../containers/comment_form_container";
import IdentificationFormContainer from "../containers/identification_form_container";
import SplitTaxon from "./split_taxon";
import TaxonMap from "./taxon_map";
import UserText from "./user_text";
import ZoomableImageGallery from "./zoomable_image_gallery";

const ObservationModal = ( {
  onClose,
  observation,
  visible,
  toggleReviewed,
  toggleCaptive,
  reviewedByCurrentUser,
  captiveByCurrentUser,
  images,
  commentFormVisible,
  identificationFormVisible,
  addIdentification,
  addComment,
  loadingDiscussionItem,
  agreeWithCurrentObservation,
  currentUserIdentification,
  showNextObservation,
  showPrevObservation
} ) => {
  if ( !observation ) {
    return <div></div>;
  }

  // skipping map until we can work out the memory issues
  let taxonMap;
  if ( observation.latitude ) {
    const obsForMap = Object.assign( {}, observation, {
      coordinates_obscured: observation.obscured
    } );
    taxonMap = (
      <TaxonMap
        key={`map-for-${obsForMap.id}`}
        taxonLayers={[{
          taxon: obsForMap.taxon,
          observations: { observation_id: obsForMap.id },
          places: { disabled: true },
          gbif: { disabled: true }
        }] }
        observations={[obsForMap]}
        zoomLevel={ obsForMap.map_scale || 8 }
        mapTypeControl={false}
        showAccuracy
        showAllLayer={false}
        overlayMenu={false}
        zoomControlOptions={{ position: google.maps.ControlPosition.TOP_LEFT }}
      />
    );
  }

  let photos = null;
  if ( images && images.length > 0 ) {
    photos = (
      <ZoomableImageGallery
        key={`map-for-${observation.id}`}
        items={images}
        showThumbnails={images && images.length > 1}
        lazyLoad={false}
        server
        showNav={false}
      />
    );
  }
  let sounds = null;
  if ( observation.sounds && observation.sounds.length > 0 ) {
    sounds = observation.sounds.map( s => (
      <iframe
        width="100%"
        height="100"
        scrolling="no"
        frameBorder="no"
        src={`https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/${s.native_sound_id}&auto_play=false&hide_related=false&show_comments=false&show_user=false&show_reposts=false&visual=false&show_artwork=false`}
      ></iframe>
    ) );
  }

  const scrollSidebarToForm = ( form ) => {
    const sidebar = $( form ).parents( ".ObservationModal:first" ).find( ".sidebar" );
    const target = $( form );
    $( ":input:visible:first", form ).focus( );
    $( sidebar ).scrollTo( target );
  };

  const showAgree = ( ) => {
    if ( !currentUserIdentification ) {
      return typeof( observation.taxon ) === "object" && observation.taxon.is_active;
    }
    return (
      observation.taxon &&
      observation.taxon.is_active &&
      observation.taxon.id !== currentUserIdentification.taxon.id
    );
  };

  const qualityGrade = ( ) => {
    if ( observation.quality_grade === "research" ) {
      return _.capitalize( I18n.t( "research_grade" ) );
    }
    return _.capitalize( I18n.t( observation.quality_grade ) );
  };

  return (
    <Modal<commit_msg>Bugfix: Identify wasn't showing modals for observations without taxa.<commit_after>import React, { PropTypes } from "react";
import ReactDOM from "react-dom";
import {
  Modal,
  Grid,
  Row,
  Col,
  Button,
  Input,
  OverlayTrigger,
  Popover,
  Tooltip
} from "react-bootstrap";
import _ from "lodash";
import moment from "moment";
import DiscussionListContainer from "../containers/discussion_list_container";
import CommentFormContainer from "../containers/comment_form_container";
import IdentificationFormContainer from "../containers/identification_form_container";
import SplitTaxon from "./split_taxon";
import TaxonMap from "./taxon_map";
import UserText from "./user_text";
import ZoomableImageGallery from "./zoomable_image_gallery";

const ObservationModal = ( {
  onClose,
  observation,
  visible,
  toggleReviewed,
  toggleCaptive,
  reviewedByCurrentUser,
  captiveByCurrentUser,
  images,
  commentFormVisible,
  identificationFormVisible,
  addIdentification,
  addComment,
  loadingDiscussionItem,
  agreeWithCurrentObservation,
  currentUserIdentification,
  showNextObservation,
  showPrevObservation
} ) => {
  if ( !observation ) {
    return <div></div>;
  }

  // skipping map until we can work out the memory issues
  let taxonMap;
  if ( observation.latitude ) {
    const obsForMap = Object.assign( {}, observation, {
      coordinates_obscured: observation.obscured
    } );
    taxonMap = (
      <TaxonMap
        key={`map-for-${obsForMap.id}`}
        taxonLayers={[{
          taxon: obsForMap.taxon,
          observations: { observation_id: obsForMap.id },
          places: { disabled: true },
          gbif: { disabled: true }
        }] }
        observations={[obsForMap]}
        zoomLevel={ obsForMap.map_scale || 8 }
        mapTypeControl={false}
        showAccuracy
        showAllLayer={false}
        overlayMenu={false}
        zoomControlOptions={{ position: google.maps.ControlPosition.TOP_LEFT }}
      />
    );
  }

  let photos = null;
  if ( images && images.length > 0 ) {
    photos = (
      <ZoomableImageGallery
        key={`map-for-${observation.id}`}
        items={images}
        showThumbnails={images && images.length > 1}
        lazyLoad={false}
        server
        showNav={false}
      />
    );
  }
  let sounds = null;
  if ( observation.sounds && observation.sounds.length > 0 ) {
    sounds = observation.sounds.map( s => (
      <iframe
        width="100%"
        height="100"
        scrolling="no"
        frameBorder="no"
        src={`https://w.soundcloud.com/player/?url=https%3A//api.soundcloud.com/tracks/${s.native_sound_id}&auto_play=false&hide_related=false&show_comments=false&show_user=false&show_reposts=false&visual=false&show_artwork=false`}
      ></iframe>
    ) );
  }

  const scrollSidebarToForm = ( form ) => {
    const sidebar = $( form ).parents( ".ObservationModal:first" ).find( ".sidebar" );
    const target = $( form );
    $( ":input:visible:first", form ).focus( );
    $( sidebar ).scrollTo( target );
  };

  const showAgree = ( ) => {
    if ( !currentUserIdentification ) {
      return observation.taxon && observation.taxon.is_active;
    }
    return (
      observation.taxon &&
      observation.taxon.is_active &&
      observation.taxon.id !== currentUserIdentification.taxon.id
    );
  };

  const qualityGrade = ( ) => {
    if ( observation.quality_grade === "research" ) {
      return _.capitalize( I18n.t( "research_grade" ) );
    }
    return _.capitalize( I18n.t( observation.quality_grade ) );
  };

  return (
    <Modal
{'fraction_non_alphanumeric': 0.1281219133624947, 'fraction_numerical': 0.004233102864399605, 'mean_word_length': 3.068886337543054, 'pattern_counts': {'":': 2, '<': 17, '<?xml version=': 0, '>': 31, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7660257', 'n_tokens_mistral': 2236, 'n_tokens_neox': 2174, 'n_words': 419}