Skip to content

Commit

Permalink
Merge pull request #2030 from daostack/dev
Browse files Browse the repository at this point in the history
Sprint 28
  • Loading branch information
MeyerPV authored Sep 3, 2023
2 parents b12382a + e816ff6 commit 3cc5f62
Show file tree
Hide file tree
Showing 65 changed files with 669 additions and 212 deletions.
6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,9 @@
"redux": "^4.0.4",
"redux-saga": "^1.1.3",
"reselect": "^4.0.0",
"slate": "^0.87.0",
"slate-history": "^0.86.0",
"slate-react": "^0.88.0",
"slate": "^0.94.1",
"slate-history": "^0.93.0",
"slate-react": "^0.98.1",
"styled-components": "^5.2.1",
"swiper": "^6.5.9",
"typesafe-actions": "^4.4.2",
Expand Down
4 changes: 4 additions & 0 deletions src/pages/Login/containers/LoginContainer/helpers.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,10 @@ const PAGES_WITH_ALLOWED_SIGN_UP = [
ROUTE_PATHS.V04_COMMON_ABOUT_TAB,
ROUTE_PATHS.V04_COMMON_MEMBERS_TAB,
ROUTE_PATHS.V04_COMMON_WALLET_TAB,
ROUTE_PATHS.COMMON,
ROUTE_PATHS.COMMON_ABOUT_TAB,
ROUTE_PATHS.COMMON_MEMBERS_TAB,
ROUTE_PATHS.COMMON_WALLET_TAB,
];

