From 5b7f735d652c7a4bfbb5458cdca099c51b457642 Mon Sep 17 00:00:00 2001 From: Megha <100185149+Megha-Dev-19@users.noreply.github.com> Date: Thu, 25 Jul 2024 20:21:37 +0530 Subject: [PATCH] refactor events-committee (#905) --- .../widget/DevGov/Notification/Item/Left.jsx | 34 - .../widget/DevGov/Notification/Item/Right.jsx | 20 - .../events-committee.near/widget/app.jsx | 8 + .../widget/devhub/components/atom/Alert.jsx | 15 - .../widget/devhub/components/atom/Icon.jsx | 45 - .../widget/devhub/components/atom/Tag.jsx | 13 - .../widget/devhub/components/atom/Toggle.jsx | 77 -- .../components/feed/MergedIndexFeed.jsx | 265 ----- .../devhub/components/feed/SubscribedFeed.jsx | 179 ---- .../devhub/components/island/banner.jsx | 100 -- .../devhub/components/island/connect.jsx | 332 ------- .../devhub/components/island/explore.jsx | 193 ---- .../widget/devhub/components/island/hero.jsx | 212 ---- .../devhub/components/island/home-section.jsx | 63 -- .../devhub/components/island/participate.jsx | 207 ---- .../devhub/components/island/support.jsx | 134 --- .../components/layout/LikeButton/Faces.jsx | 122 --- .../components/molecule/BadgeDetails.jsx | 78 -- .../devhub/components/molecule/BadgesList.jsx | 63 -- .../components/molecule/BlogControl.jsx | 16 - .../devhub/components/molecule/Button.jsx | 2 +- .../components/molecule/CommunityControl.jsx | 51 - .../components/molecule/PostControls.jsx | 51 - .../components/organism/Configurator.jsx | 316 ------ .../devhub/components/organism/Feed.jsx | 130 --- .../components/organism/Feed/NearQueryApi.jsx | 275 ------ .../devhub/components/organism/NewsLetter.jsx | 146 --- .../widget/devhub/entity/addon/blog/Card.jsx | 77 -- .../devhub/entity/addon/blog/Configurator.jsx | 45 - .../widget/devhub/entity/addon/blog/Feed.jsx | 142 --- .../widget/devhub/entity/addon/blog/Page.jsx | 129 --- .../devhub/entity/addon/blog/Viewer.jsx | 79 -- .../entity/addon/blog/editor/content.jsx | 263 ----- .../devhub/entity/addon/blog/editor/form.jsx | 169 ---- .../devhub/entity/addon/blog/editor/index.jsx | 81 -- .../entity/addon/blog/editor/layout.jsx | 36 - .../entity/addon/blog/editor/provider.jsx | 140 --- .../entity/addon/blog/editor/sidebar.jsx | 50 - .../devhub/entity/addon/blogv2/Blog.jsx | 13 - .../devhub/entity/addon/blogv2/Card.jsx | 77 -- .../entity/addon/blogv2/Configurator.jsx | 84 -- .../devhub/entity/addon/blogv2/Page.jsx | 143 --- .../devhub/entity/addon/blogv2/Viewer.jsx | 274 ----- .../addon/blogv2/editor/BlogOverview.jsx | 106 -- .../addon/blogv2/editor/BlogPostSettings.jsx | 17 - .../addon/blogv2/editor/CategoryDropdown.jsx | 153 --- .../addon/blogv2/editor/ConfirmModal.jsx | 150 --- .../entity/addon/blogv2/editor/content.jsx | 693 ------------- .../entity/addon/blogv2/editor/form.jsx | 209 ---- .../entity/addon/blogv2/editor/index.jsx | 90 -- .../entity/addon/blogv2/editor/layout.jsx | 148 --- .../entity/addon/blogv2/editor/provider.jsx | 120 --- .../entity/addon/github/Configurator.jsx | 603 ----------- .../devhub/entity/addon/github/Viewer.jsx | 38 - .../entity/addon/github/kanban_board.jsx | 232 ----- .../entity/addon/github/kanban_ticket.jsx | 123 --- .../entity/addon/kanban/Configurator.jsx | 478 --------- .../devhub/entity/addon/kanban/Viewer.jsx | 34 - .../devhub/entity/addon/kanban/post_board.jsx | 194 ---- .../entity/addon/kanban/post_ticket.jsx | 188 ---- .../entity/addon/telegram/Configurator.jsx | 119 --- .../devhub/entity/addon/telegram/Viewer.jsx | 56 -- .../devhub/entity/addon/wiki/Configurator.jsx | 163 --- .../devhub/entity/addon/wiki/Viewer.jsx | 95 -- .../devhub/entity/community/Activity.jsx | 85 -- .../devhub/entity/community/Announcements.jsx | 210 ---- .../widget/devhub/entity/community/Card.jsx | 71 -- .../devhub/entity/community/Compose.jsx | 478 --------- .../devhub/entity/community/Discussions.jsx | 276 ------ .../devhub/entity/community/Provider.jsx | 72 -- .../devhub/entity/community/Sidebar.jsx | 70 -- .../devhub/entity/community/Spawner.jsx | 100 -- .../widget/devhub/entity/community/Teams.jsx | 62 -- .../widget/devhub/entity/community/Tile.jsx | 90 -- .../configuration/AboutConfigurator.jsx | 64 -- .../AccessControlConfigurator.jsx | 174 ---- .../configuration/AddonsConfigurator.jsx | 336 ------- .../configuration/BrandingConfigurator.jsx | 165 ---- .../configuration/ConfigurationSection.jsx | 49 - .../configuration/InformationConfigurator.jsx | 78 -- .../widget/devhub/entity/post/History.jsx | 130 --- .../widget/devhub/entity/post/List.jsx | 400 -------- .../widget/devhub/entity/post/Panel.jsx | 742 -------------- .../widget/devhub/entity/post/Post.jsx | 924 ----------------- .../widget/devhub/entity/post/PostEditor.jsx | 932 ------------------ .../widget/devhub/entity/post/Postv2.jsx | 20 - .../widget/devhub/entity/post/draft.jsx | 10 - .../devhub/entity/team/Configurator.jsx | 247 ----- .../devhub/entity/team/LabelPermissions.jsx | 35 - .../widget/devhub/entity/team/LabelRow.jsx | 264 ----- .../devhub/feature/post-search/by-author.jsx | 30 - .../devhub/feature/post-search/by-tag.jsx | 30 - .../devhub/feature/post-search/panel.jsx | 218 ---- .../widget/devhub/notification/Item.jsx | 22 - .../widget/devhub/notification/LR.jsx | 26 - .../widget/devhub/notification/Left.jsx | 34 - .../widget/devhub/notification/Right.jsx | 20 - .../widget/devhub/page/addon.jsx | 170 ---- .../widget/devhub/page/announcements.jsx | 151 --- .../widget/devhub/page/blog.jsx | 111 --- .../widget/devhub/page/blogv2.jsx | 146 --- .../widget/devhub/page/communities.jsx | 222 ----- .../devhub/page/community/configuration.jsx | 189 ---- .../widget/devhub/page/community/index.jsx | 365 ------- .../widget/devhub/page/contribute.jsx | 204 ---- .../widget/devhub/page/feed.jsx | 76 -- .../widget/devhub/page/home.jsx | 12 - .../widget/devhub/page/post.jsx | 22 - .../widget/devhub/page/profile.jsx | 11 - 109 files changed, 9 insertions(+), 17092 deletions(-) delete mode 100644 instances/events-committee.near/widget/DevGov/Notification/Item/Left.jsx delete mode 100644 instances/events-committee.near/widget/DevGov/Notification/Item/Right.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/atom/Alert.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/atom/Icon.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/atom/Tag.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/atom/Toggle.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/feed/MergedIndexFeed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/feed/SubscribedFeed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/banner.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/connect.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/explore.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/hero.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/home-section.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/participate.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/island/support.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/layout/LikeButton/Faces.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/BadgeDetails.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/BadgesList.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/BlogControl.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/CommunityControl.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/molecule/PostControls.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/organism/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/organism/Feed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/organism/Feed/NearQueryApi.jsx delete mode 100644 instances/events-committee.near/widget/devhub/components/organism/NewsLetter.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/Card.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/Feed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/Page.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/content.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/form.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/index.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/layout.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/provider.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blog/editor/sidebar.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/Blog.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/Card.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/Page.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/BlogOverview.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/BlogPostSettings.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/CategoryDropdown.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/ConfirmModal.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/content.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/form.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/index.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/layout.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/blogv2/editor/provider.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/github/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/github/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/github/kanban_board.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/github/kanban_ticket.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/kanban/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/kanban/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/kanban/post_board.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/kanban/post_ticket.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/telegram/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/telegram/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/wiki/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/addon/wiki/Viewer.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Activity.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Announcements.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Card.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Compose.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Discussions.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Provider.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Sidebar.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Spawner.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Teams.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/Tile.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/AboutConfigurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/AccessControlConfigurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/AddonsConfigurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/BrandingConfigurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/ConfigurationSection.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/community/configuration/InformationConfigurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/History.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/List.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/Panel.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/Post.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/PostEditor.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/Postv2.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/post/draft.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/team/Configurator.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/team/LabelPermissions.jsx delete mode 100644 instances/events-committee.near/widget/devhub/entity/team/LabelRow.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/post-search/by-author.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/post-search/by-tag.jsx delete mode 100644 instances/events-committee.near/widget/devhub/feature/post-search/panel.jsx delete mode 100644 instances/events-committee.near/widget/devhub/notification/Item.jsx delete mode 100644 instances/events-committee.near/widget/devhub/notification/LR.jsx delete mode 100644 instances/events-committee.near/widget/devhub/notification/Left.jsx delete mode 100644 instances/events-committee.near/widget/devhub/notification/Right.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/addon.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/announcements.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/blog.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/blogv2.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/communities.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/community/configuration.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/community/index.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/contribute.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/feed.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/home.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/post.jsx delete mode 100644 instances/events-committee.near/widget/devhub/page/profile.jsx diff --git a/instances/events-committee.near/widget/DevGov/Notification/Item/Left.jsx b/instances/events-committee.near/widget/DevGov/Notification/Item/Left.jsx deleted file mode 100644 index ddad71374..000000000 --- a/instances/events-committee.near/widget/DevGov/Notification/Item/Left.jsx +++ /dev/null @@ -1,34 +0,0 @@ -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url") || (() => {}); - -if (!props.type) { - return "Loading ..."; -} - -const type = props.type.split("/")[1]; -return props.type ? ( - <> - {type == "like" - ? "liked your" - : type == "reply" - ? "replied to your" - : type == "edit" - ? "edited your" - : type == "mention" - ? "mentioned you in their" - : "???"}{" "} - - DevHub post - - -) : ( - "Loading ..." -); diff --git a/instances/events-committee.near/widget/DevGov/Notification/Item/Right.jsx b/instances/events-committee.near/widget/DevGov/Notification/Item/Right.jsx deleted file mode 100644 index fd1c98d22..000000000 --- a/instances/events-committee.near/widget/DevGov/Notification/Item/Right.jsx +++ /dev/null @@ -1,20 +0,0 @@ -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url") || (() => {}); - -return props.post === undefined ? ( - "Loading ..." -) : ( - <> - - View DevHub post - - -); diff --git a/instances/events-committee.near/widget/app.jsx b/instances/events-committee.near/widget/app.jsx index ef90d8bad..8871fdf82 100644 --- a/instances/events-committee.near/widget/app.jsx +++ b/instances/events-committee.near/widget/app.jsx @@ -86,6 +86,14 @@ function Page() { /> ); } + case "profile": { + return ( + + ); + } default: { return ( - message && ( - - ); - -return Alert(props); diff --git a/instances/events-committee.near/widget/devhub/components/atom/Icon.jsx b/instances/events-committee.near/widget/devhub/components/atom/Icon.jsx deleted file mode 100644 index b9e425dfa..000000000 --- a/instances/events-committee.near/widget/devhub/components/atom/Icon.jsx +++ /dev/null @@ -1,45 +0,0 @@ -const svgIconsByVariant = { - floppy_drive: (elementProps) => ( - - - - - - ), -}; - -const iconsByType = { - bootstrap_icon: ({ className, variant, ...otherProps }) => ( - - ), - - svg_icon: ({ variant, ...elementProps }) => - svgIconsByVariant[variant](elementProps), -}; - -const Icon = ({ type, ...otherProps }) => - typeof iconsByType[type] === "function" - ? iconsByType[type](otherProps) - : null; - -return Icon(props); diff --git a/instances/events-committee.near/widget/devhub/components/atom/Tag.jsx b/instances/events-committee.near/widget/devhub/components/atom/Tag.jsx deleted file mode 100644 index d4a8d3216..000000000 --- a/instances/events-committee.near/widget/devhub/components/atom/Tag.jsx +++ /dev/null @@ -1,13 +0,0 @@ -const black = props.black; - -const Span = styled.span` - color: ${black ? "#818181" : "#00ec97"}; - font-size: 16px; - font-style: normal; - font-weight: 700; - line-height: 20px; /* 125% */ -`; - -const Tag = ({ tag }) => {tag}; - -return Tag(props); diff --git a/instances/events-committee.near/widget/devhub/components/atom/Toggle.jsx b/instances/events-committee.near/widget/devhub/components/atom/Toggle.jsx deleted file mode 100644 index f91f10cf0..000000000 --- a/instances/events-committee.near/widget/devhub/components/atom/Toggle.jsx +++ /dev/null @@ -1,77 +0,0 @@ -const ToggleRoot = styled.div` - justify-content: space-between; - width: fit-content; - max-width: 100%; -`; - -const ToggleSwitchRoot = styled("Switch.Root")` - all: unset; - display: block; - width: 42px; - height: 25px; - background-color: #d1d1d1; - border-radius: 9999px; - position: relative; - box-shadow: 0 2px 10px var(--blackA7); - - &[data-state="checked"] { - background-color: #00d084; - } - - &[data-disabled=""] { - opacity: 0.7; - } -`; - -const ToggleSwitchThumb = styled("Switch.Thumb")` - all: unset; - display: block; - width: 21px; - height: 21px; - border-radius: 9999px; - transition: transform 100ms; - transform: translateX(2px); - will-change: transform; - - &[data-state="checked"] { - transform: translateX(19px); - } -`; - -const ToggleLabel = styled.label` - white-space: nowrap; -`; - -const Toggle = ({ - className, - direction, - disabled, - inputProps, - key, - label, - onChange, - value: checked, - ...rest -}) => ( - - {label} - - - {!disabled && } - - -); - -return Toggle(props); diff --git a/instances/events-committee.near/widget/devhub/components/feed/MergedIndexFeed.jsx b/instances/events-committee.near/widget/devhub/components/feed/MergedIndexFeed.jsx deleted file mode 100644 index 1c7567ad2..000000000 --- a/instances/events-committee.near/widget/devhub/components/feed/MergedIndexFeed.jsx +++ /dev/null @@ -1,265 +0,0 @@ -if (!props.index) { - return "props.index is not defined"; -} -const indices = JSON.parse( - JSON.stringify(Array.isArray(props.index) ? props.index : [props.index]) -); - -const filter = props.filter; - -const renderItem = - props.renderItem ?? - ((item) => ( -
- #{item.blockHeight}: {JSON.stringify(item)} -
- )); -const cachedRenderItem = (item, i) => { - const key = JSON.stringify(item); - - if (!(key in state.cachedItems)) { - state.cachedItems[key] = renderItem(item, i); - State.update(); - } - return state.cachedItems[key]; -}; - -const initialRenderLimit = props.initialRenderLimit ?? 10; -const addDisplayCount = props.nextLimit ?? initialRenderLimit; -const reverse = !!props.reverse; - -const computeFetchFrom = (items, limit, desc) => { - if (!items || items.length < limit) { - return false; - } - const blockHeight = items[items.length - 1].blockHeight; - return desc ? blockHeight - 1 : blockHeight + 1; -}; - -const mergeItems = (iIndex, oldItems, newItems, desc) => { - const index = indices[iIndex]; - const items = [ - ...new Set( - [ - ...newItems.map((item) => ({ - ...item, - action: index.action, - key: index.key, - index: iIndex, - })), - ...oldItems, - ].map((i) => JSON.stringify(i)) - ), - ].map((i) => JSON.parse(i)); - items.sort((a, b) => a.blockHeight - b.blockHeight); - if (desc) { - items.reverse(); - } - return items; -}; - -const jIndices = JSON.stringify(indices); -if (jIndices !== state.jIndices) { - State.update({ - jIndices, - feeds: indices.map(() => ({})), - items: [], - displayCount: initialRenderLimit, - cachedItems: {}, - }); -} - -let stateChanged = false; -for (let iIndex = 0; iIndex < indices.length; ++iIndex) { - const index = indices[iIndex]; - const feed = state.feeds[iIndex]; - let feedChanged = false; - index.options = index.options || {}; - index.options.limit = Math.min( - Math.max(initialRenderLimit + addDisplayCount * 2, index.options.limit), - 100 - ); - const desc = index.options.order === "desc"; - - const initialItems = Social.index( - index.action, - index.key, - index.options, - index.cacheOptions - ); - if (initialItems === null) { - continue; - } - - const jInitialItems = JSON.stringify(initialItems); - const nextFetchFrom = computeFetchFrom( - initialItems, - index.options.limit, - desc - ); - if (feed.jInitialItems !== jInitialItems) { - feed.jInitialItems = jInitialItems; - feedChanged = true; - if (nextFetchFrom !== feed.initialNextFetchFrom) { - feed.fetchFrom = false; - feed.items = mergeItems(iIndex, [], initialItems, desc); - feed.initialNextFetchFrom = nextFetchFrom; - feed.nextFetchFrom = nextFetchFrom; - } else { - feed.items = mergeItems(iIndex, feed.items, initialItems, desc); - } - } - - feed.usedCount = 0; - - if (feedChanged) { - state.feeds[iIndex] = feed; - stateChanged = true; - } -} - -// Construct merged feed and compute usage per feed. - -const filteredItems = []; -while (filteredItems.length < state.displayCount) { - let bestItem = null; - for (let iIndex = 0; iIndex < indices.length; ++iIndex) { - const index = indices[iIndex]; - const feed = state.feeds[iIndex]; - const desc = index.options.order === "desc"; - if (!feed.items) { - continue; - } - const item = feed.items[feed.usedCount]; - if (!item) { - continue; - } - if ( - bestItem === null || - (desc - ? item.blockHeight > bestItem.blockHeight - : item.blockHeight < bestItem.blockHeight) - ) { - bestItem = item; - } - } - if (!bestItem) { - break; - } - state.feeds[bestItem.index].usedCount++; - if (filter) { - if (filter.ignore) { - if (bestItem.accountId in filter.ignore) { - continue; - } - } - if (filter.require) { - if (!(bestItem.accountId in filter.require)) { - continue; - } - } - } - filteredItems.push(bestItem); -} - -// Fetch new items for feeds that don't have enough items. -for (let iIndex = 0; iIndex < indices.length; ++iIndex) { - const index = indices[iIndex]; - const feed = state.feeds[iIndex]; - const desc = index.options.order === "desc"; - let feedChanged = false; - - if ( - (feed.items.length || 0) - feed.usedCount < addDisplayCount * 2 && - !feed.fetchFrom && - feed.nextFetchFrom && - feed.nextFetchFrom !== feed.fetchFrom - ) { - feed.fetchFrom = feed.nextFetchFrom; - feedChanged = true; - } - - if (feed.fetchFrom) { - const limit = addDisplayCount; - const newItems = Social.index( - index.action, - index.key, - Object.assign({}, index.options, { - from: feed.fetchFrom, - subscribe: undefined, - limit, - }) - ); - if (newItems !== null) { - feed.items = mergeItems(iIndex, feed.items, newItems, desc); - feed.fetchFrom = false; - feed.nextFetchFrom = computeFetchFrom(newItems, limit, desc); - feedChanged = true; - } - } - - if (feedChanged) { - state.feeds[iIndex] = feed; - stateChanged = true; - } -} - -if (stateChanged) { - State.update(); -} - -const makeMoreItems = () => { - State.update({ - displayCount: state.displayCount + addDisplayCount, - }); -}; - -const loader = ( -
-
-); - -const fetchMore = - props.manual && - (state.feeds.some((f) => !!f.fetchFrom) && - filteredItems.length < state.displayCount - ? loader - : state.displayCount < filteredItems.length && ( -
- makeMoreItems()}> - {props.loadMoreText ?? "Load more..."} - -
- )); - -const items = filteredItems ? filteredItems.slice(0, state.displayCount) : []; -if (reverse) { - items.reverse(); -} - -const renderedItems = items.map(cachedRenderItem); - -return props.manual ? ( - <> - {reverse && fetchMore} - {renderedItems} - {!reverse && fetchMore} - -) : ( - - {renderedItems} - -); diff --git a/instances/events-committee.near/widget/devhub/components/feed/SubscribedFeed.jsx b/instances/events-committee.near/widget/devhub/components/feed/SubscribedFeed.jsx deleted file mode 100644 index a378f21c3..000000000 --- a/instances/events-committee.near/widget/devhub/components/feed/SubscribedFeed.jsx +++ /dev/null @@ -1,179 +0,0 @@ -const indexKey = props.indexKey ?? "main"; -const groupId = props.groupId; -const permissions = props.permissions; - -const index = [ - { - action: "post", - key: indexKey, - options: { - limit: 10, - order: props.sort ? props.sort : "desc", - subscribe: true, - accountId: props.accounts, - }, - cacheOptions: { - ignoreCache: true, - }, - }, - { - action: "repost", - key: indexKey, - options: { - limit: 10, - order: props.sort ? props.sort : "desc", - subscribe: true, - accountId: props.accounts, - }, - cacheOptions: { - ignoreCache: true, - }, - }, -]; - -const isPremiumFeed = props.isPremiumFeed; -const commentAccounts = props.commentAccounts; -const renderedPosts = {}; - -const makePostItem = (a) => ({ - type: "social", - path: `${a.accountId}/post/main`, - blockHeight: a.blockHeight, -}); - -const renderPost = (a) => { - if (a.value.type !== "md") { - return false; - } - const item = JSON.stringify(makePostItem(a)); - if (item in renderedPosts) { - return false; - } - renderedPosts[item] = true; - - return ( -
- } - src="mob.near/widget/MainPage.N.Post" - props={{ - accountId: a.accountId, - blockHeight: a.blockHeight, - isPremiumFeed, - commentAccounts, - indexKey, - groupId, - permissions, - }} - /> -
- ); -}; - -const repostSvg = ( - - - - -); - -const extractParentPost = (item) => { - if (!item || item.type !== "social" || !item.path || !item.blockHeight) { - return undefined; - } - const accountId = item.path.split("/")[0]; - return `${accountId}/post/main` === item.path - ? { accountId, blockHeight: item.blockHeight } - : undefined; -}; - -const renderRepost = (a) => { - if (a.value.type !== "repost") { - return false; - } - const post = extractParentPost(a.value.item); - if (!post) { - return false; - } - const item = JSON.stringify(makePostItem(post)); - if (item in renderedPosts) { - return false; - } - renderedPosts[item] = true; - - return ( -
-
- {repostSvg}{" "} - - Reposted by{" "} - - -
- } - src="mob.near/widget/MainPage.N.Post" - props={{ - accountId: post.accountId, - blockHeight: post.blockHeight, - reposted: true, - isPremiumFeed, - commentAccounts, - indexKey, - groupId, - permissions, - }} - /> -
- ); -}; - -const renderItem = (item) => - item.action === "post" ? renderPost(item) : renderRepost(item); -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/banner.jsx b/instances/events-committee.near/widget/devhub/components/island/banner.jsx deleted file mode 100644 index e48754ced..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/banner.jsx +++ /dev/null @@ -1,100 +0,0 @@ -const imageLink = - "https://ipfs.near.social/ipfs/bafybeiap2mzwsly4apaldxguiunx4rjwqyadksj5yxuzwrww3kue3ao5qe"; - -const HeroSection = styled.div` - position: relative; - height: auto; - z-index: 3; - width: 70%; - background: #00ec97; - clip-path: polygon(0 0, 100% 0%, 75% 100%, 0% 100%); - - padding-top: 2rem; - padding-bottom: 2rem; - padding-left: 3.375rem; - - @media screen and (max-width: 768px) { - width: 100%; - padding: 1rem 1.5rem; - clip-path: none; - } -`; - -const Title = styled.h1` - color: #f4f4f4; - font-size: 4rem; - font-style: normal; - font-weight: 700; - line-height: 100%; /* 88px */ - letter-spacing: -1.76px; - - @media screen and (max-width: 768px) { - font-size: 2.25rem; - letter-spacing: -0.72px; - margin: 0; - } -`; - -const Container = styled.div` - position: relative; - width: 100%; - height: max-content; - overflow: hidden; - - @media screen and (max-width: 768px) { - background: #f4f4f4; - } -`; - -const ImageContainer = styled.div` - width: 100%; - height: 100%; - position: absolute; - top: 0; - right: 0; - z-index: 1; - background: transparent; - - @media screen and (max-width: 768px) { - display: none; - } -`; - -const Image = styled.img` - margin-left: 15.625rem; - height: 100%; - width: 100%; - filter: grayscale(100%); - object-fit: cover; -`; - -const MobileImage = styled.img` - display: none; - - width: 100%; - height: 196px; - - width: 100%; - object-fit: cover; - filter: grayscale(1); - - @media screen and (max-width: 768px) { - display: block; - } -`; - -return ( - - - - The decentralized <br /> - <span style={{ color: "#101820" }}>home base</span> <br /> - for NEAR builders - - - - - - - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/connect.jsx b/instances/events-committee.near/widget/devhub/components/island/connect.jsx deleted file mode 100644 index 93bf68358..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/connect.jsx +++ /dev/null @@ -1,332 +0,0 @@ -const { getFeaturedCommunities } = VM.require( - "${REPL_EVENTS}/widget/core.adapter.devhub-contract" -); - -if (!getFeaturedCommunities) { - return

Loading modules...

; -} - -const communities = getFeaturedCommunities(); - -if (!communities) { - return

Loading communities...

; -} - -const [startIndex, setStartIndex] = useState(0); -const [endIndex, setEndIndex] = useState(2); - -const DescriptionHeader = styled.h2` - color: #f4f4f4; - font-size: 1.75rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 43.2px */ - - @media screen and (max-width: 786px) { - font-size: 1.5rem; - } -`; - -const Description = styled.p` - color: #f4f4f4; - text-shadow: 0px 4px 4px rgba(0, 0, 0, 0.25); - font-size: 1.25rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - - @media screen and (max-width: 786px) { - font-size: 1rem; - } -`; - -const imageSource = - "https://ipfs.near.social/ipfs/bafkreic7wxhocbnxoo63uh6n2ur3otykbzouymobt3ebgd2b4dmdiu3764"; - -const CardBody = styled.div` - border-radius: 1rem; - border: 1px solid #00ec97; - background: #3f4040; - - display: flex; - max-width: 31.5%; - height: 12rem; - padding: 1.5rem; - flex-direction: column; - justify-content: center; - align-items: flex-start; - gap: 0.5rem; - flex-shrink: 0; - align-self: stretch; - - h3 { - color: #00ec97; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 100%; /* 40px */ - } - - p { - color: #818181; - font-size: 1.125rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - } - - a { - color: #00ec97; - font-size: 1.25rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - - &:hover { - text-decoration: none; - } - } - - @media screen and (max-width: 768px) { - max-width: 80%; - } -`; - -const Card = ({ title, description, href }) => { - return ( - -

{title}

-

{description}

- Learn more → -
- ); -}; - -const Cards = communities.map((com) => { - return { - title: com.name, - description: com.description, - href: "/${REPL_EVENTS}/widget/app?page=community&handle=" + com.handle, - }; -}); - -const ForwardButton = styled.button` - all: unset; - position: absolute; - right: 0; - - margin: 1rem; - - &:hover, - &:active { - border: none; - outline: none; - } - - ${endIndex >= Cards.length - 1 && "svg {transform: rotate(180deg);}"} -`; - -const handleForward = () => { - if (endIndex <= Cards.length - 1) { - setStartIndex(endIndex + 1); - setEndIndex(endIndex + 3); - } else { - setStartIndex(0); - setEndIndex(2); - } -}; - -const CTA = styled.a` - color: #00ec97 !important; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - - @media screen and (max-width: 768px) { - font-size: 1.25rem; - } -`; - -const Subheading = styled.h3` - color: #8a8e93; - font-size: 2.25rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 43.2px */ - - padding: 3rem; - padding-top: 0; - - @media screen and (max-width: 786px) { - padding: 1rem; - padding-top: 0; - font-size: 1.5rem; - } -`; - -const Container = styled.div` - width: 100%; - display: flex; - position: relative; - align-items: center; - - @media screen and (max-width: 768px) { - flex-direction: column; - } -`; - -const DescriptionContainer = styled.div` - padding: 3rem; - width: 55%; - - @media screen and (max-width: 768px) { - padding: 1rem; - width: 100%; - } -`; - -const ImageContainer = styled.div` - position: absolute; - top: 25%; - right: 0; - - width: 50%; - height: 65%; - - @media screen and (max-width: 768px) { - position: relative; - padding: 0 1rem; - - height: 225px; - width: 100%; - } -`; - -const Image = styled.img` - width: 100%; - height: 90%; - object-fit: cover; - clip-path: polygon(15% 0, 100% 0%, 100% 100%, 0% 100%); - - @media screen and (max-width: 768px) { - clip-path: none; - } -`; - -const CardsContainer = styled.div` - padding: 3rem; - padding-top: 0; - - position: relative; - display: flex; - flex-direction: row; - gap: 1rem; - width: 100%; - align-items: center; - - @media screen and (max-width: 768px) { - display: none; - } -`; - -const ArrowIcon = () => { - return ( - - - - ); -}; - -const CTAContainer = styled.div` - padding: 3rem; - padding-top: 0; - - @media screen and (max-width: 786px) { - padding: 1rem; - padding-top: 0; - } -`; - -const MobileCards = styled.div` - display: none; - - @media screen and (max-width: 768px) { - display: flex; - padding: 1rem; - flex-direction: row; - overflow-x: auto; - gap: 1rem; - } -`; - -const Content = ( - <> - - - - Communities are the lifeblood of /dev/hub - - - We believe that communities are the foundation of a decentralized - ecosystem. Explore and engage with our diverse range of communities - today. - - - - - - - Featured Communities - - {Cards.slice(startIndex, endIndex + 1).map((card, idx) => ( - - ))} - - - - - - {Cards.map((card, idx) => ( - - ))} - - - - Explore all communities → - - - -); - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/explore.jsx b/instances/events-committee.near/widget/devhub/components/island/explore.jsx deleted file mode 100644 index 2fd20dcd9..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/explore.jsx +++ /dev/null @@ -1,193 +0,0 @@ -const Card = styled.div` - display: flex; - max-width: 20rem; - max-height: 17.5rem; - padding: 1.5rem; - flex-direction: column; - justify-content: space-between; - align-items: center; - - background: #fff; - border-radius: 1rem; - - h3 { - color: #555555; //#00ec97; - text-align: center; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - } - - p { - color: #555; - text-align: center; - font-size: 1rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 24px */ - } - - a { - color: #555555; //#00ec97; - text-align: center; - font-size: 1.25rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 24px */ - } - - @media screen and (max-width: 768px) { - h3 { - font-size: 1.5rem; - } - - p, - a { - font-size: 1rem; - } - - padding: 1rem; - } -`; - -const SectionCard = ({ title, description, href }) => { - return ( - -

{title}

-

{description}

- Learn more → -
- ); -}; - -const Cards = [ - { - title: "217 Validators", - description: - "to ensure security, liveness, and fault tolerance of the network", - href: "https://nearscope.net/", - }, - { - title: "<1s, <1¢", - description: - "Fast and cost-efficient transactions. 1s to update values with minimal fees", - href: "https://nearblocks.io/", - }, - { - title: "Awesome DevEx", - description: - "NEAR lets developers innovate with familiar tools: TypeScript, Rust, Solidity", - href: "https://docs.near.org/", - }, - { - title: "Horizontal Scaling", - description: - "Nightshade ensures maximum performance thanks to its sharded design", - href: "https://docs.near.org/concepts/advanced/papers", - }, -]; - -const CTA = styled.a` - display: flex; - padding: 0.875rem 1rem; - align-items: center; - gap: 0.5rem; - - border-radius: 1rem; - background: #00ec97; - - color: #f4f4f4 !important; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.03rem; - - width: max-content; - text-decoration: none; - - &:hover { - text-decoration: none; - background: #555555; - } - - @media screen and (max-width: 768px) { - color: #f4f4f4 !important; - font-size: 1.125rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 24px */ - letter-spacing: -0.4px; - - margin-left: auto; - margin-right: auto; - - display: flex; - padding: 14px 16px; - flex-direction: column; - justify-content: center; - align-items: flex-start; - gap: 8px; - - border-radius: 16px; - background: #00ec97; - } -`; - -const Container = styled.div` - display: flex; - flex-direction: column; - gap: 3rem; - - padding: 3rem; - padding-top: 0; - - @media screen and (max-width: 768px) { - padding: 1.5rem; - padding-top: 0; - } -`; - -const CardsContainer = styled.div` - display: flex; - justify-content: space-between; - gap: 1.5rem; - - @media screen and (max-width: 768px) { - display: grid; - grid-template-columns: 1fr 1fr; - /* gap: 2.25rem; */ - } -`; - -const Content = ( - - - {Cards.map((card) => ( - - ))} - - - Explore the Open Web on NEAR → - - -); - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/hero.jsx b/instances/events-committee.near/widget/devhub/components/island/hero.jsx deleted file mode 100644 index 8ed79b615..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/hero.jsx +++ /dev/null @@ -1,212 +0,0 @@ -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url"); - -href || (href = () => {}); - -const imageLink = - "https://ipfs.near.social/ipfs/bafybeiap2mzwsly4apaldxguiunx4rjwqyadksj5yxuzwrww3kue3ao5qe"; - -const HeroSection = styled.div` - position: relative; - height: auto; - z-index: 3; - width: 70%; - background: #00ec97; - clip-path: polygon(0 0, 100% 0%, 75% 100%, 0% 100%); - - padding-top: 2rem; - padding-bottom: 2rem; - padding-left: 3.375rem; - - @media screen and (max-width: 768px) { - width: 100%; - padding: 1rem 1.5rem; - clip-path: none; - } -`; - -const Title = styled.h1` - color: #f4f4f4; - font-size: 4rem; - font-style: normal; - font-weight: 700; - line-height: 100%; /* 88px */ - letter-spacing: -1.76px; - - @media screen and (max-width: 768px) { - font-size: 2.25rem; - letter-spacing: -0.72px; - margin: 0; - } -`; - -const Lead = styled.p` - color: #151515; - font-size: 1.75rem; - font-style: normal; - font-weight: 400; - line-height: 110%; /* 39.6px */ - - width: 70%; - - @media screen and (max-width: 768px) { - font-size: 1.5rem; - width: 100%; - } -`; - -const CTA = styled.a` - display: inline-flex; - padding: 0.875rem 1rem; - align-items: center; - gap: 0.5rem; - - border-radius: 1rem; - border: 1px solid #151515; - - color: #151515 !important; - font-size: 1.25rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.48px; - - &:hover { - background: #151515; - color: #f4f4f4 !important; - text-decoration: none; // Remove underline on hover - } - - @media screen and (max-width: 768px) { - display: inline-flex; - padding: 8px 16px; - align-items: center; - gap: 8px; - - border-radius: 16px; - background: #00ec97; - - border: none; - - color: #f4f4f4 !important; - font-size: 16px; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 19.2px */ - letter-spacing: -0.32px; - - &:hover { - background: #151515; - color: #f4f4f4; - text-decoration: none; // Remove underline on hover - } - } -`; - -const Container = styled.div` - position: relative; - width: 100%; - height: max-content; - overflow: hidden; - - @media screen and (max-width: 768px) { - background: #f4f4f4; - } -`; - -const ImageContainer = styled.div` - width: 100%; - height: 100%; - position: absolute; - top: 0; - right: 0; - z-index: 1; - background: transparent; - - @media screen and (max-width: 768px) { - display: none; - } -`; - -const Image = styled.img` - margin-left: 15.625rem; - height: 100%; - width: 100%; - filter: grayscale(100%); - object-fit: cover; -`; - -const DesktopDescription = styled.div` - @media screen and (max-width: 786px) { - display: none; - } -`; - -const MobileImage = styled.img` - display: none; - - width: 100%; - height: 196px; - - width: 100%; - object-fit: cover; - filter: grayscale(1); - - @media screen and (max-width: 768px) { - display: block; - } -`; - -const MobileDescription = styled.div` - display: none; - padding: 24px 16px; - - width: 100%; - - @media screen and (max-width: 768px) { - display: block; - } -`; - -return ( - - - - The decentralized <br /> - <span style={{ color: "#101820" }}>home base</span> <br /> - for NEAR builders - - - - Join a vibrant community of innovators shaping the open web. - - - Read more → - - - - - - - - - Join a vibrant community of innovators shaping the open web. - - Read more → - - - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/home-section.jsx b/instances/events-committee.near/widget/devhub/components/island/home-section.jsx deleted file mode 100644 index 240f40f3e..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/home-section.jsx +++ /dev/null @@ -1,63 +0,0 @@ -const title = props.title; -const titleColor = props.titleColor; -const description = props.description; -const children = props.children; -const background = props.background; - -const Section = styled.div` - ${background && "background: #292929;"} - ${background && "color: #F4F4F4;"} - width: 100%; -`; - -const SectionHeader = styled.h2` - color: ${titleColor || "#00ec97"}; - font-size: 1.5rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.24px; - - @media screen and (max-width: 768px) { - font-size: 1.25rem; - } -`; - -const SectionDescription = styled.h3` - color: #151515; - font-size: 2.25rem; - font-style: normal; - font-weight: 700; - line-height: 110%; /* 39.6px */ - letter-spacing: -0.72px; - - margin-bottom: 2.25rem; - margin-top: 2.25rem; - - max-width: 40rem; - - @media screen and (max-width: 768px) { - margin-bottom: 1.5rem; - margin-top: 1.5rem; - font-size: 1.5rem; - } -`; - -const Container = styled.div` - padding: 3rem; - padding-bottom: 0; - - @media screen and (max-width: 768px) { - padding: 1rem; - } -`; - -return ( -
- - {title} - {description && {description}} - - {children} -
-); diff --git a/instances/events-committee.near/widget/devhub/components/island/participate.jsx b/instances/events-committee.near/widget/devhub/components/island/participate.jsx deleted file mode 100644 index de1a26b8a..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/participate.jsx +++ /dev/null @@ -1,207 +0,0 @@ -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url"); - -href || (href = () => {}); - -const Container = styled.div` - margin-top: 2.25rem; - - display: flex; - flex-direction: row; - justify-content: space-between; - width: 100%; - - @media screen and (max-width: 768px) { - flex-direction: column; - margin-top: 0; - } -`; - -const LinkItem = styled.a` - color: #00ec97; - font-size: 1.25rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - - display: flex; - align-items: center; - - &:hover { - text-decoration: none; - color: #096d50; - } -`; - -const Links = [ - { - links: [ - { - title: "Ideate on DevHub", - href: "/devhub.near/widget/app?page=blog&id=2029", - count: 1, - }, - { - title: "Post a Proposal", - href: "/devhub.near/widget/app?page=blog&id=2035", - count: 2, - }, - { - title: "Host an Event", - href: "/devhub.near/widget/app?page=community&handle=hacks&tab=wiki-202", - count: 3, - }, - ], - }, - { - links: [ - { - title: "Improve NEAR Docs", - href: "https://github.com/near/docs", - count: 4, - }, - { - title: "Join the Fellowship", - href: "/devhub.near/widget/app?page=community&handle=fellowship&tab=wiki-201", - count: 5, - }, - { - title: "Join NEAR Campus", - href: "/devhub.near/widget/app?page=community&handle=near-campus", - count: 6, - }, - ], - }, - { - links: [ - { - title: "Dive into Hackbox", - href: "/hackbox.near/widget/home", - count: 7, - }, - ], - }, -]; - -const CTA = styled.a` - display: flex; - padding: 0.875rem 1rem; - align-items: center; - gap: 0.5rem; - - border-radius: 1rem; - background: #00ec97; - - color: #f4f4f4 !important; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.03rem; - - width: max-content; - margin-top: 1.5rem; - - &:hover { - background: #555555; - text-decoration: none !important; - } - - @media screen and (max-width: 768px) { - color: #f4f4f4 !important; - font-size: 20px; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 24px */ - - display: flex; - padding: 14px 16px; - align-items: center; - gap: 8px; - - border-radius: 16px; - background: #555555; - - &:hover { - //background: #555555; - text-decoration: none; - } - } -`; - -const SectionPadding = styled.div` - padding: 3rem; - padding-top: 0; - - display: flex; - flex-direction: column; - - @media screen and (max-width: 768px) { - padding: 1rem; - padding-top: 0; - } -`; - -const LinksContainer = styled.div` - width: 30%; - - @media screen and (max-width: 768px) { - width: 100%; - margin-bottom: 1rem; - } -`; - -const Content = ( - - - {Links.map((it) => ( - -
- {it.links.map((link) => ( -
- - {link.count} - {" "} - - {link.title} - -
- ))} -
-
- ))} -
- - - Learn more → - -
-); - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/island/support.jsx b/instances/events-committee.near/widget/devhub/components/island/support.jsx deleted file mode 100644 index 6a105c9e6..000000000 --- a/instances/events-committee.near/widget/devhub/components/island/support.jsx +++ /dev/null @@ -1,134 +0,0 @@ -const Items = [ - { - heading: ( - <> - Developer -
- Resources - - ), - description: "Learn the fundamentals of NEAR and build with confidence", - cta: { - href: "https://docs.near.org", - title: "Read ↗", - }, - }, - { - heading: <>Office Hours, - description: ( - <> - Need some help? -
DevRel contributors are available to answer your technical - questions - - ), - cta: { - href: "/devhub.near/widget/app?page=community&handle=devrel&tab=office-hours-support", - title: "Join ↗", - }, - }, - { - heading: <>Get Funding, - description: - "Explore funding opportunities from DevHub to fuel your vision", - cta: { - href: "/devhub.near/widget/app?page=community&handle=developer-dao&tab=funding", - title: "Learn more ↗", - }, - }, -]; - -const Circle = styled.div` - display: flex; - width: 18.75rem; - height: 18.75rem; - padding: 2.25rem; - flex-direction: column; - justify-content: center; - align-items: center; - gap: 1rem; - flex-shrink: 0; - - border-radius: 22.5rem; - border: 1px solid #00ec97; - background: #f4f4f4; - - h3 { - color: #101820; - text-align: center; - font-size: 1.75rem; - font-style: normal; - font-weight: 700; - line-height: 100%; /* 36px */ - } - - p { - color: #101820; - text-align: center; - font-size: 1.125rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.72px; - } - - a { - color: #555555; - font-size: 1.125rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - } -`; - -const Container = styled.div` - padding: 3rem; - padding-top: 0; - margin-top: 1.5rem; - - @media screen and (max-width: 786px) { - padding: 1.5rem; - padding-top: 0; - } -`; - -const ItemsContainer = styled.div` - display: flex; - flex-direction: row; - justify-content: center; - align-items: center; - width: 100%; - - flex-wrap: wrap; - gap: 3rem; - - @media screen and (max-width: 768px) { - flex-direction: column; - gap: 1rem; - } -`; - -const Content = ( - - - {Items.map((it) => ( - -

{it.heading}

-

{it.description}

- {it.cta.title} -
- ))} -
-
-); - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/layout/LikeButton/Faces.jsx b/instances/events-committee.near/widget/devhub/components/layout/LikeButton/Faces.jsx deleted file mode 100644 index 694463cbd..000000000 --- a/instances/events-committee.near/widget/devhub/components/layout/LikeButton/Faces.jsx +++ /dev/null @@ -1,122 +0,0 @@ -const accountId = context.accountId; -const likesByUsers = props.likesByUsers || {}; -const limit = props.limit ?? 3; - -let likes = Object.keys(likesByUsers).reverse(); - -const graphLikes = []; -const nonGraph = []; - -const graph = - (accountId && - Social.keys(`${accountId}/graph/follow/*`, "final")[accountId].graph - .follow) || - {}; - -likes.forEach((accountId) => { - if (accountId in graph) { - graphLikes.push(accountId); - } else { - nonGraph.push(accountId); - } -}); - -let faces = [...graphLikes, ...nonGraph]; - -if (faces.length < limit + 3) { - limit = faces.length; -} - -const renderFaces = faces.splice(0, limit); - -const Faces = styled.span` - .face { - display: inline-block; - position: relative; - margin: -0.1em; - height: 1.5em; - width: 1.5em; - min-width: 1.5em; - vertical-align: top; - img { - object-fit: cover; - border-radius: 50%; - width: 100%; - height: 100%; - } - } -`; - -const Others = styled.span` - &:hover { - color: white !important; - } -`; - -const numLikes = likes.length - limit; - -return ( - <> - - {renderFaces.map((accountId, i) => ( - - - ), - }} - /> - - ))} - - {numLikes > 0 ? ( - -
- {faces.slice(0, 10).map((accountId, i) => ( - - -
-
- ))} - {faces.length > 10 ? "..." : ""} -
- - } - > - - and {numLikes} other{numLikes === 1 ? "" : "s"} - -
- ) : ( - "" - )} - -); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/BadgeDetails.jsx b/instances/events-committee.near/widget/devhub/components/molecule/BadgeDetails.jsx deleted file mode 100644 index c3a8c2d27..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/BadgeDetails.jsx +++ /dev/null @@ -1,78 +0,0 @@ -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
badgeId
or
tokenId
to the - DevGovBadgeDetails component - - ); -} - -let badgeMetadata = - props.badgeMetadata ?? - Near.view(nearDevGovBadgesContractId, "get_badge", { - badge_id: badgeId, - }).badge_metadata; - -if (!badgeMetadata) { - return <>Loading...; -} - -return ( - <> -
-
-
- -
-
-
-
-
-
-
-

- {badgeMetadata.title} -

-
-
-
-
- Awarded to - {badgeMetadata.copies} - developers -
-
-
- -
-
-
-
-
- -); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/BadgesList.jsx b/instances/events-committee.near/widget/devhub/components/molecule/BadgesList.jsx deleted file mode 100644 index 296ed7bb4..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/BadgesList.jsx +++ /dev/null @@ -1,63 +0,0 @@ -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url") || (() => {}); - -const nearDevGovBadgesContractId = "neardevgov.near"; - -let badges = props.badges; -const mode = props.mode || "normal"; - -if (!badges) { - const accountId = props.accountId || context.accountId; - const ownedBadges = Near.view( - nearDevGovBadgesContractId, - "nft_tokens_for_owner", - { - account_id: accountId, - } - ); - if (!ownedBadges) { - return <>{mode === "compact" ? "" : "Loading..."}; - } - badges = ownedBadges; -} - -let style; -if (mode === "normal") { - style = { width: "3em", height: "3em" }; -} else if (mode === "compact") { - style = { width: "1.5em", height: "1.5em" }; -} -if (props.style) { - style = props.style; -} - -const renderedBadgesList = badges.map(({ token_id: tokenId, metadata }) => ( - - - {mode === "compact" ? null : metadata.title} - -)); - -if (mode === "compact") { - return <>{renderedBadgesList}; -} else { - return ( -
    - {renderedBadgesList.map((renderedBadge) => ( -
  • {renderedBadge}
  • - ))} -
