Loading modules...
; -} - -const communities = getFeaturedCommunities(); - -if (!communities) { - returnLoading 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 ( -{description}
- Learn more → -{description}
- Learn more → -{it.description}
- {it.cta.title} -badgeIdor
tokenIdto the - DevGovBadgeDetails component - > - ); -} - -let badgeMetadata = - props.badgeMetadata ?? - Near.view(nearDevGovBadgesContractId, "get_badge", { - badge_id: badgeId, - }).badge_metadata; - -if (!badgeMetadata) { - return <>Loading...>; -} - -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 ( - <> -{subtitle}
- {formattedDate} -No posts
- )} -{subtitle}
- {formattedDate} -{description}
-Blog posts
-{description}
- {formattedDate} -{subtitle}
-{description}
-Loading modules...
; -} - -const { href } = VM.require("${REPL_EVENTS}/widget/core.lib.url") || (() => {}); - -const { - data, - handle, - hideTitle, - communityAddonId, - setAddonView, - transactionHashes, - permissions, -} = 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); - } -`; - -if (!handle) { - return- Name - | - {props.hideColumns ? null : ( - <> -- Status - | -- Created - | -- Updated - | -- Visible Publish Date - | - > - )} -
---|---|---|---|---|
-
- {it.title}
-
- |
-
- {props.hideColumns ? null : (
- <>
- - - {it.status == "PUBLISH" ? "Published" : "Draft"} - - | -{formattedDate(it.createdAt)} | -{formattedDate(it.updatedAt)} | -{formattedDate(it.publishedAt)} | - > - )} -
- Status:{" "} - - {initialData.status === "PUBLISH" ? ( - - Published - - ) : ( - <>Draft> - )} - -
-Loading modules...
; -} -const { useQuery } = VM.require( - "${REPL_EVENTS}/widget/core.adapter.devhub-contract" -); -const { uuid, withUUIDIndex } = VM.require( - "${REPL_EVENTS}/widget/core.lib.uuid" -); - -uuid || (uuid = () => {}); -withUUIDIndex || (withUUIDIndex = () => {}); -useQuery || (useQuery = () => {}); - -const AttractableDiv = styled.div` - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } -`; - -const settings = { - maxColumnsNumber: 20, -}; - -const GithubKanbanBoardTicketFeaturesSchema = { - id: { label: "GitHub ID" }, - author: { label: "Author" }, - labels: { label: "Labels" }, - type: { label: "Type" }, -}; - -const GithubKanbanBoardTicketTypesSchema = { - issue: { label: "Issue" }, - pullRequest: { label: "Pull Request" }, -}; - -const GithubKanbanBoardLabelsSchema = { - allLabelsMust: { label: "All labels must be present in ticket" }, -}; - -const GithubKanbanBoardDefaults = { - columns: { - ...withUUIDIndex({ - description: "", - labelSearchTerms: [], - title: "", - allLabelsMust: false, - }), - }, - dataTypesIncluded: { issue: true, pullRequest: true }, - description: "", - repoURL: "", - ticketState: "all", - title: "", - metadata: { - id: uuid(), - type: "github.kanban_board", - ticket: { - type: "github.kanban_ticket", - features: { id: true, author: true, labels: true, type: true }, - }, - }, -}; - -const toMigrated = ({ metadata, id, ...restParams }) => ({ - ...GithubKanbanBoardDefaults, - metadata: { - ...GithubKanbanBoardDefaults.metadata, - ...metadata, - id: id ?? metadata.id, - }, - ...restParams, -}); - -function extractOwnerAndRepo(url) { - // Remove any leading or trailing slashes and split the URL by "/" - const parts = url - .trim() - .replace(/^\/+|\/+$/g, "") - .split("/"); - - // Check if the URL matches the GitHub repository format - if (parts.length === 5 && parts[2] === "github.com") { - const owner = parts[3]; - const repo = parts[4]; - return { owner, repo }; - } else { - return null; - } -} - -function isValidGitHubRepoLink(url) { - // Regular expression to match GitHub repository URLs - const githubRepoRegex = - /^(?:https?:\/\/)?(?:www\.)?github\.com\/([^\/]+)\/([^\/]+)\/?$/; - - // Check if the URL matches the GitHub repository format - return githubRepoRegex.test(url); -} - -const GithubViewConfigurator = ({ kanbanBoards, permissions, onSubmit }) => { - const data = kanbanBoards ? Object.values(kanbanBoards)?.[0] : {}; - - if (!data) { - return ( -{description}
-{column.description}
- - {state.error && ( -No tickets found
} - {state.fetchedTicketsCount[column.id] > 0 && ( -Loading modules...
; -} -const { useQuery } = VM.require( - "${REPL_EVENTS}/widget/core.adapter.devhub-contract" -); -const { uuid, withUUIDIndex } = VM.require( - "${REPL_EVENTS}/widget/core.lib.uuid" -); - -uuid || (uuid = () => {}); -withUUIDIndex || (withUUIDIndex = () => {}); -useQuery || (useQuery = () => {}); - -const AttractableDiv = styled.div` - box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075) !important; - transition: box-shadow 0.6s; - - &:hover { - box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15) !important; - } -`; - -const settings = { - maxColumnsNumber: 10, -}; - -const KanbanPostBoardBasicInfoSchema = { - title: { label: "Title", order: 1, placeholder: "Enter board title" }, - description: { - label: "Description", - order: 2, - placeholder: "Enter board description", - }, -}; - -const KanbanPostBoardTicketFeaturesSchema = { - author: { label: "Author" }, - like_count: { label: "Likes" }, - approved_sponsorship_value: { label: "Funding amount" }, - sponsorship_supervisor: { label: "Supervisor/Sponser" }, - tags: { label: "Tags" }, - type: { label: "Post type" }, -}; - -const KanbanPostBoardDefaults = { - metadata: { - id: uuid(), - type: "kanban.post_board", - title: "", - description: "", - ticket: { - type: "kanban.post_ticket", - features: { - author: true, - like_count: true, - approved_sponsorship_value: true, - sponsorship_supervisor: true, - tags: true, - type: true, - }, - sortBy: "", - }, - }, - payload: { - columns: {}, - }, -}; - -const toMigrated = ({ config, metadata, payload }) => ({ - metadata: { - ...KanbanPostBoardDefaults.metadata, - ...metadata, - ticket: { - ...KanbanPostBoardDefaults.metadata.ticket, - ...metadata.ticket, - features: { - ...KanbanPostBoardDefaults.metadata.ticket.features, - ...metadata.ticket.features, - }, - }, - }, - payload: { - ...KanbanPostBoardDefaults.payload, - ...payload, - ...config, - }, -}); - -const sortByOptions = [ - { label: "None", value: "none" }, - { label: "Amount: High to Low", value: "descending-amount" }, - { label: "Amount: Low to High", value: "ascending-amount" }, - { label: "Date: Newest to Oldest", value: "descending-date" }, - { label: "Date: Oldest to Newest", value: "ascending-date" }, - { label: "Author: A-Z", value: "ascending-author" }, - { label: "Author: Z-A", value: "descending-author" }, - { label: "Sponsor/Supervisor: A-Z", value: "ascending-sponsor" }, - { label: "Sponsor/Supervisor: Z-A", value: "descending-sponsor" }, - { label: "Most Likes", value: "descending-likes" }, - { label: "Fewest Likes", value: "ascending-likes" }, -]; - -const KanbanViewConfigurator = ({ handle, data, permissions, onSubmit }) => { - const tags = useCache( - () => - Near.asyncView("${REPL_EVENTS_CONTRACT}", "get_all_labels").then( - (res) => res - ), - handle, - { - subscribe: false, - } - ); - - if (!data) { - return ( -Loading modules...
; -} - -href || (href = () => {}); - -const { data, handle, permissions } = props; - -if (!data || !data?.metadata) { - return ( -{column.description}
- - -- {metadata?.description} -
-{subtitle}
-Handle not defined
; -} - -if (!href) { - returnLoading modules...
; -} - -// TODO: Why do we need to get community data again? Isn't the tag the handle... -const communityData = getCommunity({ handle }); - -if (communityData === null) { - return{description}
-Loading modules...
; -} - -const CenteredMessage = styled.div` - display: flex; - flex-direction: column; - justify-content: center; - align-items: center; - width: 100%; - height: ${(p) => p.height ?? "100%"}; -`; - -const [isLoading, setIsLoading] = useState(false); -const [error, setError] = useState(null); - -const community = getCommunity({ handle }); - -const permissions = getAccountCommunityPermissions({ - account_id: context.accountId, - community_handle: handle, -}) || { - can_configure: false, - can_delete: false, -}; - -if (isLoading) { - return ( -Loading modules...
; -} - -const { community } = props; - -const CommunitySummary = () => { - return ( - <> -Loading modules...
; -} - -const { data, onSubmit, onCancel } = props; - -const CommunityInputsPartialSchema = { - handle: { - inputProps: { - min: 2, - max: 40, - allowCommaAndSpace: false, - placeholder: - "Choose unique URL handle for your community. Example: zero-knowledge.", - required: true, - }, - - label: "URL handle", - order: 3, - }, - - name: { - inputProps: { - min: 2, - max: 30, - placeholder: "Community name.", - required: true, - }, - - label: "Name", - order: 1, - }, - - tag: { - inputProps: { - min: 2, - max: 30, - allowCommaAndSpace: false, - placeholder: - "Any posts with this tag will show up in your community feed.", - - required: true, - }, - - label: "Tag", - order: 4, - }, - - description: { - inputProps: { - min: 2, - max: 60, - - placeholder: - "Describe your community in one short sentence that will appear in the communities discovery page.", - - required: true, - }, - - label: "Description", - order: 2, - }, -}; - -const communityInputsValidator = (formValues) => - typeMatch(formValues) && - Object.values(formValues).every( - (value) => typeof value === "string" && value.length > 0 - ); - -const CommunityInputsDefaults = { - handle: "", - name: "", - tag: "", - description: "", -}; - -return ( -Loading modules...
; -} - -const AutoComplete = styled.div` - z-index: 5; - - > div > div { - padding: calc(var(--padding) / 2); - } -`; - -const Wrapper = styled.div` - .container { - display: flex; - align-items: center; - flex-wrap: wrap; - gap: 0.5em; - } - - .admins-item { - display: inline-block; - padding: 0.6em 0.8em; - border-radius: 10px; - border: 1px solid lightgray; - position: relative; - } - - .admins-item .remove { - position: absolute; - right: 5px; - top: 0; - font-size: 18px; - color: grey; - cursor: pointer; - } - - .admins-input { - flex-grow: 1; - border: none; - outline: none; - } - - input[type="text"]:disabled { - all: inherit; - } - - input::placeholder { - font-size: 16px; - } -`; - -const { data, onSubmit, onCancel, setIsActive, isActive } = props; -const initialValues = Struct.typeMatch(CommunityAccessControlSchema) - ? Struct.pick(data ?? {}, Object.keys(CommunityAccessControlSchema)) - : {}; - -const [admins, setAdmins] = useState(initialValues?.admins ?? []); -const [text, setText] = useState(""); -const [showAccountAutocomplete, setShowAutoAutocomplete] = useState(false); - -function handleKeyDown(e) { - if (e.key !== "Enter") return; - const value = e.target.value; - if (!value.trim()) return; - // Add the value to the admins array - setAdmins([...admins, value]); - setText(""); -} - -const onCancelClick = () => { - setAdmins(initialValues?.admins ?? []); - setIsActive(false); -}; - -const onSubmitClick = () => { - onSubmit({ admins: admins.map((admin) => admin.trim()) }); - setIsActive(false); -}; - -function autoCompleteAccountId(id) { - setAdmins([...admins, id]); - setText(""); - setShowAutoAutocomplete(false); -} - -return ( -
- Add or remove custom tabs, which will appear in your community's
- navigation bar.
-
- You can customize them on each page.
-
- {data.description} -
-Loading modules...
; -} - -const QUERYAPI_ENDPOINT = `https://near-queryapi.api.pagoda.co/v1/graphql/`; - -const queryName = - props.queryName ?? `bo_near_devhub_v38_posts_with_latest_snapshot`; -const totalQueryName = - props.totalQueryName ?? - "bo_near_devhub_v38_posts_with_latest_snapshot_aggregate"; -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 totalQuery = `query DevhubTotalPostsQuery($where: ${queryName}_bool_exp = {}) { - ${totalQueryName}( - where: $where - ) { - aggregate { - count - } - } - } -`; - -function 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, - }), - }); -} - -function searchConditionChanged() { - return ( - props.author != state.author || - props.term != state.term || - props.tag != state.tag || - props.recency != state.recency - ); -} - -function updateSearchCondition() { - State.update({ - author: props.author, - term: props.term, - tag: props.tag, - recency: props.recency, - loading: true, - }); -} - -const initialRenderLimit = props.initialRenderLimit ?? 3; -const addDisplayCount = props.nextLimit ?? initialRenderLimit; - -State.init({ - period: "week", - totalItems: 0, - displayCount: initialRenderLimit, -}); - -function getPostIds(tag, offset) { - if (searchConditionChanged()) { - updateSearchCondition(); - } - let where = {}; - let authorId = props.author; - let label = tag || props.tag; - if (authorId) { - where = { author_id: { _eq: authorId }, ...where }; - } - if (props.term) { - where = { description: { _ilike: `%${props.term}%` }, ...where }; - } - if (label) { - if (typeof label === "string") { - // Handle a single label - where = { labels: { _contains: label }, ...where }; - } else if (Array.isArray(label)) { - // Handle an array of labels - where = { - labels: { - _containsAny: label, - }, - ...where, - }; - } - } - if (!props.recency) { - // show only top level posts - where = { parent_id: { _is_null: true }, ...where }; - } - - // Don't show blog and devhub-test posts - where = { - _and: [ - { - _not: { - labels: { _contains: "blog" }, - parent_id: { _is_null: true }, - post_type: { _eq: "Comment" }, - }, - }, - { - _not: { - labels: { _contains: "devhub-test" }, - }, - }, - ], - ...where, - }; - - if (!offset) { - fetchGraphQL(totalQuery, "DevhubTotalPostsQuery", { - where, - }).then((result) => { - const data = result.body.data[totalQueryName]; - State.update({ - totalItems: data.aggregate.count, - }); - }); - } - - fetchGraphQL(query, "DevhubPostsQuery", { - limit: 50, - offset: offset ?? 0, - where, - }).then((result) => { - if (result.status === 200) { - if (result.body.data) { - const data = result.body.data[queryName]; - if (offset) { - State.update({ - postIds: state.postIds.concat(data.map((p) => p.post_id)), - loading: false, - }); - } else { - State.update({ - postIds: data.map((p) => p.post_id), - loading: false, - }); - } - } - } else { - State.update({ loading: false }); - } - }); -} - -if (!state.items || searchConditionChanged()) { - getPostIds(); -} - -function defaultRenderItem(postId, additionalProps) { - if (!additionalProps) { - additionalProps = {}; - } - // It is important to have a non-zero-height element as otherwise InfiniteScroll loads too many items on initial load - return ( -- Post {transaction_method_name == "edit_post" ? "edited" : "added"}{" "} - successfully. Back to{" "} - - feed - -
- ) : state.items.length > 0 ? ( -- No posts{" "} - {props.term || props.tag || props.author ? "matches search" : ""} - {props.recency === "hot" - ? " in " + getPeriodText(state.period).toLowerCase() - : ""} -
- )} - > -); diff --git a/instances/events-committee.near/widget/devhub/entity/post/Panel.jsx b/instances/events-committee.near/widget/devhub/entity/post/Panel.jsx deleted file mode 100644 index 23fa35fd8..000000000 --- a/instances/events-committee.near/widget/devhub/entity/post/Panel.jsx +++ /dev/null @@ -1,742 +0,0 @@ -////////////////////////////////////////////////////////////////////// -///STOPWORDS////////////////////////////////////////////////////////// -const stopWords = [ - "about", - "above", - "after", - "again", - "against", - "all", - "and", - "any", - "are", - "because", - "been", - "before", - "being", - "below", - "between", - "both", - "but", - "can", - "cannot", - "could", - "did", - "does", - "doing", - "down", - "during", - "each", - "etc", - "few", - "for", - "from", - "further", - "had", - "has", - "have", - "having", - "her", - "hers", - "herself", - "him", - "himself", - "his", - "how", - "into", - "its", - "itself", - "just", - "more", - "most", - "myself", - "nor", - "not", - "now", - "off", - "once", - "only", - "other", - "our", - "ours", - "ourselves", - "out", - "over", - "own", - "same", - "she", - "should", - "some", - "still", - "such", - "than", - "that", - "the", - "their", - "theirs", - "them", - "themselves", - "then", - "there", - "these", - "they", - "this", - "those", - "through", - "too", - "under", - "until", - "very", - "was", - "were", - "what", - "when", - "where", - "which", - "while", - "who", - "whom", - "why", - "will", - "with", - "you", - "your", - "yours", - "yourself", - "yourselves", - "www", - "http", - "com", -]; - -const stopWordsDictionary = {}; -for (let i = 0; i < stopWords.length; i++) { - stopWordsDictionary[stopWords[i]] = true; -} - -function isStopWord(word) { - return stopWordsDictionary.hasOwnProperty(word.toLowerCase()); -} -////////////////////////////////////////////////////////////////////// -///SYNONYMS/////////////////////////////////////////////////////////// -const synonyms = { - ether: "ethereum", - eth: "ethereum", - either: "ethereum", - app: "application", - cryptocyrrency: "crypto", - developerdao: "devdao", - dev: "develop", - doc: "document", - lib: "librari", - saw: "see", - seen: "see", - tweet: "twitter", - paid: "pai", - src: "sourc", -}; - -const applySynonym = (word) => { - if (synonyms.hasOwnProperty(word.toLowerCase())) { - return synonyms[word]; - } - return word; -}; -////////////////////////////////////////////////////////////////////// -///STEMMING/////////////////////////////////////////////////////////// -const step2list = { - ational: "ate", - tional: "tion", - enci: "ence", - anci: "ance", - izer: "ize", - bli: "ble", - alli: "al", - entli: "ent", - eli: "e", - ousli: "ous", - ization: "ize", - ation: "ate", - ator: "ate", - alism: "al", - iveness: "ive", - fulness: "ful", - ousness: "ous", - aliti: "al", - iviti: "ive", - biliti: "ble", - logi: "log", -}; - -/** @type {RecordLoading modules...
; -} - -const ButtonWithHover = styled.button` - background-color: #fff; - transition: all 300ms; - border-radius: 0.5rem; - - &:hover { - background-color: #e9ecef; - color: #000; - } - - &:disabled { - background-color: #fff; - color: #b7b7b7; - } -`; - -const LikeLoadingSpinner = ( - -); - -const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0); - -const [isLikeClicked, setIsLikeClicked] = useState(false); -const [numLikes, setNumLikes] = useState(null); - -const post = - props.post ?? - Near.view("${REPL_DEVHUB_LEGACY}", "get_post", { post_id: postId }); - -if (!post) { - return- - * Note, all projects that were granted sponsorships are required to pass - KYC to receive the funding. - -
-); - -const isFundraisingDiv = ( - // This is jank with just btns and not radios. But the radios were glitchy af - <> -- Are you seeking funding for your solution? - (Optional) -
-- Requested sponsor - (Optional) -
-- If you are requesting funding from a specific sponsor, please enter - their username. -
-- What do you want to create? -
-- {postTypeOptions[state.postType].description} -
-Loading modules...
; -} - -const accessControlInfo = getAccessControlInfo(); -const rootMembers = getRootMembers(); -const allTeamNames = Object.keys(rootMembers || {}); - -if (!accessControlInfo || !rootMembers) { - returnLoading access control info...
; -} - -const { teamName } = props; -const teamModerators = teamName == "team:moderators"; -const label = Object.keys(rootMembers[teamName].permissions)[0] || ""; -const metadata = accessControlInfo.members_list[teamName]; -const editPost = rootMembers[teamName].permissions[label].includes("edit-post"); -const useLabels = - rootMembers[teamName].permissions[label].includes("use-labels"); -const members = rootMembers[teamName].children || []; - -const configuratorData = { - teamName: teamName, - label: label, - members, - editPost, - useLabels, -}; - -const [editMode, setEditMode] = useState(false); -const [alertMessage, setAlertMessage] = useState(""); - -function arrayEq(arr1, arr2) { - if (arr1.length !== arr2.length) { - return false; - } - const sortedArr1 = arr1.slice().sort(); - const sortedArr2 = arr2.slice().sort(); - for (let i = 0; i < sortedArr1.length; i++) { - if (sortedArr1[i] !== sortedArr2[i]) { - return false; - } - } - - return true; -} - -function editTeam({ - teamName: tmnm, - label: lbl, - editPost: edtpst, - useLabels: uslbls, - members: mmbrs, -}) { - let txn = []; - let numberOfChanges = 0; - - if (backwardsCompatibleTeam(teamName) !== tmnm) { - numberOfChanges++; - if (allTeamNames.includes(`team:${tmnm}`)) { - return setAlertMessage("This team name already exists"); - } - } - - console.log(label, lbl); - if (label !== lbl) { - const allLabels = Object.keys(accessControlInfo.rules_list); - if (allLabels.includes(lbl)) { - return setAlertMessage( - "This label is already restricted by another team" - ); - } - } - - if (editPost !== edtpst || useLabels !== uslbls) { - numberOfChanges++; - } - - if (!arrayEq(members, mmbrs)) { - numberOfChanges++; - let membersAndTeams = Object.keys(accessControlInfo.members_list); - - mmbrs.forEach((member) => { - if (!membersAndTeams.includes(member)) { - // Contract panic member does not exist in the members_list yet. - txn.push({ - contractName: "${REPL_EVENTS_CONTRACT}", - methodName: "add_member", - args: { - member: member, - metadata: { - member_metadata_version: "V0", - description: "", - permissions: {}, - children: [], - parents: [], - }, - }, - gas: Big(10).pow(14), - }); - } - }); - } - - if (numberOfChanges < 1) { - return setAlertMessage("No changes found."); - } - - Near.call([ - ...txn, - { - contractName: "${REPL_EVENTS_CONTRACT}", - methodName: "edit_member", - args: { - member: `team:${tmnm}`, - metadata: { - member_metadata_version: "V0", - description: "", - permissions: { - [lbl]: [ - ...(edtpst ? ["edit-post"] : []), - ...(uslbls ? ["use-labels"] : []), - ], - }, - children: mmbrs, - parents: [], - }, - }, - gas: Big(10).pow(14), - }, - ]); -} - -function deleteLabel() { - // contract side this is called a team / member - removeMember(teamName); -} - -const backwardsCompatibleLabel = (oldLabel) => { - if (typeof oldLabel === "string") - return oldLabel.startsWith("starts-with:") ? oldLabel.slice(12) : oldLabel; - else return ""; -}; -// Teams are saved in contract by their prefix 'team:' -// This function makes the teamName display friendly. -const backwardsCompatibleTeam = (oldTeam) => - oldTeam.startsWith("team:") ? oldTeam.slice(5) : oldTeam; - -return ( - <> -{child}
) - ) : ( -Loading modules...
; -} - -const selectedAuthors = props.author ? [{ name: props.author }] : []; - -const authors = getAllAuthors(); - -if (authors === null) { - returnLoading modules...
; -} - -const selectedTags = props.tag ? [{ name: props.tag }] : []; - -const tags = getAllLabels(); - -if (tags === null) { - returnLoading modules...
; -} - -const availableAddons = getAllAddons(); - -let addonMatch = null; // If availableAddons is not an array, set addonMatch to null -if ( - Array.isArray(availableAddons) && - availableAddons !== null && - availableAddons !== undefined -) { - addonMatch = availableAddons.find((it) => it.id === addon.addon_id); -} - -if (!addonMatch) { - return ( -Back
-Loading modules...
; -} - -const onCommunitySubmit = (inputs) => - createCommunity({ - inputs: { - ...inputs, - - bio_markdown: [ - "This is a sample text about your community.", - "You can change it on the community configuration page.", - ].join("\n"), - - logo_url: - "https://ipfs.near.social/ipfs/bafkreibysr2mkwhb4j36h2t7mqwhynqdy4vzjfygfkfg65kuspd2bawauu", - - banner_url: - "https://ipfs.near.social/ipfs/bafkreic4xgorjt6ha5z4s5e3hscjqrowe5ahd7hlfc5p4hb6kdfp6prgy4", - }, - }); - -const [showSpawner, setShowSpawner] = useState(false); - -const [searchKey, setSearchKey] = useState(""); -const [sort, setSort] = useState(""); - -const communitiesMetadata = getAllCommunitiesMetadata(); - -const SortedAndFiltered = (searchKey, sortBy) => { - let communities = (communitiesMetadata ?? []).reverse(); - - let filtered = [...communities]; - if (searchKey !== "") { - filtered = communities.filter((community) => - community.name.toLowerCase().includes(searchKey.toLowerCase()) - ); - } - - let sortedCommunities = [...filtered]; - if (sortBy !== "") { - sortedCommunities.sort((a, b) => { - let nameA = a.name.toLowerCase(); - let nameB = b.name.toLowerCase(); - - if (nameA < nameB) { - return -1; - } - if (nameA > nameB) { - return 1; - } - return 0; - }); - - if (sortBy === "z-a") { - sortedCommunities.reverse(); - } - } - - return sortedCommunities; -}; - -const CardGrid = styled.div` - width: 100%; - height: 100%; - - display: grid; - grid-template-columns: repeat(3, 1fr); - gap: 3rem; - - @media screen and (max-width: 992px) { - grid-template-columns: repeat(2, 1fr); - } - - @media screen and (max-width: 768px) { - display: flex; - flex-direction: column; - gap: 2rem; - } -`; - -const InputContainer = styled.div` - display: flex; - flex-direction: row; - position: relative; - width: 100%; -`; - -const StyledDropdown = styled.div` - button { - text-align: left; - - &::after { - position: absolute; - right: 8px; - top: 45%; - transform: translateX(-50%); - } - } -`; - -return ( -{action.description}
- - {action.ctaAction} - -Loading modules...
; -} - -const Gradient = styled.div` - height: 250px; - text-align: center; - background: radial-gradient( - circle, - rgba(29, 55, 57, 1) 30%, - rgba(24, 24, 24, 1) 80% - ); - - font-family: Arial, sans-serif; - - .text-primary-gradient { - color: #53fdca; - -webkit-text-fill-color: transparent; - background-image: linear-gradient(#8e76ba, #1ed2f0); - -webkit-background-clip: text; - background-clip: text; - } - - .subtitle-above { - font-size: 18px; - letter-spacing: 1px; - font-family: Courier, monospace; - } - - .subtitle-below { - font-size: 16px; - } - - .slogan { - font-weight: 600; - font-size: 60px; - } -`; - -const FeedPage = ({ recency, tag }) => { - return ( -