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

v2.0.3 #447

Merged
merged 15 commits into from
Jun 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"socialdb": "social.near",
"gateway_url": "https://nearbuilders.org",
"new": "builddao.near",
"old": "buildhub.near"
"old": "buildhub.near",
"potlock": "potlock.near"
}
3 changes: 2 additions & 1 deletion aliases.testnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@
"socialdb": "v1.social08.testnet",
"gateway_url": "https://test.nearbuilders.org",
"new": "builddao.testnet",
"old": "buildhub.testnet"
"old": "buildhub.testnet",
"potlock": "potlock.testnet"
}
24 changes: 21 additions & 3 deletions apps/new/widget/Index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,22 @@ const { Footer } = VM.require("${config_account}/widget/components.Footer") || {
Footer: () => <></>,
};

const { isNearSocial } = VM.require("${alias_new}/widget/lib.gateway") || {
isNearSocial: false,
};

const Container = isNearSocial
? styled.div`
position: fixed;
inset: 73px 0px 0px;
width: 100%;
overflow-y: scroll;
height: 100%;
`
: styled.div`
width: 100%;
`;

const config = {
theme: {},
layout: {
Expand Down Expand Up @@ -111,7 +127,9 @@ const config = {
};

return (
<CSS>
<Widget src="${alias_old}/widget/app.view" props={{ config, ...props }} />
</CSS>
<Container>
<CSS>
<Widget src="${alias_old}/widget/app.view" props={{ config, ...props }} />
</CSS>
</Container>
);
6 changes: 6 additions & 0 deletions apps/new/widget/components/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -176,10 +176,12 @@ const Footer = () => {
<p>Dive deeper BuildDAO</p>
<SocialIcons>
<Button
noLink={true}
type="icon"
style={{
borderRadius: "30%",
}}
target="_blank"
href="https://x.com/NearBuilders"
>
<svg
Expand All @@ -194,7 +196,9 @@ const Footer = () => {
</svg>
</Button>
<Button
noLink={true}
type="icon"
target="_blank"
style={{
borderRadius: "30%",
}}
Expand All @@ -217,6 +221,8 @@ const Footer = () => {
</svg>
</Button>
<Button
noLink={true}
target="_blank"
type="icon"
style={{
borderRadius: "30%",
Expand Down
1 change: 1 addition & 0 deletions apps/new/widget/components/project/Card.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@ const EditButton = ({ item }) => {
id: item.path,
},
})}
onClick={(e) => e.stopPropagation()}
type="icon"
className={"rounded-3"}
variant="primary"
Expand Down
98 changes: 98 additions & 0 deletions apps/new/widget/components/project/ProfileCard.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
const MutedText = styled.span`
color: #818181;

font-size: 16px;
font-style: normal;
font-weight: 400;
line-height: 20px; /* 125% */
`;

const AccountName = styled.span`
color: #818181;
font-size: 16px;
font-style: normal;
font-weight: 500;
line-height: 20px;

max-width: 30ch;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
`;

const ProfileCard = (props) => {
const accountId = props.accountId ?? context.accountId;
const link = props.link ?? true;
// const hideAccountId = props.hideAccountId;
// const hideName = props.hideName;
const hideImage = props.hideImage;
const iconOnly = props.iconOnly;
const openLinkInNewTab = props.openLinkInNewTab ?? false;

const profile = props.profile ?? Social.getr(`${accountId}/profile`);

const name = profile.name ?? accountId;
const title = props.title ?? `${name} @${accountId}`;
const tooltip =
props.tooltip && (props.tooltip === true ? title : props.tooltip);

let inner = (
<div className="d-flex flex-row justify-content-center align-items-center">
{!hideImage && (
<Widget
key="image"
src="${alias_mob}/widget/ProfileImage"
props={{
style: { width: "2.5em", height: "2.5em", marginRight: "0.3em" },
profile,
accountId,
className: "d-inline-block flex-shrink-0",
imageClassName: "rounded-circle w-100 h-100 align-top",
}}
/>
)}
{!iconOnly && (
<div className="d-flex flex-column gap-1">
<AccountName key="accountName">{name}</AccountName>
<AccountName key="accountId">@{accountId}</AccountName>
</div>
)}
</div>
);

inner = link ? (
<a
href={
link !== true
? link
: `/${REPL_MOB}/widget/ProfilePage?accountId=${accountId}`
}
target={openLinkInNewTab ? "_blank" : ""}
rel="noopener noreferrer"
className="link-dark text-truncate d-inline-flex"
>
{inner}
</a>
) : (
<span className="text-truncate d-inline-flex">{inner}</span>
);

if (props.tooltip === true) {
return (
<Widget
src="${REPL_MOB}/widget/Profile.OverlayTrigger"
props={{ accountId, children: inner }}
/>
);
}
if (tooltip) {
inner = (
<OverlayTrigger placement="auto" overlay={<Tooltip>{tooltip}</Tooltip>}>
{inner}
</OverlayTrigger>
);
}
return <div className="d-flex flex-row align-items-center">{inner}</div>;
};

return ProfileCard(props);
6 changes: 6 additions & 0 deletions apps/new/widget/lib/gateway.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
const data = fetch(`https://httpbin.org/headers`);
const gatewayOrigin = data?.body?.headers?.Origin ?? "";

const isNearSocial = gatewayOrigin.includes("near.social");

return { isNearSocial, gatewayOrigin };
5 changes: 5 additions & 0 deletions apps/new/widget/page/project/QuickView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ const { href } = VM.require("${alias_old}/widget/lib.url") || {
href: () => {},
};

const { isNearSocial } = VM.require("${alias_new}/widget/lib.gateway") || {
isNearSocial: false,
};

const showCanvas = props.showCanvas;
const onClose = props.onClose;
const project = props.project;
Expand Down Expand Up @@ -86,6 +90,7 @@ return (
tabIndex="-1"
data-bs-scroll="false"
data-bs-backdrop="true"
style={{ top: isNearSocial ? "73px" : "0px" }}
>
<div class="close cursor" onClick={onClose}>
<div className="d-block d-md-none">
Expand Down
2 changes: 2 additions & 0 deletions apps/new/widget/page/project/TaskEditor.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ const task = props.task;
const onEditTask = props.onEditTask;
const onAddTask = props.onAddTask;
const project = props.project;
const isEditTask = props.isEditTask;

const [taskDetail, setTaskDetail] = useState(task);

Expand Down Expand Up @@ -136,6 +137,7 @@ return (
list: [...(taskDetail.list ?? []), { ...listItem }],
})
}
data-testid="add-task-item"
>
<i class="bi bi-plus-circle h5 pointer"></i>
</div>
Expand Down
4 changes: 3 additions & 1 deletion apps/new/widget/page/project/tabs/Task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -369,6 +369,7 @@ const DropdownMenu = ({ columnTitle, item, index, changeStatusOptions }) => {
onBlur={() => handleDropdownToggle(columnTitle, index, false)}
>
<div
data-testid="task-dropdown"
data-bs-toggle="dropdown"
aria-expanded="false"
onClick={() => {
Expand Down Expand Up @@ -479,6 +480,7 @@ const AddTaskModal = useMemo(() => {
src="${config_account}/widget/page.project.TaskEditor"
props={{
showAddTaskModal: showAddTaskModal,
isEditTask: isEditTask,
task: taskDetail,
onEditTask: onEditTask,
onAddTask: onAddTask,
Expand Down Expand Up @@ -526,7 +528,7 @@ const ViewTaskModal = () => {
<div className="assignee-item" key={index}>
<Widget
src={
"devhub.near/widget/devhub.components.molecule.ProfileCard"
"${config_account}/widget/components.project.ProfileCard"
}
props={{
accountId: assignee,
Expand Down
5 changes: 4 additions & 1 deletion apps/new/widget/page/projects/MainViewContainer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,10 @@ const ProjectCardWrapper = ({ children, project }) => {
return (
<div
className="cursor d-flex flex-1"
onClick={() => setShowQuickView(project)}
onClick={(e) => {
e.stopPropagation();
setShowQuickView(project);
}}
>
{children}
</div>
Expand Down
4 changes: 2 additions & 2 deletions apps/new/widget/page/projects/PotlockImport.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,15 @@ const { Button } = VM.require("${alias_old}/widget/components") || {
Button: () => <></>,
};
const { getTagsFromSocialProfileData, getTeamMembersFromSocialProfileData } =
VM.require("potlock.near/widget/utils") || {
VM.require("${alias_potlock}/widget/utils") || {
getTagsFromSocialProfileData: () => [],
getTeamMembersFromSocialProfileData: () => [],
};

const bootstrapTheme = props.bootstrapTheme || "dark";

let ListsSDK =
VM.require("potlock.near/widget/SDK.lists") ||
VM.require("${alias_potlock}/widget/SDK.lists") ||
(() => ({
getRegistrations: () => {},
}));
Expand Down
17 changes: 10 additions & 7 deletions apps/new/widget/page/projects/PotlockProjectCard.jsx
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@
const { potId, potDetail, payoutDetails, projects } = props;
const { nearToUsd, ipfsUrlFromCid, yoctosToNear, yoctosToUsdWithFallback } =
VM.require("potlock.near/widget/utils") || {
VM.require("${alias_potlock}/widget/utils") || {
ipfsUrlFromCid: () => "",
yoctosToNear: () => "",
yoctosToUsdWithFallback: () => "",
nearToUsd: 1,
};

const { _address } = VM.require(
`potlock.near/widget/Components.DonorsUtils`,
"${alias_potlock}/widget/Components.DonorsUtils",
) || {
_address: (address) => address,
};

const { ownerId, NADA_BOT_URL, SUPPORTED_FTS } = VM.require(
"potlock.near/widget/constants",
"${alias_potlock}/widget/constants",
) || {
ownerId: "",
NADA_BOT_URL: "",
SUPPORTED_FTS: {},
};
const { getTagsFromSocialProfileData } = VM.require(
"potlock.near/widget/utils",
"${alias_potlock}/widget/utils",
) || {
getTagsFromSocialProfileData: () => [],
};

const PotSDK = VM.require("potlock.near/widget/SDK.pot") || {
const PotSDK = VM.require("${alias_potlock}/widget/SDK.pot") || {
getDonationsForProject: () => {},
};

let DonateSDK =
VM.require("potlock.near/widget/SDK.donate") ||
VM.require("${alias_potlock}/widget/SDK.donate") ||
(() => ({
getDonationsForRecipient: () => {},
}));
Expand Down Expand Up @@ -363,7 +363,10 @@ const profileImageStyle = {
const tags = getTagsFromSocialProfileData(profile);

return (
<div onClick={() => props.setShowCreateModalProjectId(projectId)}>
<div
data-testid="potlock-card"
onClick={() => props.setShowCreateModalProjectId(projectId)}
>
<Card>
<HeaderContainer className="pt-0 position-relative">
<BackgroundImageContainer>
Expand Down
2 changes: 2 additions & 0 deletions apps/old/widget/components/Button.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ function Button({
className={linkClassName}
style={{ textDecoration: "none" }}
target={target}
onClick={(e) => e.stopPropagation()}
>
<StyledButton
id={id}
Expand All @@ -128,6 +129,7 @@ function Button({
className={linkClassName}
style={{ textDecoration: "none" }}
target={target}
onClick={(e) => e.stopPropagation()}
>
<StyledButton
id={id}
Expand Down
4 changes: 0 additions & 4 deletions apps/old/widget/components/profile/ProfileEdit.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@ if (!accountId) {

const profile = Social.getr(`${accountId}/profile`);

if (!profile) {
return "";
}

const [name, setName] = useState(profile.name ?? "");
const [description, setDescription] = useState(profile.description ?? "");
const [location, setLocation] = useState(profile.location ?? "");
Expand Down
2 changes: 1 addition & 1 deletion apps/old/widget/components/project/page/Task.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -677,7 +677,7 @@ const ViewTaskModal = () => {
<div className="assignee-item" key={index}>
<Widget
src={
"devhub.near/widget/devhub.components.molecule.ProfileCard"
"${config_account}/widget/components.project.ProfileCard"
}
props={{
accountId: assignee,
Expand Down
Loading
Loading