logo

mastofe

My custom branche(s) on git.pleroma.social/pleroma/mastofe git clone https://hacktivis.me/git/mastofe.git

column_settings.js (5521B)


  1. import React from 'react';
  2. import PropTypes from 'prop-types';
  3. import ImmutablePropTypes from 'react-immutable-proptypes';
  4. import { FormattedMessage } from 'react-intl';
  5. import ClearColumnButton from './clear_column_button';
  6. import SettingToggle from './setting_toggle';
  7. export default class ColumnSettings extends React.PureComponent {
  8. static propTypes = {
  9. settings: ImmutablePropTypes.map.isRequired,
  10. pushSettings: ImmutablePropTypes.map.isRequired,
  11. onChange: PropTypes.func.isRequired,
  12. onClear: PropTypes.func.isRequired,
  13. };
  14. onPushChange = (path, checked) => {
  15. this.props.onChange(['push', ...path], checked);
  16. }
  17. render () {
  18. const { settings, pushSettings, onChange, onClear } = this.props;
  19. const alertStr = <FormattedMessage id='notifications.column_settings.alert' defaultMessage='Desktop notifications' />;
  20. const showStr = <FormattedMessage id='notifications.column_settings.show' defaultMessage='Show in column' />;
  21. const soundStr = <FormattedMessage id='notifications.column_settings.sound' defaultMessage='Play sound' />;
  22. const showPushSettings = pushSettings.get('browserSupport') && pushSettings.get('isSubscribed');
  23. const pushStr = showPushSettings && <FormattedMessage id='notifications.column_settings.push' defaultMessage='Push notifications' />;
  24. const pushMeta = showPushSettings && <FormattedMessage id='notifications.column_settings.push_meta' defaultMessage='This device' />;
  25. return (
  26. <div>
  27. <div className='column-settings__row'>
  28. <ClearColumnButton onClick={onClear} />
  29. </div>
  30. <div role='group' aria-labelledby='notifications-follow'>
  31. <span id='notifications-follow' className='column-settings__section'><FormattedMessage id='notifications.column_settings.follow' defaultMessage='New followers:' /></span>
  32. <div className='column-settings__row'>
  33. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'follow']} onChange={onChange} label={alertStr} />
  34. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'follow']} meta={pushMeta} onChange={this.onPushChange} label={pushStr} />}
  35. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'follow']} onChange={onChange} label={showStr} />
  36. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'follow']} onChange={onChange} label={soundStr} />
  37. </div>
  38. </div>
  39. <div role='group' aria-labelledby='notifications-favourite'>
  40. <span id='notifications-favourite' className='column-settings__section'><FormattedMessage id='notifications.column_settings.favourite' defaultMessage='Favourites:' /></span>
  41. <div className='column-settings__row'>
  42. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'favourite']} onChange={onChange} label={alertStr} />
  43. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'favourite']} meta={pushMeta} onChange={this.onPushChange} label={pushStr} />}
  44. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'favourite']} onChange={onChange} label={showStr} />
  45. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'favourite']} onChange={onChange} label={soundStr} />
  46. </div>
  47. </div>
  48. <div role='group' aria-labelledby='notifications-mention'>
  49. <span id='notifications-mention' className='column-settings__section'><FormattedMessage id='notifications.column_settings.mention' defaultMessage='Mentions:' /></span>
  50. <div className='column-settings__row'>
  51. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'mention']} onChange={onChange} label={alertStr} />
  52. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'mention']} meta={pushMeta} onChange={this.onPushChange} label={pushStr} />}
  53. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'mention']} onChange={onChange} label={showStr} />
  54. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'mention']} onChange={onChange} label={soundStr} />
  55. </div>
  56. </div>
  57. <div role='group' aria-labelledby='notifications-reblog'>
  58. <span id='notifications-reblog' className='column-settings__section'><FormattedMessage id='notifications.column_settings.reblog' defaultMessage='Boosts:' /></span>
  59. <div className='column-settings__row'>
  60. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'reblog']} onChange={onChange} label={alertStr} />
  61. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'reblog']} meta={pushMeta} onChange={this.onPushChange} label={pushStr} />}
  62. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={showStr} />
  63. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'reblog']} onChange={onChange} label={soundStr} />
  64. </div>
  65. </div>
  66. </div>
  67. );
  68. }
  69. }