Skip to content

Commit

Permalink
fix(app): update legacy run type
Browse files Browse the repository at this point in the history
Move `runTimeParameters` property from `LegacyGoodRunData` to `KnownGoodRunData` since robot server
does not return RTP for server versions <7.3. Check for `runTimeParameters` property explicitly when
needed.
  • Loading branch information
ncdiehl11 committed Aug 12, 2024
1 parent e54341a commit a67b8d8
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 9 deletions.
2 changes: 1 addition & 1 deletion api-client/src/runs/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ export interface LegacyGoodRunData {
modules: LoadedModule[]
protocolId?: string
labwareOffsets?: LabwareOffset[]
runTimeParameters: RunTimeParameter[]
}

export interface KnownGoodRunData extends LegacyGoodRunData {
ok: true
runTimeParameters: RunTimeParameter[]
}

export interface KnownInvalidRunData extends LegacyGoodRunData {
Expand Down
9 changes: 6 additions & 3 deletions app/src/organisms/Devices/HistoricalProtocolRun.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,12 @@ export function HistoricalProtocolRun(
const { t } = useTranslation('run_details')
const { run, protocolName, robotIsBusy, robotName, protocolKey } = props
const [drawerOpen, setDrawerOpen] = React.useState(false)
const countRunDataFiles = run.runTimeParameters.filter(
parameter => parameter.type === 'csv_file'
).length
const countRunDataFiles =
'runTimeParameters' in run
? run?.runTimeParameters.filter(
parameter => parameter.type === 'csv_file'
).length
: 0
const runStatus = run.status
const runDisplayName = formatTimestamp(run.createdAt)
let duration = EMPTY_TIMESTAMP
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,15 @@ export function ProtocolRunRuntimeParameters({
// because the most recent analysis may not reflect the selected run (e.g. cloning a run
// from a historical protocol run from the device details page)
const run = useNotifyRunQuery(runId).data
const runTimeParameters =
(isRunTerminal
? run?.data?.runTimeParameters
: mostRecentAnalysis?.runTimeParameters) ?? []
let runTimeParameters
if (isRunTerminal) {
runTimeParameters =
run?.data != null && 'runTimeParameters' in run?.data
? run?.data?.runTimeParameters
: []
} else {
runTimeParameters = mostRecentAnalysis?.runTimeParameters ?? []
}
const hasRunTimeParameters = runTimeParameters.length > 0
const hasCustomRunTimeParameterValues = runTimeParameters.some(parameter =>
parameter.type !== 'csv_file' ? parameter.value !== parameter.default : true
Expand Down
6 changes: 5 additions & 1 deletion app/src/organisms/ProtocolUpload/hooks/useCloneRun.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export function useCloneRun(
)
const cloneRun = (): void => {
if (runRecord != null) {
const { protocolId, labwareOffsets, runTimeParameters } = runRecord.data
const { protocolId, labwareOffsets } = runRecord.data
const runTimeParameters =
'runTimeParameters' in runRecord.data
? runRecord.data.runTimeParameters
: []
const runTimeParameterValues = getRunTimeParameterValuesForRun(
runTimeParameters
)
Expand Down

0 comments on commit a67b8d8

Please sign in to comment.