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.

LinkToSalesforceButton.ts 1.6KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. import { connect } from 'react-redux';
  2. import { createToolbarEvent } from '../../../analytics/AnalyticsEvents';
  3. import { sendAnalytics } from '../../../analytics/functions';
  4. import { IReduxState } from '../../../app/types';
  5. import { openDialog } from '../../../base/dialog/actions';
  6. import { translate } from '../../../base/i18n/functions';
  7. import { IconCloudUpload } from '../../../base/icons/svg';
  8. import AbstractButton, { IProps as AbstractButtonProps } from '../../../base/toolbox/components/AbstractButton';
  9. import SalesforceLinkDialog from '../../../salesforce/components/web/SalesforceLinkDialog';
  10. import { isSalesforceEnabled } from '../../../salesforce/functions';
  11. /**
  12. * Implementation of a button for opening the Salesforce link dialog.
  13. */
  14. class LinkToSalesforce extends AbstractButton<AbstractButtonProps> {
  15. accessibilityLabel = 'toolbar.accessibilityLabel.linkToSalesforce';
  16. icon = IconCloudUpload;
  17. label = 'toolbar.linkToSalesforce';
  18. tooltip = 'toolbar.linkToSalesforce';
  19. /**
  20. * Handles clicking / pressing the button, and opens the Salesforce link dialog.
  21. *
  22. * @protected
  23. * @returns {void}
  24. */
  25. _handleClick() {
  26. const { dispatch } = this.props;
  27. sendAnalytics(createToolbarEvent('link.to.salesforce'));
  28. dispatch(openDialog(SalesforceLinkDialog));
  29. }
  30. }
  31. /**
  32. * Function that maps parts of Redux state tree into component props.
  33. *
  34. * @param {Object} state - Redux state.
  35. * @returns {Object}
  36. */
  37. const mapStateToProps = (state: IReduxState) => {
  38. return {
  39. visible: isSalesforceEnabled(state)
  40. };
  41. };
  42. export default translate(connect(mapStateToProps)(LinkToSalesforce));