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

FE add "Link stream" action #2089 #2392

Merged
merged 48 commits into from
Dec 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
541c184
add `link to` menu item
andreymikhadyuk Dec 11, 2023
5f1a694
create permissions check for `link to` option
andreymikhadyuk Dec 11, 2023
913fdfa
add linkedCommonIds field to Discussion model
andreymikhadyuk Dec 11, 2023
3e62a66
create basic link space modal
andreymikhadyuk Dec 11, 2023
61c3c42
update title of link stream modal
andreymikhadyuk Dec 11, 2023
c6365e3
hide link to option in inbox
andreymikhadyuk Dec 11, 2023
a82179a
check lowest circle ids in discussion ids for linking streams
andreymikhadyuk Dec 11, 2023
90a77e6
create util for projects fetching
andreymikhadyuk Dec 11, 2023
4ca6df3
create projects component for link space modal
andreymikhadyuk Dec 11, 2023
a52b8c1
make onCommonCreationClick optional in ProjectsTree
andreymikhadyuk Dec 11, 2023
adb41a3
change modal styles to display tree correctly
andreymikhadyuk Dec 12, 2023
f9c1e48
add Apply button to modal
andreymikhadyuk Dec 12, 2023
f3ced2c
update modal's height
andreymikhadyuk Dec 12, 2023
74de270
add loaderDelay prop to projects tree
andreymikhadyuk Dec 12, 2023
73a0fb2
fix checkIsLinkToAllowed for empty discussion circle visibility
andreymikhadyuk Dec 12, 2023
da36c85
add quotes to the modal title
andreymikhadyuk Dec 12, 2023
4e5aeb4
add onItemClick to projects tree
andreymikhadyuk Dec 12, 2023
f0e807d
update tree item trigger name's color set up
andreymikhadyuk Dec 12, 2023
c98ee87
change button's size
andreymikhadyuk Dec 12, 2023
40cd3af
clear active item id on common change
andreymikhadyuk Dec 12, 2023
cdc0d46
add disabled field to tree item
andreymikhadyuk Dec 12, 2023
0908f5a
disable Apply button if no item is selected
andreymikhadyuk Dec 12, 2023
b927a03
add logic to link streams
andreymikhadyuk Dec 12, 2023
6fb7861
add link icon to feed item title
andreymikhadyuk Dec 12, 2023
552b17b
add markers to the linked commons or original one
andreymikhadyuk Dec 12, 2023
a8ae670
update modal styles for mobile
andreymikhadyuk Dec 12, 2023
f0b60df
align loader in the center
andreymikhadyuk Dec 12, 2023
7e8bb98
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk Dec 12, 2023
e1d52a8
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk Dec 18, 2023
24ae180
fix scroll of spaces
andreymikhadyuk Dec 18, 2023
0f9831c
fix root common selection
andreymikhadyuk Dec 18, 2023
30d08fa
fix active item text and bg colors
andreymikhadyuk Dec 18, 2023
03c5705
create LinkedItemMark component
andreymikhadyuk Dec 18, 2023
987fafe
add basic tooltip element to linked item mark
andreymikhadyuk Dec 18, 2023
c60c4e3
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk Dec 19, 2023
ce1972e
add logic to fetch common paths
andreymikhadyuk Dec 19, 2023
b8a0e13
display common paths in tooltip
andreymikhadyuk Dec 19, 2023
a055b53
cut common paths in tooltip
andreymikhadyuk Dec 19, 2023
4c2ee15
add safe polygon on hover
andreymikhadyuk Dec 19, 2023
e5e14e7
refactor loader displaying in tooltip
andreymikhadyuk Dec 19, 2023
aa9c99d
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk Dec 19, 2023
1824252
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk Dec 19, 2023
0517903
add default color for common path
andreymikhadyuk Dec 19, 2023
adb2991
display arrow before last common name
andreymikhadyuk Dec 19, 2023
a4e7958
fix colors of hovered tree items on mobile
andreymikhadyuk Dec 19, 2023
366efbe
align last common name with arrow correctly
andreymikhadyuk Dec 19, 2023
33d1e93
change linked item mark text colors
andreymikhadyuk Dec 19, 2023
444d8fb
Merge branch 'dev' into feature/CW-2089-link-stream
pvm-code Dec 21, 2023
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
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ import {
GetLastMessageOptions,
GetNonAllowedItemsOptions,
} from "../FeedItem";
import { LinkSpaceModal } from "./components";
import { useMenuItems } from "./hooks";

interface DiscussionFeedCardProps {
Expand All @@ -65,6 +66,7 @@ interface DiscussionFeedCardProps {
getNonAllowedItems?: GetNonAllowedItemsOptions;
onActiveItemDataChange?: (data: FeedLayoutItemChangeData) => void;
directParent?: DirectParent | null;
rootCommonId?: string;
feedItemFollow: FeedItemFollowState;
onUserSelect?: (userId: string, commonId?: string) => void;
}
Expand Down Expand Up @@ -93,6 +95,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
getNonAllowedItems,
onActiveItemDataChange,
directParent,
rootCommonId,
feedItemFollow,
onUserSelect,
} = props;
Expand All @@ -111,6 +114,11 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
onOpen: onDeleteModalOpen,
onClose: onDeleteModalClose,
} = useModal(false);
const {
isShowing: isLinkSpaceModalOpen,
onOpen: onLinkSpaceModalOpen,
onClose: onLinkSpaceModalClose,
} = useModal(false);
const [isDeletingInProgress, setDeletingInProgress] = useState(false);
const {
fetchUser: fetchDiscussionCreator,
Expand Down Expand Up @@ -147,6 +155,7 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
report: onReportModalOpen,
share: () => onShareModalOpen(),
remove: onDeleteModalOpen,
linkSpace: onLinkSpaceModalOpen,
},
);
const user = useSelector(selectUser());
Expand Down Expand Up @@ -346,6 +355,8 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
isFeedItemUserMetadataFetched &&
feedItemUserMetadata?.hasUnseenMention
}
originalCommonIdForLinking={discussion?.commonId}
linkedCommonIds={discussion?.linkedCommonIds}
>
{renderContent()}
</FeedCard>
Expand Down Expand Up @@ -378,6 +389,18 @@ const DiscussionFeedCard = forwardRef<FeedItemRef, DiscussionFeedCardProps>(
/>
</GlobalOverlay>
)}
{commonId && (
<LinkSpaceModal
isOpen={isLinkSpaceModalOpen}
onClose={onLinkSpaceModalClose}
feedItemId={item.id}
title={cardTitle || ""}
rootCommonId={rootCommonId || commonId}
commonId={commonId}
originalCommonId={discussion?.commonId || ""}
linkedCommonIds={discussion?.linkedCommonIds}
/>
)}
</>
);
},
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
@import "../../../../../../constants";
@import "../../../../../../styles/sizes";

.modal {
max-width: 31.875rem;
width: 100%;
max-height: 33.75rem;
min-height: 24rem;
border-radius: 0;
box-shadow: 0 0.25rem 0.9375rem var(--drop-shadow);

:global(.modal__header-wrapper--with-modal-padding) {
.modalHeader {
justify-content: flex-start;
}

.modalTitle {
margin: 0;
font-family: PoppinsSans, sans-serif;
font-weight: 600;
font-size: 1.25rem;
color: var(--primary-text);
text-align: left;
word-break: break-word;
}
}

.modalContent {
width: 100%;
display: flex;
flex-direction: column;
overflow: hidden;
box-sizing: border-box;
}

.modalCloseWrapper {
top: 1.7rem;
margin: 0;

@include tablet {
top: 1.1rem;
}
}

@include tablet {
max-width: unset;
max-height: unset;
}
}

.submitButtonWrapper {
margin-top: auto;
padding-top: 1.5rem;
display: flex;
justify-content: flex-end;
}

.submitButton {
--btn-w: 100%;

max-width: 9.75rem;

@include tablet {
max-width: 100%;
}
}

.loader {
margin: 0 auto;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
import React, { FC, ReactElement, useEffect, useState } from "react";
import { useSelector } from "react-redux";
import { selectUser } from "@/pages/Auth/store/selectors";
import { Modal } from "@/shared/components";
import { useNotification } from "@/shared/hooks";
import { useStreamLinking } from "@/shared/hooks/useCases";
import { Button, ButtonVariant, Loader } from "@/shared/ui-kit";
import { emptyFunction } from "@/shared/utils";
import { Projects } from "./components";
import styles from "./LinkSpaceModal.module.scss";

interface DirectMessageModalProps {
isOpen: boolean;
onClose: () => void;
feedItemId: string;
title: string;
rootCommonId: string;
commonId: string;
originalCommonId: string;
linkedCommonIds?: string[];
}

const LinkSpaceModal: FC<DirectMessageModalProps> = (props) => {
const {
isOpen,
onClose,
feedItemId,
title,
rootCommonId,
commonId,
originalCommonId,
linkedCommonIds = [],
} = props;
const { notify } = useNotification();
const { isStreamLinking, isStreamLinked, linkStream } = useStreamLinking();
const [activeItemId, setActiveItemId] = useState("");
const user = useSelector(selectUser());
const userId = user?.uid;

const handleSubmit = () => {
if (!userId) {
return;
}

linkStream({
userId,
feedObjectId: feedItemId,
sourceCommonId: commonId,
targetCommonId: activeItemId,
});
};

const renderContent = (): ReactElement => {
if (isStreamLinking) {
return <Loader className={styles.loader} />;
}

return (
<>
<Projects
rootCommonId={rootCommonId}
commonId={commonId}
activeItemId={activeItemId}
onActiveItemId={setActiveItemId}
originalCommonId={originalCommonId}
linkedCommonIds={linkedCommonIds}
/>
<div className={styles.submitButtonWrapper}>
<Button
className={styles.submitButton}
variant={ButtonVariant.PrimaryPink}
disabled={!activeItemId}
onClick={handleSubmit}
>
Apply
</Button>
</div>
</>
);
};

useEffect(() => {
if (isStreamLinked) {
notify("Stream is successfully linked");
onClose();
}
}, [isStreamLinking, isStreamLinked]);

return (
<Modal
className={styles.modal}
isShowing={isOpen}
onClose={isStreamLinking ? emptyFunction : onClose}
title={`Link “${title}“`}
isHeaderSticky
hideCloseButton={isStreamLinking}
mobileFullScreen
styles={{
header: styles.modalHeader,
title: styles.modalTitle,
content: styles.modalContent,
closeWrapper: styles.modalCloseWrapper,
}}
>
{renderContent()}
</Modal>
);
};

export default LinkSpaceModal;
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
@import "../../../../../../../../constants";
@import "../../../../../../../../styles/sizes";

.projectsTree {
overflow-y: auto;
box-sizing: border-box;
}

.projectsTreeItemTriggerClassName {
--item-pl-per-level: 1.25rem;
--item-arrow-pl: 0.5rem;

height: 3rem;
border-radius: 0;

&:hover {
--bg-color: var(--secondary-text);
--item-text-color: #{$c-shades-white};
}

@media (hover: none) {
&:hover {
--bg-color: var(--primary-background);
--item-text-color: var(--primary-text);
}
}
}
.projectsTreeItemTriggerActiveClassName {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@andreymikhadyuk why the word "ClassName" is part of the class name?

Copy link
Collaborator Author

@andreymikhadyuk andreymikhadyuk Dec 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Old typo and I just do not want to change all the names just in case.

--bg-color: var(--primary-fill);
--item-text-color: #{$c-shades-white};

&:hover {
--bg-color: var(--primary-fill);
}

@media (hover: none) {
&:hover {
--bg-color: var(--primary-fill);
--item-text-color: #{$c-shades-white};
}
}
}

.projectsTreeItemTriggerNameClassName {
font-family: PoppinsSans, sans-serif;
font-weight: 500;
}

.projectsTreeItemTriggerImageClassName {
width: 1.5rem;
height: 1.5rem;
margin-right: 0.875rem;
}
.projectsTreeItemTriggerImageNonRoundedClassName {
border-radius: 0.375rem;
}

.loader {
margin: 1rem auto 0;
display: block;
}

.createCommonButton {
width: 100%;
padding-left: 2.125rem;
padding-right: 0.875rem;
}

.commonsMenuClassName {
max-height: 15rem;
}
Loading
Loading