Skip to content

Commit

Permalink
Feature/988 sunset announcements (#1017)
Browse files Browse the repository at this point in the history
* feat: fetch from devhub-cache-api-rs.fly.dev

* @Megha-Dev-19 WIP

* wip

* fmt

* wip

* events and devhub are ready to be reviewed

* feat: infra proposals

* fmt

* feat: rfps infra

* remove comments

* fix: spelling

* fix: spelling

* replace all nearqueryapi in devhub related to proposals and rfps

* devhub: simplemde, acceptedTerms, passing instance

* fix: devhub

* refactor events: deleted SimpleMDE and LinkedProposalsDropdown for both

* test: replace all references of queryapi in tests

* test: fix linkedProposals and simpleMDE test :)

* test: skip discussions test for now

* clean up SimpleMDE

* infra: SimpleMDE, LinkedDropdown rfp + proposal, Proposal + Rfp.jsx, remove fetchgraphql from common

* test: fix events test, 1. had to deploy events with new cors policy, 2. passing instance down to simplemde, 3. mock the test on the right api path.

* test: infra -- fix: should show correct linked RFP to a proposal in feed page

* test: infra -- fix: should create proposal and link an RFP

* remove comments

* test: @petersalomonsen fixed!

* fmt

* test: discussions test back in

* test: skip discussions test

* revert: changes to rfp comment test

* initial commit 1002

* fmt

* test for comparing local feed with production

* add events committee feed components + by-sort component

* fmt

* compare links in prod and local

* test: update events test

* add events committee feed components + by-sort component

* fmt

* test: update events test

* test: comment spec

* test: included some test from pr 982

* revert commit

* feat: simpleMDE to new api

* fmt

* feat: linkedproposaldropdown to new api

* fmt

* test: proposal autolink

* fix: simplemde + test

* linked dropdowns

* feature: update feeds with new api

* fmt

* feat: new api on proposal and rfp page

* initial changes

* fmt

* fmt

* fix: copy after feedback

* skip tests

* fix: events test

* remove unused code

---------

Co-authored-by: Peter Salomonsen <[email protected]>
  • Loading branch information
