Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(app): untangle the rest of the device hooks #16336

Merged
merged 18 commits into from
Sep 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions app/src/local-resources/deck_configuration/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './getStandardDeckViewLayerBlockList'
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { beforeEach, describe, expect, it, vi } from 'vitest'

import { useIsOEMMode } from '../../robot-settings/hooks'
import { useIsOEMMode } from '/app/resources/robot-settings/hooks'

import {
useGripperDisplayName,
Expand All @@ -11,7 +11,7 @@ import {

import type { PipetteV2Specs } from '@opentrons/shared-data'

vi.mock('../../robot-settings/hooks')
vi.mock('/app/resources/robot-settings/hooks')

const BRANDED_P1000_FLEX_DISPLAY_NAME = 'Flex 1-Channel 1000 μL'
const ANONYMOUS_P1000_FLEX_DISPLAY_NAME = '1-Channel 1000 μL'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import {
getPipetteSpecsV2,
GRIPPER_MODELS,
} from '@opentrons/shared-data'
import { useIsOEMMode } from '../robot-settings/hooks'
import { useIsOEMMode } from '/app/resources/robot-settings/hooks'

import type {
GripperModel,
Expand Down
1 change: 1 addition & 0 deletions app/src/local-resources/instruments/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './hooks'
1 change: 1 addition & 0 deletions app/src/local-resources/modules/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from './getModulePrepCommands'
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import isEqual from 'lodash/isEqual'
import { getLoadedLabwareDefinitionsByUri } from '@opentrons/shared-data'
import { getLabwareDefinitionUri } from '/app/organisms/Devices/ProtocolRun/utils/getLabwareDefinitionUri'
import { getLabwareOffsetLocation } from '/app/organisms/Devices/ProtocolRun/utils/getLabwareOffsetLocation'
import { getLabwareDefinitionUri } from '/app/transformations/protocols'
import { getLabwareOffsetLocation } from '/app/transformations/analysis'
import type { LabwareOffset } from '@opentrons/api-client'
import type {
LoadedLabware,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,13 @@ import {
expectedIncompleteRightMountTaskList,
expectedIncompleteLeftMountTaskList,
} from '../../Devices/hooks/__fixtures__/taskListFixtures'
import {
useCalibrationTaskList,
useRunHasStarted,
useAttachedPipettes,
} from '../../Devices/hooks'
import { useCalibrationTaskList, useRunHasStarted } from '../../Devices/hooks'
import { useAttachedPipettes } from '/app/resources/instruments'
import { mockLeftProtoPipette } from '/app/redux/pipettes/__fixtures__'

vi.mock('../../Devices/hooks')
vi.mock('/app/resources/runs')
vi.mock('/app/resources/instruments')

const render = (robotName: string = 'otie') => {
return renderWithProviders(
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/CalibrationTaskList/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import { StatusLabel } from '/app/atoms/StatusLabel'
import { TaskList } from '../TaskList'

import {
useAttachedPipettes,
useCalibrationTaskList,
useRunHasStarted,
} from '/app/organisms/Devices/hooks'
import { useAttachedPipettes } from '/app/resources/instruments'
import { useCurrentRunId } from '/app/resources/runs'

import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
SUCCESS,
useDispatchApiRequests,
} from '/app/redux/robot-api'
import { useAttachedPipettes } from '../../Devices/hooks'
import { useAttachedPipettes } from '/app/resources/instruments'
import { PipetteSelection } from '../PipetteSelection'
import { ExitModal } from '../ExitModal'
import { ConfirmPipette } from '../ConfirmPipette'
Expand Down Expand Up @@ -51,7 +51,7 @@ vi.mock('../PipetteSelection')
vi.mock('../ExitModal')
vi.mock('/app/molecules/InProgressModal/InProgressModal')
vi.mock('../ConfirmPipette')
vi.mock('../../Devices/hooks')
vi.mock('/app/resources/instruments')
vi.mock('/app/assets/images')

const render = (props: React.ComponentProps<typeof ChangePipette>) => {
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/ChangePipette/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {

import { WizardHeader } from '/app/molecules/WizardHeader'
import { InProgressModal } from '/app/molecules/InProgressModal/InProgressModal'
import { useAttachedPipettes } from '../Devices/hooks'
import { useAttachedPipettes } from '/app/resources/instruments'
import { ExitModal } from './ExitModal'
import { Instructions } from './Instructions'
import { ConfirmPipette } from './ConfirmPipette'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import {
} from '@opentrons/shared-data'
import { useCsvFileQuery } from '@opentrons/react-api-client'
import { DownloadCsvFileLink } from './DownloadCsvFileLink'
import { useMostRecentCompletedAnalysis } from '../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import { useDeckCalibrationData } from './hooks'
import { OffsetVector } from '/app/molecules/OffsetVector'
import type { RunData } from '@opentrons/api-client'
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/Devices/InstrumentsAndModules.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { useCurrentRunId } from '/app/resources/runs'
import { useIsFlex } from '/app/redux-resources/robots'
import { ModuleCard } from '../ModuleCard'
import { useIsRobotViewable, useRunStatuses } from './hooks'
import { getShowPipetteCalibrationWarning } from './utils'
import { getShowPipetteCalibrationWarning } from '/app/transformations/instruments'
import { PipetteCard } from './PipetteCard'
import { FlexPipetteCard } from './PipetteCard/FlexPipetteCard'
import { GripperCard } from '../GripperCard'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMostRecentCompletedAnalysis } from '../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import { useRobotType } from '/app/redux-resources/robots'
import {
getIsFixtureMismatch,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,15 @@ import {

import {
useModuleCalibrationStatus,
useRunCalibrationStatus,
useUnmatchedModulesForProtocol,
} from '../../../../hooks'
import { useRobot } from '/app/redux-resources/robots'
import { useRobotAnalyticsData } from '/app/redux-resources/analytics'
import { useCurrentRunId, useProtocolDetailsForRun } from '/app/resources/runs'
import {
useCurrentRunId,
useProtocolDetailsForRun,
useRunCalibrationStatus,
} from '/app/resources/runs'
import { useActionBtnDisabledUtils, useActionButtonProperties } from './hooks'
import { getFallbackRobotSerialNumber, isRunAgainStatus } from '../../utils'
import { useIsRobotOnWrongVersionOfSoftware } from '/app/redux/robot-update'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import * as React from 'react'

import { ErrorRecoveryFlows } from '../../../../ErrorRecoveryFlows'
import { DropTipWizardFlows } from '../../../../DropTipWizardFlows'
import { useMostRecentCompletedAnalysis } from '../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import {
ConfirmCancelModal,
HeaterShakerIsRunningModal,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@opentrons/components'
import { HEATERSHAKER_MODULE_TYPE } from '@opentrons/shared-data'

import { useAttachedModules } from '../../../../../hooks'
import { useAttachedModules } from '/app/resources/modules'
import { HeaterShakerModuleCard } from './HeaterShakerModuleCard'
import { getActiveHeaterShaker } from './utils'
import { useIsHeaterShakerInProtocol } from '../../../../../../ModuleCard/hooks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ import { renderWithProviders } from '/app/__testing-utils__'
import { mockHeaterShaker } from '/app/redux/modules/__fixtures__'
import { HeaterShakerIsRunningModal } from '../HeaterShakerIsRunningModal'
import { HeaterShakerModuleCard } from '../HeaterShakerModuleCard'
import { useAttachedModules } from '../../../../../../hooks'
import { useMostRecentCompletedAnalysis } from '../../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useAttachedModules } from '/app/resources/modules'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'

import type * as ReactApiClient from '@opentrons/react-api-client'

Expand All @@ -21,10 +21,8 @@ vi.mock('@opentrons/react-api-client', async importOriginal => {
useCreateLiveCommandMutation: vi.fn(),
}
})
vi.mock('../../../../../../hooks')
vi.mock(
'../../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
)
vi.mock('/app/resources/modules')
vi.mock('/app/resources/runs')
vi.mock('../HeaterShakerModuleCard')

const mockMovingHeaterShakerOne = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,13 @@ import { renderHook } from '@testing-library/react'
import { HEATERSHAKER_MODULE_V1 } from '@opentrons/shared-data'

import { RUN_ID_1 } from '/app/resources/runs/__fixtures__'
import { useMostRecentCompletedAnalysis } from '../../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import { useHeaterShakerModuleIdsFromRun } from '../hooks'

import type { Store } from 'redux'
import type { State } from '/app/redux/types'

vi.mock(
'../../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
)
vi.mock('/app/resources/runs')

describe('useHeaterShakerModuleIdsFromRun', () => {
const store: Store<State> = createStore(vi.fn(), {})
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { useMostRecentCompletedAnalysis } from '../../../../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'

export interface ModuleIdsFromRun {
moduleIdsFromRun: string[]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ import {
} from '@opentrons/components'

import { Divider } from '/app/atoms/structure'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useNotifyRunQuery, useRunStatus } from '/app/resources/runs'
import {
useMostRecentCompletedAnalysis,
useNotifyRunQuery,
useRunStatus,
} from '/app/resources/runs'

import type { RunTimeParameter } from '@opentrons/shared-data'
import type { RunStatus } from '@opentrons/api-client'
Expand Down
8 changes: 5 additions & 3 deletions app/src/organisms/Devices/ProtocolRun/ProtocolRunSetup.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,14 @@ import { useStoredProtocolAnalysis } from '/app/resources/analysis'
import {
useModuleCalibrationStatus,
useProtocolAnalysisErrors,
useRunCalibrationStatus,
useRunHasStarted,
useRunPipetteInfoByMount,
useUnmatchedModulesForProtocol,
} from '../hooks'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import {
useMostRecentCompletedAnalysis,
useRunPipetteInfoByMount,
useRunCalibrationStatus,
} from '/app/resources/runs'
import { SetupLabware } from './SetupLabware'
import { SetupLabwarePositionCheck } from './SetupLabwarePositionCheck'
import { SetupRobotCalibration } from './SetupRobotCalibration'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import {
} from '@opentrons/shared-data'
import { useInstrumentsQuery } from '@opentrons/react-api-client'
import { TertiaryButton } from '/app/atoms/buttons'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import { useStoredProtocolAnalysis } from '/app/resources/analysis'
import { PipetteWizardFlows } from '../../PipetteWizardFlows'
import { FLOWS } from '../../PipetteWizardFlows/constants'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,15 +10,17 @@ import {
TYPOGRAPHY,
} from '@opentrons/components'
import * as PipetteConstants from '/app/redux/pipettes/constants'
import { getShowPipetteCalibrationWarning } from '../utils'
import { getShowPipetteCalibrationWarning } from '/app/transformations/instruments'
import { PipetteRecalibrationWarning } from '../PipetteCard/PipetteRecalibrationWarning'
import { useRunPipetteInfoByMount } from '../hooks'
import { useStoredProtocolAnalysis } from '/app/resources/analysis'
import { useIsFlex } from '/app/redux-resources/robots'
import { SetupPipetteCalibrationItem } from './SetupPipetteCalibrationItem'
import { SetupFlexPipetteCalibrationItem } from './SetupFlexPipetteCalibrationItem'
import { SetupGripperCalibrationItem } from './SetupGripperCalibrationItem'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import {
useRunPipetteInfoByMount,
useMostRecentCompletedAnalysis,
} from '/app/resources/runs'
import { useInstrumentsQuery } from '@opentrons/react-api-client'
import { isGripperInCommands } from '/app/resources/protocols/utils'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import { getIsLabwareOffsetCodeSnippetsOn } from '/app/redux/config'
import { LabwareOffsetTabs } from '../../../LabwareOffsetTabs'
import { OffsetVector } from '/app/molecules/OffsetVector'
import { PythonLabwareOffsetSnippet } from '/app/molecules/PythonLabwareOffsetSnippet'
import { getLatestCurrentOffsets } from '../SetupLabwarePositionCheck/utils'
import { getLatestCurrentOffsets } from '/app/transformations/runs'

import type { LabwareOffset } from '@opentrons/api-client'
import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,11 @@ import type {
LoadLabwareRunTimeCommand,
} from '@opentrons/shared-data'
import type { ModuleRenderInfoForProtocol } from '../../hooks'
import type { LabwareSetupItem } from '/app/transformations/commands'
import type {
LabwareSetupItem,
NestedLabwareInfo,
} from '/app/transformations/commands'
import type { ModuleTypesThatRequireExtraAttention } from '../utils/getModuleTypesThatRequireExtraAttention'
import type { NestedLabwareInfo } from './getNestedLabwareInfo'

const LabwareRow = styled.div`
display: ${DISPLAY_GRID};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {
} from '@opentrons/components'
import { OddModal } from '/app/molecules/OddModal'
import { getIsOnDevice } from '/app/redux/config'
import { getLocationInfoNames } from '../utils/getLocationInfoNames'
import { getLocationInfoNames } from '/app/transformations/commands'
import { getSlotLabwareDefinition } from '../utils/getSlotLabwareDefinition'
import { Divider } from '/app/atoms/structure'
import { getModuleImage } from '../SetupModuleAndDeck/utils'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,11 @@ import {
StyledText,
COLORS,
} from '@opentrons/components'
import { getLabwareSetupItemGroups } from '/app/transformations/commands'
import {
getLabwareSetupItemGroups,
getNestedLabwareInfo,
} from '/app/transformations/commands'
import { LabwareListItem } from './LabwareListItem'
import { getNestedLabwareInfo } from './getNestedLabwareInfo'

import type { RunTimeCommand } from '@opentrons/shared-data'
import type { ModuleRenderInfoForProtocol } from '../../hooks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,11 @@ import {

import { getLabwareSetupItemGroups } from '/app/transformations/commands'
import { LabwareInfoOverlay } from '../LabwareInfoOverlay'
import { getLabwareRenderInfo } from '../utils/getLabwareRenderInfo'
import { getProtocolModulesInfo } from '../utils/getProtocolModulesInfo'
import { getStandardDeckViewLayerBlockList } from '../utils/getStandardDeckViewLayerBlockList'
import {
getProtocolModulesInfo,
getLabwareRenderInfo,
} from '/app/transformations/analysis'
import { getStandardDeckViewLayerBlockList } from '/app/local-resources/deck_configuration'
import { OffDeckLabwareList } from './OffDeckLabwareList'

import type {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,13 @@ import { getModuleTypesThatRequireExtraAttention } from '../../utils/getModuleTy
import { getIsLabwareOffsetCodeSnippetsOn } from '/app/redux/config'
import {
useLPCDisabledReason,
useRunCalibrationStatus,
useRunHasStarted,
useUnmatchedModulesForProtocol,
} from '../../../hooks'
import { SetupLabwareList } from '../SetupLabwareList'
import { SetupLabwareMap } from '../SetupLabwareMap'
import { SetupLabware } from '..'
import { useNotifyRunQuery } from '/app/resources/runs'
import { useNotifyRunQuery, useRunCalibrationStatus } from '/app/resources/runs'

vi.mock('../SetupLabwareList')
vi.mock('../SetupLabwareMap')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { renderWithProviders } from '/app/__testing-utils__'
import { i18n } from '/app/i18n'
import { getAttachedProtocolModuleMatches } from '../../../../ODD/ProtocolSetup/ProtocolSetupModulesAndDeck/utils'
import { LabwareInfoOverlay } from '../../LabwareInfoOverlay'
import { getLabwareRenderInfo } from '../../utils/getLabwareRenderInfo'
import { getLabwareRenderInfo } from '/app/transformations/analysis'
import { SetupLabwareMap } from '../SetupLabwareMap'

import type {
Expand All @@ -42,7 +42,7 @@ vi.mock('@opentrons/shared-data', async importOriginal => {

vi.mock('../../../../ODD/ProtocolSetup/ProtocolSetupModulesAndDeck/utils')
vi.mock('../../LabwareInfoOverlay')
vi.mock('../../utils/getLabwareRenderInfo')
vi.mock('/app/transformations/analysis/getLabwareRenderInfo')
vi.mock('../../utils/getModuleTypesThatRequireExtraAttention')
vi.mock('../../../../RunTimeControl/hooks')
vi.mock('../../../hooks')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {
} from '@opentrons/components'
import { useToggleGroup } from '/app/molecules/ToggleGroup/useToggleGroup'
import { getModuleTypesThatRequireExtraAttention } from '../utils/getModuleTypesThatRequireExtraAttention'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentCompletedAnalysis } from '/app/resources/runs'
import { useIsFlex } from '/app/redux-resources/robots'
import { useStoredProtocolAnalysis } from '/app/resources/analysis'
import { useModuleRenderInfoForProtocolById } from '../../hooks'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import { i18n } from '/app/i18n'
import { getIsLabwareOffsetCodeSnippetsOn } from '/app/redux/config'
import { LabwarePositionCheck } from '../../../../LabwarePositionCheck'
import { useLPCDisabledReason } from '../../../hooks'
import { getLatestCurrentOffsets } from '../utils'
import { getLatestCurrentOffsets } from '/app/transformations/runs'
import { CurrentOffsetsTable } from '../CurrentOffsetsTable'

import type { CompletedProtocolAnalysis } from '@opentrons/shared-data'
Expand All @@ -21,7 +21,7 @@ import type { LabwareOffset } from '@opentrons/api-client'
vi.mock('../../../hooks')
vi.mock('../../../../LabwarePositionCheck')
vi.mock('/app/redux/config')
vi.mock('../utils')
vi.mock('/app/transformations/runs')

vi.mock('@opentrons/shared-data', async importOriginal => {
const actual = await importOriginal<typeof getLoadedLabwareDefinitionsByUri>()
Expand Down
Loading
Loading