@@ -119,6 +119,20 @@ function* connect() {
119119 console . log ( `[sftp] Connected to EON (${ eon . ip } )` ) ;
120120}
121121
122+ function * saveActiveFile ( ) {
123+ const { fileList } = yield select ( ) ;
124+ const { activeFile, openedFiles } = fileList ;
125+ const currentFile = openedFiles [ activeFile ] ;
126+ const contentBuffer = Buffer . from ( currentFile . content ) ;
127+ yield connect ( ) ;
128+ console . log ( `[sftp] Saving ${ activeFile } ...` ) ;
129+ const savedFile = yield app . sftpClient . put ( contentBuffer , activeFile ) ;
130+ yield put ( fileListActions . SAVE_ACTIVE_FILE_SUCCESS ( ) ) ;
131+ return {
132+ savedFile
133+ } ;
134+ }
135+
122136function * retrieveFile ( remoteFile , mergeWith = { } ) {
123137 yield connect ( ) ;
124138 console . log ( `[sftp] Retrieving file ${ remoteFile } ...` ) ;
@@ -167,17 +181,11 @@ function* refreshFileList() {
167181 yield put ( eonDetailActions . REFRESH_FILE_LIST_SUCCESS ( baseItems ) ) ;
168182}
169183
170- function * fetchEndpoint ( endpoint ) {
171- const { eonDetail } = yield select ( ) ;
172- const { dataParams } = eonDetail ;
173- console . log ( "Fetching endpoint..." , endpoint ) ;
174- console . log ( "dataParams" , dataParams ) ;
175- }
176-
177184function * apiRequest ( endpointUrl ) {
178185 const { eonDetail } = yield select ( ) ;
179186 const { auth } = eonDetail ;
180187 const { commaUser } = auth ;
188+
181189 const { accessToken } = commaUser ;
182190 if ( ! accessToken ) return ;
183191 // console.log(accessToken);
@@ -199,7 +207,7 @@ function buildEndpointUrl(key, tokens = {}) {
199207 let endpoint = ENDPOINTS [ key ] ;
200208
201209 let tokenKeys = [ ] ;
202- console . log ( endpoint ) ;
210+ // console.log(endpoint);
203211 if ( tokens ) {
204212 tokenKeys = Object . keys ( tokens ) ;
205213 }
@@ -208,7 +216,7 @@ function buildEndpointUrl(key, tokens = {}) {
208216 tokenKeys . forEach ( ( tokenKey ) => {
209217 const tokenValue = tokens [ tokenKey ] ;
210218 // const length = endpoint.length
211- console . log ( `replacing ${ tokenKey } with ${ tokenValue } ` )
219+ // console.log(`replacing ${tokenKey} with ${tokenValue}`)
212220 endpoint = endpoint . replace ( / \{ \{ ( [ a - z A - Z 0 - 9 \. ] + ) \} \} / , tokenValue ) ;
213221 } ) ;
214222 }
@@ -676,6 +684,7 @@ export function* eonSagas() {
676684 takeLatest ( eonListTypes . SELECT_EON , handleSelectEon ) ,
677685 // takeEvery(types.CONNECT_FAILED, addEonListError),
678686 takeEvery ( types . BOOTSTRAP_EON , handleBootstrapEON ) ,
687+ takeEvery ( fileListActionTypes . SAVE_ACTIVE_FILE , saveActiveFile ) ,
679688 takeEvery ( fileListActionTypes . FETCH_DIRECTORY , handleFetchDirectory ) ,
680689 takeEvery ( fileListActionTypes . FETCH_FILE , handleFetchFile ) ,
681690 // takeEvery(fileListActionTypes.FETCH_DIRECTORY_SUCCESS, handleFetchDirectorySuccess),
0 commit comments