- ); -} diff --git a/instances/events-committee.near/widget/devhub/components/molecule/BlogControl.jsx b/instances/events-committee.near/widget/devhub/components/molecule/BlogControl.jsx deleted file mode 100644 index 9a1e57a4e..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/BlogControl.jsx +++ /dev/null @@ -1,16 +0,0 @@ -const { title, onClick } = props; - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx b/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx index 7d83e2edc..c7cdfae46 100644 --- a/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx +++ b/instances/events-committee.near/widget/devhub/components/molecule/Button.jsx @@ -153,7 +153,7 @@ const Button = ({ typeof iconProps === "object" && !Array.isArray(iconProps) && ( )} diff --git a/instances/events-committee.near/widget/devhub/components/molecule/CommunityControl.jsx b/instances/events-committee.near/widget/devhub/components/molecule/CommunityControl.jsx deleted file mode 100644 index 97c02bae2..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/CommunityControl.jsx +++ /dev/null @@ -1,51 +0,0 @@ -const { className, title, icon, href, onClick } = props; - -const Button = styled.button` - display: flex; - align-items: center; - gap: 8px; - - border-radius: 4px; - background: #04a46e; - - color: #f4f4f4; - font-size: 16px; - font-style: normal; - font-weight: 700; - line-height: 20px; /* 125% */ - - padding: 0.5rem 1rem; - - &:hover { - background: #555555; - text-decoration: none !important; - } - - outline: none; - border: none; -`; - -return ( -
- {props.href ? ( - - - - ) : ( - - )} -
-); diff --git a/instances/events-committee.near/widget/devhub/components/molecule/PostControls.jsx b/instances/events-committee.near/widget/devhub/components/molecule/PostControls.jsx deleted file mode 100644 index 78b06b062..000000000 --- a/instances/events-committee.near/widget/devhub/components/molecule/PostControls.jsx +++ /dev/null @@ -1,51 +0,0 @@ -const { className, title, icon, href, onClick } = props; - -const Button = styled.button` - display: flex; - align-items: center; - gap: 8px; - - border-radius: 4px; - background: #03ba16; - - color: #f4f4f4; - font-size: 16px; - font-style: normal; - font-weight: 700; - line-height: 20px; /* 125% */ - - padding: 0.5rem 1rem; - - &:hover { - background: #555555; - text-decoration: none !important; - } - - outline: none; - border: none; -`; - -return ( -
- {props.href ? ( - - - - ) : ( - - )} -
-); diff --git a/instances/events-committee.near/widget/devhub/components/organism/Configurator.jsx b/instances/events-committee.near/widget/devhub/components/organism/Configurator.jsx deleted file mode 100644 index c88bf8e18..000000000 --- a/instances/events-committee.near/widget/devhub/components/organism/Configurator.jsx +++ /dev/null @@ -1,316 +0,0 @@ -const Struct = VM.require("${REPL_EVENTS}/widget/core.lib.struct"); - -if (!Struct) { - return

Loading modules...

; -} - -const useForm = ({ initialValues, onUpdate, stateKey }) => { - const initialFormState = { - hasUnsubmittedChanges: false, - values: initialValues ?? {}, - }; - - const formState = state[stateKey] ?? null; - - const formReset = () => - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - [stateKey]: initialFormState, - hasUnsubmittedChanges: false, - })); - - const formUpdate = - ({ path, via: customFieldUpdate, ...params }) => - (fieldInput) => { - const transformFn = (node) => { - if (typeof customFieldUpdate === "function") { - return customFieldUpdate({ - input: fieldInput?.target?.value ?? fieldInput, - lastKnownValue: node, - params, - }); - } else { - return Struct.defaultFieldUpdate({ - input: fieldInput?.target?.value ?? fieldInput, - lastKnownValue: node, - params, - }); - } - }; - const updatedValues = Struct.deepFieldUpdate( - formState?.values ?? {}, - path, - (node) => transformFn(node) - ); - State.update((lastKnownComponentState) => ({ - ...lastKnownComponentState, - [stateKey]: { - hasUnsubmittedChanges: !Struct.isEqual( - updatedValues, - initialFormState.values - ), - values: updatedValues, - }, - })); - - if (typeof onUpdate === "function") { - onUpdate(updatedValues); - } - }; - - return { - hasUnsubmittedChanges: formState?.hasUnsubmittedChanges ?? false, - values: { - ...(initialValues ?? {}), - ...(formState?.values ?? {}), - }, - reset: formReset, - stateKey, - update: formUpdate, - }; -}; - -const ValueView = styled.div` - & > p { - margin: 0; - } -`; - -const fieldParamsByType = { - array: { - name: "components.molecule.Input", - inputProps: { type: "text" }, - }, - - boolean: { - name: "components.atom.Toggle", - }, - - string: { - name: "components.molecule.Input", - inputProps: { type: "text" }, - }, -}; - -const defaultFieldsRender = ({ schema, form, isEditable }) => ( - <> - {Object.entries(schema).map( - ( - [key, { format, inputProps, noop, label, order, style, ...fieldProps }], - idx - ) => { - const fieldKey = `${idx}-${key}`, - fieldValue = form.values[key]; - - const fieldType = Array.isArray(fieldValue) - ? "array" - : typeof (fieldValue ?? ""); - - const isDisabled = noop ?? inputProps.disabled ?? false; - - const viewClassName = [ - (fieldValue?.length ?? 0) > 0 ? "" : "text-muted", - "m-0", - ].join(" "); - - return ( - <> -
- - - - {format !== "markdown" ? ( - - {(fieldType === "array" && format === "comma-separated" - ? fieldValue - .filter((string) => string.length > 0) - .join(", ") - : fieldValue - )?.toString?.() || "none"} - - ) : (fieldValue?.length ?? 0) > 0 ? ( - - ) : ( - none - )} - -
- - - ); - } - )} - -); - -const Configurator = ({ - actionsAdditional, - cancelLabel, - classNames, - externalState, - fieldsRender: customFieldsRender, - formatter: toFormatted, - isValid, - isActive, - onCancel, - onChange, - onSubmit, - schema, - submitIcon, - submitLabel, - hideSubmitBtn, -}) => { - const fieldsRender = customFieldsRender || defaultFieldsRender; - - const initialValues = Struct.typeMatch(schema) - ? Struct.pick(externalState ?? {}, Object.keys(schema)) - : {}; - - const form = useForm({ initialValues, onUpdate: onChange, stateKey: "form" }); - - const formFormattedValues = toFormatted - ? toFormatted(form.values) - : form.values; - - const internalValidation = () => - Object.keys(schema).every((key) => { - const fieldDefinition = schema[key]; - const value = form.values[key]; - if (!value || value.length === 0) { - return !fieldDefinition.inputProps.required; - } else if ( - fieldDefinition.inputProps.min && - fieldDefinition.inputProps.min > value?.length - ) { - return false; - } else if ( - fieldDefinition.inputProps.max && - fieldDefinition.inputProps.max < value?.length - ) { - return false; - } else if ( - fieldDefinition.inputProps.allowCommaAndSpace === false && - /^[^,\s]*$/.test(value) === false - ) { - return false; - } else if ( - fieldDefinition.inputProps.validUrl === true && - /^(www\.)?[-a-zA-Z0-9@:%._\+~#=]{2,256}\.[a-z]{2,6}\b([-a-zA-Z0-9@:%_\+.~#?&//=]*)$/.test( - value - ) === false - ) { - return false; - } - return true; - }); - - const isFormValid = () => { - return internalValidation() && (!isValid || isValid(formFormattedValues)); - }; - - const onCancelClick = () => { - form.reset(); - if (onCancel) onCancel(); - }; - - const onSubmitClick = () => { - if (onSubmit && isFormValid()) { - onSubmit(formFormattedValues); - } - }; - - return ( -
-
- {fieldsRender({ - form, - isEditable: isActive, - schema, - })} -
- {isActive && !hideSubmitBtn && ( -
- {actionsAdditional ? ( -
{actionsAdditional}
- ) : null} - - - -
- )} -
- ); -}; - -return Configurator(props); diff --git a/instances/events-committee.near/widget/devhub/components/organism/Feed.jsx b/instances/events-committee.near/widget/devhub/components/organism/Feed.jsx deleted file mode 100644 index a238bbf0c..000000000 --- a/instances/events-committee.near/widget/devhub/components/organism/Feed.jsx +++ /dev/null @@ -1,130 +0,0 @@ -const { Feed } = VM.require("${REPL_DEVS}/widget/Feed"); -Feed = Feed || (() => <>); -const setPostExists = props.setPostExists ?? (() => {}); -const showFlagAccountFeature = props.showFlagAccountFeature ?? false; - -const filteredAccountIds = props.filteredAccountIds ?? []; - -const GRAPHQL_ENDPOINT = - props.GRAPHQL_ENDPOINT ?? "https://near-queryapi.api.pagoda.co"; - -let lastPostSocialApi = Social.index("post", "main", { - limit: 1, - order: props.sort ? props.sort : "desc", -}); - -if (lastPostSocialApi == null) { - return "Loading..."; -} - -State.init({ - // If QueryAPI Feed is lagging behind Social API, fallback to old widget. - shouldFallback: false, -}); - -function fetchGraphQL(operationsDoc, operationName, variables) { - return asyncFetch(`${GRAPHQL_ENDPOINT}/v1/graphql`, { - method: "POST", - headers: { "x-hasura-role": "dataplatform_near" }, - body: JSON.stringify({ - query: operationsDoc, - variables: variables, - operationName: operationName, - }), - }); -} - -const lastPostQuery = ` -query IndexerQuery { - dataplatform_near_social_feed_posts( limit: 1, order_by: { block_height: desc }) { - block_height - } -} -`; - -fetchGraphQL(lastPostQuery, "IndexerQuery", {}) - .then((feedIndexerResponse) => { - if ( - feedIndexerResponse && - feedIndexerResponse.body.data.dataplatform_near_social_feed_posts.length > - 0 - ) { - const nearSocialBlockHeight = lastPostSocialApi[0].blockHeight; - const feedIndexerBlockHeight = - feedIndexerResponse.body.data.dataplatform_near_social_feed_posts[0] - .block_height; - - const lag = nearSocialBlockHeight - feedIndexerBlockHeight; - let shouldFallback = lag > 2 || !feedIndexerBlockHeight; - if (shouldFallback === true) { - console.log( - "Falling back to Social index feed. Block difference is: ", - nearSocialBlockHeight - feedIndexerBlockHeight - ); - State.update({ shouldFallback }); - } - } else { - console.log( - "Falling back to Social index feed. No QueryApi data received." - ); - State.update({ shouldFallback: true }); - } - }) - .catch((error) => { - console.log( - "Error while fetching QueryApi feed (falling back to index feed): ", - error - ); - State.update({ shouldFallback: true }); - }); - -return ( -
- {state.shouldFallback ? ( - { - setPostExists(true); - - return ( - } - props={{ - accountId: item.accountId, - blockHeight: item.blockHeight, - filteredAccountIds: filteredAccountIds, - }} - /> - ); - }} - /> - ) : ( - - )} -
-); diff --git a/instances/events-committee.near/widget/devhub/components/organism/Feed/NearQueryApi.jsx b/instances/events-committee.near/widget/devhub/components/organism/Feed/NearQueryApi.jsx deleted file mode 100644 index 0781048ac..000000000 --- a/instances/events-committee.near/widget/devhub/components/organism/Feed/NearQueryApi.jsx +++ /dev/null @@ -1,275 +0,0 @@ -const LIMIT = 10; -const filteredAccountIds = props.filteredAccountIds; -const setPostExists = props.setPostExists ?? (() => {}); -const GRAPHQL_ENDPOINT = - props.GRAPHQL_ENDPOINT ?? "https://near-queryapi.api.pagoda.co"; - -const sort = props.sort || "desc"; - -// get the full list of posts that the current user has flagged so -// they can be hidden -const selfFlaggedPosts = context.accountId - ? Social.index("flag", "main", { - accountId: context.accountId, - }) ?? [] - : []; - -// V2 self moderation data, structure is like: -// { moderate: { -// "account1.near": "report", -// "account2.near": { -// ".post.main": { // slashes are not allowed in keys -// "100000123": "spam", // post ids are account/blockHeight -// } -// }, -// } -// } -const selfModeration = context.accountId - ? Social.getr(`${context.accountId}/moderate`, "optimistic") ?? [] - : []; -const postsModerationKey = ".post.main"; -const commentsModerationKey = ".post.comment"; -const matchesModeration = (moderated, socialDBObjectType, item) => { - if (!moderated) return false; - const accountFound = moderated[item.account_id]; - if (typeof accountFound === "undefined") { - return false; - } - if (typeof accountFound === "string" || accountFound[""]) { - return true; - } - const moderatedItemsOfType = accountFound[socialDBObjectType]; - return ( - moderatedItemsOfType && - typeof moderatedItemsOfType[item.block_height] !== "undefined" - ); -}; - -const shouldFilter = (item, socialDBObjectType) => { - return ( - selfFlaggedPosts.find((flagged) => { - return ( - flagged?.value?.blockHeight === item.block_height && - flagged?.value?.path.includes(item.account_id) - ); - }) || matchesModeration(selfModeration, socialDBObjectType, item) - ); -}; -function fetchGraphQL(operationsDoc, operationName, variables) { - return asyncFetch(`${GRAPHQL_ENDPOINT}/v1/graphql`, { - method: "POST", - headers: { "x-hasura-role": "dataplatform_near" }, - body: JSON.stringify({ - query: operationsDoc, - variables: variables, - operationName: operationName, - }), - }); -} - -const createQuery = (type, isUpdate) => { - let querySortOption = ""; - switch (sort) { - case "recentcommentdesc": - querySortOption = `{ last_comment_timestamp: desc_nulls_last },`; - break; - default: - querySortOption = ""; - } - - let queryFilter = ""; - let timeOperation = "_lte"; - if (isUpdate) { - timeOperation = "_gt"; - } - - const queryTime = initialQueryTime ? initialQueryTime : Date.now() * 1000000; - - if (filteredAccountIds) { - queryFilter = `where: { - _and: [ - {account_id: {_in: "${filteredAccountIds}"}}, - {block_timestamp: {${timeOperation}: ${queryTime}}} - ] - }, `; - } else { - queryFilter = `where: { - _and: [ - {block_timestamp: {${timeOperation}: ${queryTime}}} - ] - }, `; - } - - return ` -query FeedQuery($offset: Int, $limit: Int) { - dataplatform_near_social_feed_moderated_posts(${queryFilter} order_by: [${querySortOption} { block_height: desc }], offset: $offset, limit: $limit) { - account_id - block_height - block_timestamp - content - receipt_id - accounts_liked - last_comment_timestamp - comments(order_by: {block_height: asc}) { - account_id - block_height - block_timestamp - content - } - verifications { - human_provider - human_valid_until - human_verification_level - } - - } - dataplatform_near_social_feed_moderated_posts_aggregate(${queryFilter} order_by: {id: asc}) { - aggregate { - count - } - } -} -`; -}; - -const loadMorePosts = (isUpdate) => { - const queryName = "FeedQuery"; - - if (!isUpdate) { - setIsLoading(true); - } - const offset = isUpdate ? 0 : postsData.posts.length; - const limit = isUpdate ? 100 : LIMIT; - const query = createQuery("", isUpdate); - fetchGraphQL(query, queryName, { - offset: offset, - limit: limit, - }).then((result) => { - if (result.status === 200 && result.body) { - if (result.body.errors) { - console.log("error:", result.body.errors); - return; - } - let data = result.body.data; - if (data) { - const newPosts = data.dataplatform_near_social_feed_moderated_posts; - const postsCountLeft = - data.dataplatform_near_social_feed_moderated_posts_aggregate.aggregate - .count; - if (newPosts.length > 0) { - let filteredPosts = newPosts.filter( - (i) => !shouldFilter(i, postsModerationKey) - ); - filteredPosts = filteredPosts.map((post) => { - const prevComments = post.comments; - const filteredComments = prevComments.filter( - (comment) => !shouldFilter(comment, commentsModerationKey) - ); - post.comments = filteredComments; - return post; - }); - - if (isUpdate) { - setNewUnseenPosts(filteredPosts); - } else { - setPostsData({ - posts: [...postsData.posts, ...filteredPosts], - postsCountLeft, - }); - setIsLoading(false); - } - } - } - } - if (!isUpdate && initialQueryTime === null) { - const newTime = - postsData.posts && postsData.posts[0] - ? postsData.posts[0].block_timestamp - : Date.now() * 1000000; - setInitialQueryTime(newTime + 1000); - } - }); -}; - -const startFeedUpdates = () => { - if (initialQueryTime === null) return; - - clearInterval(feedInterval); - const newFeedInterval = setInterval(() => { - loadMorePosts(true); - }, 5000); - setFeedInterval(newFeedInterval); -}; - -const stopFeedUpdates = () => { - clearInterval(feedInterval); -}; - -const [initialized, setInitialized] = useState(false); -const [initialQueryTime, setInitialQueryTime] = useState(null); -const [feedInterval, setFeedInterval] = useState(null); -const [newUnseenPosts, setNewUnseenPosts] = useState([]); -const [postsData, setPostsData] = useState({ posts: [], postsCountLeft: 0 }); -const [isLoading, setIsLoading] = useState(false); - -useEffect(() => { - loadMorePosts(false); -}, []); - -useEffect(() => { - if (postsData.posts.length > 0) { - setPostExists(true); - } -}, [postsData]); - -useEffect(() => { - if (initialQueryTime === null) { - clearInterval(feedInterval); - } else { - startFeedUpdates(); - } -}, [initialQueryTime]); - -useEffect(() => { - if (newUnseenPosts && newUnseenPosts.length > 0) { - stopFeedUpdates(); - const initialQueryTime = newUnseenPosts[0].block_timestamp + 1000; // timestamp is getting rounded by 3 digits - const newTotalCount = postsData.postsCountLeft + newUnseenPosts.length; - setPostsData({ - posts: [...newUnseenPosts, ...postsData.posts], - postsCountLeft: newTotalCount, - }); - if (props.onNewUnseenPosts) { - props.onNewUnseenPosts(newUnseenPosts); - } - setNewUnseenPosts([]); - setInitialQueryTime(initialQueryTime); - } -}, [newUnseenPosts]); - -const hasMore = - postsData.postsCountLeft !== postsData.posts.length && - postsData.posts.length > 0; - -if (!initialized && sort) { - setInitialized(true); -} - -return ( - <> - { - if (!isLoading) { - loadMorePosts(false); - } - }, - posts: postsData.posts, - showFlagAccountFeature: props.showFlagAccountFeature, - }} - /> - -); diff --git a/instances/events-committee.near/widget/devhub/components/organism/NewsLetter.jsx b/instances/events-committee.near/widget/devhub/components/organism/NewsLetter.jsx deleted file mode 100644 index 6d4989e14..000000000 --- a/instances/events-committee.near/widget/devhub/components/organism/NewsLetter.jsx +++ /dev/null @@ -1,146 +0,0 @@ -const page = props.page; - -const Footer = styled.div` - width: 100%; - background-color: #00ec97; - padding: 2rem; - margin-top: 2rem; - width: 100vw; - position: relative; - left: 50%; - right: 50%; - margin-left: -50vw; - margin-right: -50vw; - - @media screen and (max-width: 768px) { - padding: 1rem; - } -`; - -const CTA = styled.a` - display: inline-flex; - padding: 0.5rem 0.8rem; - align-items: center; - gap: 0.5rem; - - border-radius: 0.5rem; - border: 1px solid #151515; - - color: #151515 !important; - font-size: 0.8rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 28.8px */ - letter-spacing: -0.48px; - - &:hover { - background: #151515; - color: #f4f4f4 !important; - text-decoration: none; // Remove underline on hover - } -`; - -const XIcon = () => { - return ( - - - - ); -}; - -const TelegramIcon = () => { - return ( - - - - ); -}; - -const YoutubeIcon = () => { - return ( - - - - ); -}; - -const MidContent = () => { - return ( - <> - - /dev/hub newsletter - - Stay in the loop. Get the latest updates, announcements, -
- opportunities, and insights from the ecosystem in your inbox. -
- - Subscribe - - - - - - - - - - - - -
- - ); -}; - -const SocialLinksContainer = () => { - return ( - - ); -}; - -return ( -
- -
-
Subscribe to our newsletter
- - Subscribe - -
-
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/Card.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/Card.jsx deleted file mode 100644 index 2ebac2cca..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/Card.jsx +++ /dev/null @@ -1,77 +0,0 @@ -function Card({ data }) { - const { category, title, subtitle, date } = data; - - const Container = styled.div` - min-height: 12.5rem; - height: 100%; - display: flex; - padding: 1rem; - flex-direction: column; - align-items: flex-start; - gap: 1rem; - flex-shrink: 0; - - border-radius: 1rem; - border: 1px solid rgba(129, 129, 129, 0.3); - background: #fffefe; - - h5 { - margin: 0; - color: #151515; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 110%; /* 39.6px */ - } - - ${category && - ` - span.category { - color: ${ - category.toLowerCase() === "news" - ? "#F40303" - : category.toLowerCase() === "guide" - ? "#004BE1" - : category.toLowerCase() === "reference" && "#FF7A00" - }; - font-size: 1rem; - font-style: normal; - font-weight: 700; - line-height: 20px; /* 125% */ - text-transform: uppercase; - } - `} - - span.date { - color: #818181; - font-size: 16px; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 125% */ - margin-top: auto; - } - - p { - margin: 0; - color: #151515; - font-size: 1rem; - font-style: normal; - font-weight: 400; - line-height: 120%; /* 28.8px */ - } - `; - - const options = { year: "numeric", month: "short", day: "numeric" }; - const formattedDate = new Date(date).toLocaleString("en-US", options); - - return ( - - {category && {category}} -
{title}
-

{subtitle}

- {formattedDate} -
- ); -} - -return { Card }; diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/Configurator.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/Configurator.jsx deleted file mode 100644 index 173dde428..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/Configurator.jsx +++ /dev/null @@ -1,45 +0,0 @@ -const { data, handle, onSubmit } = props; - -const { Tile } = - VM.require("${REPL_EVENTS}/widget/devhub.components.molecule.Tile") || - (() => <>); - -if (!Tile) { - return
Loading...
; -} - -const Container = styled.div` - display: flex; - flex-direction: column; - width: 100%; - padding: 20px; -`; - -const Item = styled.div` - padding: 10px; - margin: 5px; - display: flex; - align-items: center; - flex-direction: row; - gap: 10px; -`; - -const EditableField = styled.input` - flex: 1; -`; - -const initialData = data; - -return ( - - - - - -); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/Feed.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/Feed.jsx deleted file mode 100644 index 2669dd1f4..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/Feed.jsx +++ /dev/null @@ -1,142 +0,0 @@ -const { Item, Layout } = props; - -Layout = Layout || (() => <>); - -const Container = styled.div``; - -const Loader = styled.div` - text-align: center; - 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); - } - }); -}; - -useEffect(() => { - fetchPostIds(); -}, [props.author, props.term, props.tag, props.recency]); - -const handleLoadMore = () => { - if (!hasNext) return; - fetchPostIds(postIds.length); -}; - -const renderLoader = () => Loading...; - -const renderItem = (postId) => ( -
- {(props.renderItem && props.renderItem(postId)) ||
Post {postId}
} -
-); - -const cachedRenderItem = (postId) => { - if (!(postId in cachedItems)) { - cachedItems[postId] = renderItem(postId); - setCachedItems({ ...cachedItems }); - } - return cachedItems[postId]; -}; - -return ( - - {loading && renderLoader()} - {postIds.length > 0 ? ( - - - {/* Layout */} - {postIds.map(cachedRenderItem)} - - - ) : ( -

No posts

- )} -
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/Page.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/Page.jsx deleted file mode 100644 index 4bf432e2d..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/Page.jsx +++ /dev/null @@ -1,129 +0,0 @@ -const { getAccountCommunityPermissions } = VM.require( - "${REPL_EVENTS}/widget/core.adapter.devhub-contract" -) || { - getAccountCommunityPermissions: () => {}, -}; -const imagelink = - "https://ipfs.near.social/ipfs/bafkreiajzvmy7574k7mp3if6u53mdukfr3hoc2kjkhjadt6x56vqhd5swy"; - -function Page({ data, onEdit, labels, accountId }) { - const { category, title, description, subtitle, date, content } = data; - const handle = labels?.[1]; // community-handle - const permissions = getAccountCommunityPermissions({ - account_id: accountId, - community_handle: handle, - }); - const isAllowedToEdit = permissions?.can_configure ?? false; - const Container = styled.div` - display: flex; - flex-direction: column; - width: 100%; - - padding: 0 3rem; - margin-bottom: 2rem; - position: relative; - ${category && - ` - span.category { - color: ${ - category.toLowerCase() === "news" - ? "#F40303" - : category.toLowerCase() === "guide" - ? "#004BE1" - : category.toLowerCase() === "reference" && "#FF7A00" - }; - font-size: 1.5rem; - font-style: normal; - font-weight: 700; - line-height: 20px; /* 125% */ - text-transform: uppercase; - } - `} - - span.date { - color: #818181; - font-size: 1rem; - font-style: normal; - font-weight: 400; - line-height: 20px; /* 125% */ - margin: 1.5rem 0; - } - - h1 { - color: #151515; - font-size: 3.5rem; - font-style: normal; - font-weight: 700; - line-height: 100%; /* 88px */ - margin: 1.5rem 0; - } - - p.subtitle { - color: #555; - font-size: 1.5rem; - font-style: normal; - font-weight: 400; - line-height: 110%; /* 35.2px */ - margin: 0; - } - - .edit-icon { - position: absolute; - top: 20px; - right: 20px; - cursor: pointer; - } - - @media screen and (max-width: 768px) { - padding: 0 1rem; - - span.category { - font-size: 0.75rem; - } - - h1 { - font-size: 2rem; - } - - p.subtitle { - font-size: 1rem; - } - } - `; - - const BackgroundImage = styled.img` - width: 100%; - height: auto; - object-fit: cover; - margin-bottom: 1rem; - `; - - const options = { year: "numeric", month: "short", day: "numeric" }; - const formattedDate = new Date(date).toLocaleString("en-US", options); - - return ( - <> - - - {isAllowedToEdit && ( -
-
-
- )} - {category && {category}} -

