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

mozilla / blurts-server / #11973

pending completion
#11973

push

circleci

web-flow
Merge pull request #2775 from mozilla/MNTOR-1014/breach-resolution

Mntor 1014/breach resolution

282 of 1207 branches covered (23.36%)

Branch coverage included in aggregate %.

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

959 of 3217 relevant lines covered (29.81%)

2.42 hits per line

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

0.0
/src/views/partials/breaches.js
1
/* This Source Code Form is subject to the terms of the Mozilla Public
2
 * License, v. 2.0. If a copy of the MPL was not distributed with this
3
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
4

5
import { getMessage, getLocale } from '../../utils/fluent.js'
6
import AppConstants from '../../app-constants.js'
7

8
function createEmailOptions (data) {
9
  const emails = data.verifiedEmails.map(obj => obj.email)
×
10
  const optionElements = emails.map(email => `<option>${email}</option>`)
×
11

12
  return optionElements.join('')
×
13
}
14

15
function createEmailCTA (count) {
16
  const total = parseInt(AppConstants.MAX_NUM_ADDRESSES)
×
17

18
  if (count >= total) return '' // don't show CTA if additional emails are not available for monitor
×
19

20
  // TODO: link "add email" flow
21
  return `<a href='http://mozilla.org'>${getMessage('add-email-link')}</a>`
×
22
}
23

24
function createBreachRows (data) {
25
  const locale = getLocale()
×
26
  const shortDate = new Intl.DateTimeFormat(locale, { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: 'UTC' })
×
27
  const shortList = new Intl.ListFormat(locale, { style: 'narrow' })
×
28
  const longDate = new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeZone: 'UTC' })
×
29
  const longList = new Intl.ListFormat(locale, { style: 'long' })
×
30
  const breachRowsHTML = data.verifiedEmails.flatMap(account => {
×
31
    return account.breaches.map(breach => {
×
32
      const isHidden = !account.primary || breach.IsResolved // initial breach hidden state
×
33
      const status = breach.IsResolved ? 'resolved' : 'unresolved'
×
34
      const breachDate = Date.parse(breach.BreachDate)
×
35
      const addedDate = Date.parse(breach.AddedDate)
×
36
      const dataClassesTranslated = breach.DataClasses.map(item => getMessage(item))
×
37
      const description = getMessage('breach-description', {
×
38
        companyName: breach.Title,
39
        breachDate: longDate.format(breachDate),
40
        addedDate: longDate.format(addedDate),
41
        dataClasses: longList.format(dataClassesTranslated)
42
      })
43

44
      return `
×
45
      <details class='breach-row' data-status=${status} data-email=${account.email} hidden=${!account.primary} hidden=${isHidden}>
46
        <summary>
47
          <span>${breach.Title}</span><span>${shortList.format(dataClassesTranslated)}</span><span>${shortDate.format(addedDate)}</span>
48
        </summary>
49
        <article>
50
          <p>${description}</p>
51
          <p><strong>Resolve this breach:</strong></p>
52
          <ol class='resolve-list'>${createResolveSteps(breach)}</ol>
53
        </article>
54
      </details>
55
      `
56
    })
57
  })
58

59
  return breachRowsHTML.join('')
×
60
}
61

62
function createResolveSteps (breach) {
63
  const checkedArr = breach.ResolutionsChecked || []
×
64
  const resolveStepsHTML = Object.entries(breach.breachChecklist).map(([key, value]) => `
×
65
  <li class='resolve-list-item'>
66
    <input name='${breach.recencyIndex}' value='${key}' type='checkbox' ${checkedArr.includes(key) ? 'checked' : ''}>
×
67
    <p>${value.header}<br><i>${value.body}</i></p>
68
  </li>
69
  `)
70

71
  return resolveStepsHTML.join('')
×
72
}
73

74
export const breaches = data => `
×
75
<section>
76
  <header class='breaches-header'>
77
    <h1>${getMessage('breach-heading-email', { 'email-select': `<custom-select name='email-account'>${createEmailOptions(data.breachesData)}</custom-select>` })}</h1>
78
    <figure>
79
      <img src='/images/temp-diagram.png' width='80' height='80'>
80
      <figcaption class='breach-stats'>
81
        <strong>10 total breaches</strong>
82
        <label>Resolved</label>
83
        <label>Unresolved</label>
84
      </figcaption>
85
    </figure>
86
    <figure class='email-stats'>
87
      <img src='/images/icon-email.svg' width='55' height='30'>
88
      <figcaption>
89
        <strong>${getMessage('emails-monitored', { count: data.emailCount, total: AppConstants.MAX_NUM_ADDRESSES })}</strong>
90
        ${createEmailCTA(data.emailCount)}
91
      </figcaption>
92
    </figure>
93
  </header>
94
</section>
95
<section class='breaches-filter'>
96
  <input id='breaches-unresolved' type='radio' name='breaches-status' value='unresolved' checked>
97
  <label for='breaches-unresolved'><output>&nbsp;</output>${getMessage('filter-label-unresolved')}</label>
98
  <input id='breaches-resolved' type='radio' name='breaches-status' value='resolved'>
99
  <label for='breaches-resolved'><output>&nbsp;</output>${getMessage('filter-label-resolved')}</label>
100
</section>
101
<section class='breaches-table' data-token=${data.csrfToken}>
102
  <header>
103
    <span>${getMessage('column-company')}</span><span>${getMessage('column-breached-data')}</span><span>${getMessage('column-detected')}</span>
104
  </header>
105
  ${createBreachRows(data.breachesData)}
106
</section>
107
`
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