ExternalAccountLinkedMe.jsx 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. import React, { Fragment } from 'react';
  2. import PropTypes from 'prop-types';
  3. import { withTranslation } from 'react-i18next';
  4. import { createSubscribedElement } from '../UnstatedUtils';
  5. import { toastError } from '../../util/apiNotification';
  6. import AppContainer from '../../services/AppContainer';
  7. import PersonalContainer from '../../services/PersonalContainer';
  8. import ExternalAccountRow from './ExternalAccountRow';
  9. class ExternalAccountLinkedMe extends React.Component {
  10. async componentDidMount() {
  11. try {
  12. await this.props.personalContainer.retrieveExternalAccounts();
  13. }
  14. catch (err) {
  15. toastError(err);
  16. }
  17. }
  18. render() {
  19. const { t, personalContainer } = this.props;
  20. const { externalAccounts } = personalContainer.state;
  21. return (
  22. <Fragment>
  23. <h2 className="border-bottom">
  24. <button type="button" className="btn btn-default btn-sm pull-right">
  25. <i className="icon-plus" aria-hidden="true" />
  26. Add
  27. </button>
  28. { t('External Accounts') }
  29. </h2>
  30. <div className="row">
  31. <div className="col-md-12">
  32. <table className="table table-bordered table-user-list">
  33. <thead>
  34. <tr>
  35. <th width="120px">Authentication Provider</th>
  36. <th>
  37. <code>accountId</code>
  38. </th>
  39. <th width="200px">{ t('Created') }</th>
  40. <th width="150px">{ t('Admin') }</th>
  41. </tr>
  42. </thead>
  43. <tbody>
  44. {externalAccounts !== 0 && externalAccounts.map(account => <ExternalAccountRow account={account} key={account._id} />)}
  45. </tbody>
  46. </table>
  47. </div>
  48. </div>
  49. </Fragment>
  50. );
  51. }
  52. }
  53. const ExternalAccountLinkedMeWrapper = (props) => {
  54. return createSubscribedElement(ExternalAccountLinkedMe, props, [AppContainer, PersonalContainer]);
  55. };
  56. ExternalAccountLinkedMe.propTypes = {
  57. t: PropTypes.func.isRequired, // i18next
  58. appContainer: PropTypes.instanceOf(AppContainer).isRequired,
  59. personalContainer: PropTypes.instanceOf(PersonalContainer).isRequired,
  60. };
  61. export default withTranslation()(ExternalAccountLinkedMeWrapper);