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

Project Activity #251

Merged
merged 2 commits into from
Apr 22, 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
10 changes: 6 additions & 4 deletions apps/builddao/widget/components/modals/CreateProject.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,12 @@ const toggle = props.toggle;

const tabs = [
{ id: "overview", label: "Overview", disabled: true, checked: true },
{ id: "discussion", label: "Discussion", checked: false },
{ id: "tasks", label: "Tasks", checked: false },
{ id: "code", label: "Code", checked: false },
{ id: "roadmap", label: "Roadmap", checked: false },
{ id: "activity", label: "Activity", checked: true },
{ id: "tasks", label: "Tasks", checked: true },
// Uncomment after the support is added
// { id: "discussion", label: "Discussion", checked: false },
// { id: "code", label: "Code", checked: false },
// { id: "roadmap", label: "Roadmap", checked: false },
];

const app = props.app ?? "${config_account}";
Expand Down
69 changes: 69 additions & 0 deletions apps/builddao/widget/components/project/page/Activity.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
const { Feed } = VM.require("${alias_devs}/widget/Feed") ?? {
Feed: () => <></>,
};
const { Post } = VM.require("${config_account}/widget/components") || {
Post: () => <></>,
};
const { getProjectMeta } = VM.require(
"${config_account}/widget/lib.project-data",
) || {
getProjectMeta: () => {},
};

const { id } = props;

const project = getProjectMeta(id);
const { projectAccountId } = project;

return (
<div className="mt-3">
<Widget
loading={
<div
className="placeholder-glow h-100 w-100"
style={{ height: 400 }}
></div>
}
src="${config_account}/widget/Compose"
props={{
draftKey: id + "_discussions",
}}
/>
<Feed
index={[
{
action: "post",
key: "main",
options: {
limit: 10,
order: "desc",
accountId: [projectAccountId],
},
cacheOptions: {
ignoreCache: true,
},
},
{
action: "repost",
key: "main",
options: {
limit: 10,
order: "desc",
accountId: [projectAccountId],
},
cacheOptions: {
ignoreCache: true,
},
},
]}
Item={(p) => (
<Post
accountId={p.accountId}
blockHeight={p.blockHeight}
noBorder={true}
currentPath={`/${config_account}/widget/app?page=feed`}
/>
)}
/>
</div>
);
3 changes: 3 additions & 0 deletions apps/builddao/widget/page/feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,7 @@ const config = {
path: "${config_account}/widget/Feed",
blockHeight: "final",
init: {
feedName: "Request",
name: "Request",
icon: "bi-file-earmark-text",
requiredHashtags: ["build", "request"],
Expand Down Expand Up @@ -177,9 +178,11 @@ const config = {
path: "${config_account}/widget/Proposals",
blockHeight: "final",
init: {
feedName: "Proposals",
name: "Proposals",
icon: "bi-file-earmark-text",
daoId: "build.sputnik-dao.near",
template: "",
},
},
},
Expand Down
79 changes: 37 additions & 42 deletions apps/builddao/widget/page/project.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,54 +8,20 @@ const { ProjectLayout } = VM.require(
ProjectLayout: () => <></>,
};

const { id } = props;
const extractNearAddress = (id) => {
const parts = id.split("/");
if (parts.length > 0) {
return parts[0];
}
return "";
const { SidebarLayout } = VM.require(
"${config_account}/widget/template.SidebarLayout",
) || {
SidebarLayout: () => <></>,
};
const accountId = extractNearAddress(id);

const { id } = props;

const data = JSON.parse(Social.get(id, "final") ?? {});
if (!id || !data) {
return "Loading...";
}

const project = JSON.parse(data);

const projectSelectedRoutes = routes;

// remove unselected tabs
if (Array.isArray(project?.tabs)) {
Object.keys(projectSelectedRoutes).forEach((key) => {
if (!project.tabs.includes(key)) {
delete projectSelectedRoutes[key];
}
});
}

const profileData = {
name: data.title,
description: data.description,
linktree: {
github: data.github,
telegram: data.telegram,
twitter: data.twitter,
website: data.website,
},
backgroundImage: data.backgroundImage?.image,
image: data.profileImage?.image,
};

const { SidebarLayout } = VM.require(
"${config_account}/widget/template.SidebarLayout",
) || {
SidebarLayout: () => <></>,
};

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

const config = {
theme: {},
Expand All @@ -71,7 +37,7 @@ const config = {
<>
<ProjectLayout
profile={profile}
projectAccountId={accountId}
projectAccountId={data.projectAccountId}
page={page}
routes={config.router.routes}
project={project}
Expand All @@ -93,6 +59,13 @@ const config = {
},
default: "true",
},
activity: {
path: "${config_account}/widget/components.project.page.Activity",
blockHeight: "final",
init: {
...props,
},
},
discussion: {
path: "${config_account}/widget/components.project.page.Discussion",
blockHeight: "final",
Expand Down Expand Up @@ -125,6 +98,28 @@ const config = {
},
};

// remove unselected tabs
if (Array.isArray(data?.tabs)) {
Object.keys(config.router.routes).forEach((key) => {
if (!data.tabs.includes(key)) {
delete config.router.routes[key];
}
});
}

const profileData = {
name: data.title,
description: data.description,
linktree: {
github: data.github,
telegram: data.telegram,
twitter: data.twitter,
website: data.website,
},
backgroundImage: data.backgroundImage?.image,
image: data.profileImage?.image,
};

const Root = styled.div`
display: flex;
gap: 24px;
Expand Down
Loading