From 57fc600d5e4c69810f8ddad2bd549494f861b8ed Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Luk=C3=A1=C5=A1=20Tinkl?= Date: Wed, 26 Jul 2023 16:34:21 +0200 Subject: [PATCH] feat: Add status-go version to About screen - Settings/About now displays the `status-go` version, read from its `VERSION` file - use the actual app icon, to differentiate between prod/dev version - make the version numbers clickable, taking the user to either the release notes (prod) or the GH commit browser (dev) - add "Is production" switch to the About page in storybook Closes #11424 --- Makefile | 3 ++ .../main/profile_section/about/controller.nim | 3 ++ .../profile_section/about/io_interface.nim | 3 ++ .../main/profile_section/about/module.nim | 3 ++ .../main/profile_section/about/view.nim | 3 ++ src/app_service/service/about/service.nim | 3 ++ src/constants.nim | 3 +- storybook/pages/AboutViewPage.qml | 24 ++++++++++----- ui/app/AppLayouts/Profile/ProfileLayout.qml | 12 +++++--- .../Profile/stores/ProfileSectionStore.qml | 4 +++ ui/app/AppLayouts/Profile/views/AboutView.qml | 30 +++++++++++++++---- 11 files changed, 73 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 2d79baa327..02f9bf4aff 100644 --- a/Makefile +++ b/Makefile @@ -230,8 +230,11 @@ NIM_PARAMS += --outdir:./bin # App version VERSIONFILE=VERSION +SGVERSIONFILE=vendor/status-go/VERSION DESKTOP_VERSION=`cat $(VERSIONFILE)` +STATUSGO_VERSION=`cat $(SGVERSIONFILE)` NIM_PARAMS += -d:DESKTOP_VERSION="$(DESKTOP_VERSION)" +NIM_PARAMS += -d:STATUSGO_VERSION="$(STATUSGO_VERSION)" GIT_COMMIT=`git log --pretty=format:'%h' -n 1` NIM_PARAMS += -d:GIT_COMMIT="$(GIT_COMMIT)" diff --git a/src/app/modules/main/profile_section/about/controller.nim b/src/app/modules/main/profile_section/about/controller.nim index d49ce6aee3..090f0d5678 100644 --- a/src/app/modules/main/profile_section/about/controller.nim +++ b/src/app/modules/main/profile_section/about/controller.nim @@ -34,3 +34,6 @@ proc checkForUpdates*(self: Controller) = proc getNodeVersion*(self: Controller): string = return self.aboutService.getNodeVersion() + +proc getStatusGoVersion*(self: Controller): string = + self.aboutService.getStatusGoVersion() diff --git a/src/app/modules/main/profile_section/about/io_interface.nim b/src/app/modules/main/profile_section/about/io_interface.nim index 9fa10db4c4..84f12d309e 100644 --- a/src/app/modules/main/profile_section/about/io_interface.nim +++ b/src/app/modules/main/profile_section/about/io_interface.nim @@ -17,6 +17,9 @@ method getAppVersion*(self: AccessInterface): string {.base.} = method getNodeVersion*(self: AccessInterface): string {.base.} = raise newException(ValueError, "No implementation available") +method getStatusGoVersion*(self: AccessInterface): string {.base.} = + raise newException(ValueError, "No implementation available") + method versionFetched*(self: AccessInterface, available: bool, version: string, url: string) {.base.} = raise newException(ValueError, "No implementation available") diff --git a/src/app/modules/main/profile_section/about/module.nim b/src/app/modules/main/profile_section/about/module.nim index 243aeb3b95..a9ff8b5dd1 100644 --- a/src/app/modules/main/profile_section/about/module.nim +++ b/src/app/modules/main/profile_section/about/module.nim @@ -52,6 +52,9 @@ method getAppVersion*(self: Module): string = method getNodeVersion*(self: Module): string = return self.controller.getNodeVersion() +method getStatusGoVersion*(self: Module): string = + self.controller.getStatusGoVersion() + method checkForUpdates*(self: Module) = self.controller.checkForUpdates() diff --git a/src/app/modules/main/profile_section/about/view.nim b/src/app/modules/main/profile_section/about/view.nim index 835b7adacf..a9ec3561d1 100644 --- a/src/app/modules/main/profile_section/about/view.nim +++ b/src/app/modules/main/profile_section/about/view.nim @@ -24,6 +24,9 @@ QtObject: proc nodeVersion*(self: View): string {.slot.} = return self.delegate.getNodeVersion() + proc getStatusGoVersion*(self: View): string {.slot.} = + return self.delegate.getStatusGoVersion() + proc appVersionFetched*(self: View, available: bool, version: string, url: string) {.signal.} proc fetchingChanged(self: View) {.signal.} diff --git a/src/app_service/service/about/service.nim b/src/app_service/service/about/service.nim index b74a9d4a56..77fcfac778 100644 --- a/src/app_service/service/about/service.nim +++ b/src/app_service/service/about/service.nim @@ -53,6 +53,9 @@ QtObject: except Exception as e: error "Error getting Node version" + proc getStatusGoVersion*(self: Service): string = + STATUSGO_VERSION + proc checkForUpdates*(self: Service) = try: discard status_about.checkForUpdates(types.Mainnet, APP_UPDATES_ENS, self.getAppVersion()) diff --git a/src/constants.nim b/src/constants.nim index a9269be0bd..f5db547643 100644 --- a/src/constants.nim +++ b/src/constants.nim @@ -81,10 +81,11 @@ proc ensureDirectories*(dataDir, tmpDir, logDir: string) = # This is changed during compilation by reading the VERSION file const DESKTOP_VERSION {.strdefine.} = "0.0.0" +const STATUSGO_VERSION* {.strdefine.} = "0.0.0" # This is changed during compilation by executing git command const GIT_COMMIT* {.strdefine.} = "" -const APP_VERSION* = if defined(production): DESKTOP_VERSION else: fmt("git master {GIT_COMMIT}") +const APP_VERSION* = if defined(production): DESKTOP_VERSION else: fmt("{GIT_COMMIT}") # Name of the test environment var to check for const TEST_ENVIRONMENT_VAR* = "TEST_ENVIRONMENT" diff --git a/storybook/pages/AboutViewPage.qml b/storybook/pages/AboutViewPage.qml index 9b312de4eb..86f5135c4a 100644 --- a/storybook/pages/AboutViewPage.qml +++ b/storybook/pages/AboutViewPage.qml @@ -21,22 +21,33 @@ SplitView { contentWidth: parent.width store: QtObject { - readonly property bool isProduction: false + readonly property bool isProduction: ctrlProduction.checked function checkForUpdates() { logs.logEvent("store::checkForUpdates") } function getCurrentVersion() { - return "storybook-version" + logs.logEvent("store::getCurrentVersion") + return isProduction ? "0.13.2" : "45784cf0c" + } + + function getStatusGoVersion() { + logs.logEvent("store::getStatusGoVersion") + return "0.162.9" } function getReleaseNotes() { logs.logEvent("store::getReleaseNotes") + const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1" : + "https://github.com/status-im/status-desktop/commit/%1" + + openLink(link.arg(getCurrentVersion())) } function openLink(url) { logs.logEvent("store::openLink", ["url"], arguments) + Qt.openUrlExternally(url) } } @@ -52,13 +63,12 @@ SplitView { } } - Control { + Switch { + id: ctrlProduction SplitView.minimumWidth: 300 SplitView.preferredWidth: 300 - - font.pixelSize: 13 - - // model editor will go here + text: "Production" + checked: true } } diff --git a/ui/app/AppLayouts/Profile/ProfileLayout.qml b/ui/app/AppLayouts/Profile/ProfileLayout.qml index 54bed92dd7..16de5ef47a 100644 --- a/ui/app/AppLayouts/Profile/ProfileLayout.qml +++ b/ui/app/AppLayouts/Profile/ProfileLayout.qml @@ -283,11 +283,15 @@ StatusSectionLayout { return root.store.getCurrentVersion() } - function getReleaseNotes() { - const link = isProduction ? "https://github.com/status-im/status-desktop/releases/%1".arg(getCurrentVersion()) : - "https://github.com/status-im/status-desktop/" + function getStatusGoVersion() { + return root.store.getStatusGoVersion() + } - openLink(link) + function getReleaseNotes() { + const link = isProduction ? "https://github.com/status-im/status-desktop/releases/tag/%1" : + "https://github.com/status-im/status-desktop/commit/%1" + + openLink(link.arg(getCurrentVersion())) } function openLink(url) { diff --git a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml index c6bb152d20..acc8d48a3f 100644 --- a/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml +++ b/ui/app/AppLayouts/Profile/stores/ProfileSectionStore.qml @@ -157,6 +157,10 @@ QtObject { return aboutModuleInst.getCurrentVersion() } + function getStatusGoVersion() { + return aboutModuleInst.getStatusGoVersion() + } + function nodeVersion() { return aboutModuleInst.nodeVersion() } diff --git a/ui/app/AppLayouts/Profile/views/AboutView.qml b/ui/app/AppLayouts/Profile/views/AboutView.qml index 355742e601..45407ede16 100644 --- a/ui/app/AppLayouts/Profile/views/AboutView.qml +++ b/ui/app/AppLayouts/Profile/views/AboutView.qml @@ -32,23 +32,23 @@ SettingsContentBase { Column { Layout.fillWidth: true - Image { + StatusIcon { id: statusIcon width: 80 height: 80 - fillMode: Image.PreserveAspectFit - source: Style.png("status-logo") + icon: root.store.isProduction ? Style.svg("status-logo-circle") : Style.svg("status-logo-dev-circle") anchors.horizontalCenter: parent.horizontalCenter - cache: false } Item { width: 1; height: 8} - StatusBaseText { + StatusLinkText { anchors.horizontalCenter: parent.horizontalCenter font.pixelSize: 22 font.bold: true - text: root.store.getCurrentVersion() + normalColor: Theme.palette.directColor1 + text: (root.store.isProduction ? "" : "git:") + root.store.getCurrentVersion() + onClicked: root.store.getReleaseNotes() } StatusBaseText { @@ -59,11 +59,29 @@ SettingsContentBase { Item { width: 1; height: 17} + StatusLinkText { + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 17 + font.bold: true + normalColor: Theme.palette.directColor1 + text: root.store.getStatusGoVersion() + onClicked: root.store.openLink("https://github.com/status-im/status-go/tree/v%1".arg(root.store.getStatusGoVersion())) + } + + StatusBaseText { + anchors.horizontalCenter: parent.horizontalCenter + font.pixelSize: 13 + text: qsTr("Status Go Version") + } + + Item { width: 1; height: 17} + StatusButton { anchors.horizontalCenter: parent.horizontalCenter size: StatusBaseButton.Size.Small icon.name: "info" text: qsTr("Release Notes") + visible: root.store.isProduction onClicked: { root.store.getReleaseNotes() }