-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2392 from daostack/feature/CW-2089-link-stream
FE add "Link stream" action #2089
- Loading branch information
Showing
68 changed files
with
1,362 additions
and
110 deletions.
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; |
71 changes: 71 additions & 0 deletions
71
...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,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 { | ||
--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; | ||
} |
Oops, something went wrong.