Tom Butcher d7ad2208d4 Enhance GCodeFile, DeployJob, NewJob, and ControlPrinter components with slicer integration support
- 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.
2026-07-20 02:11:01 +01:00

117 lines
3.1 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 NewGCodeFile = ({
onOk,
defaultValues,
slicerIntegration = false,
shouldPrint = false,
currentStep,
onStepChange
}) => {
const initialValues = useMemo(
() => ({
state: { type: 'draft' },
...defaultValues
}),
[defaultValues]
)
return (
<NewObjectForm type={'gcodeFile'} defaultValues={initialValues}>
{({ handleSubmit, submitLoading, objectData, formValid }) => {
const steps = [
...(!slicerIntegration
? [
{
title: 'Upload',
key: 'upload',
content: (
<ObjectInfo
type='gcodeFile'
column={1}
bordered={false}
isEditing={true}
required={true}
objectData={objectData}
visibleProperties={{ file: true }}
showLabels={false}
/>
)
}
]
: []),
{
title: 'Required',
key: 'required',
content: (
<ObjectInfo
type='gcodeFile'
column={1}
bordered={false}
isEditing={true}
required={true}
objectData={objectData}
visibleProperties={{ file: false }}
/>
)
},
{
title: 'Summary',
key: 'summary',
content: (
<ObjectInfo
type='gcodeFile'
column={1}
bordered={false}
visibleProperties={{
_id: false,
_reference: false,
parts: false,
createdAt: false,
updatedAt: false,
startedAt: false
}}
isEditing={false}
objectData={objectData}
/>
)
}
]
return (
<WizardView
steps={steps}
loading={submitLoading}
formValid={formValid}
title='New GCode File'
showSteps={!slicerIntegration || !shouldPrint}
currentStep={currentStep}
onStepChange={onStepChange}
onSubmit={async () => {
const result = await handleSubmit()
if (result) {
onOk(result)
}
}}
/>
)
}}
</NewObjectForm>
)
}
NewGCodeFile.propTypes = {
onOk: PropTypes.func.isRequired,
reset: PropTypes.bool,
defaultValues: PropTypes.object,
slicerIntegration: PropTypes.bool,
currentStep: PropTypes.number,
onStepChange: PropTypes.func,
shouldPrint: PropTypes.bool
}
export default NewGCodeFile