Skip to content

Commit 8de01d2

Browse files
committed
Revert "issue #1991 - Email settings"
This reverts commit c93774f.
1 parent c93774f commit 8de01d2

File tree

9 files changed

+1053
-1042
lines changed

9 files changed

+1053
-1042
lines changed

package-lock.json

Lines changed: 958 additions & 958 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/components/BtnGroup/BtnGroup.jsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ class BtnGroup extends React.Component {
2424
<button
2525
key={item.value}
2626
className={cn('tc-btn tc-btn-sm tc-btn-default', { active: item.value === this.state.value })}
27-
onClick={(evt) => {
28-
// prevent parent form to be submitted
29-
evt.preventDefault()
27+
onClick={() => {
3028
if (item.value !== this.state.value) {
3129
this.setState({ value: item.value })
3230
if (this.props.onChange) {

src/components/BtnGroup/BtnGroup.scss

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,24 @@
66
> .tc-btn {
77
border-radius: 0;
88
border-left-width: 0;
9-
margin: 0;
109
}
11-
10+
1211
> .tc-btn:first-child {
1312
border-radius: 2 * $corner-radius 0 0 2 * $corner-radius;
1413
border-left-width: 1px;
1514
}
16-
15+
1716
> .tc-btn:last-child {
1817
border-radius: 0 2 * $corner-radius 2 * $corner-radius 0;
1918
}
20-
19+
2120
> .tc-btn.active,
2221
> .tc-btn.active:hover,
2322
> .tc-btn.active:active {
2423
background: $tc-gray-20;
2524
box-shadow: inset 0 1px 3px 0 rgba($tc-gray-80, 0.38);
2625
cursor: default;
2726
}
28-
29-
@media screen and (max-width: $screen-md - 1px) {
30-
> .tc-btn,
31-
> .tc-btn:first-child,
32-
> .tc-btn:last-child {
33-
border-radius: 2 * $corner-radius;
34-
border-width: 1px;
35-
margin: 5px;
36-
}
37-
}
3827
}
3928
}
29+

src/config/constants.js

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -399,11 +399,3 @@ export const SCREEN_BREAKPOINT_RG = 992
399399
export const SCREEN_BREAKPOINT_MD = 768
400400
export const SCREEN_BREAKPOINT_SM = 640
401401
export const SCREEN_BREAKPOINT_XS = 320
402-
403-
export const NOTIFICATION_SETTINGS_PERIODS = [
404-
{ text: 'Send as they happen', value: 'immediately' },
405-
{ text: 'Every 10m.', value: 'every10minutes' },
406-
{ text: 'Hourly', value: 'hourly' },
407-
{ text: 'Daily', value: 'daily' },
408-
{ text: 'Weekly', value: 'weekly' },
409-
]

src/routes/settings/components/SettingsPanel.scss

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
.settings-panel {
66
margin: 20px auto 0;
77
padding: 0 20px;
8+
min-width: 960px;
89

910
@media screen and (max-width: $screen-md - 1px) {
1011
margin: 0;
12+
min-width: 0;
1113
padding: 0;
1214
}
1315

src/routes/settings/routes/notifications/components/NotificationSettingsForm.jsx

Lines changed: 33 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,9 @@ import React from 'react'
55
import PropTypes from 'prop-types'
66
import FormsyForm from 'appirio-tech-react-components/components/Formsy'
77
const Formsy = FormsyForm.Formsy
8-
import { NOTIFICATION_SETTINGS_PERIODS } from '../../../../../config/constants'
98
import SwitchButton from 'appirio-tech-react-components/components/SwitchButton/SwitchButton'
109
import BtnGroup from '../../../../../components/BtnGroup/BtnGroup'
1110
import IconSettingsWeb from '../../../../../assets/icons/settings-icon-web.svg'
12-
import IconSettingsEmail from '../../../../../assets/icons/settings-icon-mail.svg'
1311
import './NotificationSettingsForm.scss'
1412
import _ from 'lodash'
1513

@@ -80,28 +78,22 @@ const topics = [
8078
*/
8179
const initSettings = (notInitedSettings) => {
8280
const settings = {...notInitedSettings}
83-
const notifications = {...settings.notifications}
8481
const allTypes = _.flatten(_.map(topics, 'types'))
8582

8683
allTypes.forEach((type) => {
87-
if (!notifications[type]) {
88-
notifications[type] = {}
84+
if (!settings[type]) {
85+
settings[type] = {}
8986
}
9087

91-
// check each of serviceId method separately as some can have
88+
// check each of deliveryMethod method separately as some can have
9289
// values and some don't have
93-
['web', 'email'].forEach((serviceId) => {
94-
if (!notifications[type][serviceId]) {
95-
notifications[type][serviceId] = {}
96-
}
97-
if (_.isUndefined(notifications[type][serviceId].enabled)) {
98-
notifications[type][serviceId].enabled = 'yes'
90+
['web', 'email'].forEach((deliveryMethod) => {
91+
if (_.isUndefined(settings[type][deliveryMethod])) {
92+
settings[type][deliveryMethod] = 'yes'
9993
}
10094
})
10195
})
10296

103-
settings.notifications = notifications
104-
10597
return settings
10698
}
10799

@@ -115,45 +107,26 @@ class NotificationSettingsForm extends React.Component {
115107
}
116108

117109
this.handleChange = this.handleChange.bind(this)
118-
this.handleBundleEmailChange = this.handleBundleEmailChange.bind(this)
119110
}
120111

121-
handleChange(topicIndex, serviceId) {
122-
const notifications = {...this.state.settings.notifications}
112+
handleChange(topicIndex, deliveryMethod) {
113+
const s = {
114+
settings: {
115+
...this.state.settings
116+
}
117+
}
123118

124119
// update values for all types of the topic
125120
topics[topicIndex].types.forEach((type) => {
126-
notifications[type][serviceId].enabled = notifications[type][serviceId].enabled === 'yes' ? 'no' : 'yes'
127-
})
128-
129-
this.setState({
130-
settings: {
131-
...this.state.settings,
132-
notifications,
133-
}
121+
s.settings[type][deliveryMethod] = s.settings[type][deliveryMethod] === 'yes' ? 'no' : 'yes'
134122
})
135-
}
136123

137-
handleBundleEmailChange(bundlePeriod) {
138-
this.setState({
139-
settings: {
140-
...this.state.settings,
141-
services: {
142-
...this.state.settings.services,
143-
email: {
144-
...this.state.settings.services.email,
145-
// this will be send to backend which uses null instead of 'immediately'
146-
bundlePeriod: bundlePeriod === 'immediately' ? null : bundlePeriod,
147-
}
148-
}
149-
}
150-
})
124+
this.setState(s)
151125
}
152126

153127
render() {
154128
const areSettingsProvided = !!this.props.values.settings
155129
const settings = this.state.settings
156-
const notifications = settings.notifications
157130

158131
// if settings weren't provided (not loaded) don't render anything
159132
if (!areSettingsProvided) {
@@ -172,9 +145,8 @@ class NotificationSettingsForm extends React.Component {
172145
<th><span className="th-with-icon">
173146
<IconSettingsWeb className="icon-settings-web"/>
174147
<span>Web</span></span></th>
175-
<th><span className="th-with-icon">
176-
<IconSettingsEmail />
177-
<span>Email</span></span></th>
148+
{/* as email notification currently not supported, hide them for now */}
149+
{/*<th><span className="th-with-icon"><img src={iconMail} /><span>Email</span></span></th>*/}
178150
</tr>
179151
</thead>
180152
<tbody>
@@ -185,26 +157,37 @@ class NotificationSettingsForm extends React.Component {
185157
return (
186158
<tr key={index}>
187159
<th>{topic.title}</th>
188-
<td><SwitchButton onChange={() => this.handleChange(index, 'web')} defaultChecked={notifications[topicFirstType].web.enabled === 'yes'} /></td>
189-
<td><SwitchButton onChange={() => this.handleChange(index, 'email')} defaultChecked={notifications[topicFirstType].email.enabled === 'yes'} /></td>
160+
<td><SwitchButton onChange={() => this.handleChange(index, 'web')} defaultChecked={settings[topicFirstType] && settings[topicFirstType].web === 'yes'} /></td>
161+
{/* as email notification currently not supported, hide them for now */}
162+
{/*<td><SwitchButton onChange={() => this.handleChange(topic, 'email')} defaultChecked={settings[topic] && settings[topic].email === 'yes'} /></td>*/}
190163
</tr>
191164
)
192165
})}
193-
<tr>
166+
167+
{ false && <tr>
194168
<td colSpan="3">
195169
<div className="bundle-emails">
196170
<div className="th">Bundle emails:</div>
197171
<BtnGroup
198-
items={NOTIFICATION_SETTINGS_PERIODS}
199-
onChange={this.handleBundleEmailChange}
200-
defaultValue={_.get(this.props.values, 'settings.services.email.bundlePeriod') || 'immediately'}
172+
items={[
173+
{ text: 'Send as they happen', value: 'immediately' },
174+
{ text: 'Every hour', value: 'hourly' },
175+
{ text: 'Every 12h.', value: '12h' },
176+
{ text: 'Every 24h.', value: '24h' }
177+
]}
178+
defaultValue={this.props.values.bundleEmail}
201179
/>
202180
</div>
203181
</td>
204182
</tr>
183+
}
205184
</tbody>
206185
</table>
207186

187+
<div className="email-settings">
188+
<a href="https://www.topcoder.com/settings/email/">Manage email settings</a>
189+
</div>
190+
208191
<div className="controls">
209192
<button type="submit" className="tc-btn tc-btn-primary" disabled={this.props.values.pending}>Save settings</button>
210193
</div>

src/routes/settings/routes/notifications/components/NotificationSettingsForm.scss

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -104,14 +104,6 @@
104104
margin-left: 10px;
105105
margin-bottom: 10px;
106106
}
107-
108-
@media screen and (max-width: 430px - 1px) {
109-
> span {
110-
display: block;
111-
margin-left: $base-unit;
112-
margin-right: $base-unit;
113-
}
114-
}
115107
}
116108

117109
.none {
@@ -143,5 +135,21 @@
143135
margin-top: 6 * $base-unit;
144136
text-align: center;
145137
}
138+
139+
> .email-settings {
140+
@include roboto;
141+
margin: 20px 0;
142+
143+
// Link colors
144+
a:link,
145+
a:visited {
146+
color: $tc-dark-blue;
147+
}
148+
149+
a:hover,
150+
a:active {
151+
color: $tc-dark-blue-70;
152+
}
153+
}
146154
}
147155
}

src/routes/settings/routes/notifications/containers/NotificationSettingsContainer.jsx

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,10 @@ class NotificationSettingsContainer extends React.Component {
2525
return (
2626
<SettingsPanel
2727
title="Notifications"
28+
// link={{
29+
// to: 'https://www.topcoder.com/settings/email/',
30+
// text: 'email settings here'
31+
// }}
2832
text="Notifications are a great way to get back to what matters. Sometimes things can be a bit overwhelming, we get it, so here you can turn off the things that bug you. Once off, you won’t get any notifications of that category until you turn it back on. To manage your email notifications, follow the link at the bottom of the page."
2933
isWide
3034
>

src/routes/settings/services/settings.js

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,42 @@ const getNotificationSettings = () => {
6666
.then(resp => resp.data)
6767
}
6868

69+
// TODO move this list to constants together with the same list in NotificationSettingsForm.jsx
70+
const topics = [
71+
'notifications.connect.project.created',
72+
'notifications.connect.project.updated',
73+
'notifications.connect.project.canceled',
74+
'notifications.connect.project.approved',
75+
'notifications.connect.project.paused',
76+
'notifications.connect.project.completed',
77+
'notifications.connect.project.submittedForReview',
78+
'notifications.connect.project.active',
79+
80+
'notifications.connect.project.fileUploaded',
81+
'notifications.connect.project.specificationModified',
82+
'notifications.connect.project.linkCreated',
83+
84+
'notifications.connect.project.member.joined',
85+
'notifications.connect.project.member.left',
86+
'notifications.connect.project.member.removed',
87+
'notifications.connect.project.member.managerJoined',
88+
'notifications.connect.project.member.copilotJoined',
89+
'notifications.connect.project.member.assignedAsOwner',
90+
91+
'notifications.connect.project.topic.created',
92+
'notifications.connect.project.topic.deleted',
93+
'notifications.connect.project.post.created',
94+
'notifications.connect.project.post.edited',
95+
'notifications.connect.project.post.deleted'
96+
]
97+
6998
const saveNotificationSettings = (data) => {
70-
return axios.put(`${TC_NOTIFICATION_URL}/settings`, data)
99+
const body = []
100+
_.each(topics, (topic) => {
101+
body.push({ topic, deliveryMethod: 'email', value: data[topic] && data[topic].email === 'yes' ? 'yes' : 'no' })
102+
body.push({ topic, deliveryMethod: 'web', value: data[topic] && data[topic].web === 'yes' ? 'yes' : 'no' })
103+
})
104+
return axios.put(`${TC_NOTIFICATION_URL}/settings`, body)
71105
}
72106

73107
export default {

0 commit comments

Comments
 (0)