signal-desktop/ts/components/conversation/MessageRequestActions.stories.tsx

105 lines
2.8 KiB
TypeScript
Raw Normal View History

2023-01-03 19:55:46 +00:00
// Copyright 2020 Signal Messenger, LLC
2020-10-30 20:34:04 +00:00
// SPDX-License-Identifier: AGPL-3.0-only
2020-05-27 21:37:06 +00:00
import * as React from 'react';
import { action } from '@storybook/addon-actions';
import type { Meta } from '@storybook/react';
import { MessageRequestActions } from './MessageRequestActions';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../util/setupI18n';
2020-05-27 21:37:06 +00:00
import enMessages from '../../../_locales/en/messages.json';
2024-03-12 16:29:31 +00:00
import {
getDefaultConversation,
getDefaultGroup,
} from '../../test-both/helpers/getDefaultConversation';
2020-05-27 21:37:06 +00:00
const i18n = setupI18n('en', enMessages);
2024-03-12 16:29:31 +00:00
type Args = {
conversationType: 'direct' | 'group';
isBlocked: boolean;
isHidden: boolean;
isReported: boolean;
};
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/MessageRequestActions',
argTypes: {
conversationType: {
control: {
type: 'select',
options: ['direct', 'group'],
},
},
},
args: {
conversationType: 'direct',
},
decorators: [
(Story: React.ComponentType): JSX.Element => {
return (
<div style={{ width: '480px' }}>
<Story />
</div>
);
},
],
2024-03-12 16:29:31 +00:00
} satisfies Meta<Args>;
function Example(args: Args): JSX.Element {
const conversation =
args.conversationType === 'group'
? getDefaultGroup()
: getDefaultConversation();
const addedBy =
args.conversationType === 'group' ? getDefaultConversation() : conversation;
return (
<MessageRequestActions
addedByName={addedBy}
conversationType={conversation.type}
conversationId={conversation.id}
conversationName={conversation}
i18n={i18n}
isBlocked={args.isBlocked}
isHidden={args.isHidden}
isReported={args.isReported}
acceptConversation={action('acceptConversation')}
blockAndReportSpam={action('blockAndReportSpam')}
blockConversation={action('blockConversation')}
deleteConversation={action('deleteConversation')}
reportSpam={action('reportSpam')}
/>
);
}
export function Direct(args: Args): JSX.Element {
return <Example {...args} />;
}
export function DirectBlocked(args: Args): JSX.Element {
return <Example {...args} isBlocked />;
}
export function DirectReported(args: Args): JSX.Element {
return <Example {...args} isReported />;
}
export function DirectBlockedAndReported(args: Args): JSX.Element {
return <Example {...args} isBlocked isReported />;
}
2024-03-12 16:29:31 +00:00
export function Group(args: Args): JSX.Element {
return <Example {...args} conversationType="group" />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
2024-03-12 16:29:31 +00:00
export function GroupBlocked(args: Args): JSX.Element {
return <Example {...args} conversationType="group" isBlocked />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
2024-03-12 16:29:31 +00:00
export function GroupReported(args: Args): JSX.Element {
return <Example {...args} conversationType="group" isReported />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
2024-03-12 16:29:31 +00:00
export function GroupBlockedAndReported(args: Args): JSX.Element {
return <Example {...args} conversationType="group" isBlocked isReported />;
2022-11-18 00:45:19 +00:00
}