PluginSetting.jsx 2.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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 PluginSetting 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.Enable plugin loading') }</p>
  17. <div className="row">
  18. <div className="col-md-12">
  19. <div className="form-group">
  20. <label className="col-xs-3 control-label">{ t('app_setting.Load plugins') }</label>
  21. <div className="col-xs-6">
  22. <div className="btn-group btn-toggle" data-toggle="buttons">
  23. <label
  24. className="btn btn-default btn-rounded btn-outline {% if getConfig('crowi', 'plugin:isEnabledPlugins') %}active{% endif %}"
  25. data-active-class="primary"
  26. >
  27. <input
  28. name="settingForm[plugin:isEnabledPlugins]"
  29. value="true"
  30. type="radio"
  31. />
  32. ON
  33. </label>
  34. <label
  35. className="btn btn-default btn-rounded btn-outline {% if !getConfig('crowi', 'plugin:isEnabledPlugins') %}active{% endif %}"
  36. data-active-class="default"
  37. >
  38. <input name="settingForm[plugin:isEnabledPlugins]" />
  39. OFF
  40. </label>
  41. </div>
  42. </div>
  43. </div>
  44. </div>
  45. </div>
  46. <div className="row">
  47. <div className="col-md-12">
  48. <div className="form-group">
  49. <div className="col-xs-offset-3 col-xs-6">
  50. <input type="hidden" name="_csrf" value="{{ csrf() }}" />
  51. <button type="submit" className="btn btn-primary">
  52. {t('app_setting.Update')}
  53. </button>
  54. </div>
  55. </div>
  56. </div>
  57. </div>
  58. </React.Fragment>
  59. );
  60. }
  61. }
  62. /**
  63. * Wrapper component for using unstated
  64. */
  65. const PluginSettingWrapper = (props) => {
  66. return createSubscribedElement(PluginSetting, props, [AppContainer]);
  67. };
  68. PluginSetting.propTypes = {
  69. t: PropTypes.func.isRequired, // i18next
  70. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  71. };
  72. export default withTranslation()(PluginSettingWrapper);