2020-11-11 17:36:05 +00:00
|
|
|
// Copyright 2020 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 { ContactModal, PropsType } from './ContactModal';
|
|
|
|
import { setup as setupI18n } from '../../../js/modules/i18n';
|
|
|
|
import enMessages from '../../../_locales/en/messages.json';
|
|
|
|
import { ConversationType } from '../../state/ducks/conversations';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf('Components/Conversation/ContactModal', module);
|
|
|
|
|
|
|
|
const defaultContact: ConversationType = {
|
|
|
|
id: 'abcdef',
|
|
|
|
lastUpdated: Date.now(),
|
|
|
|
markedUnread: false,
|
|
|
|
areWeAdmin: false,
|
|
|
|
title: 'Pauline Oliveros',
|
|
|
|
type: 'direct',
|
|
|
|
phoneNumber: '(333) 444-5515',
|
2021-01-26 01:01:19 +00:00
|
|
|
about: '👍 Free to chat',
|
2020-11-11 17:36:05 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
const createProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
|
|
|
areWeAdmin: boolean('areWeAdmin', overrideProps.areWeAdmin || false),
|
|
|
|
contact: overrideProps.contact || defaultContact,
|
|
|
|
i18n,
|
2021-01-29 21:19:24 +00:00
|
|
|
isAdmin: boolean('isAdmin', overrideProps.isAdmin || false),
|
2020-11-11 17:36:05 +00:00
|
|
|
isMember: boolean('isMember', overrideProps.isMember || true),
|
|
|
|
onClose: action('onClose'),
|
|
|
|
openConversation: action('openConversation'),
|
|
|
|
removeMember: action('removeMember'),
|
|
|
|
showSafetyNumber: action('showSafetyNumber'),
|
2021-01-29 21:19:24 +00:00
|
|
|
toggleAdmin: action('toggleAdmin'),
|
2020-11-11 17:36:05 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
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} />;
|
|
|
|
});
|