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

mozilla / blurts-server / #11898

pending completion
#11898

push

circleci

web-flow
Merge pull request #2770 from mozilla/license

Add license headers in source files

282 of 1138 branches covered (24.78%)

Branch coverage included in aggregate %.

959 of 3049 relevant lines covered (31.45%)

2.55 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
        <div>
50
          ${description}
51
        </div>
52
      </details>
53
      `
54
    })
55
  })
56

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

60
export const breaches = data => `
×
61
<section>
62
  <header class='breaches-header'>
63
    <h1>${getMessage('breach-heading-email', { 'email-select': `<custom-select>${createEmailOptions(data.breachesData)}</custom-select>` })}</h1>
64
    <figure>
65
      <img src='/images/temp-diagram.png' width='80' height='80'>
66
      <figcaption class='breach-stats'>
67
        <strong>10 total breaches</strong>
68
        <label>Resolved</label>
69
        <label>Unresolved</label>
70
      </figcaption>
71
    </figure>
72
    <figure class='email-stats'>
73
      <img src='/images/icon-email.svg' width='55' height='30'>
74
      <figcaption>
75
        <strong>${getMessage('emails-monitored', { count: data.emailCount, total: AppConstants.MAX_NUM_ADDRESSES })}</strong>
76
        ${createEmailCTA(data.emailCount)}
77
      </figcaption>
78
    </figure>
79
  </header>
80
</section>
81
<section class='breaches-filter'>
82
  <input id='breaches-unresolved' type='radio' name='breaches-status' value='unresolved' checked>
83
  <label for='breaches-unresolved'><output>&nbsp;</output>${getMessage('filter-label-unresolved')}</label>
84
  <input id='breaches-resolved' type='radio' name='breaches-status' value='resolved'>
85
  <label for='breaches-resolved'><output>&nbsp;</output>${getMessage('filter-label-resolved')}</label>
86
</section>
87
<section class='breaches-table'>
88
  <header>
89
    <span>${getMessage('column-company')}</span><span>${getMessage('column-breached-data')}</span><span>${getMessage('column-detected')}</span>
90
  </header>
91
  ${createBreachRows(data.breachesData)}
92
</section>
93
<section style='display:none'>
94
  <!--This is a temp section/button to test breach update post-->
95
  <button id="update-breaches">Update Breaches</button>
96
  <pre>${JSON.stringify(data.breachesData, null, 2)}</pre>
97
</section>
98
`
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