Skip to content

Commit

Permalink
refactor(app): Add resources import hierarchy (#14632)
Browse files Browse the repository at this point in the history
Closes EXEC-160
  • Loading branch information
mjhuff authored Mar 12, 2024
1 parent 49ab0dc commit 6388263
Show file tree
Hide file tree
Showing 92 changed files with 168 additions and 154 deletions.
4 changes: 2 additions & 2 deletions app/src/App/__tests__/OnDeviceDisplayApp.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ import { getIsShellReady } from '../../redux/shell'
import { getLocalRobot } from '../../redux/discovery'
import { mockConnectedRobot } from '../../redux/discovery/__fixtures__'
import { useCurrentRunRoute, useProtocolReceiptToast } from '../hooks'
import { useNotifyCurrentMaintenanceRun } from '../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun'
import { useNotifyCurrentMaintenanceRun } from '../../resources/maintenance_runs'

import type { OnDeviceDisplaySettings } from '../../redux/config/schema-types'

Expand All @@ -51,7 +51,7 @@ vi.mock('../../pages/DeckConfiguration')
vi.mock('../../redux/config')
vi.mock('../../redux/shell')
vi.mock('../../redux/discovery')
vi.mock('../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun')
vi.mock('../../resources/maintenance_runs')
vi.mock('../hooks')

const mockSettings = {
Expand Down
3 changes: 1 addition & 2 deletions app/src/App/hooks.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ import {

import { checkShellUpdate } from '../redux/shell'
import { useToaster } from '../organisms/ToasterOven'
import { useNotifyAllRunsQuery } from '../resources/runs/useNotifyAllRunsQuery'
import { useNotifyRunQuery } from '../resources/runs/useNotifyRunQuery'
import { useNotifyAllRunsQuery, useNotifyRunQuery } from '../resources/runs'

import type { SetStatusBarCreateCommand } from '@opentrons/shared-data'
import type { Dispatch } from '../redux/types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import type { OffsetCandidate } from '../useOffsetCandidatesForAnalysis'
vi.mock('../useAllHistoricOffsets')
vi.mock('../getLabwareLocationCombos')
vi.mock('@opentrons/shared-data')
vi.mock('../../../../resources/runs')
vi.mock('../../../../resources/useNotifyService')

const mockLabwareDef = fixtureTiprack300ul as LabwareDefinition2

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { appShellRequestor } from '../../redux/shell/remote'
import OT2_PNG from '../../assets/images/OT2-R_HERO.png'
import FLEX_PNG from '../../assets/images/FLEX.png'
import { RobotBusyStatusAction } from '.'
import { useNotifyAllRunsQuery } from '../../resources/runs/useNotifyAllRunsQuery'
import { useNotifyAllRunsQuery } from '../../resources/runs'

import type { IconName } from '@opentrons/components'
import type { Runs } from '@opentrons/api-client'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { useIsRobotViewable, useRunStatuses } from '../../Devices/hooks'
import { DeckFixtureSetupInstructionsModal } from '../DeckFixtureSetupInstructionsModal'
import { useIsEstopNotDisengaged } from '../../../resources/devices/hooks/useIsEstopNotDisengaged'
import { DeviceDetailsDeckConfiguration } from '../'
import { useNotifyCurrentMaintenanceRun } from '../../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun'
import { useNotifyCurrentMaintenanceRun } from '../../../resources/maintenance_runs'

import type { MaintenanceRun } from '@opentrons/api-client'
import type * as OpentronsComponents from '@opentrons/components'
Expand All @@ -30,7 +30,7 @@ vi.mock('@opentrons/components', async importOriginal => {
vi.mock('@opentrons/react-api-client')
vi.mock('../DeckFixtureSetupInstructionsModal')
vi.mock('../../Devices/hooks')
vi.mock('../../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun')
vi.mock('../../../resources/maintenance_runs')
vi.mock('../../../resources/devices/hooks/useIsEstopNotDisengaged')

const ROBOT_NAME = 'otie'
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/DeviceDetailsDeckConfiguration/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import {
SINGLE_RIGHT_SLOT_FIXTURE,
} from '@opentrons/shared-data'

import { useNotifyCurrentMaintenanceRun } from '../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun'
import { useNotifyCurrentMaintenanceRun } from '../../resources/maintenance_runs'
import { StyledText } from '../../atoms/text'
import { Banner } from '../../atoms/Banner'
import { DeckFixtureSetupInstructionsModal } from './DeckFixtureSetupInstructionsModal'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ import { getIsFixtureMismatch } from '../../../resources/deck_configuration/util
import { useDeckConfigurationCompatibility } from '../../../resources/deck_configuration/hooks'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentRunId } from '../../ProtocolUpload/hooks/useMostRecentRunId'
import { useNotifyRunQuery } from '../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../resources/runs'

import type { Run, RunError } from '@opentrons/api-client'
import type { State } from '../../../redux/types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { SetupLabwareList } from '../SetupLabwareList'
import { SetupLabwareMap } from '../SetupLabwareMap'
import { SetupLabware } from '..'
import { useNotifyRunQuery } from '../../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../../resources/runs'

vi.mock('../SetupLabwareList')
vi.mock('../SetupLabwareMap')
Expand All @@ -29,7 +29,7 @@ vi.mock('../../../../RunTimeControl/hooks')
vi.mock('../../../../../redux/config')
vi.mock('../../../hooks')
vi.mock('../../../hooks/useLPCSuccessToast')
vi.mock('../../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../../resources/runs')

const ROBOT_NAME = 'otie'
const RUN_ID = '1'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
useRobotType,
} from '../../../hooks'
import { SetupLabwarePositionCheck } from '..'
import { useNotifyRunQuery } from '../../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../../resources/runs'

import type { Mock } from 'vitest'

Expand All @@ -35,7 +35,7 @@ vi.mock('../../../../../redux/config')
vi.mock('../../../hooks')
vi.mock('../../../hooks/useLPCSuccessToast')
vi.mock('@opentrons/react-api-client')
vi.mock('../../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../../resources/runs')

const DISABLED_REASON = 'MOCK_DISABLED_REASON'
const ROBOT_NAME = 'otie'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ import { CurrentOffsetsTable } from './CurrentOffsetsTable'
import { useLaunchLPC } from '../../../LabwarePositionCheck/useLaunchLPC'
import { StyledText } from '../../../../atoms/text'
import { getLatestCurrentOffsets } from './utils'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import type { LabwareOffset } from '@opentrons/api-client'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ import {
getTotalVolumePerLiquidLabwarePair,
} from '../utils'
import { LiquidsLabwareDetailsModal } from '../LiquidsLabwareDetailsModal'
import { useNotifyRunQuery } from '../../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../../resources/runs'

import type { Mock } from 'vitest'

Expand Down Expand Up @@ -61,7 +61,7 @@ vi.mock('../../utils/getLocationInfoNames')
vi.mock('../LiquidsLabwareDetailsModal')
vi.mock('@opentrons/api-client')
vi.mock('../../../../../redux/analytics')
vi.mock('../../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../../resources/runs')

const render = (props: React.ComponentProps<typeof SetupLiquidsList>) => {
return renderWithProviders(<SetupLiquidsList {...props} />, {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import { TertiaryButton } from '../../../../atoms/buttons'
import { StatusLabel } from '../../../../atoms/StatusLabel'
import { StyledText } from '../../../../atoms/text'
import { Tooltip } from '../../../../atoms/Tooltip'
import { useChainLiveCommands } from '../../../../resources/runs/hooks'
import { useChainLiveCommands } from '../../../../resources/runs'
import { ModuleSetupModal } from '../../../ModuleCard/ModuleSetupModal'
import { ModuleWizardFlows } from '../../../ModuleWizardFlows'
import { getModulePrepCommands } from '../../getModulePrepCommands'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {
mockMagneticModuleGen2,
mockThermocycler,
} from '../../../../../redux/modules/__fixtures__'
import { useChainLiveCommands } from '../../../../../resources/runs/hooks'
import { useChainLiveCommands } from '../../../../../resources/runs'
import { ModuleSetupModal } from '../../../../ModuleCard/ModuleSetupModal'
import { ModuleWizardFlows } from '../../../../ModuleWizardFlows'
import {
Expand All @@ -38,7 +38,7 @@ vi.mock('../UnMatchedModuleWarning')
vi.mock('../../../../ModuleCard/ModuleSetupModal')
vi.mock('../../../../ModuleWizardFlows')
vi.mock('../MultipleModulesModal')
vi.mock('../../../../../resources/runs/hooks')
vi.mock('../../../../../resources/runs')
vi.mock('../../../../../redux/config')

const ROBOT_NAME = 'otie'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ import { getIsFixtureMismatch } from '../../../../resources/deck_configuration/u
import { useDeckConfigurationCompatibility } from '../../../../resources/deck_configuration/hooks'
import { useMostRecentCompletedAnalysis } from '../../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
import { useMostRecentRunId } from '../../../ProtocolUpload/hooks/useMostRecentRunId'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'
import type { UseQueryResult } from 'react-query'
import type * as ReactRouterDom from 'react-router-dom'
import type { Mock } from 'vitest'
Expand Down Expand Up @@ -148,7 +148,7 @@ vi.mock('../../../../resources/deck_configuration/utils')
vi.mock('../../../../resources/deck_configuration/hooks')
vi.mock('../../../LabwarePositionCheck/useMostRecentCompletedAnalysis')
vi.mock('../../../ProtocolUpload/hooks/useMostRecentRunId')
vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')

const ROBOT_NAME = 'otie'
const RUN_ID = '95e67900-bc9f-4fbf-92c6-cc4d7226a51b'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ import { SetupLiquids } from '../SetupLiquids'
import { SetupModuleAndDeck } from '../SetupModuleAndDeck'
import { EmptySetupStep } from '../EmptySetupStep'
import { ProtocolRunSetup } from '../ProtocolRunSetup'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import type * as SharedData from '@opentrons/shared-data'

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@ import { mockTipRackDefinition } from '../../../../redux/custom-labware/__fixtur
import { useRunPipetteInfoByMount } from '../../hooks'
import { SetupPipetteCalibrationItem } from '../SetupPipetteCalibrationItem'
import { SetupInstrumentCalibration } from '../SetupInstrumentCalibration'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import type { PipetteInfo } from '../../hooks'

vi.mock('../../hooks')
vi.mock('../SetupPipetteCalibrationItem')
vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')

const ROBOT_NAME = 'otie'
const RUN_ID = '1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { getLoadedLabwareDefinitionsByUri } from '@opentrons/shared-data'

import { getCurrentOffsetForLabwareInLocation } from '../../Devices/ProtocolRun/utils/getCurrentOffsetForLabwareInLocation'
import { getLabwareDefinitionUri } from '../../Devices/ProtocolRun/utils/getLabwareDefinitionUri'
import { getLabwareOffsetLocation } from '../../Devices/ProtocolRun/utils/getLabwareOffsetLocation'
import { useNotifyRunQuery } from '../../../resources/runs/useNotifyRunQuery'
import { getCurrentOffsetForLabwareInLocation } from './utils/getCurrentOffsetForLabwareInLocation'
import { getLabwareDefinitionUri } from './utils/getLabwareDefinitionUri'
import { getLabwareOffsetLocation } from './utils/getLabwareOffsetLocation'
import { useNotifyRunQuery } from '../../../resources/runs'

import type { LabwareOffset } from '@opentrons/api-client'
import { useMostRecentCompletedAnalysis } from '../../LabwarePositionCheck/useMostRecentCompletedAnalysis'
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/Devices/RecentProtocolRuns.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import { StyledText } from '../../atoms/text'
import { useCurrentRunId } from '../ProtocolUpload/hooks'
import { HistoricalProtocolRun } from './HistoricalProtocolRun'
import { useIsRobotViewable, useRunStatuses } from './hooks'
import { useNotifyAllRunsQuery } from '../../resources/runs/useNotifyAllRunsQuery'
import { useNotifyAllRunsQuery } from '../../resources/runs'

interface RecentProtocolRunsProps {
robotName: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ import {
useTipLengthCalibrations,
useRobot,
} from '../../../hooks'
import { useNotifyAllRunsQuery } from '../../../../../resources/runs/useNotifyAllRunsQuery'
import { useNotifyAllRunsQuery } from '../../../../../resources/runs'

import type { State, Dispatch } from '../../../../../redux/types'
import type { ResetConfigRequest } from '../../../../../redux/robot-admin/types'
Expand Down
2 changes: 1 addition & 1 deletion app/src/organisms/Devices/RobotStatusHeader.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ import {
OPENTRONS_USB,
} from '../../redux/discovery'
import { getNetworkInterfaces, fetchStatus } from '../../redux/networking'
import { useNotifyRunQuery } from '../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../resources/runs'

import type { IconName, StyleProps } from '@opentrons/components'
import type { DiscoveredRobot } from '../../redux/discovery/types'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { screen } from '@testing-library/react'
import { describe, it, vi, beforeEach } from 'vitest'
import '@testing-library/jest-dom/vitest'
import { renderWithProviders } from '../../../__testing-utils__'
import { useNotifyAllRunsQuery } from '../../../resources/runs/useNotifyAllRunsQuery'
import { useNotifyAllRunsQuery } from '../../../resources/runs'
import { i18n } from '../../../i18n'
import { useIsRobotViewable, useRunStatuses } from '../hooks'
import { RecentProtocolRuns } from '../RecentProtocolRuns'
Expand All @@ -13,7 +13,7 @@ import { HistoricalProtocolRun } from '../HistoricalProtocolRun'
import type { Runs } from '@opentrons/api-client'
import type { AxiosError } from 'axios'

vi.mock('../../../resources/runs/useNotifyAllRunsQuery')
vi.mock('../../../resources/runs')
vi.mock('../hooks')
vi.mock('../../ProtocolUpload/hooks')
vi.mock('../HistoricalProtocolRun')
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
import { getNetworkInterfaces } from '../../../redux/networking'
import { useIsFlex } from '../hooks'
import { RobotStatusHeader } from '../RobotStatusHeader'
import { useNotifyRunQuery } from '../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../resources/runs'

import type { DiscoveryClientRobotAddress } from '../../../redux/discovery/types'
import type { SimpleInterfaceStatus } from '../../../redux/networking/types'
Expand All @@ -31,7 +31,7 @@ vi.mock('../../../organisms/RunTimeControl/hooks')
vi.mock('../../../redux/discovery')
vi.mock('../../../redux/networking')
vi.mock('../hooks')
vi.mock('../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../resources/runs')

const MOCK_OTIE = {
name: 'otie',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,17 @@ import {
} from '../../../EmergencyStop'
import { useIsRobotBusy } from '../useIsRobotBusy'
import { useIsFlex } from '../useIsFlex'
import { useNotifyCurrentMaintenanceRun } from '../../../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun'
import { useNotifyAllRunsQuery } from '../../../../resources/runs/useNotifyAllRunsQuery'
import { useNotifyCurrentMaintenanceRun } from '../../../../resources/maintenance_runs'
import { useNotifyAllRunsQuery } from '../../../../resources/runs'

import type { Sessions, Runs } from '@opentrons/api-client'
import type { AxiosError } from 'axios'

vi.mock('@opentrons/react-api-client')
vi.mock('../../../ProtocolUpload/hooks')
vi.mock('../useIsFlex')
vi.mock('../../../../resources/runs/useNotifyAllRunsQuery')
vi.mock('../../../../resources/maintenance_runs/useNotifyCurrentMaintenanceRun')
vi.mock('../../../../resources/runs')
vi.mock('../../../../resources/maintenance_runs')

const mockEstopStatus = {
data: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '@opentrons/react-api-client'

import { useProtocolAnalysisErrors } from '..'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import { RUN_ID_2 } from '../../../../organisms/RunTimeControl/__fixtures__'
import { RUN_ID_2 } from '../../../RunTimeControl/__fixtures__'

import type { Run, Protocol } from '@opentrons/api-client'
import type {
Expand All @@ -20,7 +20,7 @@ import type {
} from '@opentrons/shared-data'

vi.mock('@opentrons/react-api-client')
vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')

describe('useProtocolAnalysisErrors hook', () => {
beforeEach(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
} from '@opentrons/react-api-client'

import { useProtocolDetailsForRun } from '..'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import { RUN_ID_2 } from '../../../../organisms/RunTimeControl/__fixtures__'
import { RUN_ID_2 } from '../../../RunTimeControl/__fixtures__'

import type { Protocol, Run } from '@opentrons/api-client'
import {
Expand All @@ -20,7 +20,7 @@ import {
} from '@opentrons/shared-data'

vi.mock('@opentrons/react-api-client')
vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')

const PROTOCOL_ID = 'fake_protocol_id'
const PROTOCOL_ANALYSIS = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import {
useIsFlex,
useRunPipetteInfoByMount,
} from '..'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import type { PipetteInfo } from '..'
import { Provider } from 'react-redux'
Expand All @@ -20,7 +20,7 @@ import { createStore } from 'redux'
vi.mock('../useDeckCalibrationStatus')
vi.mock('../useIsFlex')
vi.mock('../useRunPipetteInfoByMount')
vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')

let wrapper: React.FunctionComponent<{ children: React.ReactNode }>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ import { renderHook } from '@testing-library/react'
import { vi, it, expect, describe, beforeEach } from 'vitest'
import { when } from 'vitest-when'

import { mockIdleUnstartedRun } from '../../../../organisms/RunTimeControl/__fixtures__'
import { mockIdleUnstartedRun } from '../../../RunTimeControl/__fixtures__'
import { formatTimestamp } from '../../utils'
import { useRunCreatedAtTimestamp } from '../useRunCreatedAtTimestamp'
import { useNotifyRunQuery } from '../../../../resources/runs/useNotifyRunQuery'
import { useNotifyRunQuery } from '../../../../resources/runs'

import type { UseQueryResult } from 'react-query'
import type { Run } from '@opentrons/api-client'

vi.mock('../../../../resources/runs/useNotifyRunQuery')
vi.mock('../../../../resources/runs')
vi.mock('../../utils')

const MOCK_RUN_ID = '1'
Expand Down
Loading

0 comments on commit 6388263

Please sign in to comment.