-
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(protocol-designer): stepForm skeleton
closes AUTH-828
- Loading branch information
Showing
16 changed files
with
189 additions
and
132 deletions.
There are no files selected for viewing
103 changes: 0 additions & 103 deletions
103
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepFormComponent.tsx
This file was deleted.
Oops, something went wrong.
119 changes: 119 additions & 0 deletions
119
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepFormToolbox.tsx
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,119 @@ | ||
import * as React from 'react' | ||
import get from 'lodash/get' | ||
import { useTranslation } from 'react-i18next' | ||
|
||
import { | ||
ALIGN_CENTER, | ||
Flex, | ||
Icon, | ||
PrimaryButton, | ||
SPACING, | ||
StyledText, | ||
Toolbox, | ||
} from '@opentrons/components' | ||
import { stepIconsByType } from '../../../../form-types' | ||
import { | ||
CommentTools, | ||
HeaterShakerTools, | ||
MagnetTools, | ||
MixTools, | ||
MoveLabwareTools, | ||
MoveLiquidTools, | ||
PauseTools, | ||
TemperatureTools, | ||
ThermocyclerTools, | ||
} from './StepTools' | ||
import type { StepFieldName } from '../../../../steplist/fieldLevel' | ||
import type { FormData, StepType } from '../../../../form-types' | ||
import type { FieldPropsByName, FocusHandlers, StepFormProps } from './types' | ||
|
||
type StepFormMap = { | ||
[K in StepType]?: React.ComponentType<StepFormProps> | null | ||
} | ||
|
||
const STEP_FORM_MAP: StepFormMap = { | ||
mix: MixTools, | ||
pause: PauseTools, | ||
moveLabware: MoveLabwareTools, | ||
moveLiquid: MoveLiquidTools, | ||
magnet: MagnetTools, | ||
temperature: TemperatureTools, | ||
thermocycler: ThermocyclerTools, | ||
heaterShaker: HeaterShakerTools, | ||
comment: CommentTools, | ||
} | ||
|
||
interface StepFormToolboxProps { | ||
canSave: boolean | ||
dirtyFields: string[] | ||
focusHandlers: FocusHandlers | ||
focusedField: StepFieldName | null | ||
formData: FormData | ||
propsForFields: FieldPropsByName | ||
handleClose: () => void | ||
// TODO: add abiltiy to delete step? | ||
handleDelete: () => void | ||
handleSave: () => void | ||
} | ||
|
||
export const StepFormToolbox = (props: StepFormToolboxProps): JSX.Element => { | ||
const { | ||
formData, | ||
focusHandlers, | ||
canSave, | ||
handleClose, | ||
handleSave, | ||
propsForFields, | ||
} = props | ||
const { t, i18n } = useTranslation(['shared', 'application']) | ||
const icon = stepIconsByType[formData.stepType] | ||
|
||
const Tools: typeof STEP_FORM_MAP[keyof typeof STEP_FORM_MAP] = get( | ||
STEP_FORM_MAP, | ||
formData.stepType | ||
) | ||
|
||
if (!Tools) { | ||
// early-exit if step form doesn't exist | ||
return ( | ||
<div> | ||
<div>Todo: support {formData && formData.stepType} step</div> | ||
</div> | ||
) | ||
} | ||
|
||
return ( | ||
<> | ||
{/* TODO: update alerts */} | ||
{/* <Alerts | ||
focusedField={focusedField} | ||
dirtyFields={dirtyFields} | ||
componentType="Form" | ||
/> */} | ||
|
||
<Toolbox | ||
onCloseClick={handleClose} | ||
closeButtonText={t('cancel')} | ||
confirmButton={ | ||
<PrimaryButton onClick={handleSave} disabled={!canSave} width="100%"> | ||
{t('save')} | ||
</PrimaryButton> | ||
} | ||
height="calc(100vh - 64px)" | ||
title={ | ||
<Flex gridGap={SPACING.spacing8} alignItems={ALIGN_CENTER}> | ||
<Icon size="1rem" name={icon} /> | ||
<StyledText desktopStyle="bodyLargeSemiBold"> | ||
{i18n.format( | ||
t(`application:stepType.${formData.stepType}`), | ||
'capitalize' | ||
)} | ||
</StyledText> | ||
</Flex> | ||
} | ||
> | ||
<Tools {...{ formData, propsForFields, focusHandlers }} /> | ||
</Toolbox> | ||
</> | ||
) | ||
} |
5 changes: 5 additions & 0 deletions
5
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/CommentTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function CommentTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
...-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/HeaterShakerTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function HeaterShakerTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MagnetTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function MagnetTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MixTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function MixTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
...l-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLabwareTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function MoveLabwareTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
...ol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/MoveLiquidTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function MoveLiquidTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/PauseTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function PauseTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
...l-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/TemperatureTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function TemperatureTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
5 changes: 5 additions & 0 deletions
5
...-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/ThermocyclerTools/index.tsx
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,5 @@ | ||
import * as React from 'react' | ||
|
||
export function ThermocyclerTools(): JSX.Element { | ||
return <div>TODO: wire this up</div> | ||
} |
9 changes: 9 additions & 0 deletions
9
protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepTools/index.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 |
---|---|---|
@@ -0,0 +1,9 @@ | ||
export { CommentTools } from './CommentTools' | ||
export { HeaterShakerTools } from './HeaterShakerTools' | ||
export { MagnetTools } from './MagnetTools' | ||
export { MixTools } from './MixTools' | ||
export { MoveLabwareTools } from './MoveLabwareTools' | ||
export { MoveLiquidTools } from './MoveLiquidTools' | ||
export { PauseTools } from './PauseTools' | ||
export { TemperatureTools } from './TemperatureTools' | ||
export { ThermocyclerTools } from './ThermocyclerTools' |
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.