mirror of
https://github.com/maxgoedjen/secretive.git
synced 2026-03-06 01:37:22 +01:00
Add descriptions for unavailable keys (#708)
* Describe unavailable key types * Cleanup
This commit is contained in:
@@ -60,16 +60,17 @@ extension Preview {
|
||||
let id = UUID()
|
||||
var name: String { "Modifiable Preview Store" }
|
||||
let secrets: [Secret]
|
||||
var supportedKeyTypes: [KeyType] {
|
||||
if #available(macOS 26, *) {
|
||||
[
|
||||
var supportedKeyTypes: KeyAvailability {
|
||||
return KeyAvailability(
|
||||
available: [
|
||||
.ecdsa256,
|
||||
.mldsa65,
|
||||
.mldsa87,
|
||||
.mldsa87
|
||||
],
|
||||
unavailable: [
|
||||
.init(keyType: .ecdsa384, reason: .macOSUpdateRequired)
|
||||
]
|
||||
} else {
|
||||
[.ecdsa256]
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
init(secrets: [Secret]) {
|
||||
|
||||
@@ -75,10 +75,23 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
||||
Section {
|
||||
VStack {
|
||||
Picker(.createSecretKeyTypeLabel, selection: $keyType) {
|
||||
ForEach(store.supportedKeyTypes, id: \.self) { option in
|
||||
ForEach(store.supportedKeyTypes.available, id: \.self) { option in
|
||||
Text(String(describing: option))
|
||||
.tag(option)
|
||||
.font(.caption)
|
||||
}
|
||||
Divider()
|
||||
ForEach(store.supportedKeyTypes.unavailable, id: \.keyType) { option in
|
||||
VStack {
|
||||
Button {
|
||||
} label: {
|
||||
Text(String(describing: option.keyType))
|
||||
switch option.reason {
|
||||
case .macOSUpdateRequired:
|
||||
Text(.createSecretKeyTypeMacOSUpdateRequiredLabel)
|
||||
}
|
||||
}
|
||||
}
|
||||
.selectionDisabled()
|
||||
}
|
||||
}
|
||||
if keyType?.algorithm == .mldsa {
|
||||
@@ -119,7 +132,7 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
||||
.padding()
|
||||
}
|
||||
.onAppear {
|
||||
keyType = store.supportedKeyTypes.first
|
||||
keyType = store.supportedKeyTypes.available.first
|
||||
}
|
||||
.formStyle(.grouped)
|
||||
}
|
||||
@@ -146,6 +159,6 @@ struct CreateSecretView<StoreType: SecretStoreModifiable>: View {
|
||||
|
||||
}
|
||||
|
||||
//#Preview {
|
||||
// CreateSecretView(store: Preview.StoreModifiable()) { _ in }
|
||||
//}
|
||||
#Preview {
|
||||
CreateSecretView(store: Preview.StoreModifiable()) { _ in }
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user