Skip to content

Commit

Permalink
Merge branch 'main' of github.com:NEAR-DevHub/neardevhub-bos into fea…
Browse files Browse the repository at this point in the history
…ture/events-bos-ws
  • Loading branch information
Tguntenaar committed Jul 10, 2024
2 parents a620594 + bd8dbd0 commit 9695d84
Show file tree
Hide file tree
Showing 62 changed files with 11,876 additions and 37 deletions.
40 changes: 40 additions & 0 deletions .github/workflows/continuous-integration-workflow-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
name: CI - Infrastructure Committee
on:
pull_request:
push:
branches:
- main

jobs:
prettier:
name: Prettier
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- name: Install dependencies
run: npm ci
- name: Run code formatting check
run: npm run fmt:check

playwright-tests-infra:
name: Infrastructure Committee - Playwright tests
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 20
cache: "npm"
- name: Install dependencies
run: |
npm ci
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/mpeterdev/bos-loader/releases/download/v0.7.1/bos-loader-v0.7.1-installer.sh | sh
npx playwright install-deps
npx playwright install
- name: Run tests
run: |
INSTANCE=infrastructure npx playwright test --project=infrastructure playwright-tests/tests/infrastructure
49 changes: 49 additions & 0 deletions .github/workflows/deploy-prod-mainnet-infra.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Deploy Widgets to Mainnet - Infrastructure
on:
pull_request:
push:
branches: [main]
jobs:
deploy-widgets:
runs-on: ubuntu-latest
name: Deploy ( or diff from PR )
env:
NEAR_SOCIAL_DEPLOY_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }}
NEAR_SOCIAL_ACCOUNT_ID: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_ID }}
NEAR_SOCIAL_ACCOUNT_PUBLIC_KEY: ${{ vars.NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY }}
NEAR_SOCIAL_ACCOUNT_PRIVATE_KEY: ${{ secrets.NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY }}
POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }}
defaults:
run:
working-directory: ./instances/infrastructure-committee.near
steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Set replacements
id: set_replacements
run: |
echo "replacements=$(jq -r '[to_entries[] | .["find"] = "${" + .key + "}" | .["replace"] = .value | del(.key, .value), {"find": "${REPL_POSTHOG_API_KEY}", "replace": "'$POSTHOG_API_KEY'"}]' aliases.mainnet.json | tr -d "\n\r")" >> $GITHUB_OUTPUT
- name: Replace placeholders
uses: flcdrg/replace-multiple-action@v1
with:
files: "**/*.jsx"
find: "${{ steps.set_replacements.outputs.replacements }}"
prefix: "(^|.*)"
suffix: "($|.*)"

