Skip to content

Commit

Permalink
Merge pull request #1892 from daostack/cw-1838-show-user-space-intro
Browse files Browse the repository at this point in the history
Show user space intro in UserInfoPopup #1838
  • Loading branch information
andreymikhadyuk authored Jul 26, 2023
2 parents de6f753 + e26e46f commit fb2c2f3
Show file tree
Hide file tree
Showing 22 changed files with 130 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import {
Circle,
CirclesPermissions,
CommonMemberWithUserInfo,
DirectParent,
} from "@/shared/models";
import { CommonMember as CommonMemberModel } from "@/shared/models";
import { ContextMenuRef } from "@/shared/ui-kit";
Expand All @@ -29,6 +30,7 @@ interface CommonMemberProps {
commonMember?: (CommonMemberModel & CirclesPermissions) | null;
governanceCircles: Circle[];
isProject: boolean;
directParent?: DirectParent | null;
}

const CommonMember: FC<CommonMemberProps> = ({
Expand All @@ -39,6 +41,7 @@ const CommonMember: FC<CommonMemberProps> = ({
commonMember,
governanceCircles,
isProject,
directParent,
}) => {
const { isShowing, onClose, onOpen } = useModal(false);
const contextMenuRef = useRef<ContextMenuRef>(null);
Expand Down Expand Up @@ -141,6 +144,7 @@ const CommonMember: FC<CommonMemberProps> = ({
onClose={onClose}
isShowing={isShowing}
avatar={avatar}
directParent={directParent}
/>
</>
);
Expand Down
36 changes: 31 additions & 5 deletions src/pages/OldCommon/store/api.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,11 @@ import {
} from "@/pages/OldCommon/interfaces";
import { CreateDiscussionMessageDto } from "@/pages/OldCommon/interfaces";
import Api from "@/services/Api";
import { AllocateFundsTo, ApiEndpoint } from "@/shared/constants";
import {
AllocateFundsTo,
ApiEndpoint,
ProposalsTypes,
} from "@/shared/constants";
import { ModerationFlags } from "@/shared/interfaces/Moderation";
import { SubscriptionUpdateData } from "@/shared/interfaces/api/subscription";
import {
Expand Down Expand Up @@ -46,6 +50,7 @@ import {
Vote,
VoteWithUserInfo,
CommonMemberPreviewInfo,
DirectParent,
} from "@/shared/models";
import { BankAccountDetails as AddBankDetailsPayload } from "@/shared/models/BankAccountDetails";
import { NotificationItem } from "@/shared/models/Notification";
Expand Down Expand Up @@ -200,17 +205,38 @@ export async function fetchUserProposals(userId: string) {
);
}

/**
* For a space:
* 1. The commonId needs to be the direct parent id and not the space id.
* 2. circleId of the direct parent is required.
*/
export async function fetchUserMemberAdmittanceProposalWithCommonId(
userId: string,
commonId: string,
directParent?: DirectParent | null,
) {
const proposal = await firebase
let proposalQuery = firebase
.firestore()
.collection(Collection.Proposals)
.where("data.args.proposerId", "==", userId)
.where("data.args.commonId", "==", commonId)
.where("type", "==", "MEMBER_ADMITTANCE")
.get();
.where("data.args.commonId", "==", directParent?.commonId ?? commonId)
.where(
"type",
"==",
directParent?.circleId
? ProposalsTypes.ASSIGN_CIRCLE
: ProposalsTypes.MEMBER_ADMITTANCE,
);

if (directParent?.circleId) {
proposalQuery = proposalQuery.where(
"data.args.circleId",
"==",
directParent.circleId,
);
}

const proposal = await proposalQuery.get();

return transformFirebaseDataList<Proposal>(proposal)[0];
}
Expand Down
4 changes: 4 additions & 0 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import {
Circles,
CommonFeedObjectUserUnique,
CommonMember,
DirectParent,
Discussion,
DiscussionMessage,
Timestamp,
Expand Down Expand Up @@ -85,6 +86,7 @@ interface ChatComponentInterface {
isAuthorized?: boolean;
isHidden: boolean;
onMessagesAmountChange?: (newMessagesAmount: number) => void;
directParent?: DirectParent | null;
}

interface Messages {
Expand Down Expand Up @@ -122,6 +124,7 @@ export default function ChatComponent({
isHidden = false,
isCommonMemberFetched,
onMessagesAmountChange,
directParent,
}: ChatComponentInterface) {
const dispatch = useDispatch();
useZoomDisabling();
Expand Down Expand Up @@ -589,6 +592,7 @@ export default function ChatComponent({
feedItemId={feedItemId}
isLoading={isLoadingDiscussionMessages}
onMessageDelete={handleMessageDelete}
directParent={directParent}
/>
</div>
{isAuthorized && (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ import {
checkIsUserDiscussionMessage,
CommonFeedObjectUserUnique,
CommonMember,
DirectParent,
DiscussionMessage,
User,
} from "@/shared/models";
Expand Down Expand Up @@ -49,6 +50,7 @@ interface ChatContentInterface {
feedItemId: string;
isLoading: boolean;
onMessageDelete?: (messageId: string) => void;
directParent?: DirectParent | null;
}

const isToday = (someDate: Date) => {
Expand Down Expand Up @@ -81,6 +83,7 @@ const ChatContent: ForwardRefRenderFunction<
feedItemId,
isLoading,
onMessageDelete,
directParent,
},
chatContentRef,
) => {
Expand Down Expand Up @@ -255,6 +258,7 @@ const ChatContent: ForwardRefRenderFunction<
feedItemId={feedItemId}
commonMember={commonMember}
onMessageDelete={onMessageDelete}
directParent={directParent}
/>
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ export const FeedTab: FC<FeedTabProps> = (props) => {
feedItemId={chatItem.feedItemId}
lastSeenItem={chatItem.lastSeenItem}
seenOnce={chatItem.seenOnce}
directParent={common.directParent}
/>
</>
)}
Expand Down Expand Up @@ -170,6 +171,7 @@ export const FeedTab: FC<FeedTabProps> = (props) => {
discussion={chatItem.discussion}
feedItemId={chatItem.feedItemId}
lastSeenItem={chatItem.lastSeenItem}
directParent={common.directParent}
/>
)}
</ChatMobileModal>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ interface MembersTabProps {

export const MembersTab: FC<MembersTabProps> = (props) => {
const { activeTab, common, commonMember } = props;

return (
<div className={styles.container}>
<Container className={styles.tabNavigationContainer}>
Expand All @@ -25,6 +24,7 @@ export const MembersTab: FC<MembersTabProps> = (props) => {
governanceId={common.governanceId}
commonMember={commonMember}
isProject={checkIsProject(common)}
directParent={common.directParent}
/>
</Container>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,11 @@
import React, { FC, useEffect, useMemo } from "react";
import classNames from "classnames";
import { useCommonMembers } from "@/pages/OldCommon/hooks";
import { CirclesPermissions, CommonMember } from "@/shared/models";
import {
CirclesPermissions,
CommonMember,
DirectParent,
} from "@/shared/models";
import { Loader } from "@/shared/ui-kit";
import { MembersList } from "../MembersList";

Expand All @@ -10,10 +14,12 @@ interface MembersComponentProps {
governanceId: string | null;
commonMember: (CommonMember & CirclesPermissions) | null;
isProject: boolean;
directParent?: DirectParent | null;
}

const MembersComponent: FC<MembersComponentProps> = (props) => {
const { commonId, governanceId, commonMember, isProject } = props;
const { commonId, governanceId, commonMember, isProject, directParent } =
props;
const {
fetched: areCommonMembersFetched,
data: commonMembers,
Expand Down Expand Up @@ -49,6 +55,7 @@ const MembersComponent: FC<MembersComponentProps> = (props) => {
governanceId={governanceId}
commonMember={commonMember}
isProject={isProject}
directParent={directParent}
/>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ import React, { FC, memo, useEffect } from "react";
import { useDispatch, useSelector } from "react-redux";
import CommonMember from "@/pages/OldCommon/components/CommonDetailContainer/MembersComponent/CommonMemberComponent";
import { useGovernance } from "@/shared/hooks/useCases";
import { CirclesPermissions, CommonMemberWithUserInfo } from "@/shared/models";
import {
CirclesPermissions,
CommonMemberWithUserInfo,
DirectParent,
} from "@/shared/models";
import { CommonMember as CommonMemberModel } from "@/shared/models";
import { Loader } from "@/shared/ui-kit";
import { commonActions, selectRecentAssignedCircle } from "@/store/states";
Expand All @@ -14,6 +18,7 @@ interface MembersListComponentProps {
governanceId: string | null;
commonMember: (CommonMemberModel & CirclesPermissions) | null;
isProject: boolean;
directParent?: DirectParent | null;
}

const MembersList: FC<MembersListComponentProps> = ({
Expand All @@ -22,6 +27,7 @@ const MembersList: FC<MembersListComponentProps> = ({
governanceId,
commonMember,
isProject,
directParent,
}) => {
const {
data: governance,
Expand Down Expand Up @@ -63,6 +69,7 @@ const MembersList: FC<MembersListComponentProps> = ({
commonMember={commonMember}
governanceCircles={governanceCircles}
isProject={isProject}
directParent={directParent}
/>
);
})}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import {
Common,
CommonFeed,
CommonMember,
DirectParent,
Governance,
PredefinedTypes,
} from "@/shared/models";
Expand Down Expand Up @@ -49,6 +50,7 @@ interface DiscussionFeedCardProps {
getLastMessage: (options: GetLastMessageOptions) => TextEditorValue;
getNonAllowedItems?: GetNonAllowedItemsOptions;
onActiveItemDataChange?: (data: FeedLayoutItemChangeData) => void;
directParent?: DirectParent | null;
}

const DiscussionFeedCard: FC<DiscussionFeedCardProps> = (props) => {
Expand All @@ -72,6 +74,7 @@ const DiscussionFeedCard: FC<DiscussionFeedCardProps> = (props) => {
getLastMessage,
getNonAllowedItems,
onActiveItemDataChange,
directParent,
} = props;
const {
isShowing: isReportModalOpen,
Expand Down Expand Up @@ -238,6 +241,7 @@ const DiscussionFeedCard: FC<DiscussionFeedCardProps> = (props) => {
isMobileVersion={isMobileVersion}
commonId={commonId}
userId={item.userId}
directParent={directParent}
/>
<FeedCardContent
description={discussion?.message}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import avatarPlaceholderSrc from "@/shared/assets/images/avatar-placeholder.svg"
import { MenuButton, UserAvatar, UserInfoPopup } from "@/shared/components";
import { useModal } from "@/shared/hooks";
import { MenuItem } from "@/shared/interfaces";
import { DirectParent } from "@/shared/models";
import { DesktopMenu } from "@/shared/ui-kit";
import styles from "./FeedCardHeader.module.scss";

Expand All @@ -17,6 +18,7 @@ export interface FeedCardHeaderProps {
isMobileVersion?: boolean;
commonId: string;
userId?: string;
directParent?: DirectParent | null;
}

export const FeedCardHeader: React.FC<FeedCardHeaderProps> = (props) => {
Expand All @@ -30,6 +32,7 @@ export const FeedCardHeader: React.FC<FeedCardHeaderProps> = (props) => {
isMobileVersion = false,
commonId,
userId,
directParent,
} = props;
const {
isShowing: isShowingUserProfile,
Expand Down Expand Up @@ -59,6 +62,7 @@ export const FeedCardHeader: React.FC<FeedCardHeaderProps> = (props) => {
avatar={avatar}
isShowing={isShowingUserProfile}
onClose={onCloseUserProfile}
directParent={directParent}
/>
)}
</div>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/common/components/FeedItem/FeedItem.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
CommonFeed,
CommonFeedType,
CommonMember,
DirectParent,
} from "@/shared/models";
import { checkIsItemVisibleForUser } from "@/shared/utils";
import { useFeedItemSubscription } from "../../hooks";
Expand Down Expand Up @@ -33,6 +34,7 @@ interface FeedItemProps {
sizeKey?: string;
shouldCheckItemVisibility?: boolean;
onActiveItemDataChange?: (data: FeedLayoutItemChangeData) => void;
directParent?: DirectParent | null;
}

const FeedItem: FC<FeedItemProps> = (props) => {
Expand All @@ -55,6 +57,7 @@ const FeedItem: FC<FeedItemProps> = (props) => {
currentUserId,
shouldCheckItemVisibility = true,
onActiveItemDataChange,
directParent,
} = props;
const { onFeedItemUpdate, getLastMessage, getNonAllowedItems } =
useFeedItemContext();
Expand Down Expand Up @@ -89,6 +92,7 @@ const FeedItem: FC<FeedItemProps> = (props) => {
getNonAllowedItems,
isMobileVersion,
onActiveItemDataChange,
directParent,
};

if (item.data.type === CommonFeedType.Discussion) {
Expand Down
1 change: 1 addition & 0 deletions src/pages/common/components/FeedItems/FeedItems.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@ const FeedItems: FC<FeedItemsProps> = (props) => {
isMobileVersion={isTabletView}
userCircleIds={userCircleIds}
isPreviewMode
directParent={common.directParent}
/>
);
})}
Expand Down
3 changes: 3 additions & 0 deletions src/pages/commonFeed/components/FeedLayout/FeedLayout.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -414,6 +414,7 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
onActiveItemDataChange={(...args) =>
handleActiveFeedItemDataChange(...args, commonData?.id)
}
directParent={outerCommon?.directParent}
/>
);
}
Expand Down Expand Up @@ -448,6 +449,7 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
withTitle={settings?.withDesktopChatTitle}
titleRightContent={followFeedItemEl}
onMessagesAmountChange={handleMessagesAmountChange}
directParent={outerCommon?.directParent}
/>
) : (
<DesktopChatPlaceholder
Expand All @@ -466,6 +468,7 @@ const FeedLayout: ForwardRefRenderFunction<FeedLayoutRef, FeedLayoutProps> = (
shouldShowSeeMore={!chatItem?.chatChannel && shouldShowSeeMore}
rightHeaderContent={followFeedItemEl}
onMessagesAmountChange={handleMessagesAmountChange}
directParent={outerCommon?.directParent}
>
{selectedItemCommonData &&
checkIsFeedItemFollowLayoutItem(selectedFeedItem) && (
Expand Down
Loading

0 comments on commit fb2c2f3

Please sign in to comment.