diff --git a/src/Blog/Feed.jsx b/src/Blog/Feed.jsx index 4c2039d5..9be8ed10 100644 --- a/src/Blog/Feed.jsx +++ b/src/Blog/Feed.jsx @@ -1,6 +1,7 @@ const GRAPHQL_ENDPOINT = props.GRAPHQL_ENDPOINT || "https://near-queryapi.api.pagoda.co"; const contributors = props.contributors || []; +const blogComponentUrl = props.blogComponentUrl || "bosblog"; const { requestAuthentication, returnLocation, profileAccountId } = props; const [posts, setPosts] = useState([]); const promotedPostsQuery = ` @@ -379,7 +380,7 @@ const renderItem = (item, index) => { return ( ); }; diff --git a/src/BlogPostPage.jsx b/src/BlogPostPage.jsx index 632a5965..463d970f 100644 --- a/src/BlogPostPage.jsx +++ b/src/BlogPostPage.jsx @@ -1,4 +1,5 @@ const GRAPHQL_ENDPOINT = props.GRAPHQL_ENDPOINT || "https://near-queryapi.api.pagoda.co"; +const blogComponentUrl = props.blogComponentUrl || "bosblog"; const BlogPostWrapper = styled.div` @media (max-width: 1024px) { padding-left: 0; @@ -368,7 +369,10 @@ if (blog) { } }; - const destination = props.returnLocation + (props.tab === "blog" ? `&tab=blog` : "") || `/bosblog`; + const destination = + props.returnLocation && props.tab + ? props.returnLocation + (props.tab === "blog" ? `&tab=blog` : "") + : `/${blogComponentUrl}`; return ( <> @@ -487,7 +491,8 @@ if (blog) { - + + {props.includeFooter && } ); } diff --git a/src/Entities/QueryApi/Ipfs.jsx b/src/Entities/QueryApi/Ipfs.jsx index fca4fb56..c996462d 100644 --- a/src/Entities/QueryApi/Ipfs.jsx +++ b/src/Entities/QueryApi/Ipfs.jsx @@ -8,13 +8,15 @@ const ipfsUpload = (f) => }).then((res) => res.body.cid); const ipfsUrl = (cid) => { - let c = typeof cid === "object" ? cid.cid : cid; - if (c.startsWith("{")) { - try { + try { + let c = typeof cid === "object" ? cid.cid : cid; + if (c.startsWith("{")) { c = JSON.parse(c).cid; - } catch (ignored) {} + } + return `https://ipfs.near.social/ipfs/${c}`; + } catch (ignored) { + return ""; } - return `https://ipfs.near.social/ipfs/${c}`; }; return { ipfsUpload, ipfsUrl }; diff --git a/src/Entities/Template/EntityDetails.jsx b/src/Entities/Template/EntityDetails.jsx index 8dd55059..62611069 100644 --- a/src/Entities/Template/EntityDetails.jsx +++ b/src/Entities/Template/EntityDetails.jsx @@ -71,7 +71,7 @@ if (error) { if (!entity) { return

Loading...

; } -const { title } = schema; +const { entityTitle } = schema; const editType = accountId === context.accountId ? "edit" : "fork"; const editLabel = editType === "edit" ? "Edit" : "Fork"; @@ -186,6 +186,11 @@ const entityProperties = (obj) => { const listLink = href({ widgetSrc: returnTo, }); +const detailsLink = href({ + widgetSrc: `${REPL_ACCOUNT}/widget/Entities.Template.EntityDetails`, + params: { src, schemaFile, namespace, entityType, returnTo: homeLink }, +}); +const detailsUrl = "https://${REPL_NEAR_URL}/" + detailsLink; const tabs = () => { const defaultTabs = [ @@ -231,8 +236,10 @@ return ( entity, namespace, entityType, + title: entityTitle, showActions: true, returnTo, + detailsUrl, }} /> diff --git a/src/Entities/Template/EntitySummary.jsx b/src/Entities/Template/EntitySummary.jsx index 15d074ba..128f9220 100644 --- a/src/Entities/Template/EntitySummary.jsx +++ b/src/Entities/Template/EntitySummary.jsx @@ -1,12 +1,22 @@ if (!props.entity) return ""; const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url"); -if (!href) { +const { ipfsUrl } = VM.require("${REPL_ACCOUNT}/widget/Entities.QueryApi.Ipfs"); + +if (!href || !ipfsUrl) { return <>; } -const { entity, showActions, returnTo } = props; +const { entity, showActions, returnTo, entityActionUrlFunction, title, detailsUrl } = props; const { namespace, entityType, accountId, name, displayName, logoUrl, tags } = entity; +const imageUrl = logoUrl + ? typeof logoUrl == "string" && logoUrl.startsWith("http") + ? logoUrl + : ipfsUrl(logoUrl) + : "https://ipfs.near.social/ipfs/bafkreibysr2mkwhb4j36h2t7mqwhynqdy4vzjfygfkfg65kuspd2bawauu"; + +const entityActionUrl = entityActionUrlFunction ? entityActionUrlFunction(entity) : null; + const [entityDeleted, setEntityDeleted] = useState(false); const deleteEntity = async (entity) => { const { name } = entity; @@ -171,14 +181,7 @@ return (
- + {"Agent
@@ -226,14 +229,14 @@ return ( {" "} + {entityActionUrlFunction && ( + + + + ), + }} + /> + )} )} diff --git a/src/Entities/Template/GenericEntityConfig.jsx b/src/Entities/Template/GenericEntityConfig.jsx index ab8ebf02..739632cd 100644 --- a/src/Entities/Template/GenericEntityConfig.jsx +++ b/src/Entities/Template/GenericEntityConfig.jsx @@ -225,22 +225,17 @@ const Button = styled.button` const defaultRenderTableItem = (rawItem, editFunction) => { const item = convertObjectKeysSnakeToPascal(rawItem); const { accountId, name, displayName, logoUrl, tags, attributes } = item; - const itemComponent = item.component ? item.component : `${REPL_ACCOUNT}/widget/Entities.Template.EntityDetails`; const imageUrl = logoUrl ? typeof logoUrl == "string" && logoUrl.startsWith("http") ? logoUrl : ipfsUrl(logoUrl) : "https://ipfs.near.social/ipfs/bafkreibysr2mkwhb4j36h2t7mqwhynqdy4vzjfygfkfg65kuspd2bawauu"; - const actionLink = href({ - widgetSrc: itemComponent, - params: { src: `${accountId}/${entityType}/${name}`, schemaFile, namespace }, - }); const detailsLink = href({ widgetSrc: `${REPL_ACCOUNT}/widget/Entities.Template.EntityDetails`, params: { src: `${accountId}/${entityType}/${name}`, schemaFile, namespace, entityType, returnTo: homeLink }, }); + const detailsUrl = "https://${REPL_NEAR_URL}/" + detailsLink; - const actionUrl = `https://${REPL_NEAR_URL}/${itemComponent}?src=${accountId}/${entityType}/${item.name}`; const editType = accountId === context.accountId ? "edit" : "fork"; const editLabel = editType === "edit" ? "Edit" : "Fork"; const editIcon = editType === "edit" ? "ph-bold ph-pencil-simple" : "ph-bold ph-git-fork"; @@ -371,7 +366,7 @@ const defaultRenderTableItem = (rawItem, editFunction) => { @@ -379,7 +374,7 @@ const defaultRenderTableItem = (rawItem, editFunction) => { src="${REPL_ACCOUNT}/widget/ShareButton" props={{ postType: "Placeholder", - url: actionUrl, + url: detailsUrl, }} />