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

mozilla / blurts-server / 3fe052a3-a46d-4b6e-ac3b-1426227047d8

pending completion
3fe052a3-a46d-4b6e-ac3b-1426227047d8

push

circleci

GitHub
Merge pull request #2830 from mozilla/MNTOR-1160/add-new-email

282 of 1332 branches covered (21.17%)

Branch coverage included in aggregate %.

79 of 79 new or added lines in 7 files covered. (100.0%)

959 of 3548 relevant lines covered (27.03%)

4.39 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
  return `<a href='dialog/add-email'>${getMessage('add-email-link')}</a>`
×
21
}
22

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

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

64
  return breachRowsHTML.join('')
×
65
}
66

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

76
  return resolveStepsHTML.join('')
×
77
}
78

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