Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notion integration FE #2296 #2333

Merged
merged 3 commits into from
Nov 24, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 7 additions & 1 deletion src/pages/OldCommon/interfaces/CreateCommonPayload.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import { UploadFile } from "@/shared/interfaces";
import { BaseRule, CommonLink, Roles } from "@/shared/models";
import {
BaseRule,
CommonLink,
NotionIntegrationIntermediate,
Roles,
} from "@/shared/models";
import { MemberAdmittanceLimitations } from "@/shared/models/governance/proposals";
import { TextEditorValue } from "@/shared/ui-kit/TextEditor/types";

Expand Down Expand Up @@ -59,6 +64,7 @@ export interface IntermediateUpdateCommonData {
gallery?: UploadFile[];
links?: CommonLink[];
roles?: Roles;
notion?: NotionIntegrationIntermediate;
}

export interface UpdateCommonData {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
Common,
CommonFeed,
CommonMember,
CommonNotion,
DirectParent,
Governance,
PredefinedTypes,
Expand Down Expand Up @@ -52,6 +53,7 @@ interface DiscussionFeedCardProps {
commonId?: string;
commonName: string;
commonImage: string;
commonNotion?: CommonNotion;
pinnedFeedItems?: Common["pinnedFeedItems"];
commonMember?: CommonMember | null;
isProject: boolean;
Expand Down Expand Up @@ -79,6 +81,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
commonId,
commonName,
commonImage,
commonNotion,
pinnedFeedItems,
commonMember,
isProject,
Expand Down Expand Up @@ -283,6 +286,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
<FeedCardContent
description={isHome ? common?.description : discussion?.message}
images={isHome ? common?.gallery : discussion?.images}
notion={discussion?.notion}
onClick={handleOpenChat}
onMouseEnter={() => {
onHover(true);
Expand Down Expand Up @@ -334,6 +338,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
seen={feedItemUserMetadata?.seen ?? !isFeedItemUserMetadataFetched}
ownerId={item.userId}
discussionPredefinedType={discussion?.predefinedType}
notion={discussion?.notion && commonNotion}
hasUnseenMention={
isFeedItemUserMetadataFetched &&
feedItemUserMetadata?.hasUnseenMention
Expand Down
5 changes: 4 additions & 1 deletion src/pages/common/components/FeedCard/FeedCard.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import classNames from "classnames";
import { useFeedItemContext } from "@/pages/common";
import { useIsTabletView } from "@/shared/hooks/viewport";
import { ContextMenuItem } from "@/shared/interfaces";
import { CommonFeedType, PredefinedTypes } from "@/shared/models";
import { CommonFeedType, CommonNotion, PredefinedTypes } from "@/shared/models";
import { Loader, TextEditorValue } from "@/shared/ui-kit";
import { CommonCard } from "../CommonCard";
import { FeedCardRef } from "./types";
Expand Down Expand Up @@ -47,6 +47,7 @@ type FeedCardProps = PropsWithChildren<{
hasFiles?: boolean;
hasImages?: boolean;
hasUnseenMention?: boolean;
notion?: CommonNotion;
}>;

const MOBILE_HEADER_HEIGHT = 52;
Expand Down Expand Up @@ -87,6 +88,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
discussionPredefinedType,
hasImages,
hasFiles,
notion,
} = props;
const scrollTimeoutRef = useRef<ReturnType<typeof setTimeout> | null>(null);
const isTabletView = useIsTabletView();
Expand Down Expand Up @@ -210,6 +212,7 @@ export const FeedCard = forwardRef<FeedCardRef, FeedCardProps>((props, ref) => {
hasFiles,
hasImages,
hasUnseenMention,
notion,
})}
</div>
)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
.container {
display: flex;
flex-direction: column;
gap: 10px;
min-height: 4.5rem;
justify-content: space-between;
width: 100%;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
import React, { ReactNode } from "react";
import { CommonLink } from "@/shared/models";
import { CommonLink, DiscussionNotion } from "@/shared/models";
import { FeedGeneralInfo } from "../FeedGeneralInfo";
import { FeedNotionInfo } from "../FeedNotionInfo";
import styles from "./FeedCardContent.module.scss";

export type FeedCardContentProps = JSX.IntrinsicElements["div"] & {
subtitle?: ReactNode;
description?: string;
images?: CommonLink[];
notion?: DiscussionNotion;
onClick: () => void;
};

Expand All @@ -16,6 +18,7 @@ export const FeedCardContent: React.FC<FeedCardContentProps> = (props) => {
description,
subtitle,
images,
notion,
onClick,
onMouseEnter,
onMouseLeave,
Expand All @@ -28,6 +31,7 @@ export const FeedCardContent: React.FC<FeedCardContentProps> = (props) => {
onMouseEnter={onMouseEnter}
onMouseLeave={onMouseLeave}
>
{!!notion && <FeedNotionInfo notion={notion} />}
<FeedGeneralInfo
description={description}
subtitle={subtitle}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@
}

.title {
display: flex;
align-items: center;
gap: 8px;
color: var(--title-color);
font-size: $moderate-xsmall;
line-height: 1.5rem;
Expand Down Expand Up @@ -156,3 +159,14 @@
display: flex;
align-items: center;
}

.tooltipTriggerContainer {
display: inline-flex;
}

.tooltipContent {
display: flex;
flex-direction: column;
max-width: 20rem;
z-index: 3;
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
import React, { FC, MouseEventHandler, useRef, useState } from "react";
import classNames from "classnames";
import { useLongPress } from "use-long-press";
import { NotionIcon } from "@/shared/icons";
import {
checkIsTextEditorValueEmpty,
ContextMenu,
ContextMenuRef,
TextEditorWithReinitialization as TextEditor,
TimeAgo,
Tooltip,
TooltipContent,
TooltipTrigger,
} from "@/shared/ui-kit";
import { FeedItemBaseContentProps } from "../../../FeedItem";
import { FeedCardTags } from "../FeedCardTags";
Expand Down Expand Up @@ -36,6 +40,7 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
isLoading = false,
shouldHideBottomContent = false,
hasUnseenMention,
notion,
} = props;
const contextMenuRef = useRef<ContextMenuRef>(null);
const [isLongPressing, setIsLongPressing] = useState(false);
Expand Down Expand Up @@ -109,15 +114,28 @@ export const FeedItemBaseContent: FC<FeedItemBaseContentProps> = (props) => {
{renderLeftContent?.()}
<div className={styles.content}>
<div className={styles.topContent}>
<p
<div
className={classNames(
styles.text,
styles.title,
titleWrapperClassName,
)}
>
{isLoading || !title ? "Loading..." : title}
</p>
<span>{isLoading || !title ? "Loading..." : title}</span>
{Boolean(notion) && (
<Tooltip placement="top-start">
<TooltipTrigger asChild>
<div className={styles.tooltipTriggerContainer}>
<NotionIcon />
</div>
</TooltipTrigger>
<TooltipContent className={styles.tooltipContent}>
<span>Notion sync</span>
<span>Database: {notion?.title}</span>
</TooltipContent>
</Tooltip>
)}
</div>
<p
className={classNames(styles.text, styles.lastActivity, {
[styles.lastActivityActive]:
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
.notionInfo {
display: flex;
gap: 10px;
}

.link {
color: var(--primary-fill);

&:hover {
cursor: pointer;
opacity: 0.9;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
import React from "react";
import { NotionIcon } from "@/shared/icons";
import { DiscussionNotion } from "@/shared/models";
import styles from "./FeedNotionInfo.module.scss";

interface FeedNotionInfoProps {
notion: DiscussionNotion;
}

export const FeedNotionInfo: React.FC<FeedNotionInfoProps> = (props) => {
const { notion } = props;

const linkToNotionPageEl = (
<a
className={styles.link}
href={`https://www.notion.so/${notion?.pageId.split("-").join("")}`}
target="_blank"
rel="noopener noreferrer"
>
Notion pageID: {notion?.pageId}
</a>
);

return (
<div className={styles.notionInfo}>
<NotionIcon width={24} height={24} />
{linkToNotionPageEl}
</div>
);
};
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./FeedNotionInfo";
1 change: 1 addition & 0 deletions src/pages/common/components/FeedCard/components/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ export * from "./FeedGeneralInfo";
export * from "./FeedInfoHeader";
export * from "./FeedItemBaseContent";
export * from "./FeedCardTags";
export * from "./FeedNotionInfo";
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 @@ -8,6 +8,7 @@ import {
CommonFeed,
CommonFeedType,
CommonMember,
CommonNotion,
DirectParent,
} from "@/shared/models";
import { checkIsItemVisibleForUser } from "@/shared/utils";
Expand All @@ -23,6 +24,7 @@ interface FeedItemProps {
commonName: string;
commonMember?: (CommonMember & CirclesPermissions) | null;
commonImage: string;
commonNotion?: CommonNotion;
pinnedFeedItems?: Common["pinnedFeedItems"];
isProject?: boolean;
isPinned?: boolean;
Expand All @@ -48,6 +50,7 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
commonId,
commonName,
commonImage,
commonNotion,
pinnedFeedItems,
commonMember,
isProject = false,
Expand Down Expand Up @@ -112,6 +115,7 @@ const FeedItem = forwardRef<FeedItemRef, FeedItemProps>((props, ref) => {
commonId,
commonName,
commonImage,
commonNotion,
pinnedFeedItems,
isActive,
isExpanded,
Expand Down
2 changes: 2 additions & 0 deletions src/pages/common/components/FeedItem/context.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ContextMenuItem } from "@/shared/interfaces";
import {
CommonFeed,
CommonFeedType,
CommonNotion,
Discussion,
PredefinedTypes,
} from "@/shared/models";
Expand Down Expand Up @@ -45,6 +46,7 @@ export interface FeedItemBaseContentProps {
shouldHideBottomContent?: boolean;
dmUserId?: string;
hasUnseenMention?: boolean;
notion?: CommonNotion;
}

export interface GetLastMessageOptions {
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 @@ -74,6 +74,7 @@ const FeedItems: FC<FeedItemsProps> = (props) => {
commonId={common.id}
commonName={common.name}
commonImage={common.image}
commonNotion={common.notion}
pinnedFeedItems={common.pinnedFeedItems}
isPinned={isPinned}
isProject={checkIsProject(common)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import { FeedLayoutItemChangeData } from "@/shared/interfaces";
import {
Common,
CommonFeed,
CommonNotion,
Governance,
PredefinedTypes,
ResolutionType,
Expand Down Expand Up @@ -68,6 +69,7 @@ interface ProposalFeedCardProps {
commonId?: string;
commonName: string;
commonImage: string;
commonNotion?: CommonNotion;
pinnedFeedItems?: Common["pinnedFeedItems"];
isProject: boolean;
isPinned: boolean;
Expand All @@ -91,6 +93,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
commonId,
commonName,
commonImage,
commonNotion,
pinnedFeedItems,
isProject,
isPinned,
Expand Down Expand Up @@ -371,6 +374,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
proposal.data.args.description,
proposal.type,
)}
notion={discussion?.notion}
images={discussion?.images}
onClick={handleOpenChat}
onMouseEnter={() => {
Expand Down Expand Up @@ -459,6 +463,7 @@ const ProposalFeedCard = forwardRef<FeedItemRef, ProposalFeedCardProps>(
menuItems={menuItems}
ownerId={item.userId}
commonId={commonId}
notion={discussion?.notion && commonNotion}
hasUnseenMention={
isFeedItemUserMetadataFetched &&
feedItemUserMetadata?.hasUnseenMention
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {
TextField,
UploadFiles,
RolesArrayWrapper,
NotionIntegration,
} from "@/shared/components/Form/Formik";
import { CreationFormItemType } from "../../constants";
import { CreationFormItem } from "../../types";
Expand Down Expand Up @@ -79,6 +80,8 @@ const Item: FC<ItemProps> = (props) => {
disabled={disabled ?? item.props.disabled}
/>
);
case CreationFormItemType.NotionIntegration:
return <NotionIntegration {...item.props} className={className} />;
default:
return null;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ export enum CreationFormItemType {
UploadFiles = "UploadFiles",
Links = "Links",
Roles = "Roles",
NotionIntegration = "NotionIntegration",
}
Loading
Loading