UNPKG

2.36 kBJavaScriptView Raw
1import React from 'react'
2import { storiesOf } from '@storybook/react'
3import { action } from '@storybook/addon-actions'
4import { ErrorModal } from '../src'
5
6storiesOf('Error Component', module)
7 .add('Custom String Message', () => (
8 <ErrorModal modalInfo="Custom Error Message" setModalInfo={action('setting modal info')} />
9 ))
10 .add('Http Error', () => (
11 <ErrorModal
12 modalInfo={{
13 httpError: true,
14 errorMsg: 'Some Http Error',
15 targetUrl: 'http://localhost:9001/nowhere',
16 }}
17 setModalInfo={action('setting modal info')}
18 />
19 ))
20 .add('Error with Stacktrace', () => {
21 const err = new Error('Some Thrown Error')
22 return <ErrorModal modalInfo={err} setModalInfo={action('setting modal info')} />
23 })
24 .add('Application Error', () => {
25 return (
26 <ErrorModal
27 modalInfo={{
28 restfulStatus: 'FAILURE',
29 errorMsg: 'Failure via application exception with no stack trace',
30 }}
31 setModalInfo={action('setting modal info')}
32 />
33 )
34 })
35 .add('Application Error (Stack trace)', () => {
36 return (
37 <ErrorModal
38 modalInfo={{
39 restfulStatus: 'FAILURE',
40 errorMsg: 'Failure via application exception stack trace',
41 stackTrace: '<Java Stack Trace here>',
42 }}
43 setModalInfo={action('setting modal info')}
44 />
45 )
46 })
47 .add('Validation Warning', () => (
48 <ErrorModal
49 modalInfo={{
50 restfulStatus: 'WARNING',
51 validationError: [
52 {
53 errorCode: -1,
54 severity: 'warn',
55 msg: 'Some validation warn 1',
56 },
57 {
58 errorCode: -1,
59 severity: 'warn',
60 msg: 'Some validation warn 2',
61 },
62 ],
63 }}
64 setModalInfo={action('setting modal info')}
65 />
66 ))
67 .add('Validation Error', () => (
68 <ErrorModal
69 modalInfo={{
70 restfulStatus: 'INVALID',
71 validationError: [
72 {
73 errorCode: -1,
74 severity: 'error',
75 msg: 'Some validation error 1',
76 data: [{ key1: 'a', key2: 'b' }],
77 },
78 {
79 errorCode: -1,
80 severity: 'error',
81 msg: 'Some validation error 2',
82 },
83 ],
84 }}
85 setModalInfo={action('setting modal info')}
86 />
87 ))