- name: Install bos CLI
run: |
curl --proto '=https' --tlsv1.2 -LsSf https://github.com/FroVolod/bos-cli-rs/releases/download/v0.3.6/bos-cli-installer.sh | sh
- name: Deploy widgets
run: |
BRANCH="$(git rev-parse --abbrev-ref HEAD)"
echo "on branch $BRANCH"
if [[ "$BRANCH" != "main" ]]; then
echo "Not on main branch, dry run by diff with infrastructure-committee.near"
bos components diff infrastructure-committee.near network-config mainnet
else
bos components deploy "$NEAR_INFRA_SOCIAL_DEPLOY_ID" sign-as "$NEAR_INFRA_SOCIAL_ACCOUNT_ID" network-config mainnet sign-with-plaintext-private-key --signer-public-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PUBLIC_KEY" --signer-private-key "$NEAR_INFRA_SOCIAL_ACCOUNT_PRIVATE_KEY" send
fi
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ const { data, onEdit, community: handle, isAllowedToEdit } = props;
const {
category,
title,
description,
subtitle,
publishedAt: date,
content,
Expand Down Expand Up @@ -193,7 +192,6 @@ return (
)}
<div data-testid="blog-date">{formattedDate}</div>
</div>
<p>{description}</p>
<Widget
src={"${REPL_DEVHUB}/widget/devhub.components.molecule.MarkdownViewer"}
props={{ text: content }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,10 @@ const Log = ({ timestamp }) => {
: "inline-flex")
}
>
<span className="inline-flex fw-bold text-black">
<span
className="inline-flex fw-bold text-black"
style={{ marginRight: 0 }}
>
<AccountProfile accountId={editorId} showAccountId={true} />
</span>
{parseProposalKeyAndValue(i.key, i.modifiedValue, i.originalValue)}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@ const size = props.size ?? "md";
const showAccountId = props.showAccountId;
const Avatar = styled.div`
&.sm {
min-width: 30px;
max-width: 30px;
min-height: 30px;
max-height: 30px;
min-width: 26px;
max-width: 26px;
min-height: 26px;
max-height: 26px;
}
&.md {
min-width: 40px;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -391,6 +391,7 @@ const proposalStatusOptions = [
value: {
status: TIMELINE_STATUS.PAYMENT_PROCESSING,
kyc_verified_review: true,
kyc_verified: true,
test_transaction_sent: false,
request_for_trustees_created: false,
sponsor_requested_review: true,
Expand All @@ -403,6 +404,7 @@ const proposalStatusOptions = [
status: TIMELINE_STATUS.FUNDED,
trustees_released_payment: true,
kyc_verified_review: true,
kyc_verified: true,
test_transaction_sent: true,
request_for_trustees_created: true,
sponsor_requested_review: true,
Expand Down
11 changes: 10 additions & 1 deletion instances/devhub.near/widget/devhub/page/blogv2.jsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
const { id, community } = props;

const { getAccountCommunityPermissions } = VM.require(
const { getAccountCommunityPermissions, getCommunity } = VM.require(
"${REPL_DEVHUB}/widget/core.adapter.devhub-contract"
) || {
getAccountCommunityPermissions: () => {},
getCommunity: () => {},
};

const [showEditScreenData, setShowEditScreen] = useState(null);
Expand Down Expand Up @@ -127,6 +128,13 @@ if (showEditScreenData) {
</EditorContainer>
);
}

const communityObject = getCommunity({ handle: "developer-dao" });
const blogv2 = (communityObject.addons || []).find(
(addon) => addon.id === "blogv2"
);
const config = JSON.parse(blogv2.parameters || {}) || {};

return (
<div className="w-100">
<Widget src={`${REPL_DEVHUB}/widget/devhub.components.island.banner`} />
Expand All @@ -140,6 +148,7 @@ return (
handle: "developer-dao",
hideTitle: true,
communityAddonId: "blogv2",
data: config,
}}
/>
</BlogContainer>
Expand Down
25 changes: 0 additions & 25 deletions instances/devhub.near/widget/devhub/page/community/index.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,31 +56,6 @@ const [isLinkCopied, setLinkCopied] = useState(false);

const [addonView, setAddonView] = useState("viewer");

// CommunityAddOn
const blogv2 = {
addon_id: "blogv2",
display_name: "BlogV2",
enabled: true,
id: "blogv2",
parameters:
'{"title":"My blog page title",\
"subtitle":"Classic subtitle",\
"auhtorEnabled": "enabled",\
"searchEnabled": "enabled",\
"orderBy": "timedesc",\
"categoriesEnabled": "enabled",\
"categories": ["news", "guide", "reference"],\
"categoryRequired": false}',
};

const blogv2instance2 = {
addon_id: "blogv2",
display_name: "BlogV2",
enabled: true,
id: "blogv2instance2",
parameters: "{}",
};

const tabs = [];

(community.addons || []).map((addon) => {
Expand Down
2 changes: 1 addition & 1 deletion instances/events-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@
"REPL_DEVS": "devs.near",
"REPL_SOCIAL_CONTRACT": "social.near",
"REPL_RPC_URL": "https://rpc.mainnet.near.org"
}
}
2 changes: 2 additions & 0 deletions instances/infrastructure-committee.near/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
build
dist
12 changes: 12 additions & 0 deletions instances/infrastructure-committee.near/aliases.mainnet.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"REPL_DEVHUB": "devhub.near",
"REPL_INFRASTRUCTURE_COMMITTEE": "infrastructure-committee.near",
"REPL_INFRASTRUCTURE_COMMITTEE_CONTRACT": "infrastructure-committee.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"
}
6 changes: 6 additions & 0 deletions instances/infrastructure-committee.near/bos.config.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"account": "infrastructure-committee.near",
"aliasPrefix": "REPL",
"aliasesContainsPrefix": true,
"aliases": ["./aliases.mainnet.json"]
}
3 changes: 3 additions & 0 deletions instances/infrastructure-committee.near/data.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"infrastructure-committee.near": {}
}
1 change: 1 addition & 0 deletions instances/infrastructure-committee.near/src
129 changes: 129 additions & 0 deletions instances/infrastructure-committee.near/widget/app.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,129 @@
/**
* 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_INFRASTRUCTURE_COMMITTEE}/widget/components.template.AppLayout`
);

if (!AppLayout) {
return <p>Loading modules...</p>;
}

// CSS styles to be used across the app.
// Define fonts here, as well as any other global styles.
const Theme = styled.div`
a {
color: inherit;
}
.attractable {
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;
}
}
`;

if (!page) {
// If no page is specified, we default to the feed page TEMP
page = "about";
}

// This is our navigation, rendering the page based on the page parameter
function Page() {
const routes = page.split(".");
switch (routes[0]) {
case "about": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.about`}
props={passProps}
/>
);
}
case "rfps": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Feed`}
props={passProps}
/>
);
}
case "rfp": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Rfp`}
props={passProps}
/>
);
}
case "create-rfp": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.rfps.Editor`}
props={passProps}
/>
);
}
case "create-proposal": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Editor`}
props={{ ...passProps }}
/>
);
}

case "proposals": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Feed`}
props={passProps}
/>
);
}
case "proposal": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.proposals.Proposal`}
props={passProps}
/>
);
}
case "about": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.about`}
props={passProps}
/>
);
}
case "admin": {
return (
<Widget
src={`${REPL_INFRASTRUCTURE_COMMITTEE}/widget/components.pages.admin`}
props={passProps}
/>
);
}
default: {
// TODO: 404 page
return <p>404</p>;
}
}
}

return (
<Theme>
<AppLayout page={page}>
<Page />
</AppLayout>
</Theme>
);
Loading

0 comments on commit 9695d84

Please sign in to comment.