Skip to content

Commit

Permalink
Merge pull request #811 from near/develop
Browse files Browse the repository at this point in the history
weekly promotion of develop to main
  • Loading branch information
calebjacob authored May 14, 2024
2 parents 157a757 + 7e886fe commit 6f8cbfe
Show file tree
Hide file tree
Showing 6 changed files with 64 additions and 29 deletions.
3 changes: 2 additions & 1 deletion src/Blog/Feed.jsx
Original file line number Diff line number Diff line change
@@ -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 = `
Expand Down Expand Up @@ -379,7 +380,7 @@ const renderItem = (item, index) => {

return (
<BlogPage
destination={`/bosblog?accountId=${item.account_id}&blockHeight=${item.block_height}&returnLocation=${props.returnLocation}&profileAccountId=${props.profileAccountId}`}
destination={`/${blogComponentUrl}?accountId=${item.account_id}&blockHeight=${item.block_height}&returnLocation=${props.returnLocation}&profileAccountId=${props.profileAccountId}`}
/>
);
};
Expand Down
9 changes: 7 additions & 2 deletions src/BlogPostPage.jsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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 (
<>
Expand Down Expand Up @@ -487,7 +491,8 @@ if (blog) {
</BlogPostActionsWrapper>
</Container>
</BlogPostWrapper>
<Widget src="${REPL_ACCOUNT}/widget/NearOrg.Footer" />

{props.includeFooter && <Widget src="${REPL_ACCOUNT}/widget/NearOrg.Footer" />}
</>
);
}
Expand Down
12 changes: 7 additions & 5 deletions src/Entities/QueryApi/Ipfs.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 };
9 changes: 8 additions & 1 deletion src/Entities/Template/EntityDetails.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ if (error) {
if (!entity) {
return <p>Loading...</p>;
}
const { title } = schema;
const { entityTitle } = schema;

const editType = accountId === context.accountId ? "edit" : "fork";
const editLabel = editType === "edit" ? "Edit" : "Fork";
Expand Down Expand Up @@ -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 = [
Expand Down Expand Up @@ -231,8 +236,10 @@ return (
entity,
namespace,
entityType,
title: entityTitle,
showActions: true,
returnTo,
detailsUrl,
}}
/>
<ContentWrapper>
Expand Down
49 changes: 37 additions & 12 deletions src/Entities/Template/EntitySummary.jsx
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -171,14 +181,7 @@ return (
<Wrapper>
<Header size={size}>
<Thumbnail size={size}>
<Widget
src="${REPL_MOB}/widget/Image"
props={{
image: { url: logoUrl },
fallbackUrl: "https://ipfs.near.social/ipfs/bafkreibysr2mkwhb4j36h2t7mqwhynqdy4vzjfygfkfg65kuspd2bawauu",
alt: name,
}}
/>
<img src={imageUrl} alt={"Agent logo"} />
</Thumbnail>

<div>
Expand Down Expand Up @@ -226,14 +229,14 @@ return (
<Widget
src="${REPL_ACCOUNT}/widget/CopyUrlButton"
props={{
url: entityChatUrl,
url: entityActionUrl ?? detailsUrl,
}}
/>
<Widget
src="${REPL_ACCOUNT}/widget/ShareButton"
props={{
postType: "AI Entity",
url: entityChatUrl,
url: entityActionUrl ?? detailsUrl,
}}
/>
<Widget
Expand All @@ -258,6 +261,28 @@ return (
),
}}
/>{" "}
{entityActionUrlFunction && (
<Widget
src="${REPL_ACCOUNT}/widget/DIG.Tooltip"
props={{
content: "Use " + title,
trigger: (
<Link to={entityActionUrl} style={{ all: "unset" }}>
<Widget
src="${REPL_ACCOUNT}/widget/DIG.Button"
props={{
label: "Use " + title,
iconLeft: "ph-bold ph-chat-teardrop-text",
variant: "affirmative",
fill: "solid",
size: size,
}}
/>
</Link>
),
}}
/>
)}
</Actions>
)}
</Wrapper>
Expand Down
11 changes: 3 additions & 8 deletions src/Entities/Template/GenericEntityConfig.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -371,15 +366,15 @@ const defaultRenderTableItem = (rawItem, editFunction) => {
<Widget
src="${REPL_ACCOUNT}/widget/CopyUrlButton"
props={{
url: actionUrl,
url: detailsUrl,
}}
/>

<Widget
src="${REPL_ACCOUNT}/widget/ShareButton"
props={{
postType: "Placeholder",
url: actionUrl,
url: detailsUrl,
}}
/>
</Actions>
Expand Down

0 comments on commit 6f8cbfe

Please sign in to comment.