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