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

IQSS / dataverse-frontend / 10219381635

02 Aug 2024 05:08PM CUT coverage: 98.403%. Remained the same
10219381635

push

github

GermanSaracca
feat: back to disable button

86 of 90 branches covered (95.56%)

Branch coverage included in aggregate %.

222 of 223 relevant lines covered (99.55%)

198.27 hits per line

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

100.0
/packages/design-system/src/lib/components/alert/Alert.tsx
1
import { Alert as AlertBS } from 'react-bootstrap'
2
import { AlertVariant } from './AlertVariant'
3
import { AlertIcon } from './AlertIcon'
4
import { ReactNode, useState } from 'react'
5
import { AlertLink } from './AlertLink'
6

7
interface AlertProps {
8
  variant: AlertVariant
9
  dismissible?: boolean
10
  customHeading?: string
11
  children: ReactNode
12
}
13

14
function Alert({ variant, dismissible = true, customHeading, children }: AlertProps) {
228✔
15
  interface AlertHeadings {
16
    [key: string]: string
17
  }
18

19
  const ALERT_HEADINGS: AlertHeadings = {
228✔
20
    success: 'Success!',
21
    info: 'Information',
22
    warning: 'Warning',
23
    danger: 'Error'
24
  }
25
  const [show, setShow] = useState(true)
228✔
26

27
  function getAlertHeading(variant: AlertVariant, customHeading?: string): string {
28
    return customHeading ?? ALERT_HEADINGS[variant]
228✔
29
  }
30
  const heading = getAlertHeading(variant, customHeading)
228✔
31

32
  return (
228✔
33
    <>
34
      {show && (
438✔
35
        <AlertBS variant={variant} onClose={() => setShow(false)} dismissible={dismissible}>
18✔
36
          <AlertIcon variant={variant} />
37
          &nbsp;
38
          <b>{heading}</b> - {children}
39
        </AlertBS>
40
      )}
41
    </>
42
  )
43
}
48✔
44
Alert.Link = AlertLink
48✔
45

46
export { Alert }
48✔
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