File tree Expand file tree Collapse file tree 1 file changed +28
-0
lines changed
client/modules/IDE/actions Expand file tree Collapse file tree 1 file changed +28
-0
lines changed Original file line number Diff line number Diff line change @@ -309,3 +309,31 @@ export function setProjectSavedTime(updatedAt) {
309
309
value : updatedAt
310
310
} ;
311
311
}
312
+
313
+ export function changeProjectName ( id , newName ) {
314
+ return ( dispatch , getState ) => {
315
+ const state = getState ( ) ;
316
+ axios . put ( `${ ROOT_URL } /projects/${ id } ` , { name : newName } , { withCredentials : true } )
317
+ . then ( ( response ) => {
318
+ if ( response . status === 200 ) {
319
+ dispatch ( {
320
+ type : ActionTypes . RENAME_PROJECT ,
321
+ payload : { id : response . data . id , name : response . data . name }
322
+ } ) ;
323
+ if ( state . project . id === response . data . id ) {
324
+ dispatch ( {
325
+ type : ActionTypes . SET_PROJECT_NAME ,
326
+ name : response . data . name
327
+ } ) ;
328
+ }
329
+ }
330
+ } )
331
+ . catch ( ( response ) => {
332
+ console . log ( response ) ;
333
+ dispatch ( {
334
+ type : ActionTypes . PROJECT_SAVE_FAIL ,
335
+ error : response . data
336
+ } ) ;
337
+ } ) ;
338
+ } ;
339
+ }
You can’t perform that action at this time.
0 commit comments