@@ -31,6 +31,7 @@ function EditorForm({ initial }: { initial?: Job }) {
3131 useEffect ( ( ) => { const handler = ( event : BeforeUnloadEvent ) => { if ( dirty ) { event . preventDefault ( ) ; event . returnValue = "" ; } } ; window . addEventListener ( "beforeunload" , handler ) ; return ( ) => window . removeEventListener ( "beforeunload" , handler ) ; } , [ dirty ] ) ;
3232 const targets = useQuery ( targetsQuery ) , metadata = useQuery ( metadataQuery ) ;
3333 const target = targets . data ?. find ( t => t . id === draft . executionTargetId ) ;
34+ const projectId = new URLSearchParams ( location . searchStr ) . get ( "projectId" ) ?? undefined ;
3435 const update = < K extends keyof JobInput > ( key : K , value : JobInput [ K ] ) => { setSaved ( false ) ; setDraft ( previous => ( { ...previous , [ key ] : value } ) ) ; } ;
3536 const refreshConflict = useMutation ( { retry : false , mutationFn : async ( ) => {
3637 if ( ! initial ) throw new Error ( "No job selected" ) ;
@@ -39,7 +40,8 @@ function EditorForm({ initial }: { initial?: Job }) {
3940 } , onSuccess : value => { setRemote ( value ) ; setReconciling ( false ) ; } } ) ;
4041 const save = useMutation ( { retry : false , mutationFn : async ( ) => {
4142 if ( remote || conflicts . length ) throw new Error ( "Resolve the stale edit before saving." ) ;
42- const result = initial ? await api . PUT ( "/api/v1/jobs/{jobId}" , { params : { path : { jobId : initial . id } } , body : { ...writeInput ( draft ) , expectedUpdatedAt : revision } } ) : await api . POST ( "/api/v1/jobs" , { body : writeInput ( draft ) } ) ;
43+ const input = { ...writeInput ( draft ) , ...( projectId ? { projectId } : { } ) } ;
44+ const result = initial ? await api . PUT ( "/api/v1/jobs/{jobId}" , { params : { path : { jobId : initial . id } } , body : { ...input , expectedUpdatedAt : revision } } ) : await api . POST ( "/api/v1/jobs" , { body : input } ) ;
4345 if ( result . error || ! result . data ) {
4446 if ( result . error ?. error . code === "stale_job" ) { setReconciling ( true ) ; refreshConflict . mutate ( ) ; }
4547 throw new Error ( validationMessage ( result . error ) ) ;
0 commit comments