itizawa hace 6 años
padre
commit
b68cb8ad82

+ 6 - 1
src/client/js/services/AdminCustomizeContainer.js

@@ -207,7 +207,12 @@ export default class AdminCustomizeContainer extends Container {
    * @return {Array} Code highlight
    * @return {Array} Code highlight
    */
    */
   async updateHighlightJsStyle() {
   async updateHighlightJsStyle() {
-    // TODO GW-515 create apiV3
+    const response = await this.appContainer.apiv3.put('/customize-setting/highlight', {
+      highlightJsStyle: this.state.currentHighlightJsStyleId,
+      highlightJsStyleBorder: this.state.isHighlightJsStyleBorderEnabled,
+    });
+    const { customizedParams } = response.data;
+    return customizedParams;
   }
   }
 
 
 
 

+ 25 - 0
src/server/routes/apiv3/customize-setting.js

@@ -40,6 +40,9 @@ module.exports = (crowi) => {
       body('isEnabledAttachTitleHeader').isBoolean(),
       body('isEnabledAttachTitleHeader').isBoolean(),
       body('recentCreatedLimit').isInt(),
       body('recentCreatedLimit').isInt(),
     ],
     ],
+    highlight: [
+
+    ],
   };
   };
 
 
   // TODO GW-575 writte swagger
   // TODO GW-575 writte swagger
@@ -205,5 +208,27 @@ module.exports = (crowi) => {
     }
     }
   });
   });
 
 
+  // TODO writte swagger
+  router.put('/highlight', loginRequiredStrictly, adminRequired, csrf, validator.highlight, ApiV3FormValidator, async(req, res) => {
+    const requestParams = {
+      'customize:highlightJsStyle': req.body.highlightJsStyle,
+      'customize:highlightJsStyleBorder': req.body.highlightJsStyleBorder,
+    };
+
+    try {
+      await crowi.configManager.updateConfigsInTheSameNamespace('crowi', requestParams);
+      const customizedParams = {
+        styleName: await crowi.configManager.getConfig('crowi', 'customize:highlightJsStyle'),
+        styleBorder: await crowi.configManager.getConfig('crowi', 'customize:highlightJsStyleBorder'),
+      };
+      return res.apiv3({ customizedParams });
+    }
+    catch (err) {
+      const msg = 'Error occurred in updating highlight';
+      logger.error('Error', err);
+      return res.apiv3Err(new ErrorV3(msg, 'update-highlight-failed'));
+    }
+  });
+
   return router;
   return router;
 };
 };