-
Notifications
You must be signed in to change notification settings - Fork 180
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor(app): Add hook for on-the-fly maintenance run commands (#16249)
Closes EXEC-699 In pre-release work, we decided to add a drop tip CTA option of "skip and home pipettes". In order to do this, we needed to create a maintenance run, initiate commands, and then close the maintenance context. There wasn't any general purpose way of doing this (we always had a wizard flow when issuing commands up to this point), so the solution was to commandeer existing drop tip wizard hooks to do this for us. While that works, it has a few issues: * It was pretty hackily implemented, and it kind of had to be without a dedicated hook. * It makes following drop tip wizard more difficult to follow. * If we every want to issue commands to a robot outside of a wizard flow, we have to add to the tech debt. Since 8.1 should entail some drop tip wizard refactoring, this seems like a pretty good thing to refactor. This adds a new useRobotControlCommands, which is a refactor of what the more specific drop tip wizard useDropTipMaintenanceRun. useDropTipMaintenanceRun was half doing this functionality plus other things (useDropTipMaintenanceRun now only does the other things!). This PR cleans up a lot of the cruft/paves the way for more drop tip refactors in 8.1 that were a result of the refactor.
- Loading branch information
Showing
35 changed files
with
402 additions
and
333 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
app/src/organisms/DropTipWizardFlows/DropTipWizardFlows.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import * as React from 'react' | ||
|
||
import { useDropTipRouting, useDropTipWithType } from './hooks' | ||
import { DropTipWizard } from './DropTipWizard' | ||
|
||
import type { PipetteModelSpecs, RobotType } from '@opentrons/shared-data' | ||
import type { PipetteData } from '@opentrons/api-client' | ||
import type { FixitCommandTypeUtils, IssuedCommandsType } from './types' | ||
|
||
/** Provides the user toggle for rendering Drop Tip Wizard Flows. | ||
* | ||
* NOTE: Rendering these flows is independent of whether tips are actually attached. First use useTipAttachmentStatus | ||
* to get tip attachment status. | ||
*/ | ||
export function useDropTipWizardFlows(): { | ||
showDTWiz: boolean | ||
toggleDTWiz: () => void | ||
} { | ||
const [showDTWiz, setShowDTWiz] = React.useState(false) | ||
|
||
const toggleDTWiz = (): void => { | ||
setShowDTWiz(!showDTWiz) | ||
} | ||
|
||
return { showDTWiz, toggleDTWiz } | ||
} | ||
|
||
export interface DropTipWizardFlowsProps { | ||
robotType: RobotType | ||
mount: PipetteData['mount'] | ||
instrumentModelSpecs: PipetteModelSpecs | ||
/* isTakeover allows for optionally specifying a different callback if a different client cancels the "setup" type flow. */ | ||
closeFlow: (isTakeover?: boolean) => void | ||
/* Optional. If provided, DT will issue "fixit" commands and render alternate Error Recovery compatible views. */ | ||
fixitCommandTypeUtils?: FixitCommandTypeUtils | ||
} | ||
|
||
export function DropTipWizardFlows( | ||
props: DropTipWizardFlowsProps | ||
): JSX.Element { | ||
const { fixitCommandTypeUtils } = props | ||
|
||
const issuedCommandsType: IssuedCommandsType = | ||
fixitCommandTypeUtils != null ? 'fixit' : 'setup' | ||
|
||
const dropTipWithTypeUtils = useDropTipWithType({ | ||
...props, | ||
issuedCommandsType, | ||
}) | ||
|
||
const dropTipRoutingUtils = useDropTipRouting(fixitCommandTypeUtils) | ||
|
||
return ( | ||
<DropTipWizard | ||
{...props} | ||
{...dropTipWithTypeUtils} | ||
{...dropTipRoutingUtils} | ||
issuedCommandsType={issuedCommandsType} | ||
/> | ||
) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
21 changes: 21 additions & 0 deletions
21
app/src/organisms/DropTipWizardFlows/__tests__/DropTipWizardFlows.test.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { describe, it, expect, vi } from 'vitest' | ||
import { renderHook, act } from '@testing-library/react' | ||
|
||
import { useDropTipWizardFlows } from '..' | ||
|
||
vi.mock('../DropTipWizard') | ||
vi.mock('../hooks') | ||
|
||
describe('useDropTipWizardFlows', () => { | ||
it('should toggle showDTWiz state', () => { | ||
const { result } = renderHook(() => useDropTipWizardFlows()) | ||
|
||
expect(result.current.showDTWiz).toBe(false) | ||
|
||
act(() => { | ||
result.current.toggleDTWiz() | ||
}) | ||
|
||
expect(result.current.showDTWiz).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.