From a86e76991b4b20d8e50f90005a9a04f99878f2e3 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 15 Aug 2023 09:18:32 -0400 Subject: [PATCH 01/14] feat: add iframe message listener --- package.json | 2 +- src/components/blocks/MyAccount.js | 28 ++++++++++++++++++++++++++++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index cd1c8f19..5fa74f20 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "private": true, "author": "Chia Network Inc. ", "homepage": "./", diff --git a/src/components/blocks/MyAccount.js b/src/components/blocks/MyAccount.js index 9c7ea4fc..f6d5ed38 100644 --- a/src/components/blocks/MyAccount.js +++ b/src/components/blocks/MyAccount.js @@ -57,6 +57,34 @@ const MyAccount = ({ openModal = false, onClose, isHeader = true }) => { } }, []); + useEffect(() => { + // Sign in from iframe + window.addEventListener( + 'message', + event => { + if (event.origin !== window.location.origin) { + return; + } + console.log('Received message:', event.data); + if ( + event?.data?.serverAddress && + validateUrl(event?.data?.serverAddress) + ) { + dispatch( + signIn({ + apiKey: event?.data?.apiKey, + serverAddress: event?.data?.serverAddress, + }), + ); + setServerAddress(null); + setApiKey(null); + setIsLogInModalOpen(false); + } + }, + false, + ); + }, []); + return ( {isHeader && ( From 4b220a6983064583eedde1751db891857c724da5 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Tue, 15 Aug 2023 09:42:43 -0400 Subject: [PATCH 02/14] fix: clean up listener --- src/components/blocks/MyAccount.js | 55 ++++++++++++++++-------------- 1 file changed, 30 insertions(+), 25 deletions(-) diff --git a/src/components/blocks/MyAccount.js b/src/components/blocks/MyAccount.js index f6d5ed38..3bc35a55 100644 --- a/src/components/blocks/MyAccount.js +++ b/src/components/blocks/MyAccount.js @@ -58,31 +58,36 @@ const MyAccount = ({ openModal = false, onClose, isHeader = true }) => { }, []); useEffect(() => { - // Sign in from iframe - window.addEventListener( - 'message', - event => { - if (event.origin !== window.location.origin) { - return; - } - console.log('Received message:', event.data); - if ( - event?.data?.serverAddress && - validateUrl(event?.data?.serverAddress) - ) { - dispatch( - signIn({ - apiKey: event?.data?.apiKey, - serverAddress: event?.data?.serverAddress, - }), - ); - setServerAddress(null); - setApiKey(null); - setIsLogInModalOpen(false); - } - }, - false, - ); + // Function to handle the message event + const handleMessage = event => { + if (event.origin !== window.location.origin) { + return; + } + console.log('Received message:', event.data); + if ( + event?.data?.serverAddress && + validateUrl(event?.data?.serverAddress) + ) { + dispatch( + signIn({ + apiKey: event?.data?.apiKey, + serverAddress: event?.data?.serverAddress, + }), + ); + setServerAddress(null); + setApiKey(null); + setIsLogInModalOpen(false); + } + }; + + // Add the event listener + window.addEventListener('message', handleMessage, false); + + // Return a function that will be called when the component unmounts + return () => { + // Remove the event listener + window.removeEventListener('message', handleMessage, false); + }; }, []); return ( From c729618b9ec2efc510a1d863d91be3fc81f7f20a Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:46:09 -0500 Subject: [PATCH 03/14] Update to digicert hsm signing --- .github/workflows/build-installers.yaml | 469 ++++++++++++------------ 1 file changed, 241 insertions(+), 228 deletions(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 1bd02058..ec88f6ea 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -1,228 +1,241 @@ -name: Build & Release - -on: - push: - branches: - - main - tags: - - '**' - pull_request: - branches: - - '**' - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} - cancel-in-progress: true - -jobs: - build_mac: - name: Build Mac Installer - runs-on: macos-latest - steps: - - uses: Chia-Network/actions/clean-workspace@main - - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: install dmg-license - run: npm i dmg-license - - - name: npm install - run: | - node --version - npm install - - - name: Import Apple installer signing certificate - uses: Apple-Actions/import-codesign-certs@v1 - with: - p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }} - p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }} - - - name: Build electron app - env: - CSC_FOR_PULL_REQUEST: "true" - run: npm run electron:package:mac - - - name: Notarize - run: | - DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg') - npm install -g notarize-cli - notarize-cli \ - --file="$DMG_FILE" \ - --bundle-id net.chia.cadt-ui \ - --username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \ - --password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" - - - name: Upload Mac Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-mac-installer - path: ${{ github.workspace }}/dist/*.dmg - - build_windows: - name: Build Windows Installer - runs-on: windows-2019 - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: Ignore Husky where not compatible - run: npm pkg delete scripts.prepare - - - name: npm install - run: | - node --version - npm install - - - name: Build electron app - env: - CSC_LINK: ${{ secrets.WIN_CODE_SIGN_CERT }} - CSC_KEY_PASSWORD: ${{ secrets.WIN_CODE_SIGN_PASSWORD }} - run: npm run electron:package:win - - - name: Upload Windows Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-windows-installer - path: ${{ github.workspace }}/dist/*.exe - - build_linux: - name: Build Linux Installer - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: npm install - run: | - node --version - npm install - - - name: Build electron app - run: npm run electron:package:linux - - - name: Rename Linux installer to be standard format for apt - run: | - ORIGINAL=$(ls dist/*.deb) - MODIFIED=${ORIGINAL:0:-10}-1${ORIGINAL#${ORIGINAL:0:-10}} - mv $ORIGINAL $MODIFIED - - - name: Upload Linux Installer - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-linux-installer - path: ${{ github.workspace }}/dist/*.deb - - build_web: - name: Build CADT UI Web App - runs-on: ubuntu-latest - steps: - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: npm install and build - run: | - node --version - npm install - npm run build - - - name: Create .tar.gz of the web build - run: tar -cvzf cadt-ui-web-build.tar.gz build - - - name: Upload build artifact - uses: actions/upload-artifact@v3 - with: - name: cadt-ui-web-build - path: cadt-ui-web-build.tar.gz - - release: - runs-on: ubuntu-latest - if: startsWith(github.ref, 'refs/tags/') - needs: - - build_mac - - build_windows - - build_linux - - build_web - steps: - - name: Download Windows artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-windows-installer - path: cadt-ui-windows-installer - - - name: Download MacOS artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-mac-installer - path: cadt-ui-mac-installer - - - name: Download Linux artifacts - uses: actions/download-artifact@v3 - with: - name: cadt-ui-linux-installer - path: cadt-ui-linux-installer - - - name: Download Web artifact - uses: actions/download-artifact@v3 - with: - name: cadt-ui-web-build - path: cadt-ui-web-build - - - name: Get Filenames - run: | - DMG_FILE=$(find ${{ github.workspace }}/cadt-ui-mac-installer/ -type f -name '*.dmg') - DEB_FILE=$(find ${{ github.workspace }}/cadt-ui-linux-installer/ -type f -name '*.deb') - EXE_FILE=$(find ${{ github.workspace }}/cadt-ui-windows-installer/ -type f -name '*.exe') - WEB_FILE=$(find ${{ github.workspace }}/cadt-ui-web-build/ -type f -name '*.tar.gz') - - echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV - echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV - echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV - echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV - - - name: Release - uses: softprops/action-gh-release@v0.1.15 - with: - files: | - ${{ env.DMG_FILE }} - ${{ env.DEB_FILE }} - ${{ env.EXE_FILE }} - ${{ env.WEB_FILE }} - - - name: Trigger apt repo update - run: | - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy +name: Build & Release + +on: + push: + branches: + - main + tags: + - '**' + pull_request: + branches: + - '**' + +concurrency: + # SHA is added to the end if on `main` to let all main workflows run + group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} + cancel-in-progress: true + +jobs: + build_mac: + name: Build Mac Installer + runs-on: macos-latest + steps: + - uses: Chia-Network/actions/clean-workspace@main + + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: install dmg-license + run: npm i dmg-license + + - name: npm install + run: | + node --version + npm install + + - name: Import Apple installer signing certificate + uses: Apple-Actions/import-codesign-certs@v1 + with: + p12-file-base64: ${{ secrets.APPLE_DEV_ID_APP }} + p12-password: ${{ secrets.APPLE_DEV_ID_APP_PASS }} + + - name: Build electron app + env: + CSC_FOR_PULL_REQUEST: "true" + run: npm run electron:package:mac + + - name: Notarize + run: | + DMG_FILE=$(find ${{ github.workspace }}/dist/ -type f -name '*.dmg') + npm install -g notarize-cli + notarize-cli \ + --file="$DMG_FILE" \ + --bundle-id net.chia.cadt-ui \ + --username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \ + --password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" + + - name: Upload Mac Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-mac-installer + path: ${{ github.workspace }}/dist/*.dmg + + build_windows: + name: Build Windows Installer + runs-on: windows-2019 + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: Ignore Husky where not compatible + run: npm pkg delete scripts.prepare + + - name: npm install + run: | + node --version + npm install + + - name: Build electron app + run: npm run electron:package:win + + # Windows Code Signing + - name: Get installer name for signing + run: | + FILE=$(find dist -type f -name '*.exe') + echo "Installer file is $FILE" + echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV" + + - name: Sign windows artifacts + uses: chia-network/actions/digicert/windows-sign@main + with: + sm_api_key: ${{ secrets.SM_API_KEY }} + sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }} + sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} + sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} + file: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + + - name: Upload Windows Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-windows-installer + path: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + + build_linux: + name: Build Linux Installer + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: npm install + run: | + node --version + npm install + + - name: Build electron app + run: npm run electron:package:linux + + - name: Rename Linux installer to be standard format for apt + run: | + ORIGINAL=$(ls dist/*.deb) + MODIFIED=${ORIGINAL:0:-10}-1${ORIGINAL#${ORIGINAL:0:-10}} + mv $ORIGINAL $MODIFIED + + - name: Upload Linux Installer + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-linux-installer + path: ${{ github.workspace }}/dist/*.deb + + build_web: + name: Build CADT UI Web App + runs-on: ubuntu-latest + steps: + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Setup Node 18.16 + uses: actions/setup-node@v3 + with: + node-version: '18.16' + + - name: Install Husky + run: npm install --save-dev husky + + - name: npm install and build + run: | + node --version + npm install + npm run build + + - name: Create .tar.gz of the web build + run: tar -cvzf cadt-ui-web-build.tar.gz build + + - name: Upload build artifact + uses: actions/upload-artifact@v3 + with: + name: cadt-ui-web-build + path: cadt-ui-web-build.tar.gz + + release: + runs-on: ubuntu-latest + if: startsWith(github.ref, 'refs/tags/') + needs: + - build_mac + - build_windows + - build_linux + - build_web + steps: + - name: Download Windows artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-windows-installer + path: cadt-ui-windows-installer + + - name: Download MacOS artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-mac-installer + path: cadt-ui-mac-installer + + - name: Download Linux artifacts + uses: actions/download-artifact@v3 + with: + name: cadt-ui-linux-installer + path: cadt-ui-linux-installer + + - name: Download Web artifact + uses: actions/download-artifact@v3 + with: + name: cadt-ui-web-build + path: cadt-ui-web-build + + - name: Get Filenames + run: | + DMG_FILE=$(find ${{ github.workspace }}/cadt-ui-mac-installer/ -type f -name '*.dmg') + DEB_FILE=$(find ${{ github.workspace }}/cadt-ui-linux-installer/ -type f -name '*.deb') + EXE_FILE=$(find ${{ github.workspace }}/cadt-ui-windows-installer/ -type f -name '*.exe') + WEB_FILE=$(find ${{ github.workspace }}/cadt-ui-web-build/ -type f -name '*.tar.gz') + + echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV + echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV + echo "EXE_FILE=$EXE_FILE" >>$GITHUB_ENV + echo "WEB_FILE=$WEB_FILE" >>$GITHUB_ENV + + - name: Release + uses: softprops/action-gh-release@v0.1.15 + with: + files: | + ${{ env.DMG_FILE }} + ${{ env.DEB_FILE }} + ${{ env.EXE_FILE }} + ${{ env.WEB_FILE }} + + - name: Trigger apt repo update + run: | + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy From 29e8aeda4a7b60b03499f56d04b11a91e54e51bc Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:48:20 -0500 Subject: [PATCH 04/14] Run the find in bash --- .github/workflows/build-installers.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index ec88f6ea..6cb85b11 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -96,6 +96,7 @@ jobs: # Windows Code Signing - name: Get installer name for signing + shell: bash run: | FILE=$(find dist -type f -name '*.exe') echo "Installer file is $FILE" From 0fb304afcc252cf97a0b145da11f479474ed0bfb Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 10:54:49 -0500 Subject: [PATCH 05/14] Fix find command to just find the installer, not the other exes in subdirs --- .github/workflows/build-installers.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 6cb85b11..4eb84d1b 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -98,7 +98,7 @@ jobs: - name: Get installer name for signing shell: bash run: | - FILE=$(find dist -type f -name '*.exe') + FILE=$(find dist -type f -maxdepth 1 -name '*.exe') echo "Installer file is $FILE" echo "INSTALLER_FILE=$FILE" >> "$GITHUB_ENV" From ab211dcb5fa8b80df2968f37a3e43f2ba3d28a03 Mon Sep 17 00:00:00 2001 From: Chris Marslender Date: Tue, 15 Aug 2023 11:06:43 -0500 Subject: [PATCH 06/14] Try quoting file for signing --- .github/workflows/build-installers.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 4eb84d1b..b3df4fc2 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -109,13 +109,13 @@ jobs: sm_client_cert_file_b64: ${{ secrets.SM_CLIENT_CERT_FILE_B64 }} sm_client_cert_password: ${{ secrets.SM_CLIENT_CERT_PASSWORD }} sm_code_signing_cert_sha1_hash: ${{ secrets.SM_CODE_SIGNING_CERT_SHA1_HASH }} - file: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + file: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}" - name: Upload Windows Installer uses: actions/upload-artifact@v3 with: name: cadt-ui-windows-installer - path: ${{ github.workspace }}/${{ env.INSTALLER_FILE }} + path: "${{ github.workspace }}/${{ env.INSTALLER_FILE }}" build_linux: name: Build Linux Installer From 1e80d442f074aa4041778f6bfe4de75cc88d4d38 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 16 Aug 2023 11:07:44 -0400 Subject: [PATCH 07/14] feat: hide connect --- src/components/layout/Header.js | 2 +- src/navigation/AppNavigator.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/layout/Header.js b/src/components/layout/Header.js index 48812a16..4d08bb16 100644 --- a/src/components/layout/Header.js +++ b/src/components/layout/Header.js @@ -57,7 +57,7 @@ const Header = () => { )} - + {window.self === window.top && } diff --git a/src/navigation/AppNavigator.js b/src/navigation/AppNavigator.js index 83842b8d..52207288 100644 --- a/src/navigation/AppNavigator.js +++ b/src/navigation/AppNavigator.js @@ -46,7 +46,7 @@ const AppNavigator = () => { return ( {showProgressOverlay && } - {!connectionCheck ? ( + {!connectionCheck && window.self === window.top ? ( dispatch(getOrganizationData())} From 0d890cddecb6d8758ca00633ae204896774871a7 Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Wed, 16 Aug 2023 15:01:27 -0400 Subject: [PATCH 08/14] feat: hide header when in iframe --- src/components/layout/Dashboard.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/components/layout/Dashboard.js b/src/components/layout/Dashboard.js index 1f46ddf5..7f7a97c7 100644 --- a/src/components/layout/Dashboard.js +++ b/src/components/layout/Dashboard.js @@ -36,7 +36,7 @@ const InnerContainer = styled('div')` const Dashboard = withTheme(({ children }) => { return (
-
+ {window.self === window.top &&
} From 64a4dd2cdf2d6b4784dc1c17819ac9e27ec512ec Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Wed, 16 Aug 2023 15:11:39 -0700 Subject: [PATCH 09/14] build: update package.json with name of fork --- package.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index cd1c8f19..ab1e0d1e 100644 --- a/package.json +++ b/package.json @@ -1,5 +1,5 @@ { - "name": "cadt-ui", + "name": "core-registry-cadt-ui", "version": "1.2.4", "private": true, "author": "Chia Network Inc. ", @@ -102,7 +102,7 @@ }, "build": { "appId": "org.worldbank.climate-action-data-trust", - "productName": "cadt-ui", + "productName": "core-registry-cadt-ui", "files": [ "build/**/*", "node_modules/**/*" @@ -127,9 +127,9 @@ }, "linux": { "target": "deb", - "description": "Climate Action Data Trust user interface desktop application. Allows point-and-click interface for the CADT API application.", + "description": "Core Registry Climate Action Data Trust user interface desktop application. Allows point-and-click interface for the Core Registry CADT API application.", "maintainer": "Chia Network Inc ", - "vendor": "https://climateactiondata.org/", + "vendor": "https://www.chia.net/", "publish": null, "icon": "src/assets/img/CADT_Icon.png", "desktop": { From ecb282ba8e0c2f03cf629a34d3261464fa469954 Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Wed, 16 Aug 2023 15:13:38 -0700 Subject: [PATCH 10/14] ci: update name to core-registry-cadt --- .github/workflows/build-installers.yaml | 42 ++++++++++++------------- 1 file changed, 21 insertions(+), 21 deletions(-) diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 1bd02058..2dc11d1d 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -58,14 +58,14 @@ jobs: npm install -g notarize-cli notarize-cli \ --file="$DMG_FILE" \ - --bundle-id net.chia.cadt-ui \ + --bundle-id net.chia.core-registry-cadt-ui \ --username "${{ secrets.APPLE_NOTARIZE_USERNAME }}" \ --password "${{ secrets.APPLE_NOTARIZE_PASSWORD }}" - name: Upload Mac Installer uses: actions/upload-artifact@v3 with: - name: cadt-ui-mac-installer + name: core-registry-cadt-ui-mac-installer path: ${{ github.workspace }}/dist/*.dmg build_windows: @@ -100,7 +100,7 @@ jobs: - name: Upload Windows Installer uses: actions/upload-artifact@v3 with: - name: cadt-ui-windows-installer + name: core-registry-cadt-ui-windows-installer path: ${{ github.workspace }}/dist/*.exe build_linux: @@ -135,7 +135,7 @@ jobs: - name: Upload Linux Installer uses: actions/upload-artifact@v3 with: - name: cadt-ui-linux-installer + name: core-registry-cadt-ui-linux-installer path: ${{ github.workspace }}/dist/*.deb build_web: @@ -160,13 +160,13 @@ jobs: npm run build - name: Create .tar.gz of the web build - run: tar -cvzf cadt-ui-web-build.tar.gz build + run: tar -cvzf core-registry-cadt-ui-web-build.tar.gz build - name: Upload build artifact uses: actions/upload-artifact@v3 with: - name: cadt-ui-web-build - path: cadt-ui-web-build.tar.gz + name: core-registry-cadt-ui-web-build + path: core-registry-cadt-ui-web-build.tar.gz release: runs-on: ubuntu-latest @@ -180,33 +180,33 @@ jobs: - name: Download Windows artifacts uses: actions/download-artifact@v3 with: - name: cadt-ui-windows-installer - path: cadt-ui-windows-installer + name: core-registry-cadt-ui-windows-installer + path: core-registry-cadt-ui-windows-installer - name: Download MacOS artifacts uses: actions/download-artifact@v3 with: - name: cadt-ui-mac-installer - path: cadt-ui-mac-installer + name: core-registry-cadt-ui-mac-installer + path: core-registry-cadt-ui-mac-installer - name: Download Linux artifacts uses: actions/download-artifact@v3 with: - name: cadt-ui-linux-installer - path: cadt-ui-linux-installer + name: core-registry-cadt-ui-linux-installer + path: core-registry-cadt-ui-linux-installer - name: Download Web artifact uses: actions/download-artifact@v3 with: - name: cadt-ui-web-build - path: cadt-ui-web-build + name: core-registry-cadt-ui-web-build + path: core-registry-cadt-ui-web-build - name: Get Filenames run: | - DMG_FILE=$(find ${{ github.workspace }}/cadt-ui-mac-installer/ -type f -name '*.dmg') - DEB_FILE=$(find ${{ github.workspace }}/cadt-ui-linux-installer/ -type f -name '*.deb') - EXE_FILE=$(find ${{ github.workspace }}/cadt-ui-windows-installer/ -type f -name '*.exe') - WEB_FILE=$(find ${{ github.workspace }}/cadt-ui-web-build/ -type f -name '*.tar.gz') + DMG_FILE=$(find ${{ github.workspace }}/core-registry-cadt-ui-mac-installer/ -type f -name '*.dmg') + DEB_FILE=$(find ${{ github.workspace }}/core-registry-cadt-ui-linux-installer/ -type f -name '*.deb') + EXE_FILE=$(find ${{ github.workspace }}/core-registry-cadt-ui-windows-installer/ -type f -name '*.exe') + WEB_FILE=$(find ${{ github.workspace }}/core-registry-cadt-ui-web-build/ -type f -name '*.tar.gz') echo "DMG_FILE=$DMG_FILE" >>$GITHUB_ENV echo "DEB_FILE=$DEB_FILE" >>$GITHUB_ENV @@ -224,5 +224,5 @@ jobs: - name: Trigger apt repo update run: | - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy From 35c3f209ac21a0095b2c24083a725583bf6c12c4 Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Wed, 16 Aug 2023 15:18:28 -0700 Subject: [PATCH 11/14] ci: push releases to new apt repo --- .github/workflows/auto-release.yml | 2 +- .github/workflows/build-installers.yaml | 14 +++++- .github/workflows/deploy-s3.yml | 67 ------------------------- 3 files changed, 13 insertions(+), 70 deletions(-) delete mode 100644 .github/workflows/deploy-s3.yml diff --git a/.github/workflows/auto-release.yml b/.github/workflows/auto-release.yml index 41b352b4..e7209119 100644 --- a/.github/workflows/auto-release.yml +++ b/.github/workflows/auto-release.yml @@ -12,7 +12,7 @@ concurrency: jobs: check-version: - name: Check version increment + name: Tag and Create Changelog runs-on: ubuntu-latest steps: - name: Clean workspace diff --git a/.github/workflows/build-installers.yaml b/.github/workflows/build-installers.yaml index 2dc11d1d..452801c6 100644 --- a/.github/workflows/build-installers.yaml +++ b/.github/workflows/build-installers.yaml @@ -222,7 +222,17 @@ jobs: ${{ env.EXE_FILE }} ${{ env.WEB_FILE }} + - name: Get tag name + id: tag-name + run: | + echo "TAGNAME=$(echo $GITHUB_REF | cut -d / -f 3)" >>$GITHUB_OUTPUT + + - name: Get repo name + id: repo-name + run: | + echo "REPO_NAME=$(echo "$GITHUB_REPOSITORY" | cut -d "/" -f 2)" >>$GITHUB_OUTPUT + - name: Trigger apt repo update run: | - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/start - curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"cadt_repo":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}"}' ${{ secrets.GLUE_API_URL }}/api/v1/cadt/${{ github.sha }}/success/deploy + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"climate_tokenization_repo":"${{ steps.repo-name.outputs.REPO_NAME }}","application_name":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}","add_debian_version":"true","arm64":"false"}' ${{ secrets.GLUE_API_URL }}/api/v1/climate-tokenization/${{ github.sha }}/start + curl -s -XPOST -H "Authorization: Bearer ${{ secrets.GLUE_ACCESS_TOKEN }}" --data '{"climate_tokenization_repo":"${{ steps.repo-name.outputs.REPO_NAME }}","application_name":"core-registry-cadt-ui","release_version":"${{ steps.tag-name.outputs.TAGNAME }}","add_debian_version":"true","arm64":"false"}' ${{ secrets.GLUE_API_URL }}/api/v1/climate-tokenization/${{ github.sha }}/success/deploy diff --git a/.github/workflows/deploy-s3.yml b/.github/workflows/deploy-s3.yml deleted file mode 100644 index b7b21786..00000000 --- a/.github/workflows/deploy-s3.yml +++ /dev/null @@ -1,67 +0,0 @@ -name: Deploy to S3 - -on: - push: - branches: - - main - -permissions: - id-token: write - contents: read - -concurrency: - # SHA is added to the end if on `main` to let all main workflows run - group: ${{ github.ref }}-${{ github.workflow }}-${{ github.event_name }}-${{ github.ref == 'refs/heads/main' && github.sha || '' }} - cancel-in-progress: true - -jobs: - build-and-deploy: - name: Build CADT App and Upload to S3 - runs-on: [k8s-public] - container: - image: ubuntu:latest - steps: - - name: Install AWS CLI - run: | - apt-get update - export DEBIAN_FRONTEND=noninteractive - export TZ=Etc/UTC - apt-get install -y awscli - - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Setup Node 18.16 - uses: actions/setup-node@v3 - with: - node-version: '18.16' - - - name: Install Husky - run: npm install --save-dev husky - - - name: npm install and build - env: - REACT_APP_API_HOST: "https://api-green.climatewarehouse.chia.net/v1" - REACT_APP_APP_URL: "http://green-cw-ui.s3-website-us-west-2.amazonaws.com/" - run: | - node --version - npm install - npm run build - - - name: Vault Login - uses: Chia-Network/actions/vault/login@main - with: - vault_url: ${{ secrets.VAULT_URL }} - role_name: github-climate-warehouse-ui - - - name: Get ephemeral aws credentials - uses: Chia-Network/actions/vault/aws-sts@main - with: - vault_url: ${{ secrets.VAULT_URL }} - vault_token: ${{ env.VAULT_TOKEN }} - backend_name: aws-carbon - role_name: cw-s3-deploy - - - name: Upload build folder to S3 (green) - run: | - aws s3 sync --delete --no-progress ./build/ s3://green-cw-ui/ From 319abaeb4a6f76463f7ea73f799e62355b286f9a Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Wed, 16 Aug 2023 15:22:48 -0700 Subject: [PATCH 12/14] docs: name change for this fork --- README.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index 8ee2f6ec..40ca8d4a 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ -# Climate Action Data Trust User Interface +# Core Registry Climate Action Data Trust User Interface -This repository provides a graphical user interface (UI) for the [Climate Action Data Trust (CADT)](https://github.com/Chia-Network/cadt) application. CADT interfaces with the Chia Blockchain software and provides and API for entering and retrieving carbon data. This UI is a javascript application that connects to the CADT API for a convenient way to access the data. +This project is a fork of the [Climate Action Data Trust UI](https://github.com/Chia-Network/cadt-ui) and provides enhancements and compatability improvements for the Core Registry suite of tools. This repository provides a graphical user interface (UI) for the [Core Registry Climate Action Data Trust (CADT)](https://github.com/Chia-Network/core-registry-cadt) application. CADT interfaces with the Chia Blockchain software and provides and API for entering and retrieving carbon data. This UI is a javascript application that connects to the Core Registry CADT API for a convenient way to access the data. *Note that this application was previously called the Climate Warehouse UI and that name may be used interchangeably in documentation and throughout this application.* @@ -11,11 +11,11 @@ The UI application can be hosted as a web application and accessed via the brows ### Desktop Applications -The [releases](https://github.com/Chia-Network/cadt-ui/releases) page provides desktop applications packaged for Windows, Mac, and Debian-based Linux distributions. +The [releases](https://github.com/Chia-Network/core-registry-cadt-ui/releases) page provides desktop applications packaged for Windows, Mac, and Debian-based Linux distributions. #### Ubuntu Desktop via Apt -For Ubuntu-based Linux desktops the CADT UI is available for install with `apt`. +For Ubuntu-based Linux desktops the Core Registry CADT UI is available for install with `apt`. 1. Start by updating apt and allowing repository download over HTTPS: @@ -46,15 +46,15 @@ sudo apt-get install cadt-ui ### Web Application -The Climate Warehouse UI can be hosted as a web application, either for internal use, or made available to the public. When operating as a web application, the user's browser must be able to connect to the [CADT API](https://github.com/Chia-Network/cadt). This means the API must be available on the public internet if the UI is public. The `READ_ONLY` option on the API should be set when running a public observer node. +The Core Registry CADT UI can be hosted as a web application, either for internal use, or made available to the public. When operating as a web application, the user's browser must be able to connect to the [Core Registry CADT API](https://github.com/Chia-Network/core-registry-cadt). This means the API must be available on the public internet if the UI is public. The `READ_ONLY` option on the API should be set when running a public observer node. -To host the UI on the web, use the [web-build.tar.gz file from the releases page](https://github.com/Chia-Network/cadt-ui/releases). One of the simplest solutions is to uncompress these files into a [public S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html). These files could also be served by any webserver, such as Nginx or Apache. +To host the UI on the web, use the [web-build.tar.gz file from the releases page](https://github.com/Chia-Network/core-registry-cadt-ui/releases). One of the simplest solutions is to uncompress these files into a [public S3 bucket](https://docs.aws.amazon.com/AmazonS3/latest/userguide/WebsiteAccessPermissionsReqd.html). These files could also be served by any webserver, such as Nginx or Apache. ### From Source ``` npm install -g react-scripts -git clone git@github.com:Chia-Network/cadt-ui.git +git clone git@github.com:Chia-Network/core-registry-cadt-ui.git cd climate-warehouse-ui nvm install 18.16.0 nvm use 18.16.0 From 5c31d3c5a0f800ca9f6d73d1cc35cc649189812c Mon Sep 17 00:00:00 2001 From: Michael Taylor Date: Thu, 17 Aug 2023 11:35:49 -0400 Subject: [PATCH 13/14] feat: namespace localstorage keys --- package-lock.json | 4 ++-- src/store/actions/app.js | 12 ++++++------ src/store/actions/climateWarehouseActions.js | 2 +- src/utils/urlUtils.js | 2 +- 4 files changed, 10 insertions(+), 10 deletions(-) diff --git a/package-lock.json b/package-lock.json index b1a5f33f..db6d5e4c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "hasInstallScript": true, "dependencies": { "@date-io/dayjs": "^2.16.0", diff --git a/src/store/actions/app.js b/src/store/actions/app.js index bc7c2ef3..7722c33f 100644 --- a/src/store/actions/app.js +++ b/src/store/actions/app.js @@ -129,11 +129,11 @@ export const setNotificationMessage = (type, id) => { export const signIn = ({ apiKey, serverAddress }) => { return async dispatch => { if (serverAddress) { - localStorage.setItem('serverAddress', serverAddress); + localStorage.setItem('cadtRemoteServerAddress', serverAddress); let payload = { serverAddress }; if (apiKey) { - localStorage.setItem('apiKey', apiKey); + localStorage.setItem('cadtRemoteServerApiKey', apiKey); payload = { ...payload, apiKey }; } @@ -149,8 +149,8 @@ export const signIn = ({ apiKey, serverAddress }) => { export const signOut = () => { return async dispatch => { - localStorage.removeItem('apiKey'); - localStorage.removeItem('serverAddress'); + localStorage.removeItem('cadtRemoteServerApiKey'); + localStorage.removeItem('cadtRemoteServerAddress'); dispatch({ type: actions.SIGN_USER_OUT, payload: { @@ -163,8 +163,8 @@ export const signOut = () => { export const signInFromLocalStorage = () => { return async dispatch => { - const apiKey = localStorage.getItem('apiKey'); - const serverAddress = localStorage.getItem('serverAddress'); + const apiKey = localStorage.getItem('cadtRemoteServerApiKey'); + const serverAddress = localStorage.getItem('cadtRemoteServerAddress'); if (serverAddress) { let payload = { serverAddress }; diff --git a/src/store/actions/climateWarehouseActions.js b/src/store/actions/climateWarehouseActions.js index c625a404..4dd0ca17 100644 --- a/src/store/actions/climateWarehouseActions.js +++ b/src/store/actions/climateWarehouseActions.js @@ -2539,7 +2539,7 @@ export const getVintages = options => { // TODO to replace with an extended wrapper that also adds try catch finally and also handles network connection and progress indicator dispatches const fetchWrapper = async (url, payload) => { - const apiKey = localStorage.getItem('apiKey'); + const apiKey = localStorage.getItem('cadtRemoteServerApiKey'); url = overrideURL(url); diff --git a/src/utils/urlUtils.js b/src/utils/urlUtils.js index aa8a5060..56f50d88 100644 --- a/src/utils/urlUtils.js +++ b/src/utils/urlUtils.js @@ -16,7 +16,7 @@ export const validateUrl = url => { }; export const overrideURL = originalUrl => { - const serverAddress = localStorage.getItem('serverAddress'); + const serverAddress = localStorage.getItem('cadtRemoteServerAddress'); // If serverAddress is valid, replace the domain of the original URL. if (serverAddress && typeof serverAddress === 'string') { From 01bc882e810c28d8cde11d4c69df5c42e8c2e803 Mon Sep 17 00:00:00 2001 From: Zachary Brown Date: Thu, 17 Aug 2023 10:11:54 -0700 Subject: [PATCH 14/14] chore: bump version 1.2.5 --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index ab1e0d1e..615316df 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "core-registry-cadt-ui", - "version": "1.2.4", + "version": "1.2.5", "private": true, "author": "Chia Network Inc. ", "homepage": "./",