diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e5322294f..cb9e5356d 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -139,15 +139,6 @@ We use [Playwright](https://playwright.dev) for tests, which are located in the See the [test-pipeline](./.github/workflows/continuous-integration-workflow.yml) for what dependencies that needs to be installed on your workstation for tests to run. - -#### Making Changes to common.jsx - -The `common.jsx` file contains a set of shared utilities that are often reused in DevHub widgets. When you need to change it, just edit the file in the root of the project, and update the widgets with this one command: - -``` -npm run build -``` - #### Storage Deposit Sometimes there is a need to deposit extra tokens to cover the widgets’ storage cost. You can do that with [`bos` CLI](https://github.com/FroVolod/bos-cli-rs): diff --git a/module/include.js b/module/include.js deleted file mode 100644 index 2ecd08fe6..000000000 --- a/module/include.js +++ /dev/null @@ -1,46 +0,0 @@ -const fs = require("fs"); -const replaceInFiles = require("replace-in-files"); - -const options = { - files: ["src/**/*.jsx"], - from: /\/\* INCLUDE: "common\.jsx" \*\/.*\/\* END_INCLUDE: "common\.jsx" \*\//gms, - to: `/* INCLUDE: "common.jsx" */\n${fs - .readFileSync("./common.jsx", "utf8") - .toString()}/* END_INCLUDE: "common.jsx" */`, -}; - -replaceInFiles(options) - .pipe({ - from: /\/\* INCLUDE: "core\/lib\/data-request" \*\/.*\/\* END_INCLUDE: "core\/lib\/data-request" \*\//gms, - to: `/* INCLUDE: "core/lib/data-request" */\n${fs - .readFileSync("./module/core/lib/data-request.js", "utf8") - .toString()}/* END_INCLUDE: "core/lib/data-request" */`, - }) - .pipe({ - from: /\/\* INCLUDE: "core\/lib\/gui\/form" \*\/.*\/\* END_INCLUDE: "core\/lib\/gui\/form" \*\//gms, - to: `/* INCLUDE: "core/lib/gui/form" */\n${fs - .readFileSync("./module/core/lib/gui/form.js", "utf8") - .toString()}/* END_INCLUDE: "core/lib/gui/form" */`, - }) - .pipe({ - from: /\/\* INCLUDE: "core\/lib\/uuid" \*\/.*\/\* END_INCLUDE: "core\/lib\/uuid" \*\//gms, - to: `/* INCLUDE: "core/lib/uuid" */\n${fs - .readFileSync("./module/core/lib/uuid.js", "utf8") - .toString()}/* END_INCLUDE: "core/lib/uuid" */`, - }) - .pipe({ - from: /\/\* INCLUDE: "core\/lib\/autocomplete" \*\/.*\/\* END_INCLUDE: "core\/lib\/autocomplete" \*\//gms, - to: `/* INCLUDE: "core/lib/autocomplete" */\n${fs - .readFileSync("./module/core/lib/autocomplete.js", "utf8") - .toString()}/* END_INCLUDE: "core/lib/autocomplete" */`, - }) - .pipe({ - from: /\/\* INCLUDE: "entity\/viewer" \*\/.*\/\* END_INCLUDE: "entity\/viewer" \*\//gms, - to: `/* INCLUDE: "entity/viewer" */\n${fs - .readFileSync("./module/entity/viewer.js", "utf8") - .toString()}/* END_INCLUDE: "entity/viewer" */`, - }) - .then(({ changedFiles, countOfMatchesByPaths }) => { - console.log("DONE"); - }) - .catch(console.error); diff --git a/package.json b/package.json index 7a1adc520..fdfebef6d 100644 --- a/package.json +++ b/package.json @@ -13,7 +13,7 @@ "scripts": { "fmt": "prettier --write '**/*.{js,jsx,ts,tsx,json}'", "fmt:check": "prettier --check '**/*.{js,jsx,ts,tsx,json}'", - "build": "npm run fmt && node ./module/include.js", + "build": "npm run fmt", "dev:testnet": "./scripts/dev.sh", "dev:mainnet": "./scripts/dev.sh -a devhub.near -c devgovgigs.near -n mainnet", "build:preview": "node ./scripts/build-preview.mjs", diff --git a/src/devhub/entity/post/History.jsx b/src/devhub/entity/post/History.jsx index d0cdcd082..9f5e6402c 100644 --- a/src/devhub/entity/post/History.jsx +++ b/src/devhub/entity/post/History.jsx @@ -6,23 +6,7 @@ props.newTab: boolean; props.timestamp: number; props.referral: any; */ - -function href(widgetName, linkProps) { - linkProps = { ...linkProps }; - 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 `/${REPL_DEVHUB}/widget/devhub.page.${widgetName}${ - linkPropsQuery ? "?" : "" - }${linkPropsQuery}`; -} -/* END_INCLUDE: "common.jsx" */ +const { href } = VM.require("${REPL_DEVHUB}/widget/core.lib.url") || (() => {}); const postId = props.post.id ?? (props.id ? parseInt(props.id) : 0); const post = @@ -93,11 +77,14 @@ const history = ( > @@ -121,11 +108,14 @@ const history = (