2021-04-29 18:32:38 +00:00
|
|
|
// Copyright 2021 Signal Messenger, LLC
|
2021-01-29 21:19:24 +00:00
|
|
|
// SPDX-License-Identifier: AGPL-3.0-only
|
|
|
|
|
|
|
|
import * as React from 'react';
|
2021-04-29 18:32:38 +00:00
|
|
|
import { times } from 'lodash';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
import { action } from '@storybook/addon-actions';
|
|
|
|
|
2021-10-26 22:59:08 +00:00
|
|
|
import { UUID } from '../../../types/UUID';
|
2022-11-19 08:31:18 +00:00
|
|
|
import { StorySendMode } from '../../../types/Stories';
|
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';
|
2021-10-26 19:15:33 +00:00
|
|
|
import type { PropsType } from './PendingInvites';
|
|
|
|
import { PendingInvites } from './PendingInvites';
|
|
|
|
import type { ConversationType } from '../../../state/ducks/conversations';
|
2021-01-29 21:19:24 +00:00
|
|
|
import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation';
|
2021-11-18 22:27:48 +00:00
|
|
|
import { getFakeBadge } from '../../../test-both/helpers/getFakeBadge';
|
|
|
|
import { StorybookThemeContext } from '../../../../.storybook/StorybookThemeContext';
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
const i18n = setupI18n('en', enMessages);
|
|
|
|
|
2022-06-07 00:48:02 +00:00
|
|
|
export default {
|
|
|
|
title: 'Components/Conversation/ConversationDetails/PendingInvites',
|
|
|
|
};
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
const sortedGroupMembers = Array.from(Array(32)).map((_, i) =>
|
|
|
|
i === 0
|
|
|
|
? getDefaultConversation({ id: 'def456' })
|
|
|
|
: getDefaultConversation({})
|
|
|
|
);
|
|
|
|
|
|
|
|
const conversation: ConversationType = {
|
2021-05-07 22:21:10 +00:00
|
|
|
acceptedMessageRequest: true,
|
2021-01-29 21:19:24 +00:00
|
|
|
areWeAdmin: true,
|
2021-11-02 23:01:13 +00:00
|
|
|
badges: [],
|
2021-01-29 21:19:24 +00:00
|
|
|
id: '',
|
|
|
|
lastUpdated: 0,
|
|
|
|
markedUnread: false,
|
2021-05-07 22:21:10 +00:00
|
|
|
isMe: false,
|
2021-01-29 21:19:24 +00:00
|
|
|
sortedGroupMembers,
|
|
|
|
title: 'Some Conversation',
|
|
|
|
type: 'group',
|
2021-05-07 22:21:10 +00:00
|
|
|
sharedGroupNames: [],
|
2022-11-19 08:31:18 +00:00
|
|
|
acknowledgedGroupNameCollisions: {},
|
|
|
|
storySendMode: StorySendMode.IfActive,
|
2021-01-29 21:19:24 +00:00
|
|
|
};
|
|
|
|
|
2021-10-26 22:59:08 +00:00
|
|
|
const OUR_UUID = UUID.generate().toString();
|
|
|
|
|
2021-11-18 22:27:48 +00:00
|
|
|
const useProps = (overrideProps: Partial<PropsType> = {}): PropsType => ({
|
2022-12-05 22:56:23 +00:00
|
|
|
approvePendingMembershipFromGroupV2: action(
|
|
|
|
'approvePendingMembershipFromGroupV2'
|
|
|
|
),
|
2021-01-29 21:19:24 +00:00
|
|
|
conversation,
|
2021-11-18 22:27:48 +00:00
|
|
|
getPreferredBadge: () => undefined,
|
2021-01-29 21:19:24 +00:00
|
|
|
i18n,
|
2021-10-26 22:59:08 +00:00
|
|
|
ourUuid: OUR_UUID,
|
2021-04-29 18:32:38 +00:00
|
|
|
pendingApprovalMemberships: times(5, () => ({
|
|
|
|
member: getDefaultConversation(),
|
|
|
|
})),
|
|
|
|
pendingMemberships: [
|
|
|
|
...times(4, () => ({
|
|
|
|
member: getDefaultConversation(),
|
|
|
|
metadata: {
|
2021-10-26 22:59:08 +00:00
|
|
|
addedByUserId: OUR_UUID,
|
2021-04-29 18:32:38 +00:00
|
|
|
},
|
|
|
|
})),
|
|
|
|
...times(8, () => ({
|
|
|
|
member: getDefaultConversation(),
|
|
|
|
metadata: {
|
2021-10-26 22:59:08 +00:00
|
|
|
addedByUserId: UUID.generate().toString(),
|
2021-04-29 18:32:38 +00:00
|
|
|
},
|
|
|
|
})),
|
|
|
|
],
|
2022-12-05 22:56:23 +00:00
|
|
|
revokePendingMembershipsFromGroupV2: action(
|
|
|
|
'revokePendingMembershipsFromGroupV2'
|
|
|
|
),
|
2021-11-18 22:27:48 +00:00
|
|
|
theme: React.useContext(StorybookThemeContext),
|
|
|
|
...overrideProps,
|
2021-01-29 21:19:24 +00:00
|
|
|
});
|
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function Basic(): JSX.Element {
|
2021-11-18 22:27:48 +00:00
|
|
|
const props = useProps();
|
|
|
|
|
|
|
|
return <PendingInvites {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2021-11-18 22:27:48 +00:00
|
|
|
|
2022-11-18 00:45:19 +00:00
|
|
|
export function WithBadges(): JSX.Element {
|
2021-11-18 22:27:48 +00:00
|
|
|
const props = useProps({ getPreferredBadge: () => getFakeBadge() });
|
2021-01-29 21:19:24 +00:00
|
|
|
|
|
|
|
return <PendingInvites {...props} />;
|
2022-11-18 00:45:19 +00:00
|
|
|
}
|
2022-06-07 00:48:02 +00:00
|
|
|
|
|
|
|
WithBadges.story = {
|
|
|
|
name: 'With badges',
|
|
|
|
};
|