-
Notifications
You must be signed in to change notification settings - Fork 54
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: backend version based feature toggles (#647)
* feat(api): add getinfo request to JmWalletApi * chore: add server information to ServiceInfoContext * feat(features): feature toggles based on backend version * ui: hide import wallet button on unsupported backend version * ui: hide rescan chain button on unsupported backend version * fix: handle nullable serviceInfo and fix tests * test: verify import wallet is not displayed
- Loading branch information
1 parent
a559e1e
commit 6b45718
Showing
11 changed files
with
176 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,3 +19,5 @@ | |
.env.production.local | ||
|
||
npm-debug.log* | ||
|
||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { ServiceInfo } from '../context/ServiceInfoContext' | ||
|
||
interface Features { | ||
importWallet: SemVer | ||
rescanChain: SemVer | ||
} | ||
|
||
const features: Features = { | ||
importWallet: { major: 0, minor: 9, patch: 10 }, // added in https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1461 | ||
rescanChain: { major: 0, minor: 9, patch: 10 }, // added in https://github.com/JoinMarket-Org/joinmarket-clientserver/pull/1461 | ||
} | ||
|
||
type Feature = keyof Features | ||
|
||
const __isFeatureEnabled = (name: Feature, version: SemVer): boolean => { | ||
const target = features[name] | ||
return ( | ||
version.major > target.major || | ||
(version.major === target.major && version.minor > target.minor) || | ||
(version.major === target.major && version.minor === target.minor && version.patch >= target.patch) | ||
) | ||
} | ||
|
||
export const isFeatureEnabled = (name: Feature, serviceInfo: ServiceInfo): boolean => { | ||
return !!serviceInfo.server?.version && __isFeatureEnabled(name, serviceInfo.server.version) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters