-
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.
feat(app): update protocol detail and protocol setup status for deck …
…configuration ODD: Render the correct modules and deck status taking into account location conflicts, missing hardware, and missing calibrations. Render this status in both ProtocolDetails (chipText) and ProtocolSetup (Modules & deck) pages. Extend hooks to look for conflicting or missing hardware
- Loading branch information
Showing
7 changed files
with
345 additions
and
95 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
81 changes: 51 additions & 30 deletions
81
app/src/organisms/OnDeviceDisplay/RobotDashboard/hooks/useHardwareStatusText.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 |
---|---|---|
@@ -1,51 +1,72 @@ | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { useFeatureFlag } from '../../../../redux/config' | ||
|
||
import type { ProtocolHardware } from '../../../../pages/Protocols/hooks' | ||
|
||
export function useHardwareStatusText( | ||
missingProtocolHardware: ProtocolHardware[], | ||
conflictedSlots: string[] | ||
): string { | ||
const { t, i18n } = useTranslation('device_details') | ||
const enableDeckConfig = useFeatureFlag('enableDeckConfiguration') | ||
|
||
const missingProtocolHardwareType = missingProtocolHardware.map( | ||
hardware => hardware.hardwareType | ||
const missingProtocolHardwareType = missingProtocolHardware.map(hardware => | ||
hardware.hardwareType === 'pipette' || hardware.hardwareType === 'gripper' | ||
? 'instrument' | ||
: hardware.hardwareType | ||
) | ||
const countMissingHardwareType = (hwType: 'pipette' | 'module'): number => { | ||
const countMissingHardwareType = ( | ||
hwType: 'instrument' | 'module' | 'fixture' | ||
): number => { | ||
return missingProtocolHardwareType.filter( | ||
hardwareType => hardwareType === hwType | ||
).length | ||
} | ||
const countMissingPipettes = countMissingHardwareType('pipette') | ||
|
||
const countMissingInstruments = countMissingHardwareType('instrument') | ||
const countMissingModules = countMissingHardwareType('module') | ||
let chipText: string = t('ready_to_run') | ||
if (enableDeckConfig && conflictedSlots.length > 0) { | ||
const countMissingFixtures = countMissingHardwareType('fixture') | ||
|
||
const noHardwareMissing = | ||
[countMissingInstruments, countMissingModules, countMissingFixtures].filter( | ||
count => count > 0 | ||
).length === 0 | ||
const multipleHardwareTypesMissing = | ||
[countMissingInstruments, countMissingModules, countMissingFixtures].filter( | ||
count => count > 0 | ||
).length > 1 | ||
|
||
let chipText: string | ||
|
||
if (noHardwareMissing) { | ||
chipText = t('ready_to_run') | ||
} else if (conflictedSlots.length > 0) { | ||
chipText = t('location_conflicts') | ||
} else if (countMissingPipettes === 0 && countMissingModules > 0) { | ||
if (countMissingModules === 1) { | ||
chipText = t('missing_module', { | ||
num: countMissingModules, | ||
}) | ||
} else { | ||
chipText = t('missing_module_plural', { | ||
count: countMissingModules, | ||
}) | ||
} | ||
} else if (countMissingPipettes > 0 && countMissingModules === 0) { | ||
if (countMissingPipettes === 1) { | ||
chipText = t('missing_pipette', { | ||
num: countMissingPipettes, | ||
}) | ||
} else if (multipleHardwareTypesMissing) { | ||
chipText = t('missing_hardware') | ||
} else { | ||
// exactly one hardware type missing | ||
if (countMissingFixtures > 0) { | ||
chipText = | ||
countMissingFixtures === 1 | ||
? t('missing_fixture', { num: countMissingFixtures }) | ||
: t('missing_fixtures_plural', { count: countMissingFixtures }) | ||
} else if (countMissingModules > 0) { | ||
chipText = | ||
countMissingModules === 1 | ||
? t('missing_module', { | ||
num: countMissingModules, | ||
}) | ||
: t('missing_module_plural', { | ||
count: countMissingModules, | ||
}) | ||
} else { | ||
chipText = t('missing_pipettes_plural', { | ||
count: countMissingPipettes, | ||
}) | ||
chipText = | ||
countMissingInstruments === 1 | ||
? t('missing_instrument', { | ||
num: countMissingInstruments, | ||
}) | ||
: t('missing_instruments_plural', { | ||
count: countMissingInstruments, | ||
}) | ||
} | ||
} else if (countMissingPipettes > 0 && countMissingModules > 0) { | ||
chipText = t('missing_both') | ||
} | ||
return i18n.format(chipText, 'capitalize') | ||
} |
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.