Update admin drop down

This commit is contained in:
Garth Vander Houwen 2024-08-18 17:15:55 -07:00
parent 8b2bc246dd
commit dee96175bf
5 changed files with 24 additions and 16 deletions

View file

@ -60,7 +60,7 @@ extension NodeInfoEntity {
}
var canRemoteAdmin: Bool {
if !(securityConfig?.adminKey?.isEmpty ?? true) {
if UserDefaults.enableAdministration {
return true
} else {
let adminChannel = myInfo?.channels?.filter { ($0 as AnyObject).name?.lowercased() == "admin" }

View file

@ -71,6 +71,7 @@ extension UserDefaults {
case modemPreset
case firmwareVersion
case environmentEnableWeatherKit
case enableAdministration
case testIntEnum
}
@ -162,6 +163,9 @@ extension UserDefaults {
@UserDefault(.environmentEnableWeatherKit, defaultValue: true)
static var environmentEnableWeatherKit: Bool
@UserDefault(.enableAdministration, defaultValue: false)
static var enableAdministration: Bool
@UserDefault(.testIntEnum, defaultValue: .one)
static var testIntEnum: TestIntEnum
}

View file

@ -13,6 +13,7 @@ struct AppSettings: View {
@State private var isPresentingCoreDataResetConfirm = false
@State private var isPresentingDeleteMapTilesConfirm = false
@AppStorage("environmentEnableWeatherKit") private var environmentEnableWeatherKit: Bool = true
@AppStorage("enableAdministration") private var enableAdministration: Bool = false
var body: some View {
VStack {
Form {
@ -23,6 +24,10 @@ struct AppSettings: View {
UIApplication.shared.open(url)
}
}
Toggle(isOn: $enableAdministration) {
Label("Administration", systemImage: "gearshape.2")
}
.toggleStyle(SwitchToggleStyle(tint: .accentColor))
}
Section(header: Text("environment")) {
VStack(alignment: .leading) {

View file

@ -50,6 +50,18 @@ struct SaveChannelQRCode: View {
.controlSize(.large)
.padding()
.disabled(!connectedToDevice)
#if targetEnvironment(macCatalyst)
Button {
dismiss()
} label: {
Label("cancel", systemImage: "xmark")
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
#endif
} else {
Button {
dismiss()
@ -62,19 +74,6 @@ struct SaveChannelQRCode: View {
.controlSize(.large)
.padding()
}
#if targetEnvironment(macCatalyst)
Button {
dismiss()
} label: {
Label("cancel", systemImage: "xmark")
}
.buttonStyle(.bordered)
.buttonBorderShape(.capsule)
.controlSize(.large)
.padding()
#endif
}
}
.onAppear {

View file

@ -362,7 +362,7 @@ struct Settings: View {
Image(systemName: "antenna.radiowaves.left.and.right")
}
.tag(Int(node.num))
} else if node.canRemoteAdmin { /// Nodes using the new PKI system
} else if node.canRemoteAdmin && UserDefaults.enableAdministration && node.sessionPasskey != nil { /// Nodes using the new PKI system
Label {
Text("Remote: \(node.user?.longName ?? "unknown".localized)")
} icon: {
@ -376,7 +376,7 @@ struct Settings: View {
Image(systemName: "av.remote")
}
.tag(Int(node.num))
} else if hasAdmin {
} else if hasAdmin || node.user?.pkiEncrypted ?? false {
Label {
Text("Request Admin: \(node.user?.longName ?? "unknown".localized)")
} icon: {