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';
8 export default class ColumnSettings
extends React
.PureComponent
{
11 settings: ImmutablePropTypes
.map
.isRequired
,
12 pushSettings: ImmutablePropTypes
.map
.isRequired
,
13 onChange: PropTypes
.func
.isRequired
,
14 onClear: PropTypes
.func
.isRequired
,
17 onPushChange
= (path
, checked
) => {
18 this.props
.onChange(['push', ...path
], checked
);
22 const { settings
, pushSettings
, onChange
, onClear
} = this.props
;
24 const alertStr
= <FormattedMessage id
='notifications.column_settings.alert' defaultMessage
='Desktop notifications' />;
25 const showStr
= <FormattedMessage id
='notifications.column_settings.show' defaultMessage
='Show in column' />;
26 const soundStr
= <FormattedMessage id
='notifications.column_settings.sound' defaultMessage
='Play sound' />;
28 const showPushSettings
= pushSettings
.get('browserSupport') && pushSettings
.get('isSubscribed');
29 const pushStr
= showPushSettings
&& <FormattedMessage id
='notifications.column_settings.push' defaultMessage
='Push notifications' />;
30 const pushMeta
= showPushSettings
&& <FormattedMessage id
='notifications.column_settings.push_meta' defaultMessage
='This device' />;
34 <div className
='column-settings__row'>
35 <ClearColumnButton onClick
={onClear
} />
38 <div role
='group' aria
-labelledby
='notifications-follow'>
39 <span id
='notifications-follow' className
='column-settings__section'><FormattedMessage id
='notifications.column_settings.follow' defaultMessage
='New followers:' /></span>
41 <div className
='column-settings__row'>
42 <SettingToggle prefix
='notifications_desktop' settings
={settings
} settingPath
={['alerts', 'follow']} onChange
={onChange
} label
={alertStr
} />
43 {showPushSettings
&& <SettingToggle prefix
='notifications_push' settings
={pushSettings
} settingPath
={['alerts', 'follow']} meta
={pushMeta
} onChange
={this.onPushChange
} label
={pushStr
} />}
44 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['shows', 'follow']} onChange
={onChange
} label
={showStr
} />
45 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['sounds', 'follow']} onChange
={onChange
} label
={soundStr
} />
49 <div role
='group' aria
-labelledby
='notifications-favourite'>
50 <span id
='notifications-favourite' className
='column-settings__section'><FormattedMessage id
='notifications.column_settings.favourite' defaultMessage
='Favourites:' /></span>
52 <div className
='column-settings__row'>
53 <SettingToggle prefix
='notifications_desktop' settings
={settings
} settingPath
={['alerts', 'favourite']} onChange
={onChange
} label
={alertStr
} />
54 {showPushSettings
&& <SettingToggle prefix
='notifications_push' settings
={pushSettings
} settingPath
={['alerts', 'favourite']} meta
={pushMeta
} onChange
={this.onPushChange
} label
={pushStr
} />}
55 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['shows', 'favourite']} onChange
={onChange
} label
={showStr
} />
56 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['sounds', 'favourite']} onChange
={onChange
} label
={soundStr
} />
60 <div role
='group' aria
-labelledby
='notifications-mention'>
61 <span id
='notifications-mention' className
='column-settings__section'><FormattedMessage id
='notifications.column_settings.mention' defaultMessage
='Mentions:' /></span>
63 <div className
='column-settings__row'>
64 <SettingToggle prefix
='notifications_desktop' settings
={settings
} settingPath
={['alerts', 'mention']} onChange
={onChange
} label
={alertStr
} />
65 {showPushSettings
&& <SettingToggle prefix
='notifications_push' settings
={pushSettings
} settingPath
={['alerts', 'mention']} meta
={pushMeta
} onChange
={this.onPushChange
} label
={pushStr
} />}
66 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['shows', 'mention']} onChange
={onChange
} label
={showStr
} />
67 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['sounds', 'mention']} onChange
={onChange
} label
={soundStr
} />
71 <div role
='group' aria
-labelledby
='notifications-reblog'>
72 <span id
='notifications-reblog' className
='column-settings__section'><FormattedMessage id
='notifications.column_settings.reblog' defaultMessage
='Boosts:' /></span>
74 <div className
='column-settings__row'>
75 <SettingToggle prefix
='notifications_desktop' settings
={settings
} settingPath
={['alerts', 'reblog']} onChange
={onChange
} label
={alertStr
} />
76 {showPushSettings
&& <SettingToggle prefix
='notifications_push' settings
={pushSettings
} settingPath
={['alerts', 'reblog']} meta
={pushMeta
} onChange
={this.onPushChange
} label
={pushStr
} />}
77 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['shows', 'reblog']} onChange
={onChange
} label
={showStr
} />
78 <SettingToggle prefix
='notifications' settings
={settings
} settingPath
={['sounds', 'reblog']} onChange
={onChange
} label
={soundStr
} />