11import { randomAlphaString } from '../../core-utils' ;
22import { Hyperlink } from '../../core-views' ;
3- import { getFileData , storeFileData , storeGithubFileData , useSignedIn } from "@fi-sci/figurl-interface" ;
3+ import { getFileData , postMessageToParent , storeFileData , storeGithubFileData , useSignedIn } from "@fi-sci/figurl-interface" ;
44import { Button } from "@material-ui/core" ;
55import { FunctionComponent , useCallback , useEffect , useMemo , useRef , useState } from "react" ;
66import EditGithubUriControl from './EditGithubUriControl' ;
@@ -154,15 +154,15 @@ const SaveControl: FunctionComponent<Props> = ({fallbackUri, uri, setUri, object
154154 } ) . catch ( ( err2 : Error ) => {
155155 console . warn ( 'Problem getting state 2' )
156156 console . warn ( err2 )
157- setErrorString ( `Error getting ${ fallbackUri } ` )
157+ setErrorString ( `Error getting ${ fallbackUri } ` )
158158 } )
159159 }
160160 else {
161161 console . warn ( 'Problem getting state' )
162162 console . warn ( err )
163163 setErrorString ( `Error getting ${ uri } ` )
164164 }
165-
165+
166166 } )
167167 }
168168 first . current = false
@@ -224,6 +224,10 @@ const SaveControl: FunctionComponent<Props> = ({fallbackUri, uri, setUri, object
224224
225225 const [ editingGithubUri , setEditingGithubUri ] = useState ( false )
226226
227+ const handleSubmitToParent = useCallback ( ( ) => {
228+ postMessageToParent ( { type : 'submit-curation' , curation : object } )
229+ } , [ object ] )
230+
227231 return (
228232 < div >
229233 < div >
@@ -261,6 +265,7 @@ const SaveControl: FunctionComponent<Props> = ({fallbackUri, uri, setUri, object
261265 </span>
262266 )
263267 } */ }
268+ < Button style = { buttonStyle } onClick = { handleSubmitToParent } > Submit to parent</ Button >
264269 {
265270 ! editingGithubUri ? (
266271 < span >
@@ -289,7 +294,7 @@ const SaveControl: FunctionComponent<Props> = ({fallbackUri, uri, setUri, object
289294 < div style = { { paddingLeft : 8 , fontSize : 12 } } >
290295 URI: < FormatUri uri = { uri } />
291296 </ div >
292-
297+
293298 </ div >
294299 { errorString && < div style = { { color : 'red' } } > { errorString } </ div > }
295300 </ div >
@@ -309,12 +314,12 @@ function downloadTextFile(filename: string, text: string) {
309314 const element = document . createElement ( 'a' ) ;
310315 element . setAttribute ( 'href' , 'data:text/plain;charset=utf-8,' + encodeURIComponent ( text ) ) ;
311316 element . setAttribute ( 'download' , filename ) ;
312-
317+
313318 element . style . display = 'none' ;
314319 document . body . appendChild ( element ) ;
315-
320+
316321 element . click ( ) ;
317-
322+
318323 document . body . removeChild ( element ) ;
319324}
320325
0 commit comments