From 45a7d8b449b125d20a1addaaea57c0d7baa89453 Mon Sep 17 00:00:00 2001 From: Andrea Scartabelli Date: Wed, 7 Feb 2024 16:56:35 +0100 Subject: [PATCH] Allow the web wallet to be served in a sub folder Resolves #1362 --- web-wallet/CHANGELOG.md | 2 + web-wallet/README.md | 4 +- .../lib/components/AppAnchor/AppAnchor.svelte | 17 ++++ .../AppAnchorButton/AppAnchorButton.svelte | 15 ++++ .../OperationResult/OperationResult.svelte | 6 +- .../src/lib/components/Send/Send.svelte | 4 +- .../src/lib/components/Stake/Stake.svelte | 4 +- .../Transactions/Transactions.svelte | 13 +-- .../components/__tests__/AppAnchor.spec.js | 83 +++++++++++++++++++ .../__tests__/AppAnchorButton.spec.js | 67 +++++++++++++++ .../components/__tests__/Transactions.spec.js | 7 +- .../__snapshots__/AppAnchor.spec.js.snap | 13 +++ .../AppAnchorButton.spec.js.snap | 17 ++++ .../OperationResult.spec.js.snap | 12 ++- .../__snapshots__/Transactions.spec.js.snap | 10 ++- web-wallet/src/lib/components/index.js | 2 + .../dusk/components/Wizard/WizardStep.svelte | 8 +- .../navigation/__tests__/addBasePath.spec.js | 26 ++++++ .../src/lib/navigation/__tests__/goto.spec.js | 51 ++++++++++++ .../lib/navigation/__tests__/redirect.spec.js | 51 ++++++++++++ web-wallet/src/lib/navigation/addBasePath.js | 13 +++ web-wallet/src/lib/navigation/goto.js | 8 ++ web-wallet/src/lib/navigation/index.js | 3 + web-wallet/src/lib/navigation/redirect.js | 12 +++ web-wallet/src/routes/(app)/+layout.js | 2 +- .../src/routes/(app)/__tests__/layout.spec.js | 4 +- .../src/routes/(app)/dashboard/+layout.svelte | 4 +- .../__snapshots__/layout.spec.js.snap | 9 +- .../__tests__/__snapshots__/page.spec.js.snap | 14 +++- .../__tests__/__snapshots__/page.spec.js.snap | 3 +- .../src/routes/(app)/settings/+page.svelte | 8 +- .../__tests__/__snapshots__/page.spec.js.snap | 6 +- .../(app)/settings/__tests__/page.spec.js | 4 +- .../src/routes/(welcome)/login/+page.svelte | 9 +- .../__tests__/__snapshots__/page.spec.js.snap | 9 +- .../(welcome)/login/__tests__/page.spec.js | 4 +- .../src/routes/(welcome)/setup/+page.svelte | 8 +- .../(welcome)/setup/TermsOfService.svelte | 14 ++-- .../__tests__/__snapshots__/page.spec.js.snap | 9 +- .../(welcome)/setup/create/+page.svelte | 2 +- .../__tests__/__snapshots__/page.spec.js.snap | 4 +- .../(welcome)/setup/restore/+page.svelte | 2 +- .../__tests__/__snapshots__/page.spec.js.snap | 4 +- web-wallet/src/routes/+page.js | 2 +- web-wallet/src/routes/__tests__/page.spec.js | 32 +++++++ web-wallet/svelte.config.js | 7 +- web-wallet/vite-setup.js | 6 ++ 47 files changed, 537 insertions(+), 77 deletions(-) create mode 100644 web-wallet/src/lib/components/AppAnchor/AppAnchor.svelte create mode 100644 web-wallet/src/lib/components/AppAnchorButton/AppAnchorButton.svelte create mode 100644 web-wallet/src/lib/components/__tests__/AppAnchor.spec.js create mode 100644 web-wallet/src/lib/components/__tests__/AppAnchorButton.spec.js create mode 100644 web-wallet/src/lib/components/__tests__/__snapshots__/AppAnchor.spec.js.snap create mode 100644 web-wallet/src/lib/components/__tests__/__snapshots__/AppAnchorButton.spec.js.snap create mode 100644 web-wallet/src/lib/navigation/__tests__/addBasePath.spec.js create mode 100644 web-wallet/src/lib/navigation/__tests__/goto.spec.js create mode 100644 web-wallet/src/lib/navigation/__tests__/redirect.spec.js create mode 100644 web-wallet/src/lib/navigation/addBasePath.js create mode 100644 web-wallet/src/lib/navigation/goto.js create mode 100644 web-wallet/src/lib/navigation/index.js create mode 100644 web-wallet/src/lib/navigation/redirect.js create mode 100644 web-wallet/src/routes/__tests__/page.spec.js diff --git a/web-wallet/CHANGELOG.md b/web-wallet/CHANGELOG.md index e0bff246e3..34276608df 100644 --- a/web-wallet/CHANGELOG.md +++ b/web-wallet/CHANGELOG.md @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Add `fiatPrice` optional property to Balance component [#1331](https://github.com/dusk-network/rusk/pull/1331) - Add ability to revert words when entering the mnemonic phrase [#1333](https://github.com/dusk-network/rusk/pull/1333) - Add missing error handling when querying the quote API [#1344](https://github.com/dusk-network/rusk/pull/1334) +- Add `VITE_BASE_PATH` env variable [#1366](https://github.com/dusk-network/rusk/pull/1366) +- Add possibility to serve the web wallet from a sub folder [#1366](https://github.com/dusk-network/rusk/pull/1366) ### Changed diff --git a/web-wallet/README.md b/web-wallet/README.md index 6df2b7eeba..ec97e6e461 100644 --- a/web-wallet/README.md +++ b/web-wallet/README.md @@ -30,6 +30,8 @@ The application defines these variables by reading a local `.env` file containin N.B. the current `0.1.2` version of the library has no option to pick the network and uses the `LOCAL_NODE` only. The current testnet address is set in that variable in the example below: ``` +# can be empty string, must start with a slash otherwise, must not end with a slash +VITE_BASE_PATH="" VITE_CONTRACT_STAKE_DISABLED=false VITE_CONTRACT_TRANSFER_DISABLED=false VITE_CURRENT_NODE=${VITE_LOCAL_NODE} @@ -67,4 +69,4 @@ To run a local node different steps are needed, so please read the [related sect ## Running a local Rusk node -To run a local node, follow the instructions outlined in the [Rusk's readme](https://github.com/dusk-network/rusk). \ No newline at end of file +To run a local node, follow the instructions outlined in the [Rusk's readme](https://github.com/dusk-network/rusk). diff --git a/web-wallet/src/lib/components/AppAnchor/AppAnchor.svelte b/web-wallet/src/lib/components/AppAnchor/AppAnchor.svelte new file mode 100644 index 0000000000..ec34dbd65b --- /dev/null +++ b/web-wallet/src/lib/components/AppAnchor/AppAnchor.svelte @@ -0,0 +1,17 @@ + + + + + + + diff --git a/web-wallet/src/lib/components/AppAnchorButton/AppAnchorButton.svelte b/web-wallet/src/lib/components/AppAnchorButton/AppAnchorButton.svelte new file mode 100644 index 0000000000..58cb058ec8 --- /dev/null +++ b/web-wallet/src/lib/components/AppAnchorButton/AppAnchorButton.svelte @@ -0,0 +1,15 @@ + + + + + diff --git a/web-wallet/src/lib/components/OperationResult/OperationResult.svelte b/web-wallet/src/lib/components/OperationResult/OperationResult.svelte index 395ef7c424..a0159c4c4d 100644 --- a/web-wallet/src/lib/components/OperationResult/OperationResult.svelte +++ b/web-wallet/src/lib/components/OperationResult/OperationResult.svelte @@ -2,13 +2,13 @@