<commit_before>import React, {
  useState, useMemo, useContext, forwardRef,
} from 'react';
import { object, func, bool } from 'prop-types';

import Modal from './modal';
import EditForm from './edit-form';
import ProjectSubmissionContext from '../ProjectSubmissionContext';
import SubmissionTitle from './submission-title';
import Like from './like';
import VisibleToggle from './visible-toggle';

const noop = () => { };

const Submission = forwardRef(({
  submission, handleUpdate, onFlag, handleDelete, isDashboardView, handleLikeToggle,
}, ref) => {
  const { userId } = useContext(ProjectSubmissionContext);
  const [showEditModal, setShowEditModal] = useState(false);
  const isCurrentUsersSubmission = useMemo(() => (
    userId === submission.user_id
  ), [userId, submission.user_id]);

  const toggleShowEditModal = () => setShowEditModal((prevShowEditModal) => !prevShowEditModal);
  const livePreview = submission.live_preview_url.length > 0;

  return (
    <div className="submissions__item" ref={ref}>
      <div className="submissions__left-container">
        <Like submission={submission} handleLikeToggle={handleLikeToggle} />
        <p className="submissions__submission-title">
          <SubmissionTitle
            submission={submission}
            isCurrentUsersSubmission={isCurrentUsersSubmission}
            isDashboardView={isDashboardView}
          />
        </p>
      </div>

      <div className="submissions__actions">
        {isCurrentUsersSubmission && (
          <div
            className="submissions__button--edit"
            onMouseDown={toggleShowEditModal}
            role="button"
            tabIndex={0}
            aria-label="edit-button"
          />
        )}
        <a href={submission.repo_url} target="_blank" rel="noreferrer" className="submissions__button">View Code</a>
        {livePreview
          && <a href={submission.live_preview_url} target="_blank" rel="noreferrer" className="submissions__button">Live Preview</a>}

        {isCurrentUsersSubmission
          ? <VisibleToggle submission={submission} handleVisibleToggle={handleUpdate} />
          : (
            <button
              className="link-button submissions__flag hint--top"
              aria-label="Report submission"
              type="button"
              onClick={(e) => { e.preventDefault(); onFlag(submission); }}
            >
              <i className="fas fa-flag" />
            </button>
          )}
      </div>

      <Modal show={showEditModal} handleClose={toggleShowEditModal}>
        <EditForm
          submission={submission}
          onSubmit={handleUpdate}
          onDelete={handleDelete}
          onClose={toggleShowEditModal}
        />
      </Modal>
    </div>
  );
});
<commit_msg>Change toggle visible for edit icon<commit_after>import React, {
  useState, useMemo, useContext, forwardRef,
} from 'react';
import { object, func, bool } from 'prop-types';

import Modal from './modal';
import EditForm from './edit-form';
import ProjectSubmissionContext from '../ProjectSubmissionContext';
import SubmissionTitle from './submission-title';
import Like from './like';

const noop = () => { };

const Submission = forwardRef(({
  submission, handleUpdate, onFlag, handleDelete, isDashboardView, handleLikeToggle,
}, ref) => {
  const { userId } = useContext(ProjectSubmissionContext);
  const [showEditModal, setShowEditModal] = useState(false);
  const isCurrentUsersSubmission = useMemo(() => (
    userId === submission.user_id
  ), [userId, submission.user_id]);

  const toggleShowEditModal = () => setShowEditModal((prevShowEditModal) => !prevShowEditModal);
  const livePreview = submission.live_preview_url.length > 0;

  return (
    <div className="submissions__item" ref={ref}>
      <div className="submissions__left-container">
        <Like submission={submission} handleLikeToggle={handleLikeToggle} />
        <p className="submissions__submission-title">
          <SubmissionTitle
            submission={submission}
            isCurrentUsersSubmission={isCurrentUsersSubmission}
            isDashboardView={isDashboardView}
          />
        </p>
      </div>

      <div className="submissions__actions">
        <a href={submission.repo_url} target="_blank" rel="noreferrer" className="submissions__button">View Code</a>
        {livePreview
          && <a href={submission.live_preview_url} target="_blank" rel="noreferrer" className="submissions__button">Live Preview</a>}

        {isCurrentUsersSubmission
          ? (
            <div
              className="submissions__button--edit"
              onMouseDown={toggleShowEditModal}
              role="button"
              tabIndex={0}
              aria-label="edit-button"
            />
          )
          : (
            <button
              className="link-button submissions__flag hint--top"
              aria-label="Report submission"
              type="button"
              onClick={(e) => { e.preventDefault(); onFlag(submission); }}
            >
              <i className="fas fa-flag" />
            </button>
          )}
      </div>

      <Modal show={showEditModal} handleClose={toggleShowEditModal}>
        <EditForm
          submission={submission}
          onSubmit={handleUpdate}
          onDelete={handleDelete}
          onClose={toggleShowEditModal}
        />
      </Modal>
    </div>
  );
});

{'fraction_non_alphanumeric': 0.12363299351251159, 'fraction_numerical': 0.0007414272474513438, 'mean_word_length': 2.7681564245810057, 'pattern_counts': {'":': 0, '<': 46, '<?xml version=': 0, '>': 60, 'https://': 0, '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': '376787', 'n_tokens_mistral': 1465, 'n_tokens_neox': 1457, 'n_words': 277}