CustomBotWithoutProxySecretTokenSection.jsx 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104
  1. import React from 'react';
  2. import { useTranslation } from 'react-i18next';
  3. import PropTypes from 'prop-types';
  4. import AdminUpdateButtonRow from '../Common/AdminUpdateButtonRow';
  5. const CustomBotWithoutProxySecretTokenSection = (props) => {
  6. const { t } = useTranslation();
  7. const onChangeSigningSecretHandler = (signingSecretInput) => {
  8. if (props.onChangeSigningSecretHandler != null) {
  9. props.onChangeSigningSecretHandler(signingSecretInput);
  10. }
  11. };
  12. const onChangeBotTokenHandler = (botTokenInput) => {
  13. if (props.onChangeBotTokenHandler != null) {
  14. props.onChangeBotTokenHandler(botTokenInput);
  15. }
  16. };
  17. const updateSecretTokenHandler = () => {
  18. if (props.updateSecretTokenHandler != null) {
  19. props.updateSecretTokenHandler();
  20. }
  21. };
  22. return (
  23. <div className="w-75 mx-auto">
  24. <h3>Signing Secret</h3>
  25. <div className="row">
  26. <div className="col-sm">
  27. <p>Database</p>
  28. <input
  29. className="form-control"
  30. type="text"
  31. value={props.slackSigningSecret || ''}
  32. onChange={e => onChangeSigningSecretHandler(e.target.value)}
  33. />
  34. </div>
  35. <div className="col-sm">
  36. <p>Environment variables</p>
  37. <input
  38. className="form-control"
  39. type="text"
  40. value={props.slackSigningSecretEnv || ''}
  41. readOnly
  42. />
  43. <p className="form-text text-muted">
  44. {/* eslint-disable-next-line react/no-danger */}
  45. <small dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.use_env_var_if_empty', { variable: 'SLACK_SIGNING_SECRET' }) }} />
  46. </p>
  47. </div>
  48. </div>
  49. <h3>Bot User OAuth Token</h3>
  50. <div className="row">
  51. <div className="col-sm">
  52. <p>Database</p>
  53. <input
  54. className="form-control"
  55. type="text"
  56. value={props.slackBotToken || ''}
  57. onChange={e => onChangeBotTokenHandler(e.target.value)}
  58. />
  59. </div>
  60. <div className="col-sm">
  61. <p>Environment variables</p>
  62. <input
  63. className="form-control"
  64. type="text"
  65. value={props.slackBotTokenEnv || ''}
  66. readOnly
  67. />
  68. <p className="form-text text-muted">
  69. {/* eslint-disable-next-line react/no-danger */}
  70. <small dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.use_env_var_if_empty', { variable: 'SLACK_BOT_TOKEN' }) }} />
  71. </p>
  72. </div>
  73. </div>
  74. <AdminUpdateButtonRow onClick={updateSecretTokenHandler} disabled={false} />
  75. </div>
  76. );
  77. };
  78. CustomBotWithoutProxySecretTokenSection.propTypes = {
  79. updateSecretTokenHandler: PropTypes.func,
  80. onChangeSigningSecretHandler: PropTypes.func,
  81. onChangeBotTokenHandler: PropTypes.func,
  82. slackSigningSecret: PropTypes.string,
  83. slackSigningSecretEnv: PropTypes.string,
  84. slackBotToken: PropTypes.string,
  85. slackBotTokenEnv: PropTypes.string,
  86. };
  87. export default CustomBotWithoutProxySecretTokenSection;