2021-05-07 22:21:10 +00:00
|
|
|
// Copyright 2020-2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
|
|
|
|
|
|
|
import { storiesOf } from '@storybook/react';
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-09-18 00:30:08 +00:00
|
|
|
import { setupI18n } from '../../../util/setupI18n';
|
2021-01-29 21:19:24 +00:00
|
|
|
import enMessages from '../../../../_locales/en/messages.json';
|
|
|
|
import { GroupV2Permissions, PropsType } from './GroupV2Permissions';
|
|
|
|
import { ConversationType } from '../../../state/ducks/conversations';
|
|
|
|
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
|
|
|
const story = storiesOf(
|
|
|
|
'Components/Conversation/ConversationDetails/GroupV2Permissions',
|
|
|
|
module
|
|
|
|
);
|
|
|
|
|
2021-05-07 22:21:10 +00:00
|
|
|
const conversation: ConversationType = getDefaultConversation({
|
2021-01-29 21:19:24 +00:00
|
|
|
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
|
|
|
});
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
const createProps = (): PropsType => ({
|
|
|
|
conversation,
|
|
|
|
i18n,
|
|
|
|
setAccessControlAttributesSetting: action(
|
|
|
|
'setAccessControlAttributesSetting'
|
|
|
|
),
|
|
|
|
setAccessControlMembersSetting: action('setAccessControlMembersSetting'),
|
2021-07-20 20:18:35 +00:00
|
|
|
setAnnouncementsOnly: action('setAnnouncementsOnly'),
|
2021-01-29 21:19:24 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
story.add('Basic', () => {
|
|
|
|
const props = createProps();
|
|
|
|
|
|
|
|
return <GroupV2Permissions {...props} />;
|
|
|
|
});
|
2021-08-05 17:23:50 +00:00
|
|
|
|
|
|
|
story.add('Not admin', () => (
|
|
|
|
<GroupV2Permissions
|
|
|
|
{...createProps()}
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
announcementsOnly: true,
|
|
|
|
areWeAdmin: false,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Admin but not announcement ready', () => (
|
|
|
|
<GroupV2Permissions
|
|
|
|
{...createProps()}
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
announcementsOnlyReady: false,
|
|
|
|
areWeAdmin: true,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|
|
|
|
|
|
|
|
story.add('Admin, not announcement ready, but it was on', () => (
|
|
|
|
<GroupV2Permissions
|
|
|
|
{...createProps()}
|
|
|
|
conversation={getDefaultConversation({
|
|
|
|
announcementsOnly: true,
|
|
|
|
announcementsOnlyReady: false,
|
|
|
|
areWeAdmin: true,
|
|
|
|
})}
|
|
|
|
/>
|
|
|
|
));
|