-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup new portal instance for templar
- Loading branch information
1 parent
5f930bc
commit 7573a28
Showing
48 changed files
with
10,825 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
build | ||
dist |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
{ | ||
"REPL_DEVHUB": "devhub.near", | ||
"REPL_TREASURY_TEMPLAR": "treasury-templar.near", | ||
"REPL_TREASURY_TEMPLAR_CONTRACT": "treasury-templar.near", | ||
"REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT": "treasury-templar.near", | ||
"REPL_NEAR": "near", | ||
"REPL_RPC_URL": "https://rpc.mainnet.near.org", | ||
"REPL_RFP_IMAGE": "https://ipfs.near.social/ipfs/bafkreicbygt4kajytlxij24jj6tkg2ppc2dw3dlqhkermkjjfgdfnlizzy", | ||
"REPL_RFP_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfps_with_latest_snapshot", | ||
"REPL_RFP_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_rfp_snapshots", | ||
"REPL_PROPOSAL_FEED_INDEXER_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposals_with_latest_snapshot", | ||
"REPL_PROPOSAL_QUERY_NAME": "polyprogrammist_near_devhub_ic_v1_proposal_snapshots", | ||
"REPL_INDEXER_HASURA_ROLE": "polyprogrammist_near" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
{ | ||
"account": "treasury-templar.near", | ||
"aliasPrefix": "REPL", | ||
"aliasesContainsPrefix": true, | ||
"aliases": ["./aliases.mainnet.json"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"treasury-templar.near": {} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
widget |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,164 @@ | ||
/** | ||
* This is the main entry point for the RFP application. | ||
* Page route gets passed in through params, along with all other page props. | ||
*/ | ||
|
||
const { page, ...passProps } = props; | ||
|
||
// Import our modules | ||
const { AppLayout } = VM.require( | ||
`${REPL_TREASURY_TEMPLAR}/widget/components.template.AppLayout` | ||
); | ||
|
||
const { Theme } = VM.require(`${REPL_TREASURY_TEMPLAR}/widget/config.theme`); | ||
|
||
const { CssContainer } = VM.require( | ||
`${REPL_TREASURY_TEMPLAR}/widget/config.css` | ||
); | ||
|
||
if (!AppLayout || !Theme || !CssContainer) { | ||
return <p>Loading modules...</p>; | ||
} | ||
|
||
if (!page) { | ||
// If no page is specified, we default to the feed page TEMP | ||
page = "about"; | ||
} | ||
|
||
const propsToSend = { ...passProps, instance: "${REPL_TREASURY_TEMPLAR}" }; | ||
|
||
// This is our navigation, rendering the page based on the page parameter | ||
function Page() { | ||
const routes = page.split("."); | ||
switch (routes[0]) { | ||
case "rfps": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.rfps.Feed`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "rfp": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.rfps.Rfp`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "create-rfp": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.rfps.Editor`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "create-proposal": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.proposals.Editor`} | ||
props={{ ...passProps }} | ||
/> | ||
); | ||
} | ||
|
||
case "proposals": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.proposals.Proposals`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "proposal": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.proposals.Proposal`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "about": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.pages.about`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
case "admin": { | ||
return ( | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.pages.admin`} | ||
props={passProps} | ||
/> | ||
); | ||
} | ||
// FOR TREASURY, SINCE WE USE SAME ACCOUNT TO DEPLOY BOTH | ||
case "dashboard": { | ||
return ( | ||
<Widget | ||
src="${REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.dashboard.index" | ||
props={propsToSend} | ||
/> | ||
); | ||
} | ||
case "settings": { | ||
return ( | ||
<Widget | ||
src={ | ||
"${REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.settings.index" | ||
} | ||
props={propsToSend} | ||
/> | ||
); | ||
} | ||
case "payments": { | ||
return ( | ||
<Widget | ||
src={ | ||
"${REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.payments.index" | ||
} | ||
props={propsToSend} | ||
/> | ||
); | ||
} | ||
|
||
case "stake-delegation": { | ||
return ( | ||
<Widget | ||
src={ | ||
"${REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.stake-delegation.index" | ||
} | ||
props={propsToSend} | ||
/> | ||
); | ||
} | ||
|
||
case "asset-exchange": { | ||
return ( | ||
<Widget | ||
src={ | ||
"${REPL_TREASURY_BASE_DEPLOYMENT_ACCOUNT}/widget/pages.asset-exchange.index" | ||
} | ||
props={propsToSend} | ||
/> | ||
); | ||
} | ||
default: { | ||
return <Widget src={"${REPL_DEVHUB}/widget/devhub.page.notfound"} />; | ||
} | ||
} | ||
} | ||
|
||
return ( | ||
<Theme> | ||
<CssContainer> | ||
<AppLayout page={page}> | ||
<Page /> | ||
</AppLayout> | ||
</CssContainer> | ||
</Theme> | ||
); |
185 changes: 185 additions & 0 deletions
185
instances/treasury-templar.near/widget/components/admin/AboutConfigurator.jsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,185 @@ | ||
const { Tile } = VM.require( | ||
`${REPL_DEVHUB}/widget/devhub.components.molecule.Tile` | ||
) || { Tile: () => <></> }; | ||
|
||
const item = { | ||
path: `${REPL_TREASURY_TEMPLAR_CONTRACT}/profile/**`, | ||
}; | ||
|
||
const profile = Social.get(item.path); | ||
|
||
if (!profile.description) { | ||
<div | ||
style={{ height: "50vh" }} | ||
className="d-flex justify-content-center align-items-center w-100" | ||
> | ||
<Widget src={`${REPL_DEVHUB}/widget/devhub.components.molecule.Spinner`} /> | ||
</div>; | ||
} | ||
|
||
const initialData = profile.description; | ||
const [content, setContent] = useState(null); | ||
const [showCommentToast, setCommentToast] = useState(false); | ||
const [handler, setHandler] = useState(null); | ||
const [isTxnCreated, setTxnCreated] = useState(false); | ||
|
||
const Container = styled.div` | ||
width: 100%; | ||
margin: 0 auto; | ||
padding: 20px; | ||
text-align: left; | ||
`; | ||
|
||
const hasDataChanged = () => { | ||
return content !== initialData; | ||
}; | ||
|
||
const handlePublish = () => { | ||
setTxnCreated(true); | ||
Near.call([ | ||
{ | ||
contractName: "${REPL_TREASURY_TEMPLAR_CONTRACT}", | ||
methodName: "set_social_db_profile_description", | ||
args: { description: content }, | ||
gas: 270000000000000, | ||
}, | ||
]); | ||
}; | ||
|
||
useEffect(() => { | ||
if (isTxnCreated) { | ||
const checkForAboutInSocialDB = () => { | ||
Near.asyncView(REPL_SOCIAL_CONTRACT, "get", { | ||
keys: [item.path], | ||
}).then((result) => { | ||
try { | ||
const submittedAboutText = content; | ||
const lastAboutTextFromSocialDB = | ||
result["${REPL_TREASURY_TEMPLAR_CONTRACT}"].profile.description; | ||
if (submittedAboutText === lastAboutTextFromSocialDB) { | ||
setTxnCreated(false); | ||
setCommentToast(true); | ||
return; | ||
} | ||
} catch (e) {} | ||
setTimeout(() => checkForAboutInSocialDB(), 2000); | ||
}); | ||
}; | ||
checkForAboutInSocialDB(); | ||
} | ||
}, [isTxnCreated]); | ||
|
||
useEffect(() => { | ||
if (!content && initialData) { | ||
setContent(initialData); | ||
setHandler("update"); | ||
} | ||
}, [initialData]); | ||
|
||
function Preview() { | ||
return ( | ||
<Tile className="p-3" style={{ background: "white", minHeight: "500px" }}> | ||
<Widget | ||
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.SimpleMDEViewer`} | ||
props={{ | ||
content: content, | ||
height: "500px", | ||
}} | ||
/> | ||
</Tile> | ||
); | ||
} | ||
|
||
return ( | ||
<Container> | ||
<Widget | ||
src={`${REPL_NEAR}/widget/DIG.Toast`} | ||
props={{ | ||
title: "About page updated successfully", | ||
type: "success", | ||
open: showCommentToast, | ||
onOpenChange: (v) => setCommentToast(v), | ||
trigger: <></>, | ||
providerProps: { duration: 3000 }, | ||
}} | ||
/> | ||
<ul className="nav nav-tabs" id="editPreviewTabs" role="tablist"> | ||
<li className="nav-item" role="presentation"> | ||
<button | ||
className="nav-link active" | ||
id="edit-tab" | ||
data-bs-toggle="tab" | ||
data-bs-target="#edit" | ||
type="button" | ||
role="tab" | ||
aria-controls="edit" | ||
aria-selected="true" | ||
> | ||
Edit | ||
</button> | ||
</li> | ||
<li className="nav-item" role="presentation"> | ||
<button | ||
className="nav-link" | ||
id="preview-tab" | ||
data-bs-toggle="tab" | ||
data-bs-target="#preview" | ||
type="button" | ||
role="tab" | ||
aria-controls="preview" | ||
aria-selected="false" | ||
> | ||
Preview | ||
</button> | ||
</li> | ||
</ul> | ||
<div className="tab-content" id="editPreviewTabsContent"> | ||
<div | ||
className="tab-pane show active py-4" | ||
id="edit" | ||
role="tabpanel" | ||
aria-labelledby="edit-tab" | ||
> | ||
<Widget | ||
src={`${REPL_TREASURY_TEMPLAR}/widget/components.molecule.SimpleMDE`} | ||
props={{ | ||
data: { handler: handler, content: content }, | ||
onChangeKeyup: (v) => { | ||
setContent(v); | ||
}, | ||
showAutoComplete: true, | ||
}} | ||
/> | ||
|
||
<div | ||
className={"d-flex align-items-center justify-content-end gap-3 mt-4"} | ||
> | ||
<Widget | ||
src={`${REPL_DEVHUB}/widget/devhub.components.molecule.Button`} | ||
props={{ | ||
classNames: { root: "btn-success" }, | ||
disabled: !hasDataChanged(), | ||
icon: { | ||
type: "bootstrap_icon", | ||
variant: "bi-check-circle-fill", | ||
}, | ||
label: "Publish", | ||
onClick: handlePublish, | ||
}} | ||
/> | ||
</div> | ||
</div> | ||
<div | ||
className="tab-pane" | ||
id="preview" | ||
role="tabpanel" | ||
aria-labelledby="preview-tab" | ||
style={{ position: "relative" }} | ||
> | ||
<div className="w-100 h-100 py-4"> | ||
<Preview /> | ||
</div> | ||
</div> | ||
</div> | ||
</Container> | ||
); |
Oops, something went wrong.