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

91 lines
2.4 KiB
TypeScript
Raw Normal View History

2021-05-07 22:21:10 +00:00
// Copyright 2020-2021 Signal Messenger, LLC
// SPDX-License-Identifier: AGPL-3.0-only
import * as React from 'react';
import { action } from '@storybook/addon-actions';
2021-09-18 00:30:08 +00:00
import { setupI18n } from '../../../util/setupI18n';
import enMessages from '../../../../_locales/en/messages.json';
import type { PropsType } from './GroupV2Permissions';
import { GroupV2Permissions } from './GroupV2Permissions';
import type { ConversationType } from '../../../state/ducks/conversations';
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
const i18n = setupI18n('en', enMessages);
2022-06-07 00:48:02 +00:00
export default {
title: 'Components/Conversation/ConversationDetails/GroupV2Permissions',
};
2021-05-07 22:21:10 +00:00
const conversation: ConversationType = getDefaultConversation({
id: '',
lastUpdated: 0,
memberships: Array(32).fill({ member: getDefaultConversation({}) }),
pendingMemberships: Array(16).fill({ member: getDefaultConversation({}) }),
title: 'Some Conversation',
type: 'group',
2021-05-07 22:21:10 +00:00
sharedGroupNames: [],
2021-07-20 20:18:35 +00:00
announcementsOnlyReady: true,
areWeAdmin: true,
2021-05-07 22:21:10 +00:00
});
const createProps = (): PropsType => ({
conversation,
i18n,
setAccessControlAttributesSetting: action(
'setAccessControlAttributesSetting'
),
setAccessControlMembersSetting: action('setAccessControlMembersSetting'),
2021-07-20 20:18:35 +00:00
setAnnouncementsOnly: action('setAnnouncementsOnly'),
});
2022-06-07 00:48:02 +00:00
export const Basic = (): JSX.Element => {
const props = createProps();
return <GroupV2Permissions {...props} />;
2022-06-07 00:48:02 +00:00
};
2022-06-07 00:48:02 +00:00
export const NotAdmin = (): JSX.Element => (
<GroupV2Permissions
{...createProps()}
conversation={getDefaultConversation({
announcementsOnly: true,
areWeAdmin: false,
})}
/>
2022-06-07 00:48:02 +00:00
);
NotAdmin.story = {
name: 'Not admin',
};
2022-06-07 00:48:02 +00:00
export const AdminButNotAnnouncementReady = (): JSX.Element => (
<GroupV2Permissions
{...createProps()}
conversation={getDefaultConversation({
announcementsOnlyReady: false,
areWeAdmin: true,
})}
/>
2022-06-07 00:48:02 +00:00
);
AdminButNotAnnouncementReady.story = {
name: 'Admin but not announcement ready',
};
2022-06-07 00:48:02 +00:00
export const AdminNotAnnouncementReadyButItWasOn = (): JSX.Element => (
<GroupV2Permissions
{...createProps()}
conversation={getDefaultConversation({
announcementsOnly: true,
announcementsOnlyReady: false,
areWeAdmin: true,
})}
/>
2022-06-07 00:48:02 +00:00
);
AdminNotAnnouncementReadyButItWasOn.story = {
name: 'Admin, not announcement ready, but it was on',
};