{title}

-

{subtitle}

- {formattedDate} -

{description}

- -
- - ); -} - -return { Page }; diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/Viewer.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/Viewer.jsx deleted file mode 100644 index 3344eece8..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/Viewer.jsx +++ /dev/null @@ -1,79 +0,0 @@ -const { Card } = - VM.require("${REPL_EVENTS}/widget/devhub.entity.addon.blog.Card") || - (() => <>); - -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url") || (() => {}); - -const { includeLabels, excludeLabels, layout, handle, hideTitle } = props; - -const Grid = styled.div` - display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); - gap: 1rem; - - @media screen and (max-width: 768px) { - display: flex; - flex-direction: column; - gap: 1rem; - } -`; - -const Heading = styled.h3` - color: #151515; - font-size: 2rem; - font-style: normal; - font-weight: 700; - line-height: 120%; /* 48px */ - margin-bottom: 2rem; - - @media screen and (max-width: 768px) { - font-size: 1.5rem; - } -`; - -const CardContainer = styled.div` - transition: all 300ms; - border-radius: 1rem; - height: 100%; - - &:hover { - box-shadow: 0 10px 15px -3px rgb(0 0 0 / 0.1), - 0 4px 6px -4px rgb(0 0 0 / 0.1); - } -`; - -function BlogCard(postId) { - return ( - - - }} // I wonder if this could take list of types, their templates, normalizer functions, etc... and have this all as a module - /> - {/* // so then you could swap between devhub contract or social contract sources, it doesn't matter. */} - - - ); -} - -return ( -
- {!hideTitle && Latest Blog Posts} - {children}, - }} - /> -
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/content.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/content.jsx deleted file mode 100644 index 09ff9af30..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/content.jsx +++ /dev/null @@ -1,263 +0,0 @@ -const { Card } = - VM.require("${REPL_EVENTS}/widget/devhub.entity.addon.blog.Card") || - (() => <>); -const { Page } = - VM.require("${REPL_EVENTS}/widget/devhub.entity.addon.blog.Page") || - (() => <>); - -const categories = [ - { - label: "Guide", - value: "guide", - }, - { - label: "News", - value: "news", - }, - { - label: "Reference", - value: "reference", - }, -]; - -const selectOptions = useMemo( - () => - categories.map((it) => ({ - label: it.label, - value: it.value, - })), - [categories] -); - -const Banner = styled.div` - border-radius: var(--bs-border-radius-xl) !important; - height: 100%; - - & > div :not(.btn) { - position: absolute; - display: none; - margin: 0 !important; - width: 0 !important; - height: 0 !important; - } - - .btn { - padding: 0.5rem 0.75rem !important; - min-height: 32; - line-height: 1; - - border: none; - border-radius: 50px; - --bs-btn-color: #ffffff; - --bs-btn-bg: #087990; - --bs-btn-border-color: #087990; - --bs-btn-hover-color: #ffffff; - --bs-btn-hover-bg: #055160; - --bs-btn-hover-border-color: #055160; - --bs-btn-focus-shadow-rgb: 49, 132, 253; - --bs-btn-active-color: #ffffff; - --bs-btn-active-bg: #055160; - --bs-btn-active-border-color: #055160; - --bs-btn-active-shadow: inset 0 3px 5px rgba(0, 0, 0, 0.125); - opacity: 0.8; - - &:hover { - opacity: 1; - } - } -`; - -const { data, handle, onSubmit } = props; - -const initialData = data; - -const [content, setContent] = useState(initialData.content || ""); -const [title, setTitle] = useState(initialData.title || ""); -const [subtitle, setSubtitle] = useState(initialData.subtitle || ""); -const [description, setDescription] = useState(initialData.description || ""); -const [author, setAuthor] = useState(initialData.author || ""); -const [previewMode, setPreviewMode] = useState("card"); // "card" or "page" -const [date, setDate] = useState(initialData.date || new Date()); -const [category, setCategory] = useState("guide"); - -const Container = styled.div` - width: 100%; - margin: 0 auto; - padding: 20px; - text-align: left; -`; - -const hasDataChanged = () => { - return ( - content !== initialData.content || - title !== initialData.title || - author !== initialData.author || - subtitle !== initialData.subtitle || - description !== initialData.description || - date !== initialData.date || - category !== initialData.category - ); -}; - -const handlePublish = () => { - onSubmit && - onSubmit( - { - id: data.id || undefined, - title, - subtitle, - description, - date, - content, - author, - category, - community: handle, - }, - data.id !== undefined - ); -}; - -function Preview() { - switch (previewMode) { - case "card": { - return ( - - ); - } - case "page": { - return ( - - ); - } - } -} - -return ( - -
    -
  • - -
  • -
  • - -
  • -