Tguntenaar and petersalomonsen authored Dec 11, 2024
1 parent e864121 commit 2d5c662
Show file tree
Hide file tree
Showing 12 changed files with 62 additions and 337 deletions.
9 changes: 0 additions & 9 deletions instances/devhub.near/widget/app.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,15 +131,6 @@ function Page() {
/>
);
}
// ?page=feed
case "feed": {
return (
<Widget
src={"${REPL_DEVHUB}/widget/devhub.page.feed"}
props={passProps}
/>
);
}
// ?page=create
case "create": {
return (
Expand Down
23 changes: 6 additions & 17 deletions instances/devhub.near/widget/config/data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,11 @@ const proposalFeedAnnouncement = (
target="_blank"
rel="noopener noreferrer"
>
DevDAO’s New Proposal Feed!
DevDAO’s Proposal Feed!
</a>
</span>
This dedicated space replaces the
<a
href="?page=feed"
className="text-decoration-underline no-space"
target="_blank"
rel="noopener noreferrer"
>
old activity feed
</a>
, making it easier to submit and track funding requests from DevDAO, the
primary organization behind DevHub. To submit a formal proposal, click
New Proposal. See our{" "}
This space makes it easy to submit and track funding requests from
DevDAO. To submit a formal proposal, click New Proposal. See our{" "}
<a
href="?page=community&handle=developer-dao&tab=funding"
className="text-decoration-underline no-space"
Expand All @@ -35,17 +25,16 @@ const proposalFeedAnnouncement = (
>
guidelines
</a>
for details. For discussions and brainstorming, please utilize the
relevant{" "}
for details. You can also explore relevant{" "}
<a
href="?page=communities"
className="text-decoration-underline no-space"
target="_blank"
rel="noopener noreferrer"
>
communities
</a>
.
</a>{" "}
to connect and collaborate with builders.
</div>
</p>
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,11 +134,6 @@ const MobileMenu = styled.button`
`;

let links = [
{
title: "/feed",
href: "announcements",
links: [],
},
{
title: "/communities",
href: "communities",
Expand Down
76 changes: 2 additions & 74 deletions instances/devhub.near/widget/devhub/entity/addon/blog/Feed.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,89 +9,17 @@ const Loader = styled.div`
padding: 20px;
`;

const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql/`;
const DISPLAY_COUNT = 10;

const fetchGraphQL = (operationsDoc, operationName, variables) => {
return asyncFetch(QUERYAPI_ENDPOINT, {
method: "POST",
headers: { "x-hasura-role": `bo_near` },
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName,
}),
});
};

const queryName =
props.queryName ?? `bo_near_devhub_v38_posts_with_latest_snapshot`;

const query = `query DevhubPostsQuery($limit: Int = 100, $offset: Int = 0, $where: ${queryName}_bool_exp = {}) {
${queryName}(
limit: $limit
offset: $offset
order_by: {ts: desc}
where: $where
) {
post_id
}
}
`;

const [postIds, setPostIds] = useState([]);
const [loading, setLoading] = useState(false);
const [cachedItems, setCachedItems] = useState({});
const [hasNext, setHasNext] = useState(true);

const buildWhereClause = () => {
let where = {};
if (props.author) {
where = { author_id: { _eq: props.author }, ...where };
}
if (props.term) {
where = { description: { _ilike: `%${props.term}%` }, ...where };
}
if (props.includeLabels && Array.isArray(props.includeLabels)) {
const labelConditions = props.includeLabels.map((label) => ({
labels: { _contains: label },
}));

where = { _and: [...labelConditions, where] };
}
if (props.excludeLabels && Array.isArray(props.excludeLabels)) {
const labelConditions = props.excludeLabels.map((label) => ({
labels: { _nin: label },
}));

where = { _and: [...labelConditions, where] };
}
if (!props.recency) {
where = { parent_id: { _is_null: true }, ...where };
}
return where;
};

const fetchPostIds = (offset) => {
if (!offset) {
offset = 0;
}
if (loading) return;
setLoading(true);
const variables = { limit: DISPLAY_COUNT, offset, where: buildWhereClause() };
fetchGraphQL(query, "DevhubPostsQuery", variables).then((result) => {
if (result.status === 200) {
if (result.body.data) {
const data = result.body.data[queryName];
const newPostIds = data.map((p) => p.post_id);
setPostIds(offset === 0 ? newPostIds : [...postIds, ...newPostIds]);
setHasNext(data.length >= variables.limit);
} else {
console.error("GraphQL Error:", result.errors);
}
setLoading(false);
}
});

setLoading(false);
};

useEffect(() => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,76 +4,7 @@ const { getPost } = VM.require(

const { Layout, handle } = props;

const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql/`;

const fetchGraphQL = (operationsDoc, operationName, variables) => {
return fetch(QUERYAPI_ENDPOINT, {
method: "POST",
headers: { "x-hasura-role": `bo_near` },
body: JSON.stringify({
query: operationsDoc,
variables: variables,
operationName: operationName,
}),
});
};

const queryName =
props.queryName ?? `bo_near_devhub_v38_posts_with_latest_snapshot`;

const query = `query DevhubPostsQuery($limit: Int = 100, $offset: Int = 0, $where: ${queryName}_bool_exp = {}) {
${queryName}(
limit: $limit
offset: $offset
order_by: {block_height: desc}
where: $where
) {
post_id
}
}
`;

const includeLabels = ["blog", handle];

const buildWhereClause = () => {
let where = {};
if (props.author) {
where = { author_id: { _eq: props.author }, ...where };
}
if (props.term) {
where = { description: { _ilike: `%${props.term}%` }, ...where };
}
if (includeLabels && Array.isArray(includeLabels)) {
const labelConditions = includeLabels.map((label) => ({
labels: { _contains: label },
}));

where = { _and: [...labelConditions, where] };
}
if (props.excludeLabels && Array.isArray(props.excludeLabels)) {
const labelConditions = props.excludeLabels.map((label) => ({
labels: { _nin: label },
}));

where = { _and: [...labelConditions, where] };
}
if (!props.recency) {
where = { parent_id: { _is_null: true }, ...where };
}
return where;
};

const variables = { limit: DISPLAY_COUNT, offset, where: buildWhereClause() };

const posts = fetch(QUERYAPI_ENDPOINT, {
method: "POST",
headers: { "x-hasura-role": `bo_near` },
body: JSON.stringify({
query: query,
variables: variables,
operationName: "DevhubPostsQuery",
}),
});
const posts = [];

const handleOnChange = (v) => {
console.log("onChange", v);
Expand Down
Loading

0 comments on commit 2d5c662

Please sign in to comment.