@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
3
3
import ImmutablePropTypes from 'react-immutable-proptypes' ;
4
4
import { FormattedMessage } from 'react-intl' ;
5
5
import ClearColumnButton from './clear_column_button' ;
6
+ import GrantPermissionButton from './grant_permission_button' ;
6
7
import SettingToggle from './setting_toggle' ;
7
8
8
9
export default class ColumnSettings extends React . PureComponent {
@@ -23,7 +24,7 @@ export default class ColumnSettings extends React.PureComponent {
23
24
}
24
25
25
26
render ( ) {
26
- const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission } = this . props ;
27
+ const { settings, pushSettings, onChange, onClear, alertsEnabled, browserSupport, browserPermission, onRequestNotificationPermission } = this . props ;
27
28
28
29
const filterShowStr = < FormattedMessage id = 'notifications.column_settings.filter_bar.show' defaultMessage = 'Show' /> ;
29
30
const filterAdvancedStr = < FormattedMessage id = 'notifications.column_settings.filter_bar.advanced' defaultMessage = 'Display all categories' /> ;
@@ -42,6 +43,14 @@ export default class ColumnSettings extends React.PureComponent {
42
43
</ div >
43
44
) }
44
45
46
+ { alertsEnabled && browserSupport && browserPermission === 'default' && (
47
+ < div className = 'column-settings__row column-settings__row--with-margin' >
48
+ < span className = 'warning-hint' >
49
+ < FormattedMessage id = 'notifications.permission_required' defaultMessage = 'Desktop notifications are unavailable because the required permission has not been granted.' /> < GrantPermissionButton onClick = { onRequestNotificationPermission } />
50
+ </ span >
51
+ </ div >
52
+ ) }
53
+
45
54
< div className = 'column-settings__row' >
46
55
< ClearColumnButton onClick = { onClear } />
47
56
</ div >
@@ -61,7 +70,7 @@ export default class ColumnSettings extends React.PureComponent {
61
70
< span id = 'notifications-follow' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.follow' defaultMessage = 'New followers:' /> </ span >
62
71
63
72
< div className = 'column-settings__row' >
64
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'follow' ] } onChange = { onChange } label = { alertStr } />
73
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'follow' ] } onChange = { onChange } label = { alertStr } />
65
74
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'follow' ] } onChange = { this . onPushChange } label = { pushStr } /> }
66
75
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'follow' ] } onChange = { onChange } label = { showStr } />
67
76
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'follow' ] } onChange = { onChange } label = { soundStr } />
@@ -72,7 +81,7 @@ export default class ColumnSettings extends React.PureComponent {
72
81
< span id = 'notifications-follow-request' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.follow_request' defaultMessage = 'New follow requests:' /> </ span >
73
82
74
83
< div className = 'column-settings__row' >
75
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'follow_request' ] } onChange = { onChange } label = { alertStr } />
84
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'follow_request' ] } onChange = { onChange } label = { alertStr } />
76
85
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'follow_request' ] } onChange = { this . onPushChange } label = { pushStr } /> }
77
86
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'follow_request' ] } onChange = { onChange } label = { showStr } />
78
87
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'follow_request' ] } onChange = { onChange } label = { soundStr } />
@@ -83,7 +92,7 @@ export default class ColumnSettings extends React.PureComponent {
83
92
< span id = 'notifications-favourite' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.favourite' defaultMessage = 'Favourites:' /> </ span >
84
93
85
94
< div className = 'column-settings__row' >
86
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'favourite' ] } onChange = { onChange } label = { alertStr } />
95
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'favourite' ] } onChange = { onChange } label = { alertStr } />
87
96
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'favourite' ] } onChange = { this . onPushChange } label = { pushStr } /> }
88
97
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'favourite' ] } onChange = { onChange } label = { showStr } />
89
98
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'favourite' ] } onChange = { onChange } label = { soundStr } />
@@ -94,7 +103,7 @@ export default class ColumnSettings extends React.PureComponent {
94
103
< span id = 'notifications-mention' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.mention' defaultMessage = 'Mentions:' /> </ span >
95
104
96
105
< div className = 'column-settings__row' >
97
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'mention' ] } onChange = { onChange } label = { alertStr } />
106
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'mention' ] } onChange = { onChange } label = { alertStr } />
98
107
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'mention' ] } onChange = { this . onPushChange } label = { pushStr } /> }
99
108
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'mention' ] } onChange = { onChange } label = { showStr } />
100
109
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'mention' ] } onChange = { onChange } label = { soundStr } />
@@ -105,7 +114,7 @@ export default class ColumnSettings extends React.PureComponent {
105
114
< span id = 'notifications-reblog' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.reblog' defaultMessage = 'Boosts:' /> </ span >
106
115
107
116
< div className = 'column-settings__row' >
108
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'reblog' ] } onChange = { onChange } label = { alertStr } />
117
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'reblog' ] } onChange = { onChange } label = { alertStr } />
109
118
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'reblog' ] } onChange = { this . onPushChange } label = { pushStr } /> }
110
119
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'reblog' ] } onChange = { onChange } label = { showStr } />
111
120
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'reblog' ] } onChange = { onChange } label = { soundStr } />
@@ -116,7 +125,7 @@ export default class ColumnSettings extends React.PureComponent {
116
125
< span id = 'notifications-poll' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.poll' defaultMessage = 'Poll results:' /> </ span >
117
126
118
127
< div className = 'column-settings__row' >
119
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'poll' ] } onChange = { onChange } label = { alertStr } />
128
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'poll' ] } onChange = { onChange } label = { alertStr } />
120
129
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'poll' ] } onChange = { this . onPushChange } label = { pushStr } /> }
121
130
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'poll' ] } onChange = { onChange } label = { showStr } />
122
131
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'poll' ] } onChange = { onChange } label = { soundStr } />
@@ -127,7 +136,7 @@ export default class ColumnSettings extends React.PureComponent {
127
136
< span id = 'notifications-status' className = 'column-settings__section' > < FormattedMessage id = 'notifications.column_settings.status' defaultMessage = 'New toots:' /> </ span >
128
137
129
138
< div className = 'column-settings__row' >
130
- < SettingToggle disabled = { browserPermission !== 'granted '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'status' ] } onChange = { onChange } label = { alertStr } />
139
+ < SettingToggle disabled = { browserPermission === 'denied '} prefix = 'notifications_desktop' settings = { settings } settingPath = { [ 'alerts' , 'status' ] } onChange = { onChange } label = { alertStr } />
131
140
{ showPushSettings && < SettingToggle prefix = 'notifications_push' settings = { pushSettings } settingPath = { [ 'alerts' , 'status' ] } onChange = { this . onPushChange } label = { pushStr } /> }
132
141
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'shows' , 'status' ] } onChange = { onChange } label = { showStr } />
133
142
< SettingToggle prefix = 'notifications' settings = { settings } settingPath = { [ 'sounds' , 'status' ] } onChange = { onChange } label = { soundStr } />
0 commit comments