feat(@desktop/settings): [re-add] Add developer mode toggle

Fixes #4700
This commit is contained in:
Jonathan Rainville 2022-02-02 17:06:23 -05:00 committed by Iuri Matias
parent aeed9303cd
commit 967fff839b
7 changed files with 98 additions and 19 deletions

View File

@ -100,6 +100,13 @@ method setWakuV2LightClientEnabled*(self: Controller, enabled: bool) =
self.delegate.onWakuV2LightClientSet() self.delegate.onWakuV2LightClientSet()
method enableDeveloperFeatures*(self: Controller) =
discard self.settingsService.saveTelemetryServerUrl(DEFAULT_TELEMETRY_SERVER_URL)
discard self.settingsService.saveAutoMessageEnabled(true)
discard self.nodeConfigurationService.setDebugLevel(LogLevel.DEBUG)
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
method toggleTelemetry*(self: Controller) = method toggleTelemetry*(self: Controller) =
var value = "" var value = ""
if(not self.isTelemetryEnabled()): if(not self.isTelemetryEnabled()):

View File

@ -34,6 +34,9 @@ method getWakuV2LightClientEnabled*(self: AccessInterface): bool {.base.} =
method setWakuV2LightClientEnabled*(self: AccessInterface, enabled: bool) {.base.} = method setWakuV2LightClientEnabled*(self: AccessInterface, enabled: 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")

View File

@ -104,6 +104,9 @@ method onWakuV2LightClientSet*(self: Module) =
method isTelemetryEnabled*(self: Module): bool = method isTelemetryEnabled*(self: Module): bool =
self.controller.isTelemetryEnabled() self.controller.isTelemetryEnabled()
method enableDeveloperFeatures*(self: Module) =
self.controller.enableDeveloperFeatures()
method toggleTelemetry*(self: Module) = method toggleTelemetry*(self: Module) =
self.controller.toggleTelemetry() self.controller.toggleTelemetry()
@ -126,8 +129,7 @@ method toggleDebug*(self: Module) =
self.controller.toggleDebug() self.controller.toggleDebug()
method onDebugToggled*(self: Module) = method onDebugToggled*(self: Module) =
info "quit the app because of successful debug level changed" self.view.isDebugEnabledChanged()
quit(QuitSuccess) # quits the app TODO: change this to logout instead when supported
method addCustomNetwork*(self: Module, name: string, endpoint: string, networkId: int, networkType: string) = method addCustomNetwork*(self: Module, name: string, endpoint: string, networkId: int, networkType: string) =
var network: settings_service.Network var network: settings_service.Network

View File

@ -64,3 +64,6 @@ method toggleCommunitySection*(self: AccessInterface) {.base.} =
method toggleNodeManagementSection*(self: AccessInterface) {.base.} = method toggleNodeManagementSection*(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")

View File

@ -153,3 +153,6 @@ QtObject:
proc toggleNodeManagementSection*(self: View) {.slot.} = proc toggleNodeManagementSection*(self: View) {.slot.} =
self.delegate.toggleNodeManagementSection() self.delegate.toggleNodeManagementSection()
proc enableDeveloperFeatures*(self: View) {.slot.} =
self.delegate.enableDeveloperFeatures()

View File

@ -98,6 +98,13 @@ QtObject {
root.advancedModule.toggleDebug() root.advancedModule.toggleDebug()
} }
function enableDeveloperFeatures() {
if(!root.advancedModule)
return
root.advancedModule.enableDeveloperFeatures()
}
function addCustomNetwork(name, endpoint, networkId, networkType) { function addCustomNetwork(name, endpoint, networkId, networkType) {
if(!root.advancedModule) if(!root.advancedModule)
return return

View File

@ -374,6 +374,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.advancedStore.isTelemetryEnabled ||
!root.advancedStore.isDebugEnabled ||
!root.advancedStore.isAutoMessageEnabled
}
onClicked: {
Global.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")
@ -386,22 +421,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.advancedStore.currentNetworkId === 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.advancedStore.isTelemetryEnabled switchChecked: root.advancedStore.isTelemetryEnabled
onClicked: { onClicked: {
Global.openPopup(enableTelemetryConfirmationDialogComponent, {light: false}) Global.openPopup(enableTelemetryConfirmationDialogComponent)
} }
} }
@ -417,11 +441,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.advancedStore.isAutoMessageEnabled switchChecked: root.advancedStore.isAutoMessageEnabled
onClicked: { onClicked: {
Global.openPopup(enableAutoMessageConfirmationDialogComponent, {light: false}) Global.openPopup(enableAutoMessageConfirmationDialogComponent)
}
}
// TODO: replace with StatusQ component
StatusSettingsLineButton {
text: qsTr("Stickers/ENS on ropsten")
visible: root.advancedStore.currentNetworkId === Constants.networkRopsten
isSwitch: true
switchChecked: localAccountSensitiveSettings.stickersEnsRopsten
onClicked: {
localAccountSensitiveSettings.stickersEnsRopsten = !localAccountSensitiveSettings.stickersEnsRopsten
} }
} }
} }
@ -436,6 +471,25 @@ ScrollView {
advancedStore: root.advancedStore advancedStore: root.advancedStore
} }
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.advancedStore.enableDeveloperFeatures)
close()
}
onCancelButtonClicked: {
close()
}
}
}
Component { Component {
id: enableTelemetryConfirmationDialogComponent id: enableTelemetryConfirmationDialogComponent
ConfirmationDialog { ConfirmationDialog {
@ -479,7 +533,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.advancedStore.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.advancedStore.isDebugEnabled ?
qsTr("disable") : qsTr("disable") :
qsTr("enable")) qsTr("enable"))
onConfirmButtonClicked: { onConfirmButtonClicked: {