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(protocol-designer): wire up rename step #16437

Draft
wants to merge 3 commits into
base: edge
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions protocol-designer/src/assets/localization/en/shared.json
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
"message_uses_standard_namespace": "This labware definition uses the Opentrons standard labware namespace. Change the namespace if it is custom, or use the standard labware in your protocol.",
"mismatched": "The new labware has a different arrangement of wells than the labware it is replacing. Clicking Overwrite will deselect all wells in any existing steps that use this labware. You will have to edit each of those steps and select new wells.",
"module": "Module",
"name_step": "Name step",
"next": "next",
"ninety_six_channel": "96-Channel",
"no_hints_to_restore": "No hints to restore",
Expand Down
109 changes: 109 additions & 0 deletions protocol-designer/src/organisms/RenameStepModal/index.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,109 @@
import { useState } from 'react'
import { useDispatch, useSelector } from 'react-redux'

Check failure on line 2 in protocol-designer/src/organisms/RenameStepModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

'useSelector' is defined but never used

Check failure on line 2 in protocol-designer/src/organisms/RenameStepModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

'useSelector' is defined but never used
import { useTranslation } from 'react-i18next'
import { createPortal } from 'react-dom'
import styled from 'styled-components'
import {
BORDERS,
COLORS,
DIRECTION_COLUMN,
Flex,
JUSTIFY_END,
Modal,
PrimaryButton,
SecondaryButton,
SPACING,
StyledText,
TYPOGRAPHY,
InputField,
} from '@opentrons/components'
import { i18n } from '../../assets/localization'
import { getTopPortalEl } from '../../components/portals/TopPortal'
import type { FormData } from '../../form-types'

interface RenameStepModalProps {
formData: FormData
onClose: () => void
}
export function RenameStepModal(props: RenameStepModalProps): JSX.Element {
const { onClose, formData } = props
const dispatch = useDispatch()

Check failure on line 30 in protocol-designer/src/organisms/RenameStepModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

'dispatch' is assigned a value but never used

Check failure on line 30 in protocol-designer/src/organisms/RenameStepModal/index.tsx

View workflow job for this annotation

GitHub Actions / js checks

'dispatch' is assigned a value but never used
const { t } = useTranslation(['form', 'shared'])
const [stepName, setStepName] = useState<string>('')

// const saveRenameStep = (nextFormValues: FileMetadataFields): void => {
// dispatch(actions.saveFileMetadata(nextFormValues))
// onClose()
// }
// const handleSave = (): void => {
// dispatch()
// close()
// }

return createPortal(
<Modal
title={t('shared:name_step')}
type="info"
closeOnOutsideClick
onClose={onClose}
childrenPadding={SPACING.spacing24}
footer={
<Flex
justifyContent={JUSTIFY_END}
padding={`0 ${SPACING.spacing24} ${SPACING.spacing24}`}
gridGap={SPACING.spacing8}
>
<SecondaryButton onClick={onClose}>
{t('shared:cancel')}
</SecondaryButton>
<PrimaryButton
data-testid="RenameStepModal_saveButton"
disabled={false}
onClick={() => {
// handleSubmit(saveFileMetadata)()
}}
>
{t('shared:save')}
</PrimaryButton>
</Flex>
}
>
<form>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing12}>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}>
<StyledText color={COLORS.grey60} desktopStyle="captionRegular">
{t('form:step_edit_form.field.step_name.label')}
</StyledText>
<InputField
placeholder={i18n.format(t(formData.stepName), 'capitalize')}
value={stepName}
autoFocus
name="StepName"
onChange={e => {
setStepName(e.target.value)
}}
/>
</Flex>
<Flex flexDirection={DIRECTION_COLUMN} gridGap={SPACING.spacing4}>
<StyledText color={COLORS.grey60} desktopStyle="captionRegular">
{t('form:step_edit_form.field.step_notes.label')}
</StyledText>

<DescriptionField />
</Flex>
</Flex>
</form>
</Modal>,
getTopPortalEl()
)
}

const DescriptionField = styled.textarea`
min-height: 5rem;
width: 100%;
border: ${BORDERS.lineBorder};
border-radius: ${BORDERS.borderRadius4};
padding: ${SPACING.spacing8};
font-size: ${TYPOGRAPHY.fontSizeH3};
resize: none;
`
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
COLORS,
Flex,
Icon,
Modal,

Check failure on line 12 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepFormToolbox.tsx

View workflow job for this annotation

GitHub Actions / js checks

'Modal' is defined but never used

Check failure on line 12 in protocol-designer/src/pages/Designer/ProtocolSteps/StepForm/StepFormToolbox.tsx

View workflow job for this annotation

GitHub Actions / js checks

'Modal' is defined but never used
PrimaryButton,
SPACING,
SecondaryButton,
Expand Down Expand Up @@ -37,6 +38,7 @@
import { getSaveStepSnackbarText } from './utils'
import type { StepFieldName } from '../../../../steplist/fieldLevel'
import type { FormData, StepType } from '../../../../form-types'
import { RenameStepModal } from '../../../../organisms/RenameStepModal'
import type { FieldPropsByName, FocusHandlers, StepFormProps } from './types'

type StepFormMap = {
Expand Down Expand Up @@ -97,6 +99,7 @@
? 1
: 0
)
const [isRename, setIsRename] = useState<boolean>(false)
const icon = stepIconsByType[formData.stepType]

const ToolsComponent: typeof STEP_FORM_MAP[keyof typeof STEP_FORM_MAP] = get(
Expand Down Expand Up @@ -136,8 +139,17 @@
}) as string
)
}

return (
<>
{isRename ? (
<RenameStepModal
formData={formData}
onClose={() => {
setIsRename(false)
}}
/>
) : null}
<Toolbox
subHeader={
isMultiStepToolbox ? (
Expand All @@ -149,7 +161,7 @@
secondaryHeaderButton={
<Btn
onClick={() => {
console.log('TODO: wire this up')
setIsRename(true)
}}
css={BUTTON_LINK_STYLE}
textDecoration={TYPOGRAPHY.textDecorationUnderline}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@ export function MagnetTools(props: StepFormProps): JSX.Element {
const deckSetup = useSelector(getInitialDeckSetup)
const modulesOnDeck = getModulesOnDeckByType(deckSetup, MAGNETIC_MODULE_TYPE)

console.log(modulesOnDeck)

const moduleModel = moduleEntities[formData.moduleId].model

const slotInfo = moduleLabwareOptions[0].name.split('in')
Expand Down
Loading