-
Notifications
You must be signed in to change notification settings - Fork 22
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
Add discussions tab to community page #645
Merged
frol
merged 28 commits into
NEAR-DevHub:main
from
Tguntenaar:feature/584-discussions-front-end
Feb 17, 2024
Merged
Changes from 15 commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
b950911
initial commit
Tguntenaar 8de82ab
added createDiscussion and dynamic feed action
Tguntenaar 3a7dd60
remove old test
Tguntenaar b6f3db7
call grant_write_permission on socialdb contract to repost
Tguntenaar d9846b5
removed comment
Tguntenaar 51a1a1e
add import for getDepositAmountForWriteAccess
Tguntenaar 6040946
get storage_balance_of user
Tguntenaar ae0034e
grant permission for discussion to write post
Tguntenaar 61ca49d
follow the discussions account in the feed
Tguntenaar 787fbb4
removed grant_write_permission
Tguntenaar c8ac8eb
need a better way to get the blockheight
Tguntenaar 815c8db
added near view get with_block_height
Tguntenaar d4ebeda
change title
Tguntenaar 63d75bb
updated preview with latest changes
Tguntenaar b98b0a4
Merge branch 'main' of github.com:near/neardevhub-widgets into featur…
Tguntenaar 75962f1
Recreate what announcements does: TODO listen to index/repost instead…
Tguntenaar 6af9aa1
wip
Tguntenaar e171f4e
wip props.transactionHashes not recognized ?
Tguntenaar a4520e1
pass transactionHashes on from the page
Tguntenaar f95363a
Ready for review @frol
Tguntenaar b33eb09
added force option and getBlockHeightAndRepost onCommit
Tguntenaar b430920
Change the profile preview where discussions is posted from
Tguntenaar 54d6c4b
Update src/devhub/entity/community/Discussions.jsx
Tguntenaar 1b92280
added REPL_RPC_URL
Tguntenaar 9e98b74
Merge branch 'feature/584-discussions-front-end' of github.com:Tgunte…
Tguntenaar ce7be7c
removed double feed
Tguntenaar 5156218
added space to replacements
Tguntenaar 5bae5f0
notify mention in discussions
Tguntenaar 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
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
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
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,183 @@ | ||
const { handle } = props; | ||
const { getCommunity, setCommunitySocialDB } = VM.require( | ||
"${REPL_DEVHUB}/widget/core.adapter.devhub-contract" | ||
); | ||
|
||
getCommunity = getCommunity || (() => <></>); | ||
setCommunitySocialDB = setCommunitySocialDB || (() => <></>); | ||
|
||
const communityData = getCommunity({ handle }); | ||
|
||
const MainContent = styled.div` | ||
padding-left: 2rem; | ||
flex: 3; | ||
@media screen and (max-width: 960px) { | ||
padding-left: 0rem; | ||
} | ||
.post:hover { | ||
background-color: inherit !important; | ||
} | ||
`; | ||
|
||
const SidebarContainer = styled.div` | ||
flex: 1; | ||
`; | ||
|
||
const Heading = styled.div` | ||
font-size: 19px; | ||
font-weight: 600; | ||
`; | ||
|
||
const SubHeading = styled.div` | ||
font-size: 15px; | ||
font-weight: 600; | ||
`; | ||
|
||
const Container = styled.div` | ||
flex-wrap: no-wrap; | ||
max-width: 100%; | ||
|
||
.max-width-100 { | ||
max-width: 100%; | ||
} | ||
@media screen and (max-width: 960px) { | ||
flex-wrap: wrap; | ||
} | ||
|
||
.card { | ||
border-radius: 1rem !important; | ||
} | ||
`; | ||
|
||
const Tag = styled.div` | ||
border-top-right-radius: 50px; | ||
border-bottom-right-radius: 50px; | ||
border-top-left-radius: 50px; | ||
border-bottom-left-radius: 50px; | ||
padding-inline: 0.8rem; | ||
padding-block: 0.3rem; | ||
display: flex; | ||
gap: 0.5rem; | ||
border-width: 1px; | ||
border-style: solid; | ||
font-size: 14px; | ||
color: rgba(0, 236, 151, 1); | ||
font-weight: 800; | ||
`; | ||
|
||
const [sort, setSort] = useState("timedesc"); | ||
|
||
function repostOnDiscussions(blockHeight) { | ||
Near.call([ | ||
{ | ||
contractName: "${REPL_DEVHUB_CONTRACT}", | ||
methodName: "create_discussion", | ||
args: { | ||
handle, | ||
blockHeight, | ||
}, | ||
gas: Big(10).pow(14), | ||
}, | ||
]); | ||
} | ||
|
||
function setSocialDbAndRepost(v) { | ||
// TODO remove | ||
console.log("v", v); | ||
// Post to users social db | ||
const result = Social.set(v, { | ||
onCommit: (data) => { | ||
console.log("onCommit data", data); | ||
// TODO move to devhub-contract.jsx | ||
Near.asyncView("${REPL_SOCIAL_CONTRACT}", "get", { | ||
keys: [`${context.accountId}/**`], | ||
options: { | ||
with_block_height: true, | ||
}, | ||
}) | ||
.then((response) => { | ||
let blockHeight = response[context.accountId]["post"][":block"]; | ||
repostOnDiscussions(blockHeight); | ||
}) | ||
.catch(console.log); | ||
}, | ||
}); | ||
// TODO remove | ||
console.log("result", result); | ||
} | ||
|
||
return ( | ||
<div className="w-100" style={{ maxWidth: "100%" }}> | ||
<Container className="d-flex gap-3 m-3 pl-2"> | ||
<MainContent className="max-width-100"> | ||
<div className="d-flex flex-column gap-4"> | ||
{context.accountId && ( | ||
<div className="card p-4"> | ||
<Widget | ||
src={"${REPL_DEVHUB}/widget/devhub.entity.community.Compose"} | ||
props={{ | ||
onSubmit: setSocialDbAndRepost, | ||
}} | ||
/> | ||
</div> | ||
)} | ||
<div className="d-flex flex-wrap justify-content-between"> | ||
<Heading>Discussions</Heading> | ||
<div className="d-flex align-items-center gap-2"> | ||
<select | ||
name="sort" | ||
id="sort" | ||
class="form-select" | ||
value={sort} | ||
onChange={(e) => { | ||
setSort(e.target.value); | ||
}} | ||
> | ||
<option selected value="timedesc"> | ||
Latest | ||
</option> | ||
<option value="recentcommentdesc">Last Commented</option> | ||
</select> | ||
</div> | ||
</div> | ||
<Widget | ||
src="${REPL_DEVHUB}/widget/devhub.components.organism.Feed" | ||
props={{ | ||
showFlagAccountFeature: true, | ||
action: "repost", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This file is mostly a copy of the |
||
filteredAccountIds: [ | ||
`discussions.${handle}.community.${REPL_DEVHUB_CONTRACT}`, | ||
], | ||
sort: sort, | ||
}} | ||
/> | ||
</div> | ||
</MainContent> | ||
<SidebarContainer> | ||
<div className="d-flex flex-column gap-3"> | ||
<div className="card p-4"> | ||
<div className="mb-2">{communityData?.description}</div> | ||
<div className="d-flex gap-2 flex-wrap"> | ||
<Tag>{communityData?.tag} </Tag> | ||
</div> | ||
</div> | ||
<div className="card p-4 d-flex flex-column gap-2"> | ||
<SubHeading>Community Admins</SubHeading> | ||
{(communityData?.admins ?? []).map((accountId) => ( | ||
<div | ||
key={accountId} | ||
className="d-flex" | ||
style={{ fontWeight: 500 }} | ||
> | ||
<Widget | ||
src="${REPL_DEVHUB}/widget/devhub.components.molecule.ProfileCard" | ||
props={{ accountId }} | ||
/> | ||
</div> | ||
))} | ||
</div> | ||
</div> | ||
</SidebarContainer> | ||
</Container> | ||
</div> | ||
); |
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
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.
Looks good on processing user discussions!