CustomBotWithoutProxySecretTokenSection.jsx 3.4 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="card-body">
  24. <table className="table settings-table">
  25. <colgroup>
  26. <col className="item-name" />
  27. <col className="from-db" />
  28. <col className="from-env-vars" />
  29. </colgroup>
  30. <thead>
  31. <tr><th className="border-top-0"></th><th className="border-top-0">Database</th><th className="border-top-0">Environment variables</th></tr>
  32. </thead>
  33. <tbody>
  34. <tr>
  35. <th>Signing Secret</th>
  36. <td>
  37. <input
  38. className="form-control"
  39. type="text"
  40. value={props.slackSigningSecret || ''}
  41. onChange={e => onChangeSigningSecretHandler(e.target.value)}
  42. />
  43. </td>
  44. <td>
  45. <input
  46. className="form-control"
  47. type="text"
  48. value={props.slackSigningSecretEnv || ''}
  49. readOnly
  50. />
  51. <p className="form-text text-muted">
  52. {/* eslint-disable-next-line react/no-danger */}
  53. <small dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.use_env_var_if_empty', { variable: 'SLACK_SIGNING_SECRET' }) }} />
  54. </p>
  55. </td>
  56. </tr>
  57. <tr>
  58. <th>Bot User OAuth Token</th>
  59. <td>
  60. <input
  61. className="form-control"
  62. type="text"
  63. value={props.slackBotToken || ''}
  64. onChange={e => onChangeBotTokenHandler(e.target.value)}
  65. />
  66. </td>
  67. <td>
  68. <input
  69. className="form-control"
  70. type="text"
  71. value={props.slackBotTokenEnv || ''}
  72. readOnly
  73. />
  74. <p className="form-text text-muted">
  75. {/* eslint-disable-next-line react/no-danger */}
  76. <small dangerouslySetInnerHTML={{ __html: t('admin:slack_integration.use_env_var_if_empty', { variable: 'SLACK_BOT_TOKEN' }) }} />
  77. </p>
  78. </td>
  79. </tr>
  80. </tbody>
  81. </table>
  82. <AdminUpdateButtonRow onClick={updateSecretTokenHandler} disabled={false} />
  83. </div>
  84. );
  85. };
  86. CustomBotWithoutProxySecretTokenSection.propTypes = {
  87. updateSecretTokenHandler: PropTypes.func,
  88. onChangeSigningSecretHandler: PropTypes.func,
  89. onChangeBotTokenHandler: PropTypes.func,
  90. slackSigningSecret: PropTypes.string,
  91. slackSigningSecretEnv: PropTypes.string,
  92. slackBotToken: PropTypes.string,
  93. slackBotTokenEnv: PropTypes.string,
  94. fetchSlackWorkSpaceName: PropTypes.func,
  95. };
  96. export default CustomBotWithoutProxySecretTokenSection;