SiteUrlSetting.jsx 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } from '../../UnstatedUtils';
  5. import AppContainer from '../../../services/AppContainer';
  6. class SiteUrlSetting extends React.Component {
  7. constructor(props) {
  8. super(props);
  9. this.state = {
  10. };
  11. }
  12. render() {
  13. const { t } = this.props;
  14. return (
  15. <React.Fragment>
  16. <p className="well">{t('app_setting.Site URL desc')}</p>
  17. {/* {% if !getConfig('crowi', 'app:siteUrl') %}
  18. <p class="alert alert-danger"><i class="icon-exclamation"></i> {{ t('app_setting.Site URL warn') }}</p>
  19. {% endif %} */}
  20. <div className="row">
  21. <div className="col-md-12">
  22. <div className="col-xs-offset-3">
  23. <table className="table settings-table">
  24. <colgroup>
  25. <col className="from-db" />
  26. <col className="from-env-vars" />
  27. </colgroup>
  28. <thead>
  29. <tr><th>Database</th><th>Environment variables</th></tr>
  30. </thead>
  31. <tbody>
  32. <tr>
  33. <td>
  34. <input
  35. className="form-control"
  36. type="text"
  37. name="settingForm[app:siteUrl]"
  38. value="{{ getConfigFromDB('crowi', 'app:siteUrl') | default('') }}"
  39. placeholder="e.g. https://my.growi.org"
  40. />
  41. <p className="help-block">{t('app_setting.siteurl_help')}</p>
  42. </td>
  43. <td>
  44. <input
  45. className="form-control"
  46. type="text"
  47. value="{{ getConfigFromEnvVars('crowi', 'app:siteUrl') | default('') }}"
  48. readOnly
  49. />
  50. <p className="help-block">
  51. {t('app_setting.Use env var if empty', 'APP_SITE_URL')}
  52. </p>
  53. </td>
  54. </tr>
  55. </tbody>
  56. </table>
  57. </div>
  58. </div>
  59. </div>
  60. <div className="row">
  61. <div className="col-md-12">
  62. <div className="form-group">
  63. <label htmlFor="settingForm[app:confidential]" className="col-xs-3 control-label">
  64. {t('app_setting.Confidential name')}
  65. </label>
  66. <div className="col-xs-6">
  67. <input
  68. className="form-control"
  69. id="settingForm[app:confidential]"
  70. type="text"
  71. name="settingForm[app:confidential]"
  72. value="{{ getConfig('crowi', 'app:confidential') | default('') }}"
  73. placeholder="{{ t('app_setting. ex&rpar;: internal use only') }}"
  74. />
  75. <p className="help-block">{t('app_setting.header_content')}</p>
  76. </div>
  77. </div>
  78. </div>
  79. </div>
  80. <div className="row">
  81. <div className="col-md-12">
  82. <div className="form-group">
  83. <label className="col-xs-3 control-label">{t('app_setting.File Uploading')}</label>
  84. <div className="col-xs-6">
  85. <div className="checkbox checkbox-info">
  86. <input type="checkbox" id="cbFileUpload" name="settingForm[app:fileUpload]" value="1" />
  87. <label htmlFor="cbFileUpload">{t('app_setting.enable_files_except_image')}</label>
  88. </div>
  89. <p className="help-block">
  90. {t('app_setting.enable_files_except_image')}
  91. <br />
  92. {t('app_setting.attach_enable')}
  93. </p>
  94. </div>
  95. </div>
  96. </div>
  97. </div>
  98. <div className="row">
  99. <div className="col-md-12">
  100. <div className="form-group">
  101. <div className="col-xs-offset-3 col-xs-6">
  102. <input type="hidden" name="_csrf" value="{{ csrf() }}" />
  103. <button type="submit" className="btn btn-primary">
  104. {t('app_setting.Update')}
  105. </button>
  106. </div>
  107. </div>
  108. </div>
  109. </div>
  110. </React.Fragment>
  111. );
  112. }
  113. }
  114. /**
  115. * Wrapper component for using unstated
  116. */
  117. const SiteUrlSettingWrapper = (props) => {
  118. return createSubscribedElement(SiteUrlSetting, props, [AppContainer]);
  119. };
  120. SiteUrlSetting.propTypes = {
  121. t: PropTypes.func.isRequired, // i18next
  122. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  123. };
  124. export default withTranslation()(SiteUrlSettingWrapper);