-
Notifications
You must be signed in to change notification settings - Fork 179
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(app): Populate FileInfo page with JSON protocol metadata (#2278)
Closes #2129
- Loading branch information
Showing
19 changed files
with
630 additions
and
307 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,32 +1,74 @@ | ||
// @flow | ||
import * as React from 'react' | ||
import {connect} from 'react-redux' | ||
import moment from 'moment' | ||
|
||
import { | ||
getProtocolName, | ||
getProtocolAuthor, | ||
getProtocolLastUpdated, | ||
getProtocolMethod, | ||
getProtocolDescription, | ||
} from '../../protocol' | ||
import {LabeledValue} from '@opentrons/components' | ||
import InfoSection from './InfoSection' | ||
import {SectionContentHalf} from '../layout' | ||
import {SectionContentHalf, CardRow} from '../layout' | ||
|
||
import styles from './styles.css' | ||
import type {State} from '../../types' | ||
|
||
type Props = { | ||
name: string, | ||
name: ?string, | ||
author: ?string, | ||
lastUpdated: ?number, | ||
method: ?string, | ||
description: ?string, | ||
} | ||
const TITLE = 'Information' | ||
|
||
export default function InformationCard (props: Props) { | ||
const {name} = props | ||
const INFO_TITLE = 'Information' | ||
const DESCRIPTION_TITLE = 'Description' | ||
const DATE_FORMAT = 'DD MMM Y, hh:mmA' | ||
|
||
let createdBy = 'Opentrons API' | ||
if (name.endsWith('.json')) { | ||
createdBy = 'Protocol Designer' | ||
} | ||
export default connect(mapStateToProps)(InformationCard) | ||
|
||
function InformationCard (props: Props) { | ||
const {name, author, method, description} = props | ||
const lastUpdated = props.lastUpdated | ||
? moment(props.lastUpdated).format(DATE_FORMAT) | ||
: '-' | ||
|
||
return ( | ||
<InfoSection title={TITLE}> | ||
<SectionContentHalf> | ||
<LabeledValue label={'Protocol Name'} value={name} /> | ||
</SectionContentHalf> | ||
<SectionContentHalf className={styles.align_left}> | ||
<LabeledValue label={'Creation Method'} value={createdBy} /> | ||
</SectionContentHalf> | ||
</InfoSection> | ||
<React.Fragment> | ||
<InfoSection title={INFO_TITLE}> | ||
<CardRow> | ||
<SectionContentHalf> | ||
<LabeledValue label="Protocol Name" value={name || '-'} /> | ||
</SectionContentHalf> | ||
<SectionContentHalf> | ||
<LabeledValue label="Organization/Author" value={author || '-'} /> | ||
</SectionContentHalf> | ||
</CardRow> | ||
<SectionContentHalf> | ||
<LabeledValue label="Last Updated" value={lastUpdated} /> | ||
</SectionContentHalf> | ||
<SectionContentHalf> | ||
<LabeledValue label="Creation Method" value={method || '-'} /> | ||
</SectionContentHalf> | ||
</InfoSection> | ||
{description && ( | ||
<InfoSection title={DESCRIPTION_TITLE}> | ||
<p>{description}</p> | ||
</InfoSection> | ||
)} | ||
</React.Fragment> | ||
) | ||
} | ||
|
||
function mapStateToProps (state: State): Props { | ||
return { | ||
name: getProtocolName(state), | ||
author: getProtocolAuthor(state), | ||
lastUpdated: getProtocolLastUpdated(state), | ||
method: getProtocolMethod(state), | ||
description: getProtocolDescription(state), | ||
} | ||
} |
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
Oops, something went wrong.