From e5b40aa2ef652ca83715c41176b57ea56d657aaa Mon Sep 17 00:00:00 2001 From: Evan Hahn <69474926+EvanHahn-Signal@users.noreply.github.com> Date: Thu, 18 Nov 2021 16:27:48 -0600 Subject: [PATCH] Show badges on group invites screen --- .../PendingInvites.stories.tsx | 15 +++++++++-- .../conversation-details/PendingInvites.tsx | 25 ++++++++++++++++++- ts/state/smart/PendingInvites.tsx | 5 +++- 3 files changed, 41 insertions(+), 4 deletions(-) diff --git a/ts/components/conversation/conversation-details/PendingInvites.stories.tsx b/ts/components/conversation/conversation-details/PendingInvites.stories.tsx index 82ddb79060..667cf69da5 100644 --- a/ts/components/conversation/conversation-details/PendingInvites.stories.tsx +++ b/ts/components/conversation/conversation-details/PendingInvites.stories.tsx @@ -14,6 +14,8 @@ import type { PropsType } from './PendingInvites'; import { PendingInvites } from './PendingInvites'; import type { ConversationType } from '../../../state/ducks/conversations'; import { getDefaultConversation } from '../../../test-both/helpers/getDefaultConversation'; +import { getFakeBadge } from '../../../test-both/helpers/getFakeBadge'; +import { StorybookThemeContext } from '../../../../.storybook/StorybookThemeContext'; const i18n = setupI18n('en', enMessages); @@ -44,9 +46,10 @@ const conversation: ConversationType = { const OUR_UUID = UUID.generate().toString(); -const createProps = (): PropsType => ({ +const useProps = (overrideProps: Partial = {}): PropsType => ({ approvePendingMembership: action('approvePendingMembership'), conversation, + getPreferredBadge: () => undefined, i18n, ourUuid: OUR_UUID, pendingApprovalMemberships: times(5, () => ({ @@ -67,10 +70,18 @@ const createProps = (): PropsType => ({ })), ], revokePendingMemberships: action('revokePendingMemberships'), + theme: React.useContext(StorybookThemeContext), + ...overrideProps, }); story.add('Basic', () => { - const props = createProps(); + const props = useProps(); + + return ; +}); + +story.add('With badges', () => { + const props = useProps({ getPreferredBadge: () => getFakeBadge() }); return ; }); diff --git a/ts/components/conversation/conversation-details/PendingInvites.tsx b/ts/components/conversation/conversation-details/PendingInvites.tsx index 734690e000..0d3cb47f5f 100644 --- a/ts/components/conversation/conversation-details/PendingInvites.tsx +++ b/ts/components/conversation/conversation-details/PendingInvites.tsx @@ -6,7 +6,8 @@ import classNames from 'classnames'; import _ from 'lodash'; import type { ConversationType } from '../../../state/ducks/conversations'; -import type { LocalizerType } from '../../../types/Util'; +import type { LocalizerType, ThemeType } from '../../../types/Util'; +import type { PreferredBadgeSelectorType } from '../../../state/selectors/badges'; import type { UUIDStringType } from '../../../types/UUID'; import { Avatar } from '../../Avatar'; import { ConfirmationDialog } from '../../ConfirmationDialog'; @@ -16,12 +17,14 @@ import { ConversationDetailsIcon, IconType } from './ConversationDetailsIcon'; export type PropsType = { readonly conversation?: ConversationType; + readonly getPreferredBadge: PreferredBadgeSelectorType; readonly i18n: LocalizerType; readonly ourUuid: UUIDStringType; readonly pendingApprovalMemberships: ReadonlyArray; readonly pendingMemberships: ReadonlyArray; readonly approvePendingMembership: (conversationId: string) => void; readonly revokePendingMemberships: (conversationIds: Array) => void; + readonly theme: ThemeType; }; export type GroupV2PendingMembership = { @@ -54,11 +57,13 @@ type StagedMembershipType = { export const PendingInvites: React.ComponentType = ({ approvePendingMembership, conversation, + getPreferredBadge, i18n, ourUuid, pendingMemberships, pendingApprovalMemberships, revokePendingMemberships, + theme, }) => { if (!conversation || !ourUuid) { throw new Error( @@ -119,19 +124,23 @@ export const PendingInvites: React.ComponentType = ({ {selectedTab === Tab.Requests ? ( ) : null} {selectedTab === Tab.Pending ? ( ) : null} @@ -290,14 +299,18 @@ function getConfirmationMessage({ function MembersPendingAdminApproval({ conversation, + getPreferredBadge, i18n, memberships, setStagedMemberships, + theme, }: Readonly<{ conversation: ConversationType; + getPreferredBadge: PreferredBadgeSelectorType; i18n: LocalizerType; memberships: ReadonlyArray; setStagedMemberships: (stagedMembership: Array) => void; + theme: ThemeType; }>) { return ( @@ -307,9 +320,11 @@ function MembersPendingAdminApproval({ key={membership.member.id} icon={ } @@ -364,13 +379,17 @@ function MembersPendingProfileKey({ memberships, ourUuid, setStagedMemberships, + getPreferredBadge, + theme, }: Readonly<{ conversation: ConversationType; + getPreferredBadge: PreferredBadgeSelectorType; i18n: LocalizerType; members: Array; memberships: ReadonlyArray; ourUuid: string; setStagedMemberships: (stagedMembership: Array) => void; + theme: ThemeType; }>) { const groupedPendingMemberships = _.groupBy( memberships, @@ -397,9 +416,11 @@ function MembersPendingProfileKey({ key={membership.member.id} icon={ } @@ -431,9 +452,11 @@ function MembersPendingProfileKey({ key={member.id} icon={ } diff --git a/ts/state/smart/PendingInvites.tsx b/ts/state/smart/PendingInvites.tsx index 45291fb451..281c6d3353 100644 --- a/ts/state/smart/PendingInvites.tsx +++ b/ts/state/smart/PendingInvites.tsx @@ -7,7 +7,8 @@ import type { PropsType } from '../../components/conversation/conversation-detai import { PendingInvites } from '../../components/conversation/conversation-details/PendingInvites'; import type { StateType } from '../reducer'; -import { getIntl } from '../selectors/user'; +import { getIntl, getTheme } from '../selectors/user'; +import { getPreferredBadgeSelector } from '../selectors/badges'; import { getConversationByIdSelector, getConversationByUuidSelector, @@ -40,7 +41,9 @@ const mapStateToProps = ( ...props, ...getGroupMemberships(conversation, conversationByUuidSelector), conversation, + getPreferredBadge: getPreferredBadgeSelector(state), i18n: getIntl(state), + theme: getTheme(state), }; };