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

mozilla / blurts-server / #12356

pending completion
#12356

push

circleci

web-flow
Merge pull request #2848 from mozilla/MNTOR-1188/breaches-email-count

Mntor 1188/breaches email count

282 of 1374 branches covered (20.52%)

Branch coverage included in aggregate %.

12 of 12 new or added lines in 4 files covered. (100.0%)

959 of 3725 relevant lines covered (25.74%)

2.09 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 createBreachRows (data) {
16
  const locale = getLocale()
×
17
  const shortDate = new Intl.DateTimeFormat(locale, { year: 'numeric', month: '2-digit', day: '2-digit', timeZone: 'UTC' })
×
18
  const shortList = new Intl.ListFormat(locale, { style: 'narrow' })
×
19
  const longDate = new Intl.DateTimeFormat(locale, { dateStyle: 'long', timeZone: 'UTC' })
×
20
  const longList = new Intl.ListFormat(locale, { style: 'long' })
×
21
  const breachRowsHTML = data.verifiedEmails.flatMap(account => {
×
22
    return account.breaches.map(breach => {
×
23
      const isHidden = !account.primary || breach.IsResolved // initial breach hidden state
×
24
      const status = breach.IsResolved ? 'resolved' : 'unresolved'
×
25
      const breachDate = Date.parse(breach.BreachDate)
×
26
      const addedDate = Date.parse(breach.AddedDate)
×
27
      const dataClassesTranslated = breach.DataClasses.map(item => getMessage(item))
×
28
      const description = getMessage('breach-description', {
×
29
        companyName: breach.Title,
30
        breachDate: longDate.format(breachDate),
31
        addedDate: longDate.format(addedDate),
32
        dataClasses: longList.format(dataClassesTranslated)
33
      })
34

35
      return `
×
36
      <details class='breach-row' data-status=${status} data-email=${account.email} ${isHidden ? 'hidden' : ''}>
×
37
        <summary>
38
          <span>${breach.Title}</span>
39
          <span>${shortList.format(dataClassesTranslated)}</span>
40
          <span>
41
            <span class='resolution-badge is-resolved'>${getMessage('column-status-badge-resolved')}</span>
42
            <span class='resolution-badge is-active'>${getMessage('column-status-badge-active')}</span>
43
          </span>
44
          <span>${shortDate.format(addedDate)}</span>
45
        </summary>
46
        <article>
47
          <p>${description}</p>
48
          <p><strong>Resolve this breach:</strong></p>
49
          <ol class='resolve-list'>${createResolveSteps(breach)}</ol>
50
        </article>
51
      </details>
52
      `
53
    })
54
  })
55

56
  return breachRowsHTML.join('')
×
57
}
58

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

68
  return resolveStepsHTML.join('')
×
69
}
70

71
export const breaches = data => `
×
72
<section>
73
  <header class='breaches-header'>
74
    <h1>${getMessage('breach-heading-email', { 'email-select': `<custom-select name='email-account'>${createEmailOptions(data.breachesData)}</custom-select>` })}</h1>
75
    <figure>
76
      <img src='/images/temp-diagram.webp' width='80' height='80'>
77
      <figcaption class='breach-stats'>
78
        <strong>10 total breaches</strong>
79
        <label>Resolved</label>
80
        <label>Unresolved</label>
81
      </figcaption>
82
    </figure>
83
    <figure class='email-stats' data-count=${data.emailTotalCount} data-total=${AppConstants.MAX_NUM_ADDRESSES}>
84
      <img src='/images/icon-email.svg' width='55' height='30'>
85
      <figcaption>
86
        <strong>${getMessage('emails-monitored', { count: data.emailVerifiedCount, total: AppConstants.MAX_NUM_ADDRESSES })}</strong>
87
        <a href='/user/settings'>${getMessage('manage-emails-link')}</a>
88
      </figcaption>
89
    </figure>
90
  </header>
91
</section>
92
<fieldset class='breaches-filter'>
93
  <input id='breaches-unresolved' type='radio' name='breaches-status' value='unresolved' autocomplete='off' checked>
94
  <label for='breaches-unresolved'><output>&nbsp;</output>${getMessage('filter-label-unresolved')}</label>
95
  <input id='breaches-resolved' type='radio' name='breaches-status' value='resolved' autocomplete='off'>
96
  <label for='breaches-resolved'><output>&nbsp;</output>${getMessage('filter-label-resolved')}</label>
97
</fieldset>
98
<section class='breaches-table' data-token=${data.csrfToken}>
99
  <header>
100
    <span>${getMessage('column-company')}</span>
101
    <span>${getMessage('column-breached-data')}</span>
102
    ${
103
      /*
104
       * The active/resolved badge does not have a column header, but by
105
       * including an empty <span>, we can re-use the `nth-child`-based
106
       * selectors for the content columns.
107
       */
108
      '<span></span>'
109
    }
110
    <span>${getMessage('column-detected')}</span>
111
  </header>
112
  ${createBreachRows(data.breachesData)}
113
  <template class='no-breaches'>
114
    <div class="zero-state no-breaches-message">
115
      <img src='/images/breaches-none.svg' alt='' width="136" height="102" />
116
      <h2>${getMessage('breaches-none-headline')}</h2>
117
      <p>${getMessage('breaches-none-copy', { email: '<b class="current-email"></b>' })}</p>
118
      <p class='add-email-cta'>
119
        <span>${getMessage('breaches-none-cta-blurb')}</span>
120
        <button class='primary' data-dialog='add-email'>${getMessage('breaches-none-cta-button')}</button>
121
      </p>
122
    </div>
123
  </template>
124
  <template class='all-breaches-resolved'>
125
    <div class="zero-state all-breaches-resolved-message">
126
      <img src='/images/breaches-all-resolved.svg' alt='' width="136" height="102" />
127
      <h2>${getMessage('breaches-all-resolved-headline')}</h2>
128
      <p>${getMessage('breaches-all-resolved-copy', { email: '<b class="current-email"></b>' })}</p>
129
      <p class='add-email-cta'>
130
        <span>${getMessage('breaches-all-resolved-cta-blurb')}</span>
131
        <button class='primary' data-dialog='add-email'>${getMessage('breaches-all-resolved-cta-button')}</button>
132
      </p>
133
    </div>
134
  </template>
135
</section>
136
`
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