-
-
- -
- -
-
-
-
- setPreviewMode(e.target.value), - options: [ - { label: "Card", value: "card" }, - { label: "Page", value: "page" }, - ], - - title: "Preview mode selection", - }} - /> -
-
- -
-
-
-
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/form.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/form.jsx deleted file mode 100644 index 2dc0c29a2..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/form.jsx +++ /dev/null @@ -1,169 +0,0 @@ -const FormContainer = styled.div` - & > *:not(:last-child) { - margin-bottom: 1rem; - } -`; - -const { - title, - setTitle, - subtitle, - setSubtitle, - options, - category, - setCategory, - description, - setDescription, - debouncedUpdateState, - author, - setAuthor, - date, - setDate, - content, - setContent, -} = props; - -const TitleInput = ({ title, setTitle }) => { - return ( -
-
Title
-
- setTitle(e.target.value), - value: title, - placeholder: "Title", - inputProps: { name: "title" }, - }} - /> -
-
- ); -}; -const SubtitleInput = ({ subtitle, setSubtitle }) => { - return ( -
-
Subtitle
-
- setSubtitle(e.target.value), - value: subtitle, - placeholder: "Subtitle", - inputProps: { name: "subtitle" }, - }} - /> -
-
- ); -}; - -const CategorySelect = ({ options, category, setCategory }) => { - return ( -
-
Category
-
- setCategory(e.target.value), - placeholder: "Select a category", - }} - /> -
-
- ); -}; - -const DescriptionInput = ({ description, setDescription }) => { - return ( -
-
Description
-
- setDescription(e.target.value), - value: description, - placeholder: "Description", - inputProps: { name: "description" }, - }} - /> -
-
- ); -}; - -const AuthorInput = ({ author, setAuthor }) => { - return ( -
-
Author
-
- setAuthor(e.target.value), - value: author, - placeholder: "Author", - inputProps: { name: "author" }, - }} - /> -
-
- ); -}; - -const DateInput = ({ date, setDate }) => { - return ( -
-
Date
- setDate(e.target.value)} - /> -
- ); -}; - -const ContentEditor = ({ content, setContent }) => { - return ( -
-
Content
- -
- ); -}; - -return ( - - - - - - - - - -); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/index.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/index.jsx deleted file mode 100644 index d22b66a1c..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/index.jsx +++ /dev/null @@ -1,81 +0,0 @@ -let theme = props.theme; -let variables = props.variables; -const editData = props.data; - -if (!variables) { - variables = ``; -} - -if (!theme) { - theme = ``; -} - -const Root = styled.div` - ${variables} - ${theme} - - a { - text-decoration: none; - color: var(--base900); - } -`; - -const Container = styled.div` - display: flex; - justify-content: center; - align-items: center; - height: 100%; - width: 100%; -`; - -// What would be the first steps? -// Create this container and an empty provider -// Provider has some items, onChange, onSubmit console logs -// Create a layout that takes in Editor - -return ( - - {/* Get any layout */} - - { - const { data, onChange, onSubmit, onCancel, getData } = - providerProps; - return ( - ( - - ), - Content: (p) => ( - - ), - }} - /> - ); - }, - }} - /> - - -); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/layout.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/layout.jsx deleted file mode 100644 index 714cc9136..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/layout.jsx +++ /dev/null @@ -1,36 +0,0 @@ -const { Sidebar, Content, getData, editData } = props; - -const [selectedItem, setSelectedItem] = useState(editData); - -const handleItemClick = (item) => { - if (item) { - getData(item).then((item) => { - setSelectedItem(item); - }); - } else { - setSelectedItem(null); - } -}; - -return ( -
-
- -
-
- -
-
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/provider.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/provider.jsx deleted file mode 100644 index 9f6aa5a07..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/provider.jsx +++ /dev/null @@ -1,140 +0,0 @@ -const { getPost } = VM.require( - "${REPL_EVENTS}/widget/core.adapter.devhub-contract" -) || { getPost: () => {} }; - -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 handleOnChange = (v) => { - console.log("onChange", v); -}; - -const handleGetData = (v) => { - const postId = parseInt(v); - return Near.asyncView("${REPL_DEVHUB_LEGACY}", "get_post", { - post_id: postId, - }).then((post) => { - const description = JSON.parse(post.snapshot.description || "null") || {}; - return { - id: postId, - ...description, - }; - }); -}; - -const handleOnSubmit = (v, isEdit) => { - if (isEdit) { - Near.call({ - contractName: "${REPL_DEVHUB_LEGACY}", - methodName: "edit_post", - args: { - id: parseInt(v.id), - labels: ["blog", handle], - body: { - post_type: "Comment", - description: JSON.stringify(v), - comment_version: "V2", - }, - }, - gas: Big(10).pow(14), - }); - } else { - Near.call({ - contractName: "${REPL_DEVHUB_LEGACY}", - methodName: "add_post", - args: { - labels: ["blog", handle], - body: { - post_type: "Comment", - description: JSON.stringify(v), - comment_version: "V2", - }, - }, - gas: Big(10).pow(14), - }); - } -}; - -const handleOnCancel = (v) => { - console.log("onCancel", v); -}; - -return ( - -); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/sidebar.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/sidebar.jsx deleted file mode 100644 index 4628da78b..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blog/editor/sidebar.jsx +++ /dev/null @@ -1,50 +0,0 @@ -const { data, editPostId, handleItemClick, selectedItem } = props; - -const SidebarContainer = styled.div` - background-color: #f0f0f0; - padding: 16px; - width: 200px; - display: flex; - flex-direction: column; - align-items: center; - height: 100%; - gap: 4px; -`; - -const SidebarButton = styled.button` - display: flex; - padding: 14px 16px; - text-align: center; - cursor: pointer; - gap: 16px; - width: 100%; - - border-radius: 4px; - border: 1px solid #00ec97; - - background-color: ${({ selected }) => (selected ? "#00ec97" : "white")}; - color: ${({ selected }) => (selected ? "white" : "black")}; -`; - -return ( - -

Blog posts

- handleItemClick(null)} - id="create-new-blog" - > - New - - {(data || []).map((it) => ( - handleItemClick(it.post_id)} - > - Id: {it.post_id} - - ))} -
-); diff --git a/instances/events-committee.near/widget/devhub/entity/addon/blogv2/Blog.jsx b/instances/events-committee.near/widget/devhub/entity/addon/blogv2/Blog.jsx deleted file mode 100644 index c55425f09..000000000 --- a/instances/events-committee.near/widget/devhub/entity/addon/blogv2/Blog.jsx +++ /dev/null @@ -1,13 +0,0 @@ -const { blogId, template, handle } = props; - -const blog = - Social.get(`${handle}.community.devhub.near/blog/${blogId}/**`, "final") || - {}; - -if (!blog || Object.keys(blog).length === 0) { - return
Loading ...
; -} - -const Template = template || (() => <>); - -return