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

Merge pull request #1445 from weseek/reactify-admin/adjust-customize-page-for-master-merge

Reactify admin/adjust customize page for master merge
Yuki Takei 6 лет назад
Родитель
Сommit
fa26a9aee4

+ 1 - 1
src/client/js/components/Admin/Customize/CustomizeLayoutSetting.jsx

@@ -56,7 +56,7 @@ class CustomizeLayoutSetting extends React.Component {
       <React.Fragment>
         <h2 className="admin-setting-header">{t('customize_page.Layout')}</h2>
         <CustomizeLayoutOptions />
-        <h2 className="admin-setting-header">{ t('customize_page.Theme') }</h2>
+        <h2 className="admin-setting-header">{t('customize_page.Theme')}</h2>
         {this.renderDevAlert()}
         <CustomizeThemeOptions />
         <AdminUpdateButtonRow onClick={this.onClickSubmit} disabled={adminCustomizeContainer.state.retrieveError != null} />

+ 2 - 2
src/client/js/components/Admin/Customize/CustomizeTitle.jsx

@@ -49,12 +49,12 @@ class CustomizeTitle extends React.Component {
         <p className="help-block">
           Default Value: <code>&#123;&#123;page&#125;&#125; - &#123;&#123;sitename&#125;&#125;</code>
           <br />
-          Default Output: <pre><code className="xml">&lt;title&gt;/Sandbox - { 'GROWI' }&lt;&#047;title&gt;</code></pre>
+          Default Output: <pre><code className="xml">&lt;title&gt;/Sandbox - {'GROWI'}&lt;&#047;title&gt;</code></pre>
         </p>
         <div className="form-group">
           <input
             className="form-control"
-            value={currentCustomizeTitle}
+            defaultValue={currentCustomizeTitle}
             onChange={(e) => { adminCustomizeContainer.changeCustomizeTitle(e.target.value) }}
           />
         </div>

+ 0 - 12
src/server/form/index.js

@@ -25,18 +25,6 @@ module.exports = {
     securityPassportGitHub: require('./admin/securityPassportGitHub'),
     securityPassportTwitter: require('./admin/securityPassportTwitter'),
     securityPassportOidc: require('./admin/securityPassportOidc'),
-    markdown: require('./admin/markdown'),
-    markdownXss: require('./admin/markdownXss'),
-    markdownPresentation: require('./admin/markdownPresentation'),
-    customcss: require('./admin/customcss'),
-    customscript: require('./admin/customscript'),
-    customheader: require('./admin/customheader'),
-    customtheme: require('./admin/customtheme'),
-    customtitle: require('./admin/customtitle'),
-    custombehavior: require('./admin/custombehavior'),
-    customlayout: require('./admin/customlayout'),
-    customfeatures: require('./admin/customfeatures'),
-    customhighlightJsStyle: require('./admin/customhighlightJsStyle'),
     slackIwhSetting: require('./admin/slackIwhSetting'),
     slackSetting: require('./admin/slackSetting'),
     userGroupCreate: require('./admin/userGroupCreate'),

+ 0 - 15
src/server/routes/admin.js

@@ -16,7 +16,6 @@ module.exports = function(crowi, app) {
     configManager,
     aclService,
     slackNotificationService,
-    customizeService,
     exportService,
   } = crowi;
 
@@ -868,20 +867,6 @@ module.exports = function(crowi, app) {
     return res.json({ status: true });
   };
 
-  actions.api.customizeSetting = async function(req, res) {
-    const form = req.form.settingForm;
-
-    if (req.form.isValid) {
-      debug('form content', form);
-      await configManager.updateConfigsInTheSameNamespace('crowi', form);
-      customizeService.initCustomCss();
-      customizeService.initCustomTitle();
-
-      return res.json({ status: true });
-    }
-
-    return res.json({ status: false, message: req.form.errors.join('\n') });
-  };
 
   // app.post('/_api/admin/notifications.add'    , admin.api.notificationAdd);
   actions.api.notificationAdd = function(req, res) {

+ 40 - 61
src/server/routes/apiv3/customize-setting.js

@@ -70,6 +70,8 @@ module.exports = (crowi) => {
   const loginRequiredStrictly = require('../../middleware/login-required')(crowi);
   const adminRequired = require('../../middleware/admin-required')(crowi);
   const csrf = require('../../middleware/csrf')(crowi);
+  const { customizeService } = crowi;
+
 
   const { ApiV3FormValidator } = crowi.middlewares;
 
@@ -161,21 +163,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  layoutType:
-   *                    description: type of layout
-   *                    type: string
-   *                  themeType:
-   *                    description: type of theme
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
    *      responses:
    *        200:
    *          description: Succeeded to update layout and theme
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeLayoutTheme'
    */
   router.put('/layoutTheme', loginRequiredStrictly, adminRequired, csrf, validator.layoutTheme, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -212,18 +209,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  behaviorType:
-   *                    description: type of behavior
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
    *      responses:
    *        200:
    *          description: Succeeded to update behavior
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeBehavior'
    */
   router.put('/behavior', loginRequiredStrictly, adminRequired, csrf, validator.behavior, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -258,27 +253,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  isEnabledTimeline:
-   *                    description: is enabled timeline
-   *                    type: boolean
-   *                  isSavedStatesOfTabChanges:
-   *                    description: is saved states of tabChanges
-   *                    type: boolean
-   *                  isEnabledAttachTitleHeader:
-   *                    description: is enabled attach titleHeader
-   *                    type: boolean
-   *                  recentCreatedLimit:
-   *                    description: limit of recent created
-   *                    type: number
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
    *      responses:
    *        200:
    *          description: Succeeded to update function
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeFunction'
    */
   router.put('/function', loginRequiredStrictly, adminRequired, csrf, validator.function, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -319,21 +303,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  highlightJsStyle:
-   *                    description: style name of highlight
-   *                    type: string
-   *                  highlightJsStyleBorder:
-   *                    description: enable border of highlight
-   *                    type: boolean
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
    *      responses:
-   *          200:
-   *            description: Succeeded to update highlight
-   *            content:
-   *              application/json:
-   *                schema:
-   *                  properties:
-   *                    customizedParams:
-   *                      $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
+   *        200:
+   *          description: Succeeded to update highlight
+   *          content:
+   *            application/json:
+   *              schema:
+   *                type: object
+   *                properties:
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHighlight'
    */
   router.put('/highlight', loginRequiredStrictly, adminRequired, csrf, validator.highlight, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -370,12 +349,16 @@ module.exports = (crowi) => {
    *              schema:
    *                type: object
    *                properties:
-   *                  title:
-   *                    description: customized title
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeTitle'
    *      responses:
-   *          200:
-   *            description: Succeeded to update customizeTitle
+   *        200:
+   *          description: Succeeded to update customizeTitle
+   *          content:
+   *            application/json:
+   *              schema:
+   *                type: object
+   *                properties:
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeTitle'
    */
   router.put('/customize-title', loginRequiredStrictly, adminRequired, csrf, validator.customizeTitle, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -387,6 +370,7 @@ module.exports = (crowi) => {
       const customizedParams = {
         customizeTitle: await crowi.configManager.getConfig('crowi', 'customize:title'),
       };
+      customizeService.initCustomTitle();
       return res.apiv3({ customizedParams });
     }
     catch (err) {
@@ -410,18 +394,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  customizeHeader:
-   *                    description: customize header
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
    *      responses:
    *        200:
    *          description: Succeeded to update customize header
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeHeader'
    */
   router.put('/customize-header', loginRequiredStrictly, adminRequired, csrf, validator.customizeHeader, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -455,18 +437,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  customizeCss:
-   *                    description: customize css
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
    *      responses:
    *        200:
    *          description: Succeeded to update customize css
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeCss'
    */
   router.put('/customize-css', loginRequiredStrictly, adminRequired, csrf, validator.customizeCss, ApiV3FormValidator, async(req, res) => {
     const requestParams = {
@@ -477,6 +457,7 @@ module.exports = (crowi) => {
       const customizedParams = {
         customizeCss: await crowi.configManager.getConfig('crowi', 'customize:css'),
       };
+      customizeService.initCustomCss();
       return res.apiv3({ customizedParams });
     }
     catch (err) {
@@ -500,18 +481,16 @@ module.exports = (crowi) => {
    *              schama:
    *                type: object
    *                properties:
-   *                  customizeScript:
-   *                    description: customize script
-   *                    type: string
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
    *      responses:
    *        200:
    *          description: Succeeded to update customize script
    *          content:
    *            application/json:
    *              schema:
+   *                type: object
    *                properties:
-   *                  customizedParams:
-   *                    $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
+   *                  $ref: '#/components/schemas/CustomizeParams/CustomizeScript'
    */
   router.put('/customize-script', loginRequiredStrictly, adminRequired, csrf, validator.customizeScript, ApiV3FormValidator, async(req, res) => {
     const requestParams = {

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

@@ -93,17 +93,8 @@ module.exports = function(crowi, app) {
   // markdown admin
   app.get('/admin/markdown'                   , loginRequiredStrictly , adminRequired , admin.markdown.index);
 
-  // markdown admin
+  // customize admin
   app.get('/admin/customize'                , loginRequiredStrictly , adminRequired , admin.customize.index);
-  app.post('/_api/admin/customize/css'      , loginRequiredStrictly , adminRequired , csrf, form.admin.customcss, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/script'   , loginRequiredStrictly , adminRequired , csrf, form.admin.customscript, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/header'   , loginRequiredStrictly , adminRequired , csrf, form.admin.customheader, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/theme'    , loginRequiredStrictly , adminRequired , csrf, form.admin.customtheme, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/title'    , loginRequiredStrictly , adminRequired , csrf, form.admin.customtitle, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/behavior' , loginRequiredStrictly , adminRequired , csrf, form.admin.custombehavior, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/layout'   , loginRequiredStrictly , adminRequired , csrf, form.admin.customlayout, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/features' , loginRequiredStrictly , adminRequired , csrf, form.admin.customfeatures, admin.api.customizeSetting);
-  app.post('/_api/admin/customize/highlightJsStyle' , loginRequiredStrictly , adminRequired , csrf, form.admin.customhighlightJsStyle, admin.api.customizeSetting);
 
   // search admin
   app.get('/admin/search'              , loginRequiredStrictly , adminRequired , admin.search.index);