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

mozilla / blurts-server / #11788

pending completion
#11788

push

circleci

web-flow
Merge pull request #2741 from mozilla/MNTOR-802/conditional-hide-add-email-cta

Mntor 802/conditional hide add email cta

282 of 1124 branches covered (25.09%)

Branch coverage included in aggregate %.

13 of 13 new or added lines in 1 file covered. (100.0%)

959 of 3022 relevant lines covered (31.73%)

2.56 hits per line

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

0.0
/src/views/partials/breaches.js
1
import { getMessage, getLocale } from '../../utils/fluent.js'
2
import AppConstants from '../../app-constants.js'
3

4
function createEmailOptions (data) {
5
  const emails = data.verifiedEmails.map(obj => obj.email)
×
6
  const optionElements = emails.map(email => `<option>${email}</option>`)
×
7

8
  return optionElements.join('')
×
9
}
10

11
function createEmailCTA (count) {
12
  const total = parseInt(AppConstants.MAX_NUM_ADDRESSES)
×
13

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

16
  // TODO: link "add email" flow
17
  return `<a href='http://mozilla.org'>${getMessage('add-email-link')}</a>`
×
18
}
19

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

40
      return `
×
41
      <details class='breach-row' data-status=${status} data-email=${account.email} hidden=${!account.primary} hidden=${isHidden}>
42
        <summary>
43
          <span>${breach.Title}</span><span>${shortList.format(dataClassesTranslated)}</span><span>${shortDate.format(addedDate)}</span>
44
        </summary>
45
        <div>
46
          ${description}
47
        </div>
48
      </details>
49
      `
50
    })
51
  })
52

53
  return breachRowsHTML.join('')
×
54
}
55

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