From 081d6097b6dbe662b005bf1c42331c6dc8ff0662 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Walther?= Date: Wed, 15 Feb 2023 10:02:19 +0100 Subject: [PATCH 1/4] Github Actions: Remove keybase notifications --- .github/workflows/audit.yml | 8 +-- .github/workflows/build-ts-packages.yml | 8 +-- .github/workflows/network-explorer.yml | 8 +-- .github/workflows/nightly_build.yml | 8 +-- .github/workflows/nightly_build_release.yml | 8 +-- .github/workflows/nightly_build_release2.yml | 8 +-- .github/workflows/nym-connect.yml | 8 +-- .github/workflows/nym-wallet-storybook.yml | 8 +-- .github/workflows/support-files/.env.example | 6 +- .github/workflows/support-files/README.md | 19 ++++--- .../notifications/send_message.js | 57 ------------------- .github/workflows/support-files/package.json | 5 +- .github/workflows/typescript-lint.yml | 8 +-- 13 files changed, 31 insertions(+), 128 deletions(-) diff --git a/.github/workflows/audit.yml b/.github/workflows/audit.yml index b8c64425cb..212f1a0501 100644 --- a/.github/workflows/audit.yml +++ b/.github/workflows/audit.yml @@ -39,18 +39,14 @@ jobs: uses: actions/setup-node@v3 with: node-version: 16 - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: security NYM_PROJECT_NAME: "Daily security report" GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "security" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" MATRIX_USER_ID: "${{ secrets.MATRIX_USER_ID }}" diff --git a/.github/workflows/build-ts-packages.yml b/.github/workflows/build-ts-packages.yml index 82a9d0b9b5..ba744b1a65 100644 --- a/.github/workflows/build-ts-packages.yml +++ b/.github/workflows/build-ts-packages.yml @@ -43,10 +43,10 @@ jobs: REMOTE_USER: ${{ secrets.CI_WWW_REMOTE_USER }} TARGET: ${{ secrets.CI_WWW_REMOTE_TARGET }}/ts-${{ env.GITHUB_REF_SLUG }}-example EXCLUDE: "/dist/, /node_modules/" - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: ts-packages NYM_PROJECT_NAME: "ts-packages" @@ -54,10 +54,6 @@ jobs: NYM_CI_WWW_LOCATION: "ts-${{ env.GITHUB_REF_SLUG }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-ts-packages" IS_SUCCESS: "${{ job.status == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/network-explorer.yml b/.github/workflows/network-explorer.yml index 4ae55435de..9f50548105 100644 --- a/.github/workflows/network-explorer.yml +++ b/.github/workflows/network-explorer.yml @@ -57,10 +57,10 @@ jobs: REMOTE_USER: ${{ secrets.CI_WWW_REMOTE_USER }} TARGET: ${{ secrets.CI_WWW_REMOTE_TARGET }}/ne-sb-${{ env.GITHUB_REF_SLUG }} EXCLUDE: "/dist/, /node_modules/" - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: network-explorer NYM_PROJECT_NAME: "Network Explorer" @@ -69,10 +69,6 @@ jobs: NYM_CI_WWW_LOCATION_STORYBOOK: "ne-sb-${{ env.GITHUB_REF_SLUG }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-network-explorer" IS_SUCCESS: "${{ job.status == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/nightly_build.yml b/.github/workflows/nightly_build.yml index 70ac8c105f..af49b2c04c 100644 --- a/.github/workflows/nightly_build.yml +++ b/.github/workflows/nightly_build.yml @@ -153,11 +153,11 @@ jobs: if: env.WORKFLOW_CONCLUSION == 'failure' with: node-version: 16 - - name: Keybase - Node Install + - name: Matrix - Node Install if: env.WORKFLOW_CONCLUSION == 'failure' run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification if: env.WORKFLOW_CONCLUSION == 'failure' env: NYM_NOTIFICATION_KIND: nightly @@ -165,10 +165,6 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-nightly" IS_SUCCESS: "${{ env.WORKFLOW_CONCLUSION == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/nightly_build_release.yml b/.github/workflows/nightly_build_release.yml index 6db1effc5a..0eece7c5f5 100644 --- a/.github/workflows/nightly_build_release.yml +++ b/.github/workflows/nightly_build_release.yml @@ -168,11 +168,11 @@ jobs: if: env.WORKFLOW_CONCLUSION == 'failure' with: node-version: 16 - - name: Keybase - Node Install + - name: Matrix - Node Install if: env.WORKFLOW_CONCLUSION == 'failure' run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification if: env.WORKFLOW_CONCLUSION == 'failure' env: NYM_NOTIFICATION_KIND: nightly @@ -180,10 +180,6 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH_NAME: "${{needs.get_release.outputs.output1}}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-nightly-release" IS_SUCCESS: "${{ env.WORKFLOW_CONCLUSION == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/nightly_build_release2.yml b/.github/workflows/nightly_build_release2.yml index 05987d55a6..402729cac1 100644 --- a/.github/workflows/nightly_build_release2.yml +++ b/.github/workflows/nightly_build_release2.yml @@ -168,11 +168,11 @@ jobs: if: env.WORKFLOW_CONCLUSION == 'failure' with: node-version: 16 - - name: Keybase - Node Install + - name: Matrix - Node Install if: env.WORKFLOW_CONCLUSION == 'failure' run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification if: env.WORKFLOW_CONCLUSION == 'failure' env: NYM_NOTIFICATION_KIND: nightly @@ -180,10 +180,6 @@ jobs: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH_NAME: "${{needs.get_release.outputs.output1}}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-nightly-release" IS_SUCCESS: "${{ env.WORKFLOW_CONCLUSION == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/nym-connect.yml b/.github/workflows/nym-connect.yml index e941259252..69f5acb147 100644 --- a/.github/workflows/nym-connect.yml +++ b/.github/workflows/nym-connect.yml @@ -39,10 +39,10 @@ jobs: REMOTE_USER: ${{ secrets.CI_WWW_REMOTE_USER }} TARGET: ${{ secrets.CI_WWW_REMOTE_TARGET }}/nym-connect-${{ env.GITHUB_REF_SLUG }} EXCLUDE: "/dist/, /node_modules/" - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: nym-connect NYM_PROJECT_NAME: "nym-connect" @@ -50,10 +50,6 @@ jobs: NYM_CI_WWW_LOCATION: "nym-connect-${{ env.GITHUB_REF_SLUG }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-nym-connect" IS_SUCCESS: "${{ job.status == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/nym-wallet-storybook.yml b/.github/workflows/nym-wallet-storybook.yml index 7c17893beb..b4b290cca2 100644 --- a/.github/workflows/nym-wallet-storybook.yml +++ b/.github/workflows/nym-wallet-storybook.yml @@ -35,10 +35,10 @@ jobs: REMOTE_USER: ${{ secrets.CI_WWW_REMOTE_USER }} TARGET: ${{ secrets.CI_WWW_REMOTE_TARGET }}/wallet-${{ env.GITHUB_REF_SLUG }} EXCLUDE: "/dist/, /node_modules/" - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: nym-wallet NYM_PROJECT_NAME: "nym-wallet" @@ -46,10 +46,6 @@ jobs: NYM_CI_WWW_LOCATION: "wallet-${{ env.GITHUB_REF_SLUG }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-nym-wallet" IS_SUCCESS: "${{ job.status == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" diff --git a/.github/workflows/support-files/.env.example b/.github/workflows/support-files/.env.example index df05f1801c..bbd09935d7 100644 --- a/.github/workflows/support-files/.env.example +++ b/.github/workflows/support-files/.env.example @@ -1,7 +1,3 @@ -KEYBASE_NYM_CHANNEL= -KEYBASE_NYMBOT_USERNAME= -KEYBASE_NYMBOT_PAPERKEY= - MATRIX_SERVER= MATRIX_ROOM= MATRIX_ROOM_OF_SHAME= @@ -39,4 +35,4 @@ NYM_CI_WWW_BASE=example.com # Nightly builds WORKFLOW_CONCLUSION=success -SHOW_DEBUG=true \ No newline at end of file +SHOW_DEBUG=true diff --git a/.github/workflows/support-files/README.md b/.github/workflows/support-files/README.md index 5e46357967..9cac90aecc 100644 --- a/.github/workflows/support-files/README.md +++ b/.github/workflows/support-files/README.md @@ -4,7 +4,7 @@ This is a collection of scripts and files to support GitHub Actions. ## Sending Notifications -These scripts send CI notifications to Keybase by creating messages from templates and env vars passed from GitHub Actions. +These scripts send CI notifications to Matrix by creating messages from templates and env vars passed from GitHub Actions. ### Adding notifications to a GitHub Action @@ -19,10 +19,11 @@ jobs: env: NYM_NOTIFICATION_KIND: "my-component" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-network-explorer" + MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" + MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" + MATRIX_USER_ID: "${{ secrets.MATRIX_USER_ID }}" + MATRIX_TOKEN: "${{ secrets.MATRIX_TOKEN }}" + MATRIX_DEVICE_ID: "${{ secrets.MATRIX_DEVICE_ID }}" IS_SUCCESS: "${{ job.status == 'success' }}" uses: docker://keybaseio/client:stable-node with: @@ -34,8 +35,8 @@ Notifications are run by adding the snippet above to a GitHub Action, and: 1. Installing node packages needed at run time 2. Set the env vars as required: - `NYM_NOTIFICATION_KIND` matches the directory in `.github/workflows/support-files/${NYM_NOTIFICATION_KIND}` to provide the templates and extra scripting in `index.js` - - Keybase credentials, channel and other env vars for the status of the build and repo -3. Replacing the default entry point shell script on the `keybaseio/client:stable-node` docker image to run `.github/workflows/support-files/notifications/entry_point.sh` + - Matrix credentials, room and other env vars for the status of the build and repo +3. Replacing the default entry point shell script on the `keybaseio/client:stable-node` docker image to run `.github/workflows/support-files/notifications/entry_point.sh` ### Running locally @@ -43,7 +44,7 @@ You will need: - Node 16 LTS - npm -Copy `.github/workflows/support-files/.env.example` to `.github/workflows/support-files/.env` and valid Keybase credentials. +Copy `.github/workflows/support-files/.env.example` to `.github/workflows/support-files/.env` and valid Matrix credentials. Then run `npm install` to get dependencies. @@ -55,4 +56,4 @@ npm install cp .env.example .env vi .env npm run dev -``` \ No newline at end of file +``` diff --git a/.github/workflows/support-files/notifications/send_message.js b/.github/workflows/support-files/notifications/send_message.js index c83a43d88a..2d0c18d6a9 100644 --- a/.github/workflows/support-files/notifications/send_message.js +++ b/.github/workflows/support-files/notifications/send_message.js @@ -1,6 +1,5 @@ require('dotenv').config(); -const Bot = require('keybase-bot'); const { sendMatrixMessage } = require('./send_message_to_matrix'); let context = { @@ -24,21 +23,6 @@ function validateContext() { 'Please set env var NYM_PROJECT_NAME with the project name for displaying in notification messages', ); } - if (!context.env.KEYBASE_NYM_CHANNEL) { - throw new Error( - 'Please set env var KEYBASE_NYM_CHANNEL with the channel name for the notification message', - ); - } - if (!context.env.KEYBASE_NYMBOT_USERNAME) { - throw new Error( - 'Username is not defined. Please set env var KEYBASE_NYMBOT_USERNAME', - ); - } - if (!context.env.KEYBASE_NYMBOT_PAPERKEY) { - throw new Error( - 'Paperkey is not defined. Please set env var KEYBASE_NYMBOT_PAPERKEY', - ); - } if (context.env.MATRIX_ROOM) { if (!context.env.MATRIX_SERVER) { throw new Error( @@ -84,12 +68,6 @@ function createTemplateContext() { context.kind = context.env.NYM_NOTIFICATION_KIND; - context.keybase = { - channel: context.env.KEYBASE_NYM_CHANNEL, - username: context.env.KEYBASE_NYMBOT_USERNAME, - paperkey: context.env.KEYBASE_NYMBOT_PAPERKEY, - }; - if (!context.env.GIT_BRANCH_NAME) { context.env.GIT_BRANCH_NAME = context.env.GITHUB_REF.split('/') .slice(2) @@ -99,40 +77,6 @@ function createTemplateContext() { context.status = process.env.IS_SUCCESS === 'true' ? 'success' : 'failure'; } -async function sendKeybaseMessage(messageBody) { - const bot = new Bot(); - try { - console.log( - `Initialising keybase with user "${ - context.keybase.username - }" and key: "${'*'.repeat(context.keybase.paperkey.length)}"...`, - ); - await bot.init(context.keybase.username, context.keybase.paperkey, { - verbose: false, - }); - - const channel = { - name: context.env.KEYBASE_NYMBOT_TEAM || 'nymtech_bot', - membersType: 'team', - topicName: context.keybase.channel, - topic_type: 'CHAT', - }; - const message = { - body: messageBody, - }; - - console.log(`Sending to ${channel.name}#${channel.topicName}...`); - await bot.chat.send(channel, message); - - console.log('Message sent!'); - } catch (error) { - console.error(error); - process.exitCode = -1; - } finally { - await bot.deinit(); - } -} - /** * Uses the `kind` set in the context to process the context and generate a notification message * @returns {Promise} A string notification message body @@ -169,7 +113,6 @@ async function main() { console.log(messageBody); console.log('-----------------------------------------'); } - await sendKeybaseMessage(messageBody); if(context.env.MATRIX_ROOM) { await sendMatrixMessage(context, messageBody, context.env.MATRIX_ROOM) } diff --git a/.github/workflows/support-files/package.json b/.github/workflows/support-files/package.json index 8f20c34091..801d8e9bdd 100644 --- a/.github/workflows/support-files/package.json +++ b/.github/workflows/support-files/package.json @@ -1,6 +1,6 @@ { - "name": "send-keybase-message", - "description": "Sends a notification message with the keybase package that fails when piped into the keybase CLI", + "name": "send-matrix-message", + "description": "Sends a notification message with the matrix sdk", "version": "1.0.0", "private": true, "scripts": { @@ -10,7 +10,6 @@ "dependencies": { "dotenv": "^16.0.0", "handlebars": "^4.7.7", - "keybase-bot": "^3.6.1", "matrix-js-sdk": "^9.3.0", "node-localstorage": "^2.1.6", "octokit": "^1.7.1", diff --git a/.github/workflows/typescript-lint.yml b/.github/workflows/typescript-lint.yml index 8a378635d7..c4e1f63b62 100644 --- a/.github/workflows/typescript-lint.yml +++ b/.github/workflows/typescript-lint.yml @@ -25,10 +25,10 @@ jobs: run: npm install -g yarn - name: Lint run: yarn && yarn lint && yarn tsc - - name: Keybase - Node Install + - name: Matrix - Node Install run: npm install working-directory: .github/workflows/support-files - - name: Keybase - Send Notification + - name: Matrix - Send Notification env: NYM_NOTIFICATION_KIND: ts-packages NYM_PROJECT_NAME: "ts-packages" @@ -36,10 +36,6 @@ jobs: NYM_CI_WWW_LOCATION: "ts-${{ env.GITHUB_REF_SLUG }}" GIT_COMMIT_MESSAGE: "${{ github.event.head_commit.message }}" GIT_BRANCH: "${GITHUB_REF##*/}" - KEYBASE_NYMBOT_USERNAME: "${{ secrets.KEYBASE_NYMBOT_USERNAME }}" - KEYBASE_NYMBOT_PAPERKEY: "${{ secrets.KEYBASE_NYMBOT_PAPERKEY }}" - KEYBASE_NYMBOT_TEAM: "${{ secrets.KEYBASE_NYMBOT_TEAM }}" - KEYBASE_NYM_CHANNEL: "ci-ts-packages" IS_SUCCESS: "${{ job.status == 'success' }}" MATRIX_SERVER: "${{ secrets.MATRIX_SERVER }}" MATRIX_ROOM: "${{ secrets.MATRIX_ROOM }}" From c8bd6b99fa75270db910fa3c10dcde2cce329a9b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jon=20H=C3=A4ggblad?= Date: Tue, 14 Feb 2023 16:09:44 +0100 Subject: [PATCH 2/4] nym-wallet: update Cargo.lock --- nym-wallet/Cargo.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-wallet/Cargo.lock b/nym-wallet/Cargo.lock index e06347885a..2efa31c900 100644 --- a/nym-wallet/Cargo.lock +++ b/nym-wallet/Cargo.lock @@ -3000,7 +3000,7 @@ dependencies = [ [[package]] name = "nym_wallet" -version = "1.1.8" +version = "1.1.9" dependencies = [ "aes-gcm", "argon2 0.3.4", From 9c77e15a2cbd5b24ec42ba9a7674ddd4b87ad32b Mon Sep 17 00:00:00 2001 From: Pierre Dommerc Date: Wed, 15 Feb 2023 11:12:43 +0100 Subject: [PATCH 3/4] NC Android - UI changes (#3032) * feat(nc-android): update ui (font size&weight) * feat(nc-android): update power button * refactor(nc-android): replace tooltip by dialog * refactor(nc-android): replace tooltip by dialog --- nym-connect-android/src-tauri/Cargo.lock | 4 +- .../src/components/ConnectionStatus.tsx | 65 +++++++-- .../src/components/ConntectionTimer.tsx | 6 +- .../src/components/IpAddressAndPort.tsx | 60 ++------ .../src/components/PowerButton.tsx | 132 ------------------ .../components/PowerButton/PowerButton.tsx | 29 +++- .../components/PowerButton/power-button.css | 2 +- .../src/components/TooltipInfo.tsx | 8 -- .../src/pages/connection/Disconnected.tsx | 2 +- nym-connect-android/src/pages/menu/index.tsx | 8 +- nym-connect-android/src/theme/theme.tsx | 2 +- 11 files changed, 102 insertions(+), 216 deletions(-) delete mode 100644 nym-connect-android/src/components/PowerButton.tsx diff --git a/nym-connect-android/src-tauri/Cargo.lock b/nym-connect-android/src-tauri/Cargo.lock index 444b47e34f..642ba1d8cf 100644 --- a/nym-connect-android/src-tauri/Cargo.lock +++ b/nym-connect-android/src-tauri/Cargo.lock @@ -628,7 +628,7 @@ dependencies = [ [[package]] name = "client-core" -version = "1.1.8" +version = "1.1.9" dependencies = [ "async-trait", "client-connections", @@ -3648,7 +3648,7 @@ dependencies = [ [[package]] name = "nym-socks5-client" -version = "1.1.8" +version = "1.1.9" dependencies = [ "build-information", "clap", diff --git a/nym-connect-android/src/components/ConnectionStatus.tsx b/nym-connect-android/src/components/ConnectionStatus.tsx index 0c02ff2585..0a04f4993f 100644 --- a/nym-connect-android/src/components/ConnectionStatus.tsx +++ b/nym-connect-android/src/components/ConnectionStatus.tsx @@ -1,13 +1,13 @@ -import React from 'react'; -import { Box, CircularProgress, Tooltip, Typography } from '@mui/material'; +import React, { useState } from 'react'; +import { Box, CircularProgress, Typography } from '@mui/material'; import { DateTime } from 'luxon'; import { ErrorOutline, InfoOutlined } from '@mui/icons-material'; import { ConnectionStatusKind, GatewayPerformance } from '../types'; import { ServiceProvider } from '../types/directory'; import { GatwayWarningInfo, ServiceProviderInfo } from './TooltipInfo'; +import { InfoModal } from './InfoModal'; const FONT_SIZE = '14px'; -const FONT_WEIGHT = '600'; const FONT_STYLE = 'normal'; const ConnectionStatusContent: FCWithChildren<{ @@ -15,9 +15,22 @@ const ConnectionStatusContent: FCWithChildren<{ serviceProvider?: ServiceProvider; gatewayError: boolean; }> = ({ status, serviceProvider, gatewayError }) => { + const [showSpInfo, setShowSpInfo] = useState(false); + const [showGatewayWarn, setShowGatewayWarn] = useState(false); + if (gatewayError) { return ( - : undefined}> + <> + {serviceProvider && ( + setShowGatewayWarn(false)} + > + + + )} - + Gateway has issues - + ); } switch (status) { case 'connected': return ( - : undefined}> - + <> + {serviceProvider && ( + setShowSpInfo(false)}> + + + )} + setShowSpInfo(true)} + justifyContent="center" + sx={{ cursor: 'pointer' }} + > - + Connected to Nym Mixnet - + ); case 'disconnected': return ( - + Connect to the mixnet ); @@ -56,7 +93,7 @@ const ConnectionStatusContent: FCWithChildren<{ return ( - + Disconnecting... @@ -65,7 +102,7 @@ const ConnectionStatusContent: FCWithChildren<{ return ( - + Connecting... @@ -85,7 +122,7 @@ export const ConnectionStatus: FCWithChildren<{ const color = status === 'connected' || status === 'disconnecting' ? '#21D072' : 'white'; return ( - + - + Connection time - {duration || '00:00:00'} + + {duration || '00:00:00'} + ); }; diff --git a/nym-connect-android/src/components/IpAddressAndPort.tsx b/nym-connect-android/src/components/IpAddressAndPort.tsx index 4e7618ed87..4ecf356d18 100644 --- a/nym-connect-android/src/components/IpAddressAndPort.tsx +++ b/nym-connect-android/src/components/IpAddressAndPort.tsx @@ -1,8 +1,6 @@ -import { Box, Stack, Tooltip, Typography } from '@mui/material'; +import { Box, Typography } from '@mui/material'; import React from 'react'; import { styled } from '@mui/system'; -import { writeText } from '@tauri-apps/api/clipboard'; -import CheckCircleOutlineIcon from '@mui/icons-material/CheckCircleOutline'; const IpAddressAndPortContainer = styled('div')({ '.hoverAddressCopy:hover': { @@ -37,60 +35,20 @@ export const IpAddressAndPort: FCWithChildren<{ return ( - + {label} - + Port - - - SOCKS5 proxy hostname copied to the clipboard - - ) : ( - <>Click to copy SOCKS5 proxy hostname - ) - } - > - { - await writeText(`${ipAddress}`); - setIpAddressCopied(true); - }} - > - {ipAddress} - - - - - SOCKS5 proxy port copied to the clipboard - - ) : ( - <>Click to copy SOCKS5 proxy port - ) - } - > - { - await writeText(`${port}`); - setPortCopied(true); - }} - > - {port} - - + + {ipAddress} + + + {port} + ); diff --git a/nym-connect-android/src/components/PowerButton.tsx b/nym-connect-android/src/components/PowerButton.tsx deleted file mode 100644 index 426028a767..0000000000 --- a/nym-connect-android/src/components/PowerButton.tsx +++ /dev/null @@ -1,132 +0,0 @@ -import React from 'react'; -import { ConnectionStatusKind } from 'src/types'; - -const getStatusFillColor = (status: ConnectionStatusKind, hover: boolean, isError: boolean): string => { - if (isError && hover) { - return '#21D072'; - } - if (isError) { - return '#40475C'; - } - - switch (status) { - case 'disconnected': - if (hover) { - return '#FFF'; - } - return '#BBB'; - case 'connecting': - return '#FFF'; - case 'disconnecting': - return '#FFF'; - default: - // connected - if (hover) { - return '#E43E3E'; - } - return '#21D072'; - } -}; - -export const PowerButton: FCWithChildren<{ - onClick?: (status: ConnectionStatusKind) => void; - isError?: boolean; - disabled?: boolean; - status: ConnectionStatusKind; - busy?: boolean; -}> = ({ onClick, disabled, status, isError }) => { - const [hover, setHover] = React.useState(false); - - const handleClick = () => { - if (disabled === true) { - return; - } - if (onClick) { - onClick(status); - } - }; - - const statusFillColor = getStatusFillColor(status, hover, Boolean(isError)); - - return ( - !disabled && setHover(true)} - onMouseLeave={() => !disabled && setHover(false)} - > - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ); -}; diff --git a/nym-connect-android/src/components/PowerButton/PowerButton.tsx b/nym-connect-android/src/components/PowerButton/PowerButton.tsx index 34def91f9f..59b30d9eed 100644 --- a/nym-connect-android/src/components/PowerButton/PowerButton.tsx +++ b/nym-connect-android/src/components/PowerButton/PowerButton.tsx @@ -74,10 +74,22 @@ export const PowerButton: FCWithChildren<{ return undefined; }; + let statusText: string; + switch (status) { + case 'connected': + statusText = 'stop'; + break; + case 'disconnected': + statusText = 'start'; + break; + default: + return ''; + } + return ( + + {statusText.toUpperCase()} + diff --git a/nym-connect-android/src/components/PowerButton/power-button.css b/nym-connect-android/src/components/PowerButton/power-button.css index a493d8df25..b73d01ca32 100644 --- a/nym-connect-android/src/components/PowerButton/power-button.css +++ b/nym-connect-android/src/components/PowerButton/power-button.css @@ -50,7 +50,7 @@ } circle, -path { +path, text { transition: stroke 0.5s, fill 0.5s; } diff --git a/nym-connect-android/src/components/TooltipInfo.tsx b/nym-connect-android/src/components/TooltipInfo.tsx index 2d76c6859e..438d9f8da3 100644 --- a/nym-connect-android/src/components/TooltipInfo.tsx +++ b/nym-connect-android/src/components/TooltipInfo.tsx @@ -4,10 +4,6 @@ import { ServiceProvider } from 'src/types/directory'; export const ServiceProviderInfo = ({ serviceProvider }: { serviceProvider: ServiceProvider }) => ( - - Connection info - - Gateway {serviceProvider.gateway} @@ -20,10 +16,6 @@ export const ServiceProviderInfo = ({ serviceProvider }: { serviceProvider: Serv export const GatwayWarningInfo = () => ( - - Connection issue - - Try disconnecting and connecting again ); diff --git a/nym-connect-android/src/pages/connection/Disconnected.tsx b/nym-connect-android/src/pages/connection/Disconnected.tsx index 86df776618..d3937fea24 100644 --- a/nym-connect-android/src/pages/connection/Disconnected.tsx +++ b/nym-connect-android/src/pages/connection/Disconnected.tsx @@ -38,7 +38,7 @@ export const Disconnected: FCWithChildren<{ fontWeight={600} textTransform="uppercase" textAlign="center" - fontSize="12px" + fontSize="14px" sx={{ wordSpacing: 1.5, letterSpacing: 1.5 }} color="warning.main" > diff --git a/nym-connect-android/src/pages/menu/index.tsx b/nym-connect-android/src/pages/menu/index.tsx index 4949639588..d58a08c25f 100644 --- a/nym-connect-android/src/pages/menu/index.tsx +++ b/nym-connect-android/src/pages/menu/index.tsx @@ -1,6 +1,6 @@ import React from 'react'; import { Apps, HelpOutline } from '@mui/icons-material'; -import { Stack, Link, List, ListItem, ListItemButton, ListItemIcon, ListItemText } from '@mui/material'; +import { Stack, Link, List, ListItem, ListItemButton, ListItemIcon, ListItemText, Typography } from '@mui/material'; import { Link as RouterLink } from 'react-router-dom'; import { AppVersion } from 'src/components/AppVersion'; @@ -19,7 +19,11 @@ export const Menu = () => ( {' '} - {item.title} + + + {item.title} + + diff --git a/nym-connect-android/src/theme/theme.tsx b/nym-connect-android/src/theme/theme.tsx index 18678fce98..58a1becba1 100644 --- a/nym-connect-android/src/theme/theme.tsx +++ b/nym-connect-android/src/theme/theme.tsx @@ -234,7 +234,7 @@ export const getDesignTokens = (mode: PaletteMode, isShipyard: boolean = false): 'Ubuntu', 'Helvetica Neue', ].join(','), - fontSize: 14, + fontSize: 16, fontWeightRegular: 500, button: { textTransform: 'none', From a5056007d46dd60ad46bc7235972a2da11478619 Mon Sep 17 00:00:00 2001 From: pierre Date: Wed, 15 Feb 2023 11:16:58 +0100 Subject: [PATCH 4/4] fix(nc-android): typo --- nym-connect-android/src/components/PowerButton/PowerButton.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nym-connect-android/src/components/PowerButton/PowerButton.tsx b/nym-connect-android/src/components/PowerButton/PowerButton.tsx index 59b30d9eed..bc399e70b9 100644 --- a/nym-connect-android/src/components/PowerButton/PowerButton.tsx +++ b/nym-connect-android/src/components/PowerButton/PowerButton.tsx @@ -83,7 +83,7 @@ export const PowerButton: FCWithChildren<{ statusText = 'start'; break; default: - return ''; + statusText = ''; } return (