Skip to content

Commit

Permalink
Features/GitHub sync (#123)
Browse files Browse the repository at this point in the history
* chore: Lint docs

* Update package-lock

* Update scripts

* chore: Update spell checking dictionary

* wip: Create community GitHub activity tab

* wip: Update GH integration draft

* wip: Update GitHub activity page

* wip: Create GitHub board component

* wip: Update components

* wip: Update GitHub activity page & Format `common`

* wip: Update GitHub activity page

* chore: Inspect the whole `response`

* wip: Update Git Board components

* wip: Create GitHub ticket card component
& Combine GitHub integration components into single entity

* wip: Update GitHub integration components

* wip: Rename bos-loader script

* chore: Update package-lock

* wip: Update GitHub integration components & Fix errors

* wip: Fix errors in GH repo ticket card

* wip: Enable active page indicator for GH activity page

* wip: Update GH integration UI
& Create common components

* wip: Update GH integration UI
& Make board config fetch function shared

* chore: Use JSON strings for log

* fix: Handle nullable props in a simpler way

* fix: Resolve #123 (comment)

* wip: Add global editor toggle & Update styles

* wip: Update GH integration components

* fix: Use correct reference path

* fix: Update state correctly

* wip: Add WIP label to the global editor toggle

* fix: Broken column title update

* wip: Use only 1 column in GH board config mock

* chore: Remove TODO

* wip: Update page name & Remove redundant code

* chore: Ger rid of clunky names

* wip: Create generic form handler & shared toggle GUI

* wip: Update mocks & GUI
& Fix errors

* fix: Add gap between columns

* fix: Broken horizontal scroll

* chore: Change new column default title

* fix: Don't use empty search terms

* wip: Improve responsiveness

* wip: Improve responsiveness

* chore: Format

* wip: Split shared code & Update form lib

* chore: Remove irrelevant changes

* wip: Use indexed columns & update GUI

* wip: Update board config GUI

* wip: Support most use cases with useForm

* wip: Reduce functionalities for MVP

* wip: Lock pull requests enabled

* wip: Hide the global editor toggle

* wip: Extract the feature into separate module
& Update GUI
& Update communities mock
& Move communities mock to the appropriate module

* wip: Pre-MVP

* fix: Include column id into column data

* wip: Replace OR labels search rule with AND

* fix: Use full page URL

* feat: Make columns deletable

* Reset irrelevant changes

* Reset irrelevant changes

* Get ready to MVP release

* chore: Use shorter task name

* Apply code review remarks

* chore: Clarify naming
  • Loading branch information
carina-akaia authored Jun 2, 2023
1 parent d21ba90 commit 0c2aebc
Show file tree
Hide file tree
Showing 44 changed files with 2,013 additions and 141 deletions.
30 changes: 23 additions & 7 deletions build.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,30 @@ const options = {

replaceInFiles(options)
.pipe({
from: /\/\* INCLUDE: "communities\.jsx" \*\/.*\/\* END_INCLUDE: "communities\.jsx" \*\//gms,
to: `/* INCLUDE: "communities.jsx" */\n${fs
.readFileSync("./communities.jsx", "utf8")
.toString()}/* END_INCLUDE: "communities.jsx" */`,
from: /\/\* INCLUDE: "shared\/lib\/form" \*\/.*\/\* END_INCLUDE: "shared\/lib\/form" \*\//gms,
to: `/* INCLUDE: "shared/lib/form" */\n${fs
.readFileSync("./shared/lib/form.js", "utf8")
.toString()}/* END_INCLUDE: "shared/lib/form" */`,
})
.pipe({
from: /\/\* INCLUDE: "shared\/lib\/gui" \*\/.*\/\* END_INCLUDE: "shared\/lib\/gui" \*\//gms,
to: `/* INCLUDE: "shared/lib/gui" */\n${fs
.readFileSync("./shared/lib/gui.js", "utf8")
.toString()}/* END_INCLUDE: "shared/lib/gui" */`,
})
.pipe({
from: /\/\* INCLUDE: "shared\/lib\/uuid" \*\/.*\/\* END_INCLUDE: "shared\/lib\/uuid" \*\//gms,
to: `/* INCLUDE: "shared/lib/uuid" */\n${fs
.readFileSync("./shared/lib/uuid.js", "utf8")
.toString()}/* END_INCLUDE: "shared/lib/uuid" */`,
})
.pipe({
from: /\/\* INCLUDE: "shared\/mocks" \*\/.*\/\* END_INCLUDE: "shared\/mocks" \*\//gms,
to: `/* INCLUDE: "shared/mocks" */\n${fs
.readFileSync("./shared/mocks.js", "utf8")
.toString()}/* END_INCLUDE: "shared/mocks" */`,
})
.then(({ changedFiles, countOfMatchesByPaths }) => {
console.log("DONE");
})
.catch((error) => {
console.error("Error occurred:", error);
});
.catch(console.error);
8 changes: 8 additions & 0 deletions common.jsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];

const nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];
Expand All @@ -12,6 +13,7 @@ function widget(widgetName, widgetProps, key) {
nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId,
referral: props.referral,
};

