You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AbstractRecentList.tsx 2.6KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. import React from 'react';
  2. import { createRecentClickedEvent, createRecentSelectedEvent } from '../../analytics/AnalyticsEvents';
  3. import { sendAnalytics } from '../../analytics/functions';
  4. import { appNavigate } from '../../app/actions';
  5. import { IStore } from '../../app/types';
  6. import AbstractPage from '../../base/react/components/AbstractPage';
  7. import { Container, Text } from '../../base/react/components/index';
  8. // @ts-ignore
  9. import styles from './styles';
  10. /**
  11. * The type of the React {@code Component} props of {@link AbstractRecentList}.
  12. */
  13. interface IProps {
  14. /**
  15. * The redux store's {@code dispatch} function.
  16. */
  17. dispatch: IStore['dispatch'];
  18. /**
  19. * The translate function.
  20. */
  21. t: Function;
  22. }
  23. /**
  24. * An abstract component for the recent list.
  25. *
  26. */
  27. export default class AbstractRecentList<P extends IProps> extends AbstractPage<P> {
  28. /**
  29. * Initializes a new {@code RecentList} instance.
  30. *
  31. * @inheritdoc
  32. */
  33. constructor(props: P) {
  34. super(props);
  35. this._onPress = this._onPress.bind(this);
  36. }
  37. /**
  38. * Implements React's {@link Component#componentDidMount()}. Invoked
  39. * immediately after this component is mounted.
  40. *
  41. * @inheritdoc
  42. * @returns {void}
  43. */
  44. componentDidMount() {
  45. sendAnalytics(createRecentSelectedEvent());
  46. }
  47. /**
  48. * Returns a list empty component if a custom one has to be rendered instead
  49. * of the default one in the {@link NavigateSectionList}.
  50. *
  51. * @private
  52. * @returns {React$Component}
  53. */
  54. _getRenderListEmptyComponent() {
  55. const { t } = this.props;
  56. const descriptionId = 'meetings-list-empty-description';
  57. return (
  58. <Container
  59. aria-describedby = { descriptionId }
  60. aria-label = { t('welcomepage.recentList') }
  61. className = 'meetings-list-empty'
  62. role = 'region'
  63. style = { styles.emptyListContainer as any }>
  64. <Text // @ts-ignore
  65. className = 'description'
  66. id = { descriptionId }
  67. style = { styles.emptyListText as any }>
  68. { t('welcomepage.recentListEmpty') }
  69. </Text>
  70. </Container>
  71. );
  72. }
  73. /**
  74. * Handles the list's navigate action.
  75. *
  76. * @private
  77. * @param {string} url - The url string to navigate to.
  78. * @returns {void}
  79. */
  80. _onPress(url: string) {
  81. const { dispatch } = this.props;
  82. sendAnalytics(createRecentClickedEvent('meeting.tile'));
  83. dispatch(appNavigate(url));
  84. }
  85. }