Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): make protocol runs from history clickable #10537

Merged
merged 4 commits into from
Jun 1, 2022

Conversation

jerader
Copy link
Collaborator

@jerader jerader commented May 31, 2022

closes #10502

Overview

This PR makes each run and protocol in the run history clickable. When clicking on run, it links to the run details page. When clicking on protocol Name, it links to the protocol details page.

Changelog

  • changes HistoricalProtocolRun to take in a protocol key prop and also gets stored protocols
  • extends prop in RecentProtocolRuns

Review requests

  • click on a run in your robot's recent Protocol Runs, it should link you to the correct run details page.
  • click on a protocol name in your robot's recent Protocol Runs, it should link you to the correct protocol details page.
  • go into Protocol Cards and delete a protocol. When you return to the Protocol Runs, the run and protocol name for that deleted protocol should not be clickable.

Risk assessment

low

@jerader jerader requested a review from a team as a code owner May 31, 2022 16:10
@jerader jerader requested review from brenthagen, smb2268, b-cooper and koji and removed request for a team May 31, 2022 16:10
@codecov
Copy link

codecov bot commented May 31, 2022

Codecov Report

Merging #10537 (788b43b) into edge (1c051fe) will increase coverage by 0.04%.
The diff coverage is 90.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             edge   #10537      +/-   ##
==========================================
+ Coverage   73.81%   73.85%   +0.04%     
==========================================
  Files        2139     2141       +2     
  Lines       57526    57889     +363     
  Branches     5807     5945     +138     
==========================================
+ Hits        42460    42756     +296     
- Misses      13846    13871      +25     
- Partials     1220     1262      +42     
Flag Coverage Δ
app 71.52% <90.00%> (+0.23%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
app/src/organisms/Devices/RecentProtocolRuns.tsx 81.25% <ø> (ø)
...pp/src/organisms/Devices/HistoricalProtocolRun.tsx 60.71% <90.00%> (+13.34%) ⬆️
...s/CalibrationDetails/TipLengthCalibrationItems.tsx 83.33% <0.00%> (-6.67%) ⬇️
app/src/pages/Devices/RobotSettings/index.tsx 96.00% <0.00%> (-4.00%) ⬇️
...librationDetails/PipetteOffsetCalibrationItems.tsx 76.92% <0.00%> (-1.65%) ⬇️
...ms/Devices/RobotSettings/RobotSettingsAdvanced.tsx 45.90% <0.00%> (-1.47%) ⬇️
app/src/redux/config/constants.ts 100.00% <0.00%> (ø)
...isms/Devices/HistoricalProtocolRunOffsetDrawer.tsx 0.00% <0.00%> (ø)
.../Devices/RobotSettings/RobotSettingsNetworking.tsx 100.00% <0.00%> (ø)
...Devices/RobotSettings/AdvancedTab/FactoryReset.tsx 100.00% <0.00%> (ø)
... and 12 more

@jerader jerader force-pushed the app_protocol-runs-add-buttons branch from 982b7f5 to 0abd5b4 Compare May 31, 2022 18:49
Copy link
Contributor

@sakibh sakibh left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple small comments. Otherwise, this works as expected!! ✅

interface HistoricalProtocolRunProps {
run: RunData
protocolKey?: string
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Optional props should go last probably.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ooh i've never really thought about that/knew this was the convention. But it makes sense to make it more readable.

Comment on lines 61 to 65
const protocolKeys = storedProtocols.map(({ protocolKey }) => protocolKey)
const protocolKeyInStoredKeys = Object.values(protocolKeys).find(
key => key === protocolKey
)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Object.values returns an array. protocolKeys here is an array so you don't need to use that. I think this can also be simplified to the following:

  const protocolKeyInStoredKeys = storedProtocols
    .map(({ protocolKey }) => protocolKey)
    .find(key => key === protocolKey)

@@ -43,6 +58,10 @@ export function HistoricalProtocolRun(
duration = formatInterval(run.createdAt, new Date().toString())
}
}
const protocolKeyInStoredKeys = storedProtocols
.map(({ protocolKey }) => protocolKey)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oooo, there's already a variable called protocolKey in this component. we should be able to avoid this confusion by just simplifying this to one .find call

e.g. storedProtocols.find(({protocolKey: key}) => protocolKey === key)

this allows us to destructure out the value in the protocolKey of each storedProtocol, but immediately alias it to key so we don't have to worry about the name collision

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That makes sense! I'll make that change. Thanks!

>
{protocolName}
</StyledText>
{protocolKeyInStoredKeys != null ? (
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like this ternary statement could be moved within the onClick callback of the protocolName as that's the only thing that actually switches on whether or not the protocolKey was found in a locally stored protocol.

It also looks like there is a bit of unintentional functionality here. This currently only allows a user to link to the run record, if the associated protocol exists locally on the app. There is no reason for this restriction, a user should be able to view the run detail page for any run record, regardless of whether or not the protocol with the corresponding key is present on the file system.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, i misunderstood the AC. I thought we didn't want to be able to access the run record if the protocol was deleted. Will fix that now. Thanks.

@jerader jerader requested a review from b-cooper June 1, 2022 12:31
@jerader jerader merged commit b98abee into edge Jun 1, 2022
@jerader jerader deleted the app_protocol-runs-add-buttons branch June 1, 2022 18:01
@nusrat813
Copy link

go into Protocol Cards and delete a protocol. When you return to the Protocol Runs, the run and protocol name for that deleted protocol should not be clickable.

  • After a protocol is deleted, the run is still clickable

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6.0 Feedback: 6.0.0-alpha.0 Recent protocol runs are missing clickable items
4 participants