Просмотр исходного кода

BugFix: attach file with PageEditor

Yuki Takei 6 лет назад
Родитель
Сommit
0f3e8b3524
2 измененных файлов с 3 добавлено и 3 удалено
  1. 2 2
      src/client/js/components/PageEditor.jsx
  2. 1 1
      src/server/routes/index.js

+ 2 - 2
src/client/js/components/PageEditor.jsx

@@ -156,7 +156,7 @@ class PageEditor extends React.Component {
       formData.append('_csrf', appContainer.csrfToken);
       formData.append('_csrf', appContainer.csrfToken);
       formData.append('file', file);
       formData.append('file', file);
       formData.append('path', pageContainer.state.path);
       formData.append('path', pageContainer.state.path);
-      formData.append('page_id', this.state.pageId || 0);
+      formData.append('page_id', pageContainer.state.pageId);
 
 
       res = await appContainer.apiPost('/attachments.add', formData);
       res = await appContainer.apiPost('/attachments.add', formData);
       const attachment = res.attachment;
       const attachment = res.attachment;
@@ -172,7 +172,7 @@ class PageEditor extends React.Component {
 
 
       // when if created newly
       // when if created newly
       if (res.pageCreated) {
       if (res.pageCreated) {
-        // do nothing
+        logger.info('Page is created', res.pageCreated._id);
       }
       }
     }
     }
     catch (e) {
     catch (e) {

+ 1 - 1
src/server/routes/index.js

@@ -224,7 +224,7 @@ module.exports = function(crowi, app) {
   app.post('/_api/attachments.removeProfileImage', accessTokenParser, loginRequired(crowi, app), csrf, attachment.api.removeProfileImage);
   app.post('/_api/attachments.removeProfileImage', accessTokenParser, loginRequired(crowi, app), csrf, attachment.api.removeProfileImage);
   app.post('/_api/attachments.uploadProfileImage'   , uploads.single('file'), autoReap, accessTokenParser, loginRequired(crowi, app) ,csrf, attachment.api.uploadProfileImage);
   app.post('/_api/attachments.uploadProfileImage'   , uploads.single('file'), autoReap, accessTokenParser, loginRequired(crowi, app) ,csrf, attachment.api.uploadProfileImage);
   app.post('/_api/attachments.remove' , accessTokenParser , loginRequired(crowi, app) , csrf, attachment.api.remove);
   app.post('/_api/attachments.remove' , accessTokenParser , loginRequired(crowi, app) , csrf, attachment.api.remove);
-  app.get('/_api/attachments.limit'  , accessTokenParser , loginRequired(crowi, app) , csrf, attachment.api.limit);
+  app.get('/_api/attachments.limit'   , accessTokenParser , loginRequired(crowi, app) , attachment.api.limit);
 
 
   app.get('/_api/revisions.get'      , accessTokenParser , loginRequired(crowi, app, false) , revision.api.get);
   app.get('/_api/revisions.get'      , accessTokenParser , loginRequired(crowi, app, false) , revision.api.get);
   app.get('/_api/revisions.ids'      , accessTokenParser , loginRequired(crowi, app, false) , revision.api.ids);
   app.get('/_api/revisions.ids'      , accessTokenParser , loginRequired(crowi, app, false) , revision.api.ids);