route to ide from part edit
This commit is contained in:
@@ -29,14 +29,11 @@ export const Success = ({ part }) => {
|
|||||||
const { addMessage } = useFlash()
|
const { addMessage } = useFlash()
|
||||||
const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION, {
|
const [updatePart, { loading, error }] = useMutation(UPDATE_PART_MUTATION, {
|
||||||
onCompleted: () => {
|
onCompleted: () => {
|
||||||
navigate(routes.parts())
|
|
||||||
addMessage('Part updated.', { classes: 'rw-flash-success' })
|
addMessage('Part updated.', { classes: 'rw-flash-success' })
|
||||||
},
|
},
|
||||||
})
|
})
|
||||||
|
|
||||||
const onSave = (input, id) => {
|
const onSave = (input, id) => updatePart({ variables: { id, input } })
|
||||||
updatePart({ variables: { id, input } })
|
|
||||||
}
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<PartForm part={part} onSave={onSave} error={error} loading={loading} />
|
<PartForm part={part} onSave={onSave} error={error} loading={loading} />
|
||||||
|
|||||||
@@ -8,16 +8,24 @@ import {
|
|||||||
Submit,
|
Submit,
|
||||||
} from '@redwoodjs/forms'
|
} from '@redwoodjs/forms'
|
||||||
import { useState } from 'react';
|
import { useState } from 'react';
|
||||||
|
import { navigate, routes } from '@redwoodjs/router'
|
||||||
|
|
||||||
import Editor from "rich-markdown-editor";
|
import Editor from "rich-markdown-editor";
|
||||||
|
|
||||||
const PartForm = (props) => {
|
const PartForm = (props) => {
|
||||||
const [description, setDescription] = useState(props?.part?.description)
|
const [description, setDescription] = useState(props?.part?.description)
|
||||||
const onSubmit = (data) => {
|
const onSubmit = async (data, e) => {
|
||||||
props.onSave({
|
|
||||||
|
await props.onSave({
|
||||||
...data,
|
...data,
|
||||||
description,
|
description,
|
||||||
}, props?.part?.id)
|
}, props?.part?.id)
|
||||||
|
const shouldOpenIde = e?.nativeEvent?.submitter?.dataset?.openIde
|
||||||
|
if(shouldOpenIde) {
|
||||||
|
navigate(routes.partIde({id: props?.part?.id}))
|
||||||
|
} else {
|
||||||
|
navigate(routes.part({id: props?.part?.id}))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
@@ -80,6 +88,9 @@ const PartForm = (props) => {
|
|||||||
<Submit disabled={props.loading} className="rw-button rw-button-blue">
|
<Submit disabled={props.loading} className="rw-button rw-button-blue">
|
||||||
Save
|
Save
|
||||||
</Submit>
|
</Submit>
|
||||||
|
<Submit disabled={props.loading} data-open-ide={true} className="rw-button rw-button-blue">
|
||||||
|
Save and open IDE
|
||||||
|
</Submit>
|
||||||
</div>
|
</div>
|
||||||
</Form>
|
</Form>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user