- Updated NewGCodeFile and NewJob components to include slicerIntegration, currentStep, and onStepChange props for improved workflow management. - Modified DeployJob to handle printer online status and added slicerIntegration support for conditional rendering of actions and steps. - Enhanced ControlPrinter to manage visibility of actions based on slicerIntegration, improving user experience in printer control. - Refactored form handling to pass result objects to onOk callbacks, ensuring better data handling upon submission.
101 lines
2.5 KiB
JavaScript
101 lines
2.5 KiB
JavaScript
import { useMemo } from 'react'
|
|
import PropTypes from 'prop-types'
|
|
import ObjectInfo from '../../common/ObjectInfo'
|
|
import NewObjectForm from '../../common/NewObjectForm'
|
|
import WizardView from '../../common/WizardView'
|
|
|
|
const NewJob = ({
|
|
onOk,
|
|
defaultValues,
|
|
slicerIntegration = false,
|
|
currentStep,
|
|
onStepChange
|
|
}) => {
|
|
const initialValues = useMemo(
|
|
() => ({
|
|
state: { type: 'draft' },
|
|
...defaultValues
|
|
}),
|
|
[defaultValues]
|
|
)
|
|
|
|
return (
|
|
<NewObjectForm type={'job'} defaultValues={initialValues}>
|
|
{({ handleSubmit, submitLoading, objectData, formValid }) => {
|
|
const steps = [
|
|
{
|
|
title: 'Required',
|
|
key: 'required',
|
|
content: (
|
|
<ObjectInfo
|
|
type='job'
|
|
column={1}
|
|
bordered={false}
|
|
isEditing={true}
|
|
required={true}
|
|
labelWidth='100px'
|
|
objectData={objectData}
|
|
/>
|
|
)
|
|
},
|
|
{
|
|
title: 'Summary',
|
|
key: 'summary',
|
|
content: (
|
|
<ObjectInfo
|
|
type='job'
|
|
column={1}
|
|
bordered={false}
|
|
labelWidth='100px'
|
|
visibleProperties={{
|
|
_id: false,
|
|
_reference: false,
|
|
createdAt: false,
|
|
updatedAt: false,
|
|
startedAt: false,
|
|
finishedAt: false,
|
|
totalTime: false
|
|
}}
|
|
isEditing={false}
|
|
objectData={objectData}
|
|
/>
|
|
)
|
|
}
|
|
]
|
|
return (
|
|
<WizardView
|
|
steps={steps}
|
|
loading={submitLoading}
|
|
formValid={formValid}
|
|
title='New Job'
|
|
showSteps={!slicerIntegration}
|
|
currentStep={currentStep}
|
|
onStepChange={onStepChange}
|
|
showSkipButton={slicerIntegration}
|
|
onSkip={() => {
|
|
onOk(null)
|
|
}}
|
|
onSubmit={async () => {
|
|
const result = await handleSubmit()
|
|
if (result) {
|
|
onOk(result)
|
|
}
|
|
}}
|
|
/>
|
|
)
|
|
}}
|
|
</NewObjectForm>
|
|
)
|
|
}
|
|
|
|
NewJob.propTypes = {
|
|
onOk: PropTypes.func.isRequired,
|
|
reset: PropTypes.bool,
|
|
defaultValues: PropTypes.object,
|
|
slicerIntegration: PropTypes.bool,
|
|
currentStep: PropTypes.number,
|
|
onStepChange: PropTypes.func
|
|
}
|
|
|
|
export default NewJob
|