signal-desktop/ts/components/conversation/conversation-details/ConversationDetailsActions.stories.tsx

72 lines
2.2 KiB
TypeScript
Raw Normal View History

// Copyright 2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { isBoolean } from 'lodash';
import { action } from '@storybook/addon-actions';
import type { Meta } from '@storybook/react';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../../util/setupI18n';
import enMessages from '../../../../_locales/en/messages.json';
import type { Props } from './ConversationDetailsActions';
import { ConversationDetailsActions } from './ConversationDetailsActions';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title:
'Components/Conversation/ConversationDetails/ConversationDetailsActions',
} satisfies Meta<Props>;
const createProps = (overrideProps: Partial<Props> = {}): Props => ({
2022-12-06 19:03:09 +00:00
acceptConversation: action('acceptConversation'),
blockConversation: action('blockConversation'),
cannotLeaveBecauseYouAreLastAdmin: isBoolean(
overrideProps.cannotLeaveBecauseYouAreLastAdmin
)
? overrideProps.cannotLeaveBecauseYouAreLastAdmin
: false,
2022-12-06 19:03:09 +00:00
conversationId: '123',
conversationTitle: overrideProps.conversationTitle || '',
i18n,
isBlocked: isBoolean(overrideProps.isBlocked),
isGroup: true,
2022-12-06 19:03:09 +00:00
left: isBoolean(overrideProps.left) ? overrideProps.left : false,
onLeave: action('onLeave'),
});
2022-11-18 00:45:19 +00:00
export function Basic(): JSX.Element {
const props = createProps();
return <ConversationDetailsActions {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function LeftTheGroup(): JSX.Element {
const props = createProps({ left: true });
return <ConversationDetailsActions {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function BlockedAndLeftTheGroup(): JSX.Element {
const props = createProps({
left: true,
isBlocked: true,
conversationTitle: '😸 Cat Snaps',
});
return <ConversationDetailsActions {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-11-18 00:45:19 +00:00
export function CannotLeaveBecauseYouAreTheLastAdmin(): JSX.Element {
const props = createProps({ cannotLeaveBecauseYouAreLastAdmin: true });
return <ConversationDetailsActions {...props} />;
2022-11-18 00:45:19 +00:00
}
2022-06-07 00:48:02 +00:00
export const _11 = (): JSX.Element => (
<ConversationDetailsActions {...createProps()} isGroup={false} />
2022-06-07 00:48:02 +00:00
);
export const _11Blocked = (): JSX.Element => (
<ConversationDetailsActions {...createProps()} isGroup={false} isBlocked />
2022-06-07 00:48:02 +00:00
);