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.js 2.5KB

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