<commit_before>import { Icon } from "@blueprintjs/core"
import { IconNames } from "@blueprintjs/icons"
import AppContext from "components/AppContext"
import AssessmentModal from "components/assessments/AssessmentModal"
import { PeriodPropType, periodToString } from "components/assessments/utils"
import ConfirmDelete from "components/ConfirmDelete"
import { ReadonlyCustomFields } from "components/CustomFields"
import { Formik } from "formik"
import LinkTo from "components/LinkTo"
import Model from "components/Model"
import { Person } from "models"
import moment from "moment"
import PropTypes from "prop-types"
import React, { useState } from "react"
import { Button, Panel } from "react-bootstrap"
import REMOVE_ICON from "resources/delete.png"
import "components/assessments/AssessmentResultsTable.css"

const BasePeriodicAssessment = ({
  assessment,
  assessmentYupSchema,
  assessmentConfig,
  note,
  entity,
  period,
  recurrence,
  onUpdateAssessment,
  currentUser
}) => {
  const [showAssessmentModalKey, setShowAssessmentModalKey] = useState(null)

  const byMe = Person.isEqual(currentUser, note.author)
  const parentFieldName = `assessment-${note.uuid}`
  const periodDisplay = periodToString(period)

  return (
    <Panel bsStyle="primary" style={{ borderRadius: "15px" }}>
      <Panel.Heading
        style={{
          padding: "1px 1px",
          borderTopLeftRadius: "15px",
          borderTopRightRadius: "15px",
          paddingRight: "10px",
          paddingLeft: "10px",
          // whiteSpace: "nowrap", TODO: disabled for now as not working well in IE11
          display: "flex",
          flexDirection: "row",
          alignItems: "flex-end"
        }}
      >
        <>
          <i>{moment(note.updatedAt).fromNow()}</i>{" "}
          <LinkTo
            modelType="Person"
            model={note.author}
            style={{ color: "white" }}
          />
          {byMe && (
            <>
              <Button
                title="Edit assessment"
                onClick={() => setShowAssessmentModalKey(note.uuid)}
                bsSize="xsmall"
                bsStyle="primary"
              >
                <Icon icon={IconNames.EDIT} />
              </Button>
              <AssessmentModal
                showModal={showAssessmentModalKey === note.uuid}
                note={note}
                assessment={assessment}
                assessmentYupSchema={assessmentYupSchema}
                assessmentConfig={assessmentConfig}
                assessmentPeriod={period}
                recurrence={recurrence}
                title={`Assessment for ${entity.toString()} for ${periodDisplay}`}
                onSuccess={() => {
                  setShowAssessmentModalKey(null)
                  onUpdateAssessment()
                }}
                onCancel={() => setShowAssessmentModalKey(null)}
              />
              <ConfirmDelete
                // FIXME: implement delete assessment
                onConfirmDelete={() => console.log("to be implemented")}
                objectType="note"
                objectDisplay={"#" + note.uuid}
                title="Delete note"
                bsSize="xsmall"
                bsStyle="primary"
              >
                <img src={REMOVE_ICON} height={14} alt="Delete assessment" />
              </ConfirmDelete>
            </>
          )}
        </>
      </Panel.Heading>
      <Panel.Body>
        <div
          style={{
            overflowWrap: "break-word",
            /* IE: */ wordWrap: "break-word"
          }}
        >
          <Formik
            enableReinitialize
            initialValues={{
              [parentFieldName]: assessment
            }}
          >
            {({ values }) => {
              return (
                <ReadonlyCustomFields
                  parentFieldName={parentFieldName}
                  fieldsConfig={assessmentConfig}
                  values={values}
                  vertical
                />
              )
            }}
          </Formik>
        </div>
      </Panel.Body>
    </Panel><commit_msg>NCI-Agency/anet#2977: Remove delete assessment icon<commit_after>import { Icon } from "@blueprintjs/core"
import { IconNames } from "@blueprintjs/icons"
import AppContext from "components/AppContext"
import AssessmentModal from "components/assessments/AssessmentModal"
import { PeriodPropType, periodToString } from "components/assessments/utils"
import { ReadonlyCustomFields } from "components/CustomFields"
import { Formik } from "formik"
import LinkTo from "components/LinkTo"
import Model from "components/Model"
import { Person } from "models"
import moment from "moment"
import PropTypes from "prop-types"
import React, { useState } from "react"
import { Button, Panel } from "react-bootstrap"
import "components/assessments/AssessmentResultsTable.css"

const BasePeriodicAssessment = ({
  assessment,
  assessmentYupSchema,
  assessmentConfig,
  note,
  entity,
  period,
  recurrence,
  onUpdateAssessment,
  currentUser
}) => {
  const [showAssessmentModalKey, setShowAssessmentModalKey] = useState(null)

  const byMe = Person.isEqual(currentUser, note.author)
  const parentFieldName = `assessment-${note.uuid}`
  const periodDisplay = periodToString(period)

  return (
    <Panel bsStyle="primary" style={{ borderRadius: "15px" }}>
      <Panel.Heading
        style={{
          padding: "1px 1px",
          borderTopLeftRadius: "15px",
          borderTopRightRadius: "15px",
          paddingRight: "10px",
          paddingLeft: "10px",
          // whiteSpace: "nowrap", TODO: disabled for now as not working well in IE11
          display: "flex",
          flexDirection: "row",
          alignItems: "flex-end"
        }}
      >
        <>
          <i>{moment(note.updatedAt).fromNow()}</i>{" "}
          <LinkTo
            modelType="Person"
            model={note.author}
            style={{ color: "white" }}
          />
          {byMe && (
            <>
              <Button
                title="Edit assessment"
                onClick={() => setShowAssessmentModalKey(note.uuid)}
                bsSize="xsmall"
                bsStyle="primary"
              >
                <Icon icon={IconNames.EDIT} />
              </Button>
              <AssessmentModal
                showModal={showAssessmentModalKey === note.uuid}
                note={note}
                assessment={assessment}
                assessmentYupSchema={assessmentYupSchema}
                assessmentConfig={assessmentConfig}
                assessmentPeriod={period}
                recurrence={recurrence}
                title={`Assessment for ${entity.toString()} for ${periodDisplay}`}
                onSuccess={() => {
                  setShowAssessmentModalKey(null)
                  onUpdateAssessment()
                }}
                onCancel={() => setShowAssessmentModalKey(null)}
              />
            </>
          )}
        </>
      </Panel.Heading>
      <Panel.Body>
        <div
          style={{
            overflowWrap: "break-word",
            /* IE: */ wordWrap: "break-word"
          }}
        >
          <Formik
            enableReinitialize
            initialValues={{
              [parentFieldName]: assessment
            }}
          >
            {({ values }) => {
              return (
                <ReadonlyCustomFields
                  parentFieldName={parentFieldName}
                  fieldsConfig={assessmentConfig}
                  values={values}
                  vertical
                />
              )
            }}
          </Formik>
        </div>
      </Panel.Body>
    </Panel>
{'fraction_non_alphanumeric': 0.10960863346768951, 'fraction_numerical': 0.004420751527759719, 'mean_word_length': 1.7981084030556567, 'pattern_counts': {'":': 0, '<': 50, '<?xml version=': 0, '>': 61, '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': '3830409', 'n_tokens_mistral': 2023, 'n_tokens_neox': 1979, 'n_words': 403}