AdminSecurityContainer.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. import { Container } from 'unstated';
  2. import loggerFactory from '@alias/logger';
  3. // eslint-disable-next-line no-unused-vars
  4. const logger = loggerFactory('growi:services:AdminSecurityContainer');
  5. /**
  6. * Service container for admin security page (SecurityManagement.jsx)
  7. * @extends {Container} unstated Container
  8. */
  9. export default class AdminSecurityContainer extends Container {
  10. constructor(appContainer) {
  11. super();
  12. this.appContainer = appContainer;
  13. this.state = {
  14. // TODO GW-583 set value
  15. isLocalEnabled: true,
  16. registrationMode: 'open',
  17. };
  18. this.init();
  19. this.switchIsLocalEnabled = this.switchIsLocalEnabled.bind(this);
  20. this.changeRegistrationMode = this.changeRegistrationMode.bind(this);
  21. }
  22. init() {
  23. // TODO GW-583 fetch config value with api
  24. }
  25. /**
  26. * Workaround for the mangling in production build to break constructor.name
  27. */
  28. static getClassName() {
  29. return 'AdminSecurityContainer';
  30. }
  31. /**
  32. * Switch local enabled
  33. */
  34. switchIsLocalEnabled() {
  35. this.setState({ isLocalEnabled: !this.state.isLocalEnabled });
  36. }
  37. /**
  38. * Change registration mode
  39. */
  40. changeRegistrationMode(value) {
  41. this.setState({ registrationMode: value });
  42. }
  43. }