The code powering m.abunchtell.com https://m.abunchtell.com
您最多选择25个主题 主题必须以字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符
 
 
 
 

119 行
8.1 KiB

  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 filterShowStr = <FormattedMessage id='notifications.column_settings.filter_bar.show' defaultMessage='Show' />;
  20. const filterAdvancedStr = <FormattedMessage id='notifications.column_settings.filter_bar.advanced' defaultMessage='Display all categories' />;
  21. const alertStr = <FormattedMessage id='notifications.column_settings.alert' defaultMessage='Desktop notifications' />;
  22. const showStr = <FormattedMessage id='notifications.column_settings.show' defaultMessage='Show in column' />;
  23. const soundStr = <FormattedMessage id='notifications.column_settings.sound' defaultMessage='Play sound' />;
  24. const showPushSettings = pushSettings.get('browserSupport') && pushSettings.get('isSubscribed');
  25. const pushStr = showPushSettings && <FormattedMessage id='notifications.column_settings.push' defaultMessage='Push notifications' />;
  26. return (
  27. <div>
  28. <div className='column-settings__row'>
  29. <ClearColumnButton onClick={onClear} />
  30. </div>
  31. <div role='group' aria-labelledby='notifications-filter-bar'>
  32. <span id='notifications-filter-bar' className='column-settings__section'>
  33. <FormattedMessage id='notifications.column_settings.filter_bar.category' defaultMessage='Quick filter bar' />
  34. </span>
  35. <div className='column-settings__row'>
  36. <SettingToggle id='show-filter-bar' prefix='notifications' settings={settings} settingPath={['quickFilter', 'show']} onChange={onChange} label={filterShowStr} />
  37. <SettingToggle id='show-filter-bar' prefix='notifications' settings={settings} settingPath={['quickFilter', 'advanced']} onChange={onChange} label={filterAdvancedStr} />
  38. </div>
  39. </div>
  40. <div role='group' aria-labelledby='notifications-follow'>
  41. <span id='notifications-follow' className='column-settings__section'><FormattedMessage id='notifications.column_settings.follow' defaultMessage='New followers:' /></span>
  42. <div className='column-settings__row'>
  43. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'follow']} onChange={onChange} label={alertStr} />
  44. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'follow']} onChange={this.onPushChange} label={pushStr} />}
  45. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'follow']} onChange={onChange} label={showStr} />
  46. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'follow']} onChange={onChange} label={soundStr} />
  47. </div>
  48. </div>
  49. <div role='group' aria-labelledby='notifications-follow-request'>
  50. <span id='notifications-follow-request' className='column-settings__section'><FormattedMessage id='notifications.column_settings.follow_request' defaultMessage='New follow requests:' /></span>
  51. <div className='column-settings__row'>
  52. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'follow_request']} onChange={onChange} label={alertStr} />
  53. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'follow_request']} onChange={this.onPushChange} label={pushStr} />}
  54. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'follow_request']} onChange={onChange} label={showStr} />
  55. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'follow_request']} onChange={onChange} label={soundStr} />
  56. </div>
  57. </div>
  58. <div role='group' aria-labelledby='notifications-favourite'>
  59. <span id='notifications-favourite' className='column-settings__section'><FormattedMessage id='notifications.column_settings.favourite' defaultMessage='Favourites:' /></span>
  60. <div className='column-settings__row'>
  61. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'favourite']} onChange={onChange} label={alertStr} />
  62. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'favourite']} onChange={this.onPushChange} label={pushStr} />}
  63. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'favourite']} onChange={onChange} label={showStr} />
  64. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'favourite']} onChange={onChange} label={soundStr} />
  65. </div>
  66. </div>
  67. <div role='group' aria-labelledby='notifications-mention'>
  68. <span id='notifications-mention' className='column-settings__section'><FormattedMessage id='notifications.column_settings.mention' defaultMessage='Mentions:' /></span>
  69. <div className='column-settings__row'>
  70. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'mention']} onChange={onChange} label={alertStr} />
  71. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'mention']} onChange={this.onPushChange} label={pushStr} />}
  72. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'mention']} onChange={onChange} label={showStr} />
  73. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'mention']} onChange={onChange} label={soundStr} />
  74. </div>
  75. </div>
  76. <div role='group' aria-labelledby='notifications-reblog'>
  77. <span id='notifications-reblog' className='column-settings__section'><FormattedMessage id='notifications.column_settings.reblog' defaultMessage='Boosts:' /></span>
  78. <div className='column-settings__row'>
  79. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'reblog']} onChange={onChange} label={alertStr} />
  80. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'reblog']} onChange={this.onPushChange} label={pushStr} />}
  81. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'reblog']} onChange={onChange} label={showStr} />
  82. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'reblog']} onChange={onChange} label={soundStr} />
  83. </div>
  84. </div>
  85. <div role='group' aria-labelledby='notifications-poll'>
  86. <span id='notifications-poll' className='column-settings__section'><FormattedMessage id='notifications.column_settings.poll' defaultMessage='Poll results:' /></span>
  87. <div className='column-settings__row'>
  88. <SettingToggle prefix='notifications_desktop' settings={settings} settingPath={['alerts', 'poll']} onChange={onChange} label={alertStr} />
  89. {showPushSettings && <SettingToggle prefix='notifications_push' settings={pushSettings} settingPath={['alerts', 'poll']} onChange={this.onPushChange} label={pushStr} />}
  90. <SettingToggle prefix='notifications' settings={settings} settingPath={['shows', 'poll']} onChange={onChange} label={showStr} />
  91. <SettingToggle prefix='notifications' settings={settings} settingPath={['sounds', 'poll']} onChange={onChange} label={soundStr} />
  92. </div>
  93. </div>
  94. </div>
  95. );
  96. }
  97. }