export const getAuthCode = (
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ export default function ChatComponent({
<ChatMessage
key={message.id}
user={user}
commonMember={commonMember}
discussionMessage={message}
chatType={type}
scrollToRepliedMessage={scrollToRepliedMessage}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,10 @@ import { Orientation, ChatType, EntityTypes } from "@/shared/constants";
import {
checkIsSystemDiscussionMessage,
checkIsUserDiscussionMessage,
CommonMember,
DiscussionMessage,
User,
Circles,
} from "@/shared/models";
import { StaticLinkType, getUserName } from "@/shared/utils";
import EditMessageInput from "./EditMessageInput";
Expand All @@ -19,6 +21,8 @@ interface ChatMessageProps {
onMessageDropdownOpen?: (isOpen: boolean) => void;
user: User | null;
scrollToRepliedMessage: (messageId: string) => void;
commonMember: CommonMember | null;
governanceCircles?: Circles;
}

const getStaticLinkByChatType = (chatType: ChatType): StaticLinkType => {
Expand All @@ -38,6 +42,8 @@ export default function ChatMessage({
onMessageDropdownOpen,
user,
scrollToRepliedMessage,
commonMember,
governanceCircles,
}: ChatMessageProps) {
const [isEditMode, setEditMode] = useState(false);
const createdAtDate = new Date(discussionMessage.createdAt.seconds * 1000);
Expand Down Expand Up @@ -122,6 +128,8 @@ export default function ChatMessage({
</div>
</div>
<ElementDropdown
commonMember={commonMember}
governanceCircles={governanceCircles}
linkType={getStaticLinkByChatType(chatType)}
entityType={
[ChatType.DiscussionMessages, ChatType.ChatMessages].includes(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { getCommonGovernanceCircles } from "@/pages/OldCommon/store/api";
import { ElementDropdown } from "@/shared/components";
import { EntityTypes } from "@/shared/constants";
import { useFullText } from "@/shared/hooks";
import { Discussion, Governance } from "@/shared/models";
import { CommonMember, Discussion, Governance } from "@/shared/models";
import {
checkIsTextEditorValueEmpty,
parseStringToTextEditorValue,
Expand All @@ -23,12 +23,14 @@ interface DiscussionItemComponentProps {
discussion: Discussion;
loadDiscussionDetail: (payload: { discussion: Discussion }) => void;
governance: Governance;
commonMember: CommonMember | null;
}

export default function DiscussionItemComponent({
discussion,
loadDiscussionDetail,
governance,
commonMember,
}: DiscussionItemComponentProps) {
const [imageError, setImageError] = useState(false);
const [circleNames, setCircleNames] = useState("");
Expand Down Expand Up @@ -91,6 +93,8 @@ export default function DiscussionItemComponent({
</div>
</div>
<ElementDropdown
commonMember={commonMember}
governanceCircles={governance.circles}
entityType={EntityTypes.Discussion}
linkType={StaticLinkType.Discussion}
elem={discussion}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ export default function DiscussionsComponent({
<DiscussionItemComponent
key={d.id}
discussion={d}
commonMember={commonMember}
loadDiscussionDetail={loadDiscussionDetail}
governance={governance}
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import React from "react";
import { useCommonMember } from "@/pages/OldCommon/hooks";
import { UserAvatar, ElementDropdown } from "@/shared/components";
import { EntityTypes, ProposalsTypes } from "@/shared/constants";
import { Proposal } from "@/shared/models";
import { Circles, Proposal } from "@/shared/models";
import {
StaticLinkType,
formatPrice,
Expand All @@ -15,11 +15,13 @@ import { VotesComponent } from "../VotesComponent";
interface ProposalItemComponentProps {
loadProposalDetail: (payload: Proposal) => void;
proposal: Proposal;
governanceCircles?: Circles;
}

export default function ProposalItemComponent({
proposal,
loadProposalDetail,
governanceCircles,
}: ProposalItemComponentProps) {
const { data: commonMember } = useCommonMember();

Expand All @@ -44,6 +46,8 @@ export default function ProposalItemComponent({
</div>
<div onClick={(e) => e.stopPropagation()}>
<ElementDropdown
commonMember={commonMember}
governanceCircles={governanceCircles}
entityType={EntityTypes.Proposal}
linkType={StaticLinkType.Proposal}
elem={proposal}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export default function ProposalsComponent({
key={proposal.id}
proposal={proposal}
loadProposalDetail={loadProposalDetail}
governanceCircles={governance.circles}
/>
);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,20 @@
align-items: flex-end;
}

.loaderWrapper {
width: 100%;
display: flex;
align-items: center;
justify-content: center;
}

.permissionsText {
font-size: $mobile-title;
color: $light-gray-2;
color: var(--primary-fill);
margin-right: 0.3125rem;
width: 100%;
text-align: center;
cursor: pointer;
}

.messageInput {
Expand All @@ -92,11 +100,8 @@
}

.messageInputEmpty {
line-height: 2.625rem;
line-height: 2.25rem;
padding-left: 0;
@include tablet {
line-height: 0;
}
}

.addFilesIcon {
Expand Down
27 changes: 24 additions & 3 deletions src/pages/common/components/ChatComponent/ChatComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import React, {
useCallback,
ChangeEvent,
useRef,
ReactNode,
} from "react";
import { useDispatch, useSelector } from "react-redux";
import { useDebounce, useMeasure } from "react-use";
Expand Down Expand Up @@ -47,6 +48,7 @@ import {
TextEditorSize,
removeTextEditorEmptyEndLinesValues,
countTextEditorEmojiElements,
Loader,
} from "@/shared/ui-kit";
import { getUserName, hasPermission, isMobile } from "@/shared/utils";
import {
Expand Down Expand Up @@ -86,6 +88,8 @@ interface ChatComponentInterface {
isHidden: boolean;
onMessagesAmountChange?: (newMessagesAmount: number) => void;
directParent?: DirectParent | null;
isJoinPending?: boolean;
onJoinCommon?: () => void;
onUserClick?: (userId: string) => void;
}

Expand Down Expand Up @@ -124,6 +128,8 @@ export default function ChatComponent({
isCommonMemberFetched,
onMessagesAmountChange,
directParent,
isJoinPending = false,
onJoinCommon,
onUserClick,
}: ChatComponentInterface) {
const dispatch = useDispatch();
Expand Down Expand Up @@ -555,6 +561,22 @@ export default function ChatComponent({
}
}, [discussionMessages.length]);

const renderJoinCommonContent = (): ReactNode => {
if (isJoinPending) {
return (
<div className={styles.loaderWrapper}>
<Loader />
</div>
);
}

return (
<span className={styles.permissionsText} onClick={onJoinCommon}>
{directParent ? "Join the space" : "Join the effort"}
</span>
);
};

return (
<div className={styles.chatWrapper}>
<div
Expand All @@ -567,6 +589,7 @@ export default function ChatComponent({
ref={chatContentRef}
type={type}
commonMember={commonMember}
governanceCircles={governanceCircles}
isCommonMemberFetched={isCommonMemberFetched}
isJoiningPending={false}
hasAccess={hasAccess}
Expand Down Expand Up @@ -595,9 +618,7 @@ export default function ChatComponent({
})}
>
{!isChatChannel && (!commonMember || !hasAccess || isHidden) ? (
<span className={styles.permissionsText}>
Only members can send messages
</span>
renderJoinCommonContent()
) : (
<>
<ButtonIcon
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
DirectParent,
DiscussionMessage,
User,
Circles,
} from "@/shared/models";
import { formatDate } from "@/shared/utils";
import { Separator } from "./components";
Expand All @@ -36,6 +37,7 @@ export interface ChatContentRef {
interface ChatContentInterface {
type: ChatType;
commonMember: CommonMember | null;
governanceCircles?: Circles;
isCommonMemberFetched: boolean;
isJoiningPending?: boolean;
hasAccess: boolean;
Expand Down Expand Up @@ -70,6 +72,7 @@ const ChatContent: ForwardRefRenderFunction<
{
type,
commonMember,
governanceCircles,
isCommonMemberFetched,
isJoiningPending,
hasAccess,
Expand Down Expand Up @@ -259,6 +262,7 @@ const ChatContent: ForwardRefRenderFunction<
users={users}
feedItemId={feedItemId}
commonMember={commonMember}
governanceCircles={governanceCircles}
onMessageDelete={onMessageDelete}
directParent={directParent}
onUserClick={onUserClick}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
.memberInfo {
display: flex;
flex-direction: column;
justify-content: center;
overflow: hidden;

@include tablet {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export const PopoverButton: FC<PopoverButtonProps> = (props) => {
<div className={styles.contentWrapper}>
{!isMobileVersion && <Avatar2Icon className={styles.avatarIcon} />}
<div className={styles.memberInfo}>
<span className={styles.title}>
{pendingCircleName ? "Join circle request..." : "You are a member"}
</span>
{Boolean(pendingCircleName) && (
<span className={styles.title}>Join circle request...</span>
)}
<span className={styles.circleNames} title={circleNames}>
{circleNames} {pendingCircleName ? `-> ${pendingCircleName}` : ""}
</span>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@
display: flex;
justify-content: space-between;
align-items: center;
flex-wrap: wrap;
gap: 0.5rem;
width: 100%;
padding: 1.125rem 1.5rem;
text-decoration: none;
Expand Down Expand Up @@ -50,14 +52,6 @@
color: $light-gray-2;
}

.membersCount {
display: inline-flex;
align-items: center;
font-size: $xxsmall-2;
color: $light-gray-2;
margin: 0;
}

.membersCountLoader {
height: 1rem;
width: 1rem;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,9 +141,8 @@ export const PopoverItem: FC<CommonMemberInfoProps> = (props) => {
[styles.disabled]: !isMember,
})}
>
{circleName}
{`${membersCount} ${circleName}${membersCount === 1 ? "" : "s"}`}
</p>
<span className={styles.membersCount}>{membersCount} members</span>
</div>
<ActionButton />
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import { useIsTabletView } from "@/shared/hooks/viewport";
import { Common } from "@/shared/models";
import { MemberAdmittanceLimitations } from "@/shared/models/governance/proposals";
import { Container } from "@/shared/ui-kit";
import { checkIsProject } from "@/shared/utils";
import { CommonCard } from "../../../../../CommonCard";
import { CommonEntranceItem, CommonEntranceJoin } from "./components";
import styles from "./CommonEntranceInfo.module.scss";
Expand All @@ -16,7 +17,7 @@ interface CommonEntranceInfoProps {

const CommonEntranceInfo: FC<CommonEntranceInfoProps> = (props) => {
const { limitations, withJoinRequest = false, common } = props;
const isProject = Boolean(common.directParent);
const isProject = checkIsProject(common);
const isTabletView = useIsTabletView();

return (
Expand Down
Loading

0 comments on commit 3cc5f62

Please sign in to comment.