|
|
@@ -0,0 +1,79 @@
|
|
|
+import React from 'react';
|
|
|
+import PropTypes from 'prop-types';
|
|
|
+import { withTranslation } from 'react-i18next';
|
|
|
+
|
|
|
+import loggerFactory from '@alias/logger';
|
|
|
+
|
|
|
+import AppContainer from '../../../services/AppContainer';
|
|
|
+import AdminCustomizeContainer from '../../../services/AdminCustomizeContainer';
|
|
|
+import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
|
|
|
+import { createSubscribedElement } from '../../UnstatedUtils';
|
|
|
+import { toastSuccess, toastError } from '../../../util/apiNotification';
|
|
|
+
|
|
|
+const logger = loggerFactory('growi:Customize');
|
|
|
+
|
|
|
+class CustomizeTitle extends React.Component {
|
|
|
+
|
|
|
+ constructor(props) {
|
|
|
+ super(props);
|
|
|
+
|
|
|
+ this.onClickSubmit = this.onClickSubmit.bind(this);
|
|
|
+ }
|
|
|
+
|
|
|
+ async onClickSubmit() {
|
|
|
+ const { t, adminCustomizeContainer } = this.props;
|
|
|
+
|
|
|
+ try {
|
|
|
+ await adminCustomizeContainer.updateCustomizeTitle();
|
|
|
+ toastSuccess(t('customize_page.update_customTitle_success'));
|
|
|
+ }
|
|
|
+ catch (err) {
|
|
|
+ toastError(err);
|
|
|
+ logger.error(err);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ render() {
|
|
|
+ const { t, adminCustomizeContainer } = this.props;
|
|
|
+ const { currentCustomizeTitle } = adminCustomizeContainer.state;
|
|
|
+
|
|
|
+ return (
|
|
|
+ <React.Fragment>
|
|
|
+ <h2 className="admin-setting-header">{t('customize_page.custom_title')}</h2>
|
|
|
+ <p
|
|
|
+ className="well"
|
|
|
+ // eslint-disable-next-line react/no-danger, max-len
|
|
|
+ dangerouslySetInnerHTML={{ __html: '<code><title></code>タグのコンテンツをカスタマイズできます。<br><code>{{sitename}}</code>がサイト名、<code>{{page}}</code>がページ名またはページパスに置換されます。' }}
|
|
|
+ />
|
|
|
+ {/* TODO i18n */}
|
|
|
+ <p className="help-block">
|
|
|
+ Default Value: <code>{{page}} - {{sitename}}</code>
|
|
|
+ <br />
|
|
|
+ Default Output: <pre><code className="xml"><title>/Sandbox - { 'GROWI' }</title></code></pre>
|
|
|
+ </p>
|
|
|
+ <div className="form-group">
|
|
|
+ <input
|
|
|
+ className="form-control"
|
|
|
+ value={currentCustomizeTitle}
|
|
|
+ onChange={(e) => { adminCustomizeContainer.changeCustomizeTitle(e.target.value) }}
|
|
|
+ />
|
|
|
+ </div>
|
|
|
+
|
|
|
+ <AdminUpdateButtonRow onClick={this.onClickSubmit} />
|
|
|
+ </React.Fragment>
|
|
|
+ );
|
|
|
+ }
|
|
|
+
|
|
|
+}
|
|
|
+
|
|
|
+const CustomizeTitleWrapper = (props) => {
|
|
|
+ return createSubscribedElement(CustomizeTitle, props, [AppContainer, AdminCustomizeContainer]);
|
|
|
+};
|
|
|
+
|
|
|
+CustomizeTitle.propTypes = {
|
|
|
+ t: PropTypes.func.isRequired, // i18next
|
|
|
+ appContainer: PropTypes.instanceOf(AppContainer).isRequired,
|
|
|
+ adminCustomizeContainer: PropTypes.instanceOf(AdminCustomizeContainer).isRequired,
|
|
|
+};
|
|
|
+
|
|
|
+export default withTranslation()(CustomizeTitleWrapper);
|