-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
/
ContactModal.stories.tsx
100 lines (82 loc) · 2.73 KB
/
ContactModal.stories.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
// Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import { boolean } from '@storybook/addon-knobs';
import { storiesOf } from '@storybook/react';
import { getDefaultConversation } from '../../test-both/helpers/getDefaultConversation';
import type { PropsType } from './ContactModal';
import { ContactModal } from './ContactModal';
import { setupI18n } from '../../util/setupI18n';
import enMessages from '../../../_locales/en/messages.json';
import type { ConversationType } from '../../state/ducks/conversations';
import { getFakeBadges } from '../../test-both/helpers/getFakeBadge';
import { ThemeType } from '../../types/Util';
const i18n = setupI18n('en', enMessages);
const story = storiesOf('Components/Conversation/ContactModal', module);
const defaultContact: ConversationType = getDefaultConversation({
id: 'abcdef',
areWeAdmin: false,
title: 'Pauline Oliveros',
phoneNumber: '(333) 444-5515',
about: '👍 Free to chat',
});
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
areWeAdmin: boolean('areWeAdmin', overrideProps.areWeAdmin || false),
badges: overrideProps.badges || [],
contact: overrideProps.contact || defaultContact,
hideContactModal: action('hideContactModal'),
i18n,
isAdmin: boolean('isAdmin', overrideProps.isAdmin || false),
isMember: boolean('isMember', overrideProps.isMember || true),
openConversationInternal: action('openConversationInternal'),
removeMemberFromGroup: action('removeMemberFromGroup'),
theme: ThemeType.light,
toggleSafetyNumberModal: action('toggleSafetyNumberModal'),
toggleAdmin: action('toggleAdmin'),
updateConversationModelSharedGroups: action(
'updateConversationModelSharedGroups'
),
});
story.add('As non-admin', () => {
const props = createProps({
areWeAdmin: false,
});
return <ContactModal {...props} />;
});
story.add('As admin', () => {
const props = createProps({
areWeAdmin: true,
});
return <ContactModal {...props} />;
});
story.add('As admin, viewing non-member of group', () => {
const props = createProps({
isMember: false,
});
return <ContactModal {...props} />;
});
story.add('Without phone number', () => {
const props = createProps({
contact: {
...defaultContact,
phoneNumber: undefined,
},
});
return <ContactModal {...props} />;
});
story.add('Viewing self', () => {
const props = createProps({
contact: {
...defaultContact,
isMe: true,
},
});
return <ContactModal {...props} />;
});
story.add('With badges', () => {
const props = createProps({
badges: getFakeBadges(2),
});
return <ContactModal {...props} />;
});