From b6dcc1ac989fb5ce49c6c8196e78f9357bbef7da Mon Sep 17 00:00:00 2001 From: Megha <100185149+Megha-Dev-19@users.noreply.github.com> Date: Fri, 9 Aug 2024 23:41:18 +0530 Subject: [PATCH] Refactor proposal feed component (#912) * fix solution action * fix preview for proposals * reused feed component * delete components * remove comments * update test * move all props to one file --- instances/devhub.near/widget/app.jsx | 30 +- instances/devhub.near/widget/config/css.jsx | 26 + instances/devhub.near/widget/config/data.jsx | 97 +++ instances/devhub.near/widget/config/theme.jsx | 5 + .../widget/devhub/entity/proposal/Feed.jsx | 234 ++++--- .../devhub/entity/proposal/LikeButton.jsx | 3 +- .../proposal/MultiSelectLabelsDropdown.jsx | 193 ++++++ .../feature/proposal-search/by-author.jsx | 7 +- .../feature/proposal-search/by-category.jsx | 66 +- .../widget/devhub/page/proposals.jsx | 4 +- .../events-committee.near/widget/app.jsx | 30 +- .../widget/config/css.jsx | 17 + .../widget/config/data.jsx | 52 ++ .../widget/config/theme.jsx | 5 + .../widget/devhub/entity/proposal/Feed.jsx | 582 ----------------- .../feature/proposal-search/by-author.jsx | 42 -- .../feature/proposal-search/by-category.jsx | 51 -- .../feature/proposal-search/by-sort.jsx | 27 - .../feature/proposal-search/by-stage.jsx | 30 - .../widget/devhub/page/proposals.jsx | 6 +- .../widget/app.jsx | 37 +- .../widget/components/proposals/Feed.jsx | 612 ------------------ .../widget/components/proposals/Proposals.jsx | 8 + .../widget/config/css.jsx | 22 + .../widget/config/data.jsx | 71 ++ .../widget/config/theme.jsx | 5 + package.json | 1 + .../tests/proposal/proposals.spec.js | 2 +- 28 files changed, 691 insertions(+), 1574 deletions(-) create mode 100644 instances/devhub.near/widget/config/css.jsx create mode 100644 instances/devhub.near/widget/config/data.jsx create mode 100644 instances/devhub.near/widget/config/theme.jsx create mode 100644 instances/devhub.near/widget/devhub/entity/proposal/MultiSelectLabelsDropdown.jsx create mode 100644 instances/events-committee.near/widget/config/css.jsx create mode 100644 instances/events-committee.near/widget/config/data.jsx create mode 100644 instances/events-committee.near/widget/config/theme.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/proposal/Feed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/proposal-search/by-author.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/proposal-search/by-category.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/proposal-search/by-sort.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/proposal-search/by-stage.jsx delete mode 100644 instances/infrastructure-committee.near/widget/components/proposals/Feed.jsx create mode 100644 instances/infrastructure-committee.near/widget/components/proposals/Proposals.jsx create mode 100644 instances/infrastructure-committee.near/widget/config/css.jsx create mode 100644 instances/infrastructure-committee.near/widget/config/data.jsx create mode 100644 instances/infrastructure-committee.near/widget/config/theme.jsx diff --git a/instances/devhub.near/widget/app.jsx b/instances/devhub.near/widget/app.jsx index 83b9e40aa..be0619899 100644 --- a/instances/devhub.near/widget/app.jsx +++ b/instances/devhub.near/widget/app.jsx @@ -14,27 +14,13 @@ const { AppLayout } = VM.require( "${REPL_DEVHUB}/widget/devhub.components.templates.AppLayout" ); -if (!AppLayout) { +const { CssContainer } = VM.require("${REPL_DEVHUB}/widget/config.css"); +const { Theme } = VM.require("${REPL_DEVHUB}/widget/config.theme"); + +if (!AppLayout || !Theme || !CssContainer) { return
Loading modules...
; } -// CSS styles to be used across the app. -// Define fonts here, as well as any other global styles. -const Theme = styled.div` - a { - color: inherit; - } - - .attractable { - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } - } -`; - if (!page) { // If no page is specified, we default to the feed page TEMP page = "home"; @@ -256,8 +242,10 @@ function Page() { return (+
Loading modules...
; +function isNumber(v) { + return typeof v === "number"; } const Container = styled.div` @@ -49,18 +75,8 @@ const Container = styled.div` } } - .green-btn { - background-color: #04a46e !important; - border: none; - color: white; - - &:active { - color: white; - } - } - @media screen and (max-width: 768px) { - .green-btn { + .theme-btn { padding: 0.5rem 0.8rem !important; min-height: 32px; } @@ -115,14 +131,17 @@ const FeedItem = ({ proposal, index }) => { const blockHeight = parseInt(proposal.social_db_post_block_height); const item = { type: "social", - path: `${REPL_DEVHUB_CONTRACT}/post/main`, + path: `${contract}/post/main`, blockHeight: blockHeight, }; + const isLinked = isNumber(proposal.linked_rfp); + const rfpData = proposal.rfpData; + return ( {-
Loading modules...
; } -// CSS styles to be used across the app. -// Define fonts here, as well as any other global styles. -const Theme = styled.div` - a { - color: inherit; - } - - .attractable { - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } - } -`; - if (!page) { // If no page is specified, we default to the feed page TEMP page = "home"; @@ -107,8 +93,10 @@ function Page() { return (+
Loading modules...
; -} - -const Container = styled.div` - .full-width-div { - width: 100vw; - position: relative; - left: 50%; - right: 50%; - margin-left: -50vw; - margin-right: -50vw; - } - - .card.no-border { - border-left: none !important; - border-right: none !important; - margin-bottom: -3.5rem; - } - - @media screen and (max-width: 768px) { - font-size: 13px; - } - - .text-sm { - font-size: 13px; - } - - .bg-grey { - background-color: #f4f4f4; - } - - .border-bottom { - border-bottom: 1px solid grey; - } - - .cursor-pointer { - cursor: pointer; - } - - .proposal-card { - border-left: none !important; - border-right: none !important; - border-bottom: none !important; - &:hover { - background-color: #f4f4f4; - } - } - - .green-btn { - background-color: #03ba16 !important; - border: none; - color: white; - - &:active { - color: white; - } - } - - @media screen and (max-width: 768px) { - .green-btn { - padding: 0.5rem 0.8rem !important; - min-height: 32px; - } - } - - a.no-space { - display: inline-block; - } - - .text-wrap { - overflow: hidden; - white-space: normal; - } -`; - -const Heading = styled.div` - font-size: 24px; - font-weight: 700; - width: 100%; - - .text-normal { - font-weight: normal !important; - } - - @media screen and (max-width: 768px) { - font-size: 18px; - } -`; - -const FeedItem = ({ proposal, index }) => { - const accountId = proposal.author_id; - const profile = Social.get(`${accountId}/profile/**`, "final"); - // We will have to get the proposal from the contract to get the block height. - const blockHeight = parseInt(proposal.social_db_post_block_height); - const item = { - type: "social", - path: `${REPL_EVENTS_CONTRACT}/post/main`, - blockHeight: blockHeight, - }; - - return ( - e.stopPropagation()} - style={{ textDecoration: "none" }} - > --
Loading modules...
; -} - -// CSS styles to be used across the app. -// Define fonts here, as well as any other global styles. -const Theme = styled.div` - a { - color: inherit; - } +const { Theme } = VM.require( + `${REPL_INFRASTRUCTURE_COMMITTEE}/widget/config.theme` +); - .attractable { - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; +const { CssContainer } = VM.require( + `${REPL_INFRASTRUCTURE_COMMITTEE}/widget/config.css` +); - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } - } -`; +if (!AppLayout || !Theme || !CssContainer) { + returnLoading modules...
; +} if (!page) { // If no page is specified, we default to the feed page TEMP @@ -84,7 +75,7 @@ function Page() { case "proposals": { return (-
+