feat(@desktop/settings): Add developer mode toggle

This commit is contained in:
Anthony Laibe 2021-12-07 10:31:21 +01:00 committed by Anthony Laibe
parent 56743143bb
commit 60a3158cae
8 changed files with 108 additions and 24 deletions

View File

@ -38,6 +38,9 @@ method delete*[T](self: Controller[T]) =
method init*[T](self: Controller[T]) =
discard
method enableDeveloperFeatures*[T](self: Controller[T]) =
self.settingsService.enableDeveloperFeatures()
method toggleTelemetry*[T](self: Controller[T]) =
self.settingsService.toggleTelemetry()

View File

@ -9,6 +9,9 @@ method delete*(self: AccessInterface) {.base.} =
method init*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method enableDeveloperFeatures*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleTelemetry*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -11,6 +11,9 @@ method load*(self: AccessInterface) {.base.} =
method isLoaded*(self: AccessInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method enableDeveloperFeatures*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")
method toggleTelemetry*(self: AccessInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -98,6 +98,9 @@ method isLoaded*[T](self: Module[T]): bool =
method viewDidLoad*(self: Module) =
discard
method enableDeveloperFeatures*[T](self: Module[T]) =
self.controller.enableDeveloperFeatures()
method toggleTelemetry*[T](self: Module[T]) =
self.controller.toggleTelemetry()

View File

@ -11,7 +11,7 @@ QtObject:
isDebugEnabled: bool
isAutoMessageEnabled: bool
proc setup(self: View) =
proc setup(self: View) =
self.QObject.setup
proc delete*(self: View) =
@ -35,7 +35,7 @@ QtObject:
read = getIsTelemetryEnabled
notify = isTelemetryEnabledChanged
proc toggleTelemetry*(self: View) {.slot.} =
proc toggleTelemetry*(self: View) {.slot.} =
self.delegate.toggleTelemetry()
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
@ -52,7 +52,7 @@ QtObject:
read = getIsDebugEnabled
notify = isDebugEnabledChanged
proc toggleDebug*(self: View) {.slot.} =
proc toggleDebug*(self: View) {.slot.} =
self.delegate.toggleDebug()
self.setIsDebugEnabled(not self.isDebugEnabled)
@ -69,6 +69,12 @@ QtObject:
read = getIsAutoMessageEnabled
notify = isAutoMessageEnabledChanged
proc toggleAutoMessage*(self: View) {.slot.} =
proc toggleAutoMessage*(self: View) {.slot.} =
self.delegate.toggleAutoMessage()
self.setIsAutoMessageEnabled(not self.isAutoMessageEnabled)
self.setIsAutoMessageEnabled(not self.isAutoMessageEnabled)
proc enableDeveloperFeatures*(self: View) {.slot.} =
self.delegate.enableDeveloperFeatures()
self.setIsTelemetryEnabled(true)
self.setIsDebugEnabled(true)
self.setIsAutoMessageEnabled(true)

View File

@ -18,6 +18,7 @@ logScope:
topics = "settings-service"
const DEFAULT_NETWORK_NAME = "mainnet_rpc"
const TELEMETRY_BASE_URL = "https://telemetry.status.im"
type
Service* = ref object of ServiceInterface
@ -81,11 +82,19 @@ method getCurrentNetworkDetails*(self: Service): NetworkDetails =
if n.id == currNetwork:
return n
method enableDeveloperFeatures*(self: Service) =
discard status_go_settings.saveSetting(Setting.TelemetryServerUrl, TELEMETRY_BASE_URL)
discard status_go_settings.saveSetting(Setting.AutoMessageEnabled, true)
var nodeConfig = status_go_settings.getNodeConfig()
nodeConfig["LogLevel"] = newJString($LogLevel.DEBUG)
discard status_go_settings.saveSetting(Setting.NodeConfig, nodeConfig)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
method toggleTelemetry*(self: Service) =
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
var newValue = ""
if telemetryServerUrl == "":
newValue = "https://telemetry.status.im"
newValue = TELEMETRY_BASE_URL
discard status_go_settings.saveSetting(Setting.TelemetryServerUrl, newValue)
@ -107,7 +116,6 @@ method toggleDebug*(self: Service) =
else:
nodeConfig["LogLevel"] = newJString($LogLevel.INFO)
discard status_go_settings.saveSetting(Setting.NodeConfig, nodeConfig)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
method isDebugEnabled*(self: Service): bool =
let nodeConfig = status_go_settings.getNodeConfig()

View File

@ -8,7 +8,7 @@ export network_details
export node_config
export upstream_config
type
type
ServiceInterface* {.pure inheritable.} = ref object of RootObj
## Abstract class for this service access.
@ -68,3 +68,6 @@ method toggleDebug*(self: ServiceInterface) {.base.} =
method isDebugEnabled*(self: ServiceInterface): bool {.base.} =
raise newException(ValueError, "No implementation available")
method enableDeveloperFeatures*(self: ServiceInterface) {.base.} =
raise newException(ValueError, "No implementation available")

View File

@ -386,6 +386,41 @@ ScrollView {
}
}
StatusSectionHeadline {
text: qsTr("Developer features")
topPadding: Style.current.bigPadding
bottomPadding: Style.current.padding
}
Separator {
anchors.topMargin: Style.current.bigPadding
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
}
StatusSettingsLineButton {
text: qsTr("Full developer mode")
isEnabled: {
return !localAccountSensitiveSettings.downloadChannelMessagesEnabled ||
!root.store.profileModuleInst.isTelemetryEnabled ||
!root.store.profileModuleInst.isDebugEnabled ||
!root.store.profileModuleInst.isAutoMessageEnabled
}
onClicked: {
openPopup(enableDeveloperFeaturesConfirmationDialogComponent)
}
}
Separator {
anchors.topMargin: Style.current.bigPadding
anchors.left: parent.left
anchors.leftMargin: -Style.current.padding
anchors.right: parent.right
anchors.rightMargin: -Style.current.padding
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Download messages")
@ -398,22 +433,11 @@ ScrollView {
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Stickers/ENS on ropsten")
visible: root.store.currentNetwork === Constants.networkRopsten
isSwitch: true
switchChecked: localAccountSensitiveSettings.stickersEnsRopsten
onClicked: {
localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten
}
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Enable Telemetry")
text: qsTr("Telemetry")
isSwitch: true
switchChecked: root.store.profileModuleInst.isTelemetryEnabled
onClicked: {
openPopup(enableTelemetryConfirmationDialogComponent, {light: false})
openPopup(enableTelemetryConfirmationDialogComponent)
}
}
@ -429,11 +453,22 @@ ScrollView {
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Enable Auto message")
text: qsTr("Auto message")
isSwitch: true
switchChecked: root.store.profileModuleInst.isAutoMessageEnabled
onClicked: {
openPopup(enableAutoMessageConfirmationDialogComponent, {light: false})
openPopup(enableAutoMessageConfirmationDialogComponent)
}
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Stickers/ENS on ropsten")
visible: root.store.currentNetwork === Constants.networkRopsten
isSwitch: true
switchChecked: localAccountSensitiveSettings.stickersEnsRopsten
onClicked: {
localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten
}
}
}
@ -446,6 +481,26 @@ ScrollView {
id: fleetModal
}
Component {
id: enableDeveloperFeaturesConfirmationDialogComponent
ConfirmationDialog {
property bool mode: false
id: confirmDialog
showCancelButton: true
confirmationText: qsTr("Are you sure you want to enable all the develoer features? The app will be restarted.")
onConfirmButtonClicked: {
localAccountSensitiveSettings.downloadChannelMessagesEnabled = true
Qt.callLater(root.store.profileModuleInst.enableDeveloperFeatures)
close()
}
onCancelButtonClicked: {
close()
}
}
}
Component {
id: enableTelemetryConfirmationDialogComponent
ConfirmationDialog {
@ -489,7 +544,7 @@ ScrollView {
id: confirmDialog
showCancelButton: true
confirmationText: qsTr("Are you sure you want to %1 debug mode? The app will be restarted for this change to take effect.").arg(root.store.profileModuleInst.isDebugEnabled ?
confirmationText: qsTr("Are you sure you want to %1 debug mode? You need to restart the app for this change to take effect.").arg(root.store.profileModuleInst.isDebugEnabled ?
qsTr("disable") :
qsTr("enable"))
onConfirmButtonClicked: {