feat(@desktop/settings): Add developer mode toggle
This commit is contained in:
parent
56743143bb
commit
60a3158cae
|
@ -38,6 +38,9 @@ method delete*[T](self: Controller[T]) =
|
||||||
method init*[T](self: Controller[T]) =
|
method init*[T](self: Controller[T]) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
method enableDeveloperFeatures*[T](self: Controller[T]) =
|
||||||
|
self.settingsService.enableDeveloperFeatures()
|
||||||
|
|
||||||
method toggleTelemetry*[T](self: Controller[T]) =
|
method toggleTelemetry*[T](self: Controller[T]) =
|
||||||
self.settingsService.toggleTelemetry()
|
self.settingsService.toggleTelemetry()
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,9 @@ method delete*(self: AccessInterface) {.base.} =
|
||||||
method init*(self: AccessInterface) {.base.} =
|
method init*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method enableDeveloperFeatures*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -11,6 +11,9 @@ method load*(self: AccessInterface) {.base.} =
|
||||||
method isLoaded*(self: AccessInterface): bool {.base.} =
|
method isLoaded*(self: AccessInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method enableDeveloperFeatures*(self: AccessInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
method toggleTelemetry*(self: AccessInterface) {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
|
|
@ -98,6 +98,9 @@ method isLoaded*[T](self: Module[T]): bool =
|
||||||
method viewDidLoad*(self: Module) =
|
method viewDidLoad*(self: Module) =
|
||||||
discard
|
discard
|
||||||
|
|
||||||
|
method enableDeveloperFeatures*[T](self: Module[T]) =
|
||||||
|
self.controller.enableDeveloperFeatures()
|
||||||
|
|
||||||
method toggleTelemetry*[T](self: Module[T]) =
|
method toggleTelemetry*[T](self: Module[T]) =
|
||||||
self.controller.toggleTelemetry()
|
self.controller.toggleTelemetry()
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@ QtObject:
|
||||||
isDebugEnabled: bool
|
isDebugEnabled: bool
|
||||||
isAutoMessageEnabled: bool
|
isAutoMessageEnabled: bool
|
||||||
|
|
||||||
proc setup(self: View) =
|
proc setup(self: View) =
|
||||||
self.QObject.setup
|
self.QObject.setup
|
||||||
|
|
||||||
proc delete*(self: View) =
|
proc delete*(self: View) =
|
||||||
|
@ -35,7 +35,7 @@ QtObject:
|
||||||
read = getIsTelemetryEnabled
|
read = getIsTelemetryEnabled
|
||||||
notify = isTelemetryEnabledChanged
|
notify = isTelemetryEnabledChanged
|
||||||
|
|
||||||
proc toggleTelemetry*(self: View) {.slot.} =
|
proc toggleTelemetry*(self: View) {.slot.} =
|
||||||
self.delegate.toggleTelemetry()
|
self.delegate.toggleTelemetry()
|
||||||
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
|
self.setIsTelemetryEnabled(not self.isTelemetryEnabled)
|
||||||
|
|
||||||
|
@ -52,7 +52,7 @@ QtObject:
|
||||||
read = getIsDebugEnabled
|
read = getIsDebugEnabled
|
||||||
notify = isDebugEnabledChanged
|
notify = isDebugEnabledChanged
|
||||||
|
|
||||||
proc toggleDebug*(self: View) {.slot.} =
|
proc toggleDebug*(self: View) {.slot.} =
|
||||||
self.delegate.toggleDebug()
|
self.delegate.toggleDebug()
|
||||||
self.setIsDebugEnabled(not self.isDebugEnabled)
|
self.setIsDebugEnabled(not self.isDebugEnabled)
|
||||||
|
|
||||||
|
@ -69,6 +69,12 @@ QtObject:
|
||||||
read = getIsAutoMessageEnabled
|
read = getIsAutoMessageEnabled
|
||||||
notify = isAutoMessageEnabledChanged
|
notify = isAutoMessageEnabledChanged
|
||||||
|
|
||||||
proc toggleAutoMessage*(self: View) {.slot.} =
|
proc toggleAutoMessage*(self: View) {.slot.} =
|
||||||
self.delegate.toggleAutoMessage()
|
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)
|
|
@ -18,6 +18,7 @@ logScope:
|
||||||
topics = "settings-service"
|
topics = "settings-service"
|
||||||
|
|
||||||
const DEFAULT_NETWORK_NAME = "mainnet_rpc"
|
const DEFAULT_NETWORK_NAME = "mainnet_rpc"
|
||||||
|
const TELEMETRY_BASE_URL = "https://telemetry.status.im"
|
||||||
|
|
||||||
type
|
type
|
||||||
Service* = ref object of ServiceInterface
|
Service* = ref object of ServiceInterface
|
||||||
|
@ -81,11 +82,19 @@ method getCurrentNetworkDetails*(self: Service): NetworkDetails =
|
||||||
if n.id == currNetwork:
|
if n.id == currNetwork:
|
||||||
return n
|
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) =
|
method toggleTelemetry*(self: Service) =
|
||||||
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
let telemetryServerUrl = status_go_settings.getSetting[string](Setting.TelemetryServerUrl)
|
||||||
var newValue = ""
|
var newValue = ""
|
||||||
if telemetryServerUrl == "":
|
if telemetryServerUrl == "":
|
||||||
newValue = "https://telemetry.status.im"
|
newValue = TELEMETRY_BASE_URL
|
||||||
|
|
||||||
discard status_go_settings.saveSetting(Setting.TelemetryServerUrl, newValue)
|
discard status_go_settings.saveSetting(Setting.TelemetryServerUrl, newValue)
|
||||||
|
|
||||||
|
@ -107,7 +116,6 @@ method toggleDebug*(self: Service) =
|
||||||
else:
|
else:
|
||||||
nodeConfig["LogLevel"] = newJString($LogLevel.INFO)
|
nodeConfig["LogLevel"] = newJString($LogLevel.INFO)
|
||||||
discard status_go_settings.saveSetting(Setting.NodeConfig, nodeConfig)
|
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 =
|
method isDebugEnabled*(self: Service): bool =
|
||||||
let nodeConfig = status_go_settings.getNodeConfig()
|
let nodeConfig = status_go_settings.getNodeConfig()
|
||||||
|
|
|
@ -8,7 +8,7 @@ export network_details
|
||||||
export node_config
|
export node_config
|
||||||
export upstream_config
|
export upstream_config
|
||||||
|
|
||||||
type
|
type
|
||||||
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
ServiceInterface* {.pure inheritable.} = ref object of RootObj
|
||||||
## Abstract class for this service access.
|
## Abstract class for this service access.
|
||||||
|
|
||||||
|
@ -68,3 +68,6 @@ method toggleDebug*(self: ServiceInterface) {.base.} =
|
||||||
|
|
||||||
method isDebugEnabled*(self: ServiceInterface): bool {.base.} =
|
method isDebugEnabled*(self: ServiceInterface): bool {.base.} =
|
||||||
raise newException(ValueError, "No implementation available")
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
||||||
|
method enableDeveloperFeatures*(self: ServiceInterface) {.base.} =
|
||||||
|
raise newException(ValueError, "No implementation available")
|
||||||
|
|
|
@ -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
|
// TODO: replace with StatusQ component
|
||||||
StatusSettingsLineButton {
|
StatusSettingsLineButton {
|
||||||
text: qsTr("Download messages")
|
text: qsTr("Download messages")
|
||||||
|
@ -398,22 +433,11 @@ ScrollView {
|
||||||
|
|
||||||
// TODO: replace with StatusQ component
|
// TODO: replace with StatusQ component
|
||||||
StatusSettingsLineButton {
|
StatusSettingsLineButton {
|
||||||
text: qsTr("Stickers/ENS on ropsten")
|
text: qsTr("Telemetry")
|
||||||
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")
|
|
||||||
isSwitch: true
|
isSwitch: true
|
||||||
switchChecked: root.store.profileModuleInst.isTelemetryEnabled
|
switchChecked: root.store.profileModuleInst.isTelemetryEnabled
|
||||||
onClicked: {
|
onClicked: {
|
||||||
openPopup(enableTelemetryConfirmationDialogComponent, {light: false})
|
openPopup(enableTelemetryConfirmationDialogComponent)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -429,11 +453,22 @@ ScrollView {
|
||||||
|
|
||||||
// TODO: replace with StatusQ component
|
// TODO: replace with StatusQ component
|
||||||
StatusSettingsLineButton {
|
StatusSettingsLineButton {
|
||||||
text: qsTr("Enable Auto message")
|
text: qsTr("Auto message")
|
||||||
isSwitch: true
|
isSwitch: true
|
||||||
switchChecked: root.store.profileModuleInst.isAutoMessageEnabled
|
switchChecked: root.store.profileModuleInst.isAutoMessageEnabled
|
||||||
onClicked: {
|
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
|
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 {
|
Component {
|
||||||
id: enableTelemetryConfirmationDialogComponent
|
id: enableTelemetryConfirmationDialogComponent
|
||||||
ConfirmationDialog {
|
ConfirmationDialog {
|
||||||
|
@ -489,7 +544,7 @@ ScrollView {
|
||||||
|
|
||||||
id: confirmDialog
|
id: confirmDialog
|
||||||
showCancelButton: true
|
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("disable") :
|
||||||
qsTr("enable"))
|
qsTr("enable"))
|
||||||
onConfirmButtonClicked: {
|
onConfirmButtonClicked: {
|
||||||
|
|
Loading…
Reference in New Issue