• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mozilla / blurts-server / c9ae2591-186f-4294-a5e5-a502a4f2d392

pending completion
c9ae2591-186f-4294-a5e5-a502a4f2d392

push

circleci

Robert Helmer
Merge branch 'MNTOR-983-settings-v2-frontend-additions' into MNTOR-803/settings-v2-integration

282 of 1265 branches covered (22.29%)

Branch coverage included in aggregate %.

95 of 95 new or added lines in 3 files covered. (100.0%)

959 of 3391 relevant lines covered (28.28%)

2.3 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/client/js/settings.js
1
const settingsUpdateCommOption = document.getElementsByClassName(
×
2
  'radio-comm-option'
3
)
4
if (settingsUpdateCommOption.length) {
×
5
  for (const el of settingsUpdateCommOption) {
×
6
    el.addEventListener('click', async (event) => {
×
7
      try {
×
8
        const communicationOption = event.target.getAttribute('data-comm-option')
×
9
        const csrfToken = document
×
10
          .getElementById('settings')
11
          .getAttribute('data-csrf-token')
12

13
        const response = await fetch('/api/v1/user/update-comm-option', {
×
14
          headers: {
15
            'Content-Type': 'application/json',
16
            'x-csrf-token': csrfToken
17
          },
18
          mode: 'same-origin',
19
          method: 'POST',
20
          body: JSON.stringify({ communicationOption })
21
        })
22

23
        if (response && response.redirected === true) {
×
24
          throw response.error
×
25
        }
26
      } catch (err) {
27
        throw new Error(`Updating communication option failed: ${err}`)
×
28
      }
29
      event.preventDefault()
×
30
      return false
×
31
    })
32
  }
33
}
34

35
const settingsAddEmail = document.getElementById('settings-add-email')
×
36
if (settingsAddEmail) {
×
37
  settingsAddEmail.addEventListener('click', async (_) => {
×
38
    try {
×
39
      const addEmailDialog = document.getElementById('add-email-modal')
×
40
      addEmailDialog.showModal()
×
41
    } catch (err) {
42
      console.error(`Error: ${err}`)
×
43
    }
44
  })
45
}
46

47
const settingsClose = document.getElementById('settings-close')
×
48
if (settingsClose) {
×
49
  settingsClose.addEventListener('click', async (_) => {
×
50
    try {
×
51
      const addEmailDialog = document.getElementById('add-email-modal')
×
52
      addEmailDialog.close()
×
53
    } catch (err) {
54
      console.error(`Error: ${err}`)
×
55
    }
56
  })
57
}
58

59
const settingsAddVerification = document.getElementById('send-verification')
×
60
if (settingsAddVerification) {
×
61
  settingsAddVerification.addEventListener('click', async (_) => {
×
62
    const email = document.getElementById('email').value
×
63
    const csrfToken = document
×
64
      .getElementById('settings')
65
      .getAttribute('data-csrf-token')
66

67
    const response = await fetch('/api/v1/user/email', {
×
68
      headers: {
69
        'Content-Type': 'application/json',
70
        'x-csrf-token': csrfToken
71
      },
72
      mode: 'same-origin',
73
      method: 'POST',
74
      body: JSON.stringify({ email })
75
    })
76

77
    if (!response || !response.ok) {
×
78
      throw new Error(`sending verification email failed: ${response.error}`)
×
79
    }
80

81
    const addEmailDialogContent = document.getElementById('add-email-modal-content')
×
82
    addEmailDialogContent.textContent = `Verify the link sent to ${email} to add it to Firefox Monitor. Manage all email addresses in Settings.`
×
83

84
    const addEmailDialogControls = document.getElementById('add-email-modal-controls')
×
85
    addEmailDialogControls.hidden = true
×
86

87
    const addEmailDialog = document.getElementById('add-email-modal')
×
88
    addEmailDialog.addEventListener('close', _ => {
×
89
      addEmailDialogControls.hidden = false
×
90
      return window.location.reload(true)
×
91
    }, { once: true })
92
  })
93
}
94

95
const settingsRemoveEmail = document.getElementsByClassName('js-remove-email')
×
96
if (settingsRemoveEmail.length) {
×
97
  for (const el of settingsRemoveEmail) {
×
98
    el.addEventListener('click', async (event) => {
×
99
      try {
×
100
        const subscriberId = event.target.getAttribute('data-subscriber-id')
×
101
        const emailId = event.target.getAttribute('data-email-id')
×
102
        const csrfToken = document
×
103
          .getElementById('settings')
104
          .getAttribute('data-csrf-token')
105

106
        const response = await fetch('/api/v1/user/remove-email', {
×
107
          headers: {
108
            'Content-Type': 'application/json',
109
            'x-csrf-token': csrfToken
110
          },
111
          mode: 'same-origin',
112
          method: 'POST',
113
          body: JSON.stringify({ emailId, subscriberId })
114
        })
115

116
        if (response && response.redirected === true) {
×
117
          return window.location.reload(true)
×
118
        }
119
      } catch (err) {
120
        console.error(`Error: ${err}`)
×
121
      }
122
    })
123
  }
124
}
125

126
const settingsResendEmail = document.getElementsByClassName(
×
127
  'settings-resend-email'
128
)
129
if (settingsResendEmail.length) {
×
130
  for (const el of settingsResendEmail) {
×
131
    el.addEventListener('click', async (event) => {
×
132
      try {
×
133
        const emailId = event.target.getAttribute('data-email-id')
×
134
        const csrfToken = document
×
135
          .getElementById('settings')
136
          .getAttribute('data-csrf-token')
137

138
        const response = await fetch('/api/v1/user/resend-email', {
×
139
          headers: {
140
            'Content-Type': 'application/json',
141
            'x-csrf-token': csrfToken
142
          },
143
          mode: 'same-origin',
144
          method: 'POST',
145
          body: JSON.stringify({ emailId })
146
        })
147

148
        if (response && response.redirected === true) {
×
149
          throw response.error
×
150
        }
151
      } catch (err) {
152
        throw new Error(`re-sending verification email failed: ${err}`)
×
153
      }
154
      event.preventDefault()
×
155
      return false
×
156
    })
157
  }
158
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc