-
Notifications
You must be signed in to change notification settings - Fork 0
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
Changes from 42 commits
Commits
Show all changes
48 commits
Select commit
Hold shift + click to select a range
541c184
add `link to` menu item
andreymikhadyuk 5f1a694
create permissions check for `link to` option
andreymikhadyuk 913fdfa
add linkedCommonIds field to Discussion model
andreymikhadyuk 3e62a66
create basic link space modal
andreymikhadyuk 61c3c42
update title of link stream modal
andreymikhadyuk c6365e3
hide link to option in inbox
andreymikhadyuk a82179a
check lowest circle ids in discussion ids for linking streams
andreymikhadyuk 90a77e6
create util for projects fetching
andreymikhadyuk 4ca6df3
create projects component for link space modal
andreymikhadyuk a52b8c1
make onCommonCreationClick optional in ProjectsTree
andreymikhadyuk adb41a3
change modal styles to display tree correctly
andreymikhadyuk f9c1e48
add Apply button to modal
andreymikhadyuk f3ced2c
update modal's height
andreymikhadyuk 74de270
add loaderDelay prop to projects tree
andreymikhadyuk 73a0fb2
fix checkIsLinkToAllowed for empty discussion circle visibility
andreymikhadyuk da36c85
add quotes to the modal title
andreymikhadyuk 4e5aeb4
add onItemClick to projects tree
andreymikhadyuk f0e807d
update tree item trigger name's color set up
andreymikhadyuk c98ee87
change button's size
andreymikhadyuk 40cd3af
clear active item id on common change
andreymikhadyuk cdc0d46
add disabled field to tree item
andreymikhadyuk 0908f5a
disable Apply button if no item is selected
andreymikhadyuk b927a03
add logic to link streams
andreymikhadyuk 6fb7861
add link icon to feed item title
andreymikhadyuk 552b17b
add markers to the linked commons or original one
andreymikhadyuk a8ae670
update modal styles for mobile
andreymikhadyuk f0b60df
align loader in the center
andreymikhadyuk 7e8bb98
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk e1d52a8
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk 24ae180
fix scroll of spaces
andreymikhadyuk 0f9831c
fix root common selection
andreymikhadyuk 30d08fa
fix active item text and bg colors
andreymikhadyuk 03c5705
create LinkedItemMark component
andreymikhadyuk 987fafe
add basic tooltip element to linked item mark
andreymikhadyuk c60c4e3
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk ce1972e
add logic to fetch common paths
andreymikhadyuk b8a0e13
display common paths in tooltip
andreymikhadyuk a055b53
cut common paths in tooltip
andreymikhadyuk 4c2ee15
add safe polygon on hover
andreymikhadyuk e5e14e7
refactor loader displaying in tooltip
andreymikhadyuk aa9c99d
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk 1824252
Merge branch 'dev' into feature/CW-2089-link-stream
andreymikhadyuk 0517903
add default color for common path
andreymikhadyuk adb2991
display arrow before last common name
andreymikhadyuk a4e7958
fix colors of hovered tree items on mobile
andreymikhadyuk 366efbe
align last common name with arrow correctly
andreymikhadyuk 33d1e93
change linked item mark text colors
andreymikhadyuk 444d8fb
Merge branch 'dev' into feature/CW-2089-link-stream
pvm-code File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
...common/components/DiscussionFeedCard/components/LinkSpaceModal/LinkSpaceModal.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; | ||
} |
110 changes: 110 additions & 0 deletions
110
src/pages/common/components/DiscussionFeedCard/components/LinkSpaceModal/LinkSpaceModal.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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; |
57 changes: 57 additions & 0 deletions
57
...nts/DiscussionFeedCard/components/LinkSpaceModal/components/Projects/Projects.module.scss
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
@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}; | ||
} | ||
} | ||
.projectsTreeItemTriggerActiveClassName { | ||
--bg-color: #{var(--primary-fill)}; | ||
--item-text-color: #{$c-shades-white}; | ||
|
||
&:hover { | ||
--bg-color: #{var(--primary-fill)}; | ||
} | ||
} | ||
|
||
.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; | ||
} |
85 changes: 85 additions & 0 deletions
85
.../components/DiscussionFeedCard/components/LinkSpaceModal/components/Projects/Projects.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
import React, { FC, ReactNode, useEffect, useMemo, useState } from "react"; | ||
import { LOADER_APPEARANCE_DELAY } from "@/shared/constants"; | ||
import { TreeItemTriggerStyles } from "@/shared/layouts"; | ||
import { ProjectsTree } from "@/shared/layouts/CommonSidenavLayout/components/SidenavContent/components/ProjectsTree"; | ||
import { Loader } from "@/shared/ui-kit"; | ||
import { useProjectsData } from "./hooks"; | ||
import styles from "./Projects.module.scss"; | ||
|
||
interface ProjectsProps { | ||
rootCommonId: string; | ||
commonId: string; | ||
activeItemId: string; | ||
onActiveItemId: (activeItemId: string) => void; | ||
originalCommonId: string; | ||
linkedCommonIds: string[]; | ||
renderNoItemsInfo?: () => ReactNode; | ||
} | ||
|
||
const Projects: FC<ProjectsProps> = (props) => { | ||
const { | ||
activeItemId, | ||
onActiveItemId, | ||
renderNoItemsInfo, | ||
originalCommonId, | ||
linkedCommonIds, | ||
} = props; | ||
const [currentCommonId, setCurrentCommonId] = useState(props.rootCommonId); | ||
const { | ||
parentItem, | ||
areCommonsLoading, | ||
areProjectsLoading, | ||
commons, | ||
items, | ||
activeItem, | ||
parentItemIds, | ||
} = useProjectsData({ | ||
currentCommonId, | ||
activeItemId, | ||
originalCommonId, | ||
linkedCommonIds, | ||
}); | ||
const treeItemTriggerStyles = useMemo<TreeItemTriggerStyles>( | ||
() => ({ | ||
container: styles.projectsTreeItemTriggerClassName, | ||
containerActive: styles.projectsTreeItemTriggerActiveClassName, | ||
name: styles.projectsTreeItemTriggerNameClassName, | ||
image: styles.projectsTreeItemTriggerImageClassName, | ||
imageNonRounded: styles.projectsTreeItemTriggerImageNonRoundedClassName, | ||
}), | ||
[], | ||
); | ||
|
||
useEffect(() => { | ||
onActiveItemId(""); | ||
}, [currentCommonId]); | ||
|
||
if (!parentItem) { | ||
return areCommonsLoading ? ( | ||
<Loader className={styles.loader} delay={LOADER_APPEARANCE_DELAY} /> | ||
) : ( | ||
<>{renderNoItemsInfo?.() || null}</> | ||
); | ||
} | ||
|
||
return ( | ||
<ProjectsTree | ||
className={styles.projectsTree} | ||
treeItemTriggerStyles={treeItemTriggerStyles} | ||
parentItem={parentItem} | ||
commons={commons} | ||
items={items} | ||
activeItem={activeItem} | ||
parentItemIds={parentItemIds} | ||
currentCommonId={currentCommonId} | ||
onCommonClick={setCurrentCommonId} | ||
isLoading={areProjectsLoading} | ||
withScrollbar={false} | ||
commonsMenuClassName={styles.commonsMenuClassName} | ||
loaderDelay={0} | ||
onItemClick={onActiveItemId} | ||
/> | ||
); | ||
}; | ||
|
||
export default Projects; |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.