SecuritySetting.jsx 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  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. import AdminSecuritySettingContainer from '../../../services/AdminSecuritySettingContainer';
  7. class SecuritySetting extends React.Component {
  8. render() {
  9. const { t, adminSecuritySettingContainer } = this.props;
  10. return (
  11. <React.Fragment>
  12. <fieldset>
  13. <legend className="alert-anchor">{ t('security_settings') }</legend>
  14. <div className="form-group">
  15. <label htmlFor="settingForm[security:restrictGuestMode]" className="col-xs-3 control-label">{ t('security_setting.Guest Users Access') }</label>
  16. <div className="col-xs-6">
  17. <input
  18. id="restrictGuestMode"
  19. type="checkbox"
  20. checked={adminSecuritySettingContainer.state.currentRestrictGuestMode}
  21. onChange={() => { adminSecuritySettingContainer.switchRestrictGuestMode() }}
  22. />
  23. <option value={adminSecuritySettingContainer.state.currentRestrictGuestMode}>{ t('modeLabel') }</option>
  24. <p className="alert alert-warning mt-2">
  25. <i className="icon-exclamation icon-fw">
  26. </i><b>FIXED</b>
  27. { t('security_setting.Fixed by env var', 'FORCE_WIKI_MODE') }<br></br>
  28. </p>
  29. </div>
  30. </div>
  31. <div className="form-group">
  32. <label htmlFor="{{configName}}" className="col-xs-3 control-label">{ t('security_setting.page_listing_1') }</label>
  33. <div className="col-xs-9">
  34. <div className="btn-group btn-toggle" data-toggle="buttons">
  35. <label className="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  36. <input name="{{configName}}" value="false" type="radio"></input>
  37. </label>
  38. <label className="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  39. <input name="{{configName}}" value="true" type="radio"></input>
  40. </label>
  41. </div>
  42. <p className="help-block small">
  43. { t('security_setting.page_listing_1_desc') }
  44. </p>
  45. </div>
  46. </div>
  47. <div className="form-group">
  48. <label htmlFor="{{configName}}" className="col-xs-3 control-label">{ t('security_setting.page_listing_2') }</label>
  49. <div className="col-xs-9">
  50. <div className="btn-group btn-toggle" data-toggle="buttons">
  51. <label className="btn btn-default btn-rounded btn-outline {% if isEnabled %}active{% endif %}" data-active-class="primary">
  52. <input name="{{configName}}" value="false" type="radio" />
  53. </label>
  54. <label className="btn btn-default btn-rounded btn-outline {% if !isEnabled %}active{% endif %}" data-active-class="default">
  55. <input name="{{configName}}" value="true" type="radio" />
  56. </label>
  57. </div>
  58. <p className="help-block small">
  59. { t('security_setting.page_listing_2_desc') }
  60. </p>
  61. </div>
  62. </div>
  63. <div className="form-group">
  64. <label htmlFor="{{configName}}" className="col-xs-3 control-label">{ t('security_setting.complete_deletion') }</label>
  65. <div className="col-xs-6">
  66. <select className="form-control selectpicker" name="settingForm[security:pageCompleteDeletionAuthority]" value="{{ configValue }}">
  67. <option value="anyOne">{ t('security_setting.anyone') }</option>
  68. <option value="adminOnly">{ t('security_setting.admin_only') }</option>
  69. <option value="adminAndAuthor">{ t('security_setting.admin_and_author') }</option>
  70. </select>
  71. <p className="help-block small">
  72. { t('security_setting.complete_deletion_explain') }
  73. </p>
  74. </div>
  75. </div>
  76. {/* TODO GW-540 */}
  77. <div className="form-group">
  78. <div className="col-xs-offset-3 col-xs-6">
  79. <input type="hidden" name="_csrf" value={this.props.csrf} />
  80. </div>
  81. </div>
  82. </fieldset>
  83. </React.Fragment>
  84. );
  85. }
  86. }
  87. SecuritySetting.propTypes = {
  88. t: PropTypes.func.isRequired, // i18next
  89. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  90. csrf: PropTypes.string,
  91. adminSecuritySettingContainer: PropTypes.instanceOf(AdminSecuritySettingContainer).isRequired,
  92. };
  93. const SecuritySettingWrapper = (props) => {
  94. return createSubscribedElement(SecuritySetting, props, [AppContainer, AdminSecuritySettingContainer]);
  95. };
  96. export default withTranslation()(SecuritySettingWrapper);