-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(protocol-designer): make 8_2_2 migration to migrate HS set timer … (
#17124) …field The `heaterShakerSetTimer` field's type is `heaterShakerSetTimer: 'true' | 'false' | null` - this was written 3 years ago. However, despite this, the field when checking the checkbox in the form in PD would populate it as `true` or `false` booleans rather than the true/false strings. 2 weeks ago, right before 8.2.0 was released, there was a bug checking the timer checkbox for the temperature module and it was because of this boolean vs boolean strings issue. So I extended it onto the heater-shaker set timer field as well because of its type. Unfortunately, that resulted in this current error: - protocols created in 8.2.0 and 8.2.1 have the `heaterShakerSetTimer` field set to either `'true'` or `'false'` strings - protocols created prior to 8.2.0 have the `heaterShakerSetTimer` field set to `true` or `false` boolean - my initial fix was to update the form field to check for `true` or `false` boolean but that didn't fix any protocols created in 8.2.0 and 8.2.1. - the extended fix unfortunately required a migration so now if `'true'` or `'false'` strings are used in the field, they get migrated to `true` or `false` boolean -- this i believe is the only way to fix all protocol versions
- Loading branch information
Showing
7 changed files
with
61 additions
and
6 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import type { ProtocolFile } from '@opentrons/shared-data' | ||
import type { DesignerApplicationData } from './utils/getLoadLiquidCommands' | ||
|
||
export const migrateFile = ( | ||
appData: ProtocolFile<DesignerApplicationData> | ||
): ProtocolFile<DesignerApplicationData> => { | ||
const { designerApplication } = appData | ||
|
||
if (designerApplication == null || designerApplication?.data == null) { | ||
throw Error('The designerApplication key in your file is corrupt.') | ||
} | ||
const savedStepForms = designerApplication.data | ||
?.savedStepForms as DesignerApplicationData['savedStepForms'] | ||
|
||
const savedStepsWithUpdatedHeaterShakerTimerField = Object.values( | ||
savedStepForms | ||
).reduce((acc, form) => { | ||
if (form.stepType === 'heaterShaker') { | ||
const { id, heaterShakerSetTimer } = form | ||
let newSetTimer = heaterShakerSetTimer | ||
|
||
if (heaterShakerSetTimer === 'false') { | ||
newSetTimer = false | ||
} else if (heaterShakerSetTimer === 'true') { | ||
newSetTimer = true | ||
} | ||
return { | ||
...acc, | ||
[id]: { | ||
...form, | ||
heaterShakerSetTimer: newSetTimer, | ||
}, | ||
} | ||
} | ||
return acc | ||
}, {}) | ||
|
||
return { | ||
...appData, | ||
designerApplication: { | ||
...designerApplication, | ||
data: { | ||
...designerApplication.data, | ||
savedStepForms: { | ||
...designerApplication.data.savedStepForms, | ||
...savedStepsWithUpdatedHeaterShakerTimerField, | ||
}, | ||
}, | ||
}, | ||
} | ||
} |
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