return (
<Widget
src={`${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.${widgetName}`}
Expand All @@ -23,20 +25,26 @@ function widget(widgetName, widgetProps, key) {

function href(widgetName, linkProps) {
linkProps = { ...linkProps };

if (props.nearDevGovGigsContractAccountId) {
linkProps.nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId;
}

if (props.nearDevGovGigsWidgetsAccountId) {
linkProps.nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId;
}

if (props.referral) {
linkProps.referral = props.referral;
}

const linkPropsQuery = Object.entries(linkProps)
.filter(([_key, nullable]) => (nullable ?? null) !== null)
.map(([key, value]) => `${key}=${value}`)
.join("&");

return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${
linkPropsQuery ? "?" : ""
}${linkPropsQuery}`;
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
"scripts": {
"fmt": "prettier --write '**/*.{js,jsx,ts,tsx,json}'",
"fmt:check": "prettier --check '**/*.{js,jsx,ts,tsx,json}'",
"build": "node build.js"
"build": "npm run fmt && node build.js",
"dev": "~/.cargo/bin/bos-loader devgovgigs.near --path src"
},
"repository": {
"type": "git",
Expand Down
90 changes: 90 additions & 0 deletions shared/lib/form.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,90 @@
/**
*! TODO: Extract into separate library module
*! once `useForm` is converted into a form factory widget
*/
const traversalUpdate = ({
input,
target: treeOrBranch,
path: [currentBranchKey, ...remainingBranch],
params,
via: nodeUpdate,
}) => ({
...treeOrBranch,

[currentBranchKey]:
remainingBranch.length > 0
? traversalUpdate({
input,

target:
typeof treeOrBranch[currentBranchKey] === "object"
? treeOrBranch[currentBranchKey]
: {
...((treeOrBranch[currentBranchKey] ?? null) !== null
? { __archivedLeaf__: treeOrBranch[currentBranchKey] }
: {}),
},

path: remainingBranch,
via: nodeUpdate,
})
: nodeUpdate({
input,
lastKnownState: treeOrBranch[currentBranchKey],
params,
}),
});

const fieldDefaultUpdate = ({
input,
lastKnownState,
params: { arrayDelimiter },
}) => {
switch (typeof input) {
case "boolean":
return input;

case "object":
return Array.isArray(input) && typeof lastKnownState === "string"
? input.join(arrayDelimiter ?? ",")
: input;

case "string":
return Array.isArray(lastKnownState)
? input.split(arrayDelimiter ?? ",").map((string) => string.trim())
: input;

default: {
if ((input ?? null) === null) {
switch (typeof lastKnownState) {
case "boolean":
return !lastKnownState;

default:
return lastKnownState;
}
} else return input;
}
}
};

const useForm = ({ stateKey: formStateKey }) => ({
formState: state[formStateKey],

formUpdate:
({ path: fieldPath, via: fieldCustomUpdate, ...params }) =>
(fieldInput) =>
State.update((lastKnownState) =>
traversalUpdate({
input: fieldInput?.target?.value ?? fieldInput,
target: lastKnownState,
path: [formStateKey, ...fieldPath],
params,

via:
typeof fieldCustomUpdate === "function"
? fieldCustomUpdate
: fieldDefaultUpdate,
})
),
});
10 changes: 10 additions & 0 deletions shared/lib/gui.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const Card = styled.div`
&:hover {
box-shadow: rgba(3, 102, 214, 0.3) 0px 0px 0px 3px;
}
`;

const CompactContainer = styled.div`
width: fit-content !important;
max-width: 100%;
`;
15 changes: 15 additions & 0 deletions shared/lib/uuid.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
const uuid = () =>
[Date.now().toString(16)]
.concat(
Array.from(
{ length: 4 },
() => Math.floor(Math.random() * 0xffffffff) & 0xffffffff
).map((value) => value.toString(16))
)
.join("-");

const uuidIndexed = (data) => {
const id = uuid();

return Object.fromEntries([[id, { ...data, id }]]);
};
42 changes: 42 additions & 0 deletions communities.jsx → shared/mocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,39 +2,81 @@ const communities = {
"zero-knowledge": {
overviewId: 397,
eventsId: 401,

icon: "https://ipfs.near.social/ipfs/bafkreiajwq6ep3n7veddozji2djv5vviyisabhycbweslvpwhsoyuzcwi4",

cover:
"https://ipfs.near.social/ipfs/bafkreihgxg5kwts2juldaeasveyuddkm6tcabmrat2aaq5u6uyljtyt7lu",

title: "Zero Knowledge",
desc: "Building a zero knowledge ecosystem on NEAR.",
telegram: "NearZeroKnowledge",
},

protocol: {
overviewId: 412,
eventsId: 413,

icon: "https://ipfs.near.social/ipfs/bafkreidpitdafcnhkp4uyomacypdgqvxr35jtfnbxa5s6crby7qjk2nv5a",

cover:
"https://ipfs.near.social/ipfs/bafkreicg4svzfz5nvllomsahndgm7u62za4sib4mmbygxzhpcl4htqwr4a",

title: "Protocol",
desc: "Supporting the ongoing innovation of the NEAR Protocol.",

integrations: {
github: {
kanban: {
boards: {
"18855b9c9f2-216091d-6484800b-42593f54-6102b48a": {
id: "18855b9c9f2-216091d-6484800b-42593f54-6102b48a",

columns: {
"18855f4a93e-76a9b704-14c3ebdb-1e6c0f05-22653630": {
id: "18855f4a93e-76a9b704-14c3ebdb-1e6c0f05-22653630",
description: "Lorem ipsum",
labelSearchTerms: ["S-draft"],
title: "Draft",
},
},

dataTypesIncluded: { Issue: false, PullRequest: true },
description: "Latest NEAR Enhancement Proposals by status",
repoURL: "https://github.com/near/NEPs",
title: "NEAR Protocol NEPs",
},
},
},
},
},

telegram: "NEAR_Protocol_Community_Group",
},

tooling: {
overviewId: 416,
eventsId: 417,

icon: "https://ipfs.near.social/ipfs/bafkreie2eaj5czmpfe6pe53kojzcspgozebdsonffwvbxtpuipnwahybvi",

cover:
"https://ipfs.near.social/ipfs/bafkreiehzr7z2fhoqqmkt3z667wubccbch6sqtsnvd6msodyzpnf72cszy",

title: "Tooling",
desc: "Supporting the ongoing innovation of tooling.",
telegram: "NEAR_Tools_Community_Group",
},

"contract-standards": {
overviewId: 414,
eventsId: 415,

icon: "https://ipfs.near.social/ipfs/bafkreiepgdnu7soc6xgbyd4adicbf3eyxiiwqawn6tguaix6aklfpir634",

cover:
"https://ipfs.near.social/ipfs/bafkreiaowjqxds24fwcliyriintjd4ucciprii2rdxjmxgi7f5dmzuscey",

title: "Contract Standards",
desc: "Coordinating the contribution to the NEAR dapp standards.",
telegram: "nearnft",
Expand Down
8 changes: 8 additions & 0 deletions src/DevGov/Notification/Item/Left.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];

const nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];
Expand All @@ -13,6 +14,7 @@ function widget(widgetName, widgetProps, key) {
nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId,
referral: props.referral,
};

return (
<Widget
src={`${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.${widgetName}`}
Expand All @@ -24,20 +26,26 @@ function widget(widgetName, widgetProps, key) {

function href(widgetName, linkProps) {
linkProps = { ...linkProps };

if (props.nearDevGovGigsContractAccountId) {
linkProps.nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId;
}

if (props.nearDevGovGigsWidgetsAccountId) {
linkProps.nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId;
}

if (props.referral) {
linkProps.referral = props.referral;
}

const linkPropsQuery = Object.entries(linkProps)
.filter(([_key, nullable]) => (nullable ?? null) !== null)
.map(([key, value]) => `${key}=${value}`)
.join("&");

return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${
linkPropsQuery ? "?" : ""
}${linkPropsQuery}`;
Expand Down
8 changes: 8 additions & 0 deletions src/DevGov/Notification/Item/Right.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
const nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];

const nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId ||
(context.widgetSrc ?? "devgovgigs.near").split("/", 1)[0];
Expand All @@ -13,6 +14,7 @@ function widget(widgetName, widgetProps, key) {
nearDevGovGigsWidgetsAccountId: props.nearDevGovGigsWidgetsAccountId,
referral: props.referral,
};

return (
<Widget
src={`${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.${widgetName}`}
Expand All @@ -24,20 +26,26 @@ function widget(widgetName, widgetProps, key) {

function href(widgetName, linkProps) {
linkProps = { ...linkProps };

if (props.nearDevGovGigsContractAccountId) {
linkProps.nearDevGovGigsContractAccountId =
props.nearDevGovGigsContractAccountId;
}

if (props.nearDevGovGigsWidgetsAccountId) {
linkProps.nearDevGovGigsWidgetsAccountId =
props.nearDevGovGigsWidgetsAccountId;
}

if (props.referral) {
linkProps.referral = props.referral;
}

const linkPropsQuery = Object.entries(linkProps)
.filter(([_key, nullable]) => (nullable ?? null) !== null)
.map(([key, value]) => `${key}=${value}`)
.join("&");

return `/#/${nearDevGovGigsWidgetsAccountId}/widget/gigs-board.pages.${widgetName}${
linkPropsQuery ? "?" : ""
}${linkPropsQuery}`;
Expand Down
Loading

0 comments on commit 0c2aebc

Please sign in to comment.