itizawa 6 лет назад
Родитель
Сommit
2542187bd4

+ 2 - 1
resource/locales/en-US/translation.json

@@ -679,7 +679,8 @@
     "recently_created_n_draft_num_desc": "Number of recently created pages and drafts displayed on user page",
     "update_layout_success": "Succeeded to update layout",
     "update_behavior_success": "Succeeded to update behavior",
-    "update_function_success": "Succeeded to update function"
+    "update_function_success": "Succeeded to update function",
+    "update_script_success": "Succeeded to update custom script"
   },
 
   "user_management": {

+ 2 - 1
resource/locales/ja/translation.json

@@ -663,7 +663,8 @@
     "recently_created_n_draft_num_desc": "ホーム画面の Recently Created での、1ページの表示数を設定します。",
     "update_layout_success": "レイアウトを更新しました",
     "update_behavior_success": "挙動を更新しました",
-    "update_function_success": "機能を更新しました"
+    "update_function_success": "機能を更新しました",
+    "update_script_success": "カスタムスクリプトを更新しました"
   },
 
   "user_management": {

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

@@ -9,6 +9,7 @@ import { createSubscribedElement } from '../../UnstatedUtils';
 import CustomizeLayoutSetting from './CustomizeLayoutSetting';
 import CustomizeBehaviorSetting from './CustomizeBehaviorSetting';
 import CustomizeFunctionSetting from './CustomizeFunctionSetting';
+import CustomizeCustomScriptSetting from './CustomizeCustomScriptSetting';
 
 class Customize extends React.Component {
 
@@ -32,8 +33,9 @@ class Customize extends React.Component {
         {/* カスタムタイトルフォームの react componentをここで呼ぶ(GW-278) */}
         <legend>{t('customize_page.Custom CSS')}</legend>
         {/* カスタムCSSフォームの react componentをここで呼ぶ(GW-279) */}
-        <legend>{t('customize_page.Custom script')}</legend>
-        {/* カスタムスクリプトフォームの react componentをここで呼ぶ(GW-280) */}
+        <div className="my-3">
+          <CustomizeCustomScriptSetting />
+        </div>
       </Fragment>
     );
   }

+ 62 - 0
src/client/js/components/Admin/Customize/CustomizeCustomScriptSetting.jsx

@@ -0,0 +1,62 @@
+import React from 'react';
+import PropTypes from 'prop-types';
+import { withTranslation } from 'react-i18next';
+
+import loggerFactory from '@alias/logger';
+
+import { createSubscribedElement } from '../../UnstatedUtils';
+import { toastSuccess, toastError } from '../../../util/apiNotification';
+
+import AppContainer from '../../../services/AppContainer';
+
+import AdminCustomizeContainer from '../../../services/AdminCustomizeContainer';
+import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
+
+const logger = loggerFactory('growi:customizeScript');
+
+class CustomizeCustomScriptSetting extends React.Component {
+
+  constructor(props) {
+    super(props);
+
+    this.onClickSubmit = this.onClickSubmit.bind(this);
+  }
+
+  async onClickSubmit() {
+    const { t } = this.props;
+
+    try {
+      // await adminCustomizeContainer.updateCustomizeFunction();
+      toastSuccess(t('customize_page.update_script_success'));
+    }
+    catch (err) {
+      toastError(err);
+      logger.error(err);
+    }
+  }
+
+  render() {
+    const { t } = this.props;
+
+    return (
+      <React.Fragment>
+        <h2>{t('customize_page.Custom script')}</h2>
+
+        <AdminUpdateButtonRow onClick={this.onClickSubmit} />
+      </React.Fragment>
+    );
+  }
+
+}
+
+const CustomizeCustomScriptSettingWrapper = (props) => {
+  return createSubscribedElement(CustomizeCustomScriptSetting, props, [AppContainer, AdminCustomizeContainer]);
+};
+
+CustomizeCustomScriptSetting.propTypes = {
+  t: PropTypes.func.isRequired, // i18next
+  appContainer: PropTypes.instanceOf(AppContainer).isRequired,
+  adminCustomizeContainer: PropTypes.instanceOf(AdminCustomizeContainer).isRequired,
+};
+
+export default withTranslation()(CustomizeCustomScriptSettingWrapper);