Skip to content

Commit

Permalink
migrates neardevgov to devhub (#610)
Browse files Browse the repository at this point in the history
  • Loading branch information
elliotBraem authored Dec 28, 2023
1 parent be71b63 commit 424c0a4
Show file tree
Hide file tree
Showing 7 changed files with 104 additions and 5 deletions.
78 changes: 78 additions & 0 deletions src/devhub/components/molecule/BadgeDetails.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
const nearDevGovBadgesContractId = "neardevgov.near";

let badgeId, ownerAccountId;
if (props.tokenId) {
let [_badgeId, _ownerAccountId] = props.tokenId.split(":", 2);
badgeId = _badgeId;
ownerAccountId = _ownerAccountId;
} else {
badgeId = props.badgeId;
}

if (!badgeId) {
return (
<>
Please, provide <pre>badgeId</pre> or <pre>tokenId</pre> to the
DevGovBadgeDetails component
</>
);
}

let badgeMetadata =
props.badgeMetadata ??
Near.view(nearDevGovBadgesContractId, "get_badge", {
badge_id: badgeId,
}).badge_metadata;

if (!badgeMetadata) {
return <>Loading...</>;
}

return (
<>
<div className="bg-white shadow rounded overflow-hidden">
<div className="px-4 pt-0 pb-5 bg-dark position-relative">
<div
className="profile-picture d-inline-block"
style={{ transform: "translateY(7rem)" }}
>
<Widget
src="${REPL_MOB}/widget/NftImage"
props={{
style: { width: "10em", height: "10em" },
className: "rounded-circle w-100 h-100 img-thumbnail d-block",
nft: {
tokenMetadata: badgeMetadata,
contractId: nearDevGovBadgesContractId,
},
alt: badgeMetadata.title,
}}
/>
</div>
</div>
<div className="bg-light px-4 pb-4">
<div className="d-md-flex justify-content-between pt-3 mb-2">
<div style={{ paddingTop: "3rem" }}>
<div className="me-2 d-sm-flex gap-1 flex-row align-items-center">
<div className="me-2 position-relative">
<h4 className="mt-0 mb-0 text-truncate">
{badgeMetadata.title}
</h4>
</div>
</div>
<div className="d-flex flex-row">
<div className="me-4">
<span className="text-muted">Awarded to</span>
<span className="fw-bolder">{badgeMetadata.copies}</span>
<span className="text-muted">developers</span>
</div>
</div>
<div>
<Markdown text={badgeMetadata.description} />
</div>
</div>
</div>
</div>
</div>
</>
);
2 changes: 1 addition & 1 deletion src/devhub/components/molecule/MarkdownViewer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ const renderMention =
((accountId) => (
<span key={accountId} className="d-inline-flex" style={{ fontWeight: 500 }}>
<Widget
src="neardevgov.near/widget/ProfileLine"
src="${REPL_DEVHUB}/widget/devhub.components.molecule.ProfileLine"
props={{
accountId: accountId.toLowerCase(),
hideAccountId: true,
Expand Down
2 changes: 1 addition & 1 deletion src/devhub/components/molecule/ProfileCard.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ const ProfileCard = (props) => {
<div className="d-flex flex-row align-items-center">
{inner}
<Widget
src="neardevgov.near/widget/BadgesList"
src="${REPL_DEVHUB}/widget/devhub.components.molecule.BadgesList"
props={{
accountId,
mode: "compact",
Expand Down
21 changes: 21 additions & 0 deletions src/devhub/components/molecule/ProfileLine.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
const accountId = props.accountId ?? context.accountId;

return (
<span>
<Widget
src="${REPL_MOB}/widget/ProfileLine"
props={{
...props,
accountId,
link: `#/${REPL_MOB}/widget/ProfilePage?accountId=${accountId}`,
}}
/>
<Widget
src="${REPL_DEVHUB}/widget/devhub.components.molecule.BadgesList"
props={{
accountId,
mode: "compact",
}}
/>
</span>
);
2 changes: 1 addition & 1 deletion src/devhub/entity/community/Teams.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ const UserList = ({ name, users }) => (
style={{ fontWeight: 500 }}
>
<Widget
src="neardevgov.near/widget/ProfileLine"
src="${REPL_DEVHUB}/widget/devhub.components.molecule.ProfileLine"
props={{ accountId: user, hideAccountId: true, tooltip: true }}
/>
</span>
Expand Down
2 changes: 1 addition & 1 deletion src/devhub/entity/post/Post.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -648,7 +648,7 @@ const postExtra =
<h6 class="card-subtitle mb-2 text-muted">
Supervisor:{" "}
<Widget
src={"neardevgov.near/widget/ProfileLine"}
src={"${REPL_DEVHUB}/widget/devhub.components.molecule.ProfileLine"}
props={{ accountId: snapshot.supervisor }}
/>
</h6>
Expand Down
2 changes: 1 addition & 1 deletion src/devhub/page/admin/moderatorsTab.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ return (
moderators.map((child) => (
<Tile className="w-25 p-3 m-1" minHeight={10}>
<Widget
src={`neardevgov.near/widget/ProfileLine`}
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.ProfileLine`}
props={{ accountId: child }}
/>
</Tile>
Expand Down

0 comments on commit 424c0a4

Please sign in to comment.