Commit 3b24d0e5 authored by Marek Veselý's avatar Marek Veselý
Browse files

Resolve "Chore: New version of Backend - v3.34.0"

parent 83f0a090
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
{
  "name": "@inject/analyst",
  "version": "3.1.0",
  "version": "3.34.0",
  "description": "Analyst module for Inject Exercise Platform",
  "main": "index.js",
  "license": "MIT",
+32 −32
Original line number Diff line number Diff line
@@ -2,10 +2,7 @@ import { Icon, NonIdealState } from '@blueprintjs/core'
import { css, cx } from '@emotion/css'
import { useRelativeTime } from '@inject/shared'

import type {
  ActionLog as ActionLogFragment,
  MilestoneState,
} from '@inject/graphql'
import type { IActionLog, MilestoneState } from '@inject/graphql'
import {
  ellipsized,
  highlightedOnActive,
@@ -19,7 +16,7 @@ import { useCallback, useContext, useMemo } from 'react'
import useActionLogs from '../dataHooks/useActionLogs'
import useMilestoneStates from '../dataHooks/useMilestoneStates'
import { ExerciseContext } from '../ExerciseContext'
import type { selectedReducerActionProps } from '../Overview/selectedReducer'
import type { SelectedAction } from '../Overview/selectedReducer'
import useFormatTimestamp from '../useFormatTimestamp'
import { actionTypeColor, compareDates, getTeamById } from '../utilities'

@@ -33,13 +30,15 @@ const td = css`
  cursor: pointer;
`

const getIcon = (logType: ActionLogFragment['type']) => {
const getIcon = (logType: IActionLog['logType']): JSX.Element => {
  switch (logType) {
    case 'INJECT':
    case 'CUSTOM_INJECT':
    case 'TOOL':
    case 'FORM_SUBMISSION':
    case 'FORM':
    case 'FORM_REVIEW':
    case 'CONFIRMATION':
      return (
        <Icon icon='full-circle' color={actionTypeColor(logType.toString())} />
      )
@@ -48,17 +47,26 @@ const getIcon = (logType: ActionLogFragment['type']) => {
  }
}

const getContent = (actionLog: ActionLogFragment): string => {
const getContent = (actionLog: IActionLog): string => {
  switch (actionLog.details.__typename) {
    case 'InjectDetailsType':
    case 'IInjectDetailsType':
    case 'ICustomInjectDetailsType':
      return textFromRenderedContent(actionLog.details.content.rendered)
    case 'CustomInjectDetailsType':
      return textFromRenderedContent(actionLog.details.content.rendered)
    case 'ToolDetailsType':
    case 'IToolDetailsType':
      return `${actionLog.details.tool.displayName}, ${actionLog.details.tool.requiresInput ? `${actionLog.details.argument} → ` : ''}${textFromRenderedContent(actionLog.details.content.rendered)}`
    case 'TeamQuestionnaireStateType':
    case 'ITeamQuestionnaireStateType':
      return actionLog.details.questionnaire.displayName
    case 'EmailType': {
    case 'IQuestionnaireSubmissionType': {
      const { teamQuestionnaireState } = actionLog.details
      return `${teamQuestionnaireState.questionnaire.displayName} submitted by ${teamQuestionnaireState.team.name}`
    }
    case 'IQuestionnaireReviewDetailsType':
      // TODO: 3.34.0 follow-up
      return ''
    case 'IConfirmationDetailsType':
      // TODO: 3.34.0 follow-up
      return ''
    case 'IEmailType': {
      const senderAddress = actionLog.details.sender.address
      const recipients = actionLog.details.thread.participants
        .filter(participant => participant.address !== senderAddress)
@@ -66,10 +74,6 @@ const getContent = (actionLog: ActionLogFragment): string => {
        .join(', ')
      return `${senderAddress}${recipients}: ${textFromRenderedContent(actionLog.details.content.rendered)}`
    }
    case 'QuestionnaireSubmissionType': {
      const { teamQuestionnaireState } = actionLog.details
      return `${teamQuestionnaireState.questionnaire.displayName} submitted by ${teamQuestionnaireState.team.name}`
    }
  }
}

@@ -83,7 +87,7 @@ type ActionLogItem = {
}

interface ActionLogProps {
  selectedDispatch: Dispatch<selectedReducerActionProps>
  selectedDispatch: Dispatch<SelectedAction>
}

export const ActionLog: FC<ActionLogProps> = ({ selectedDispatch }) => {
@@ -94,18 +98,11 @@ export const ActionLog: FC<ActionLogProps> = ({ selectedDispatch }) => {
  const { exercise } = useContext(ExerciseContext)

  const getHandleClick = useCallback(
    (actionLog: ActionLogFragment) => () => {
      switch (actionLog.type) {
        case 'INJECT':
        case 'CUSTOM_INJECT':
        case 'TOOL':
        case 'FORM':
        case 'FORM_SUBMISSION':
          return selectedDispatch({ type: 'selectActions', actionLog })
        case 'EMAIL':
          return selectedDispatch({ type: 'selectEmails', actionLog })
      }
    },
    (actionLog: IActionLog) => () =>
      selectedDispatch({
        type: 'selectActionLog',
        actionLog,
      }),
    [selectedDispatch]
  )

@@ -121,7 +118,7 @@ export const ActionLog: FC<ActionLogProps> = ({ selectedDispatch }) => {
  const items: ActionLogItem[] = useMemo(() => {
    const items: ActionLogItem[] = actionLogs.map(actionLog => ({
      id: actionLog.id,
      icon: getIcon(actionLog.type),
      icon: getIcon(actionLog.logType),
      text: getContent(actionLog),
      timestamp: actionLog.timestamp,
      handleClick: getHandleClick(actionLog),
@@ -143,7 +140,10 @@ export const ActionLog: FC<ActionLogProps> = ({ selectedDispatch }) => {
              `teams: ${milestoneStateTeamNames(milestoneState)}`,
            timestamp: milestoneState.timestampReached,
            handleClick: () =>
              selectedDispatch({ type: 'selectMilestones', milestoneState }),
              selectedDispatch({
                type: 'selectMilestoneState',
                milestoneState,
              }),
            teamId,
          })
        )
+3 −3
Original line number Diff line number Diff line
@@ -8,7 +8,7 @@ import type { Dispatch, FC } from 'react'
import { useContext } from 'react'
import useMilestoneStates from '../dataHooks/useMilestoneStates'
import { ExerciseContext } from '../ExerciseContext'
import type { selectedReducerActionProps } from '../Overview/selectedReducer'
import type { SelectedAction } from '../Overview/selectedReducer'
import { milestoneCard } from './milestoneCardCss'

const wrapper = css`
@@ -21,7 +21,7 @@ const wrapper = css`
interface AllTeamsMilestoneCardProps {
  isSelected?: boolean
  milestone: Milestone
  selectedDispatch: Dispatch<selectedReducerActionProps>
  selectedDispatch: Dispatch<SelectedAction>
}

const AllTeamsMilestoneCard: FC<AllTeamsMilestoneCardProps> = ({
@@ -56,7 +56,7 @@ const AllTeamsMilestoneCard: FC<AllTeamsMilestoneCardProps> = ({
      icon={null}
      onClick={() =>
        selectedDispatch({
          type: 'selectMilestones',
          type: 'selectMilestoneState',
          milestoneState: filteredMilestoneStates[0],
        })
      }
+3 −3
Original line number Diff line number Diff line
@@ -5,7 +5,7 @@ import { MilestoneDescription } from '@inject/frontend'
import type { MilestoneState } from '@inject/graphql'
import { StyledTag } from '@inject/shared'
import type { Dispatch, FC } from 'react'
import type { selectedReducerActionProps } from '../Overview/selectedReducer'
import type { SelectedAction } from '../Overview/selectedReducer'
import useFormatTimestamp from '../useFormatTimestamp'
import { milestoneCard } from './milestoneCardCss'

@@ -19,7 +19,7 @@ const wrapper = css`
interface MilestoneCardProps {
  isSelected?: boolean
  milestoneState: MilestoneState
  selectedDispatch: Dispatch<selectedReducerActionProps>
  selectedDispatch: Dispatch<SelectedAction>
  teamId: string
}

@@ -39,7 +39,7 @@ const MilestoneCard: FC<MilestoneCardProps> = ({
      intent={milestoneState.reached ? 'success' : undefined}
      icon={null}
      onClick={() =>
        selectedDispatch({ type: 'selectMilestones', milestoneState })
        selectedDispatch({ type: 'selectMilestoneState', milestoneState })
      }
    >
      <div className={wrapper}>
+2 −2
Original line number Diff line number Diff line
import type { MilestoneState } from '@inject/graphql'
import type { Dispatch, FC } from 'react'
import type { selectedReducerActionProps } from '../Overview/selectedReducer'
import type { SelectedAction } from '../Overview/selectedReducer'
import useMilestoneStates from '../dataHooks/useMilestoneStates'
import useMilestones from '../dataHooks/useMilestones'
import AllTeamsMilestoneCard from './AllTeamsMilestoneCard'
@@ -9,7 +9,7 @@ import MilestoneCard from './MilestoneCard'
interface MilestoneCardsProps {
  teamId: string | undefined
  selectedState?: MilestoneState
  selectedDispatch: Dispatch<selectedReducerActionProps>
  selectedDispatch: Dispatch<SelectedAction>
}

const MilestoneCards: FC<MilestoneCardsProps> = ({
Loading