fix(settings): grey out API & Access while offline
New API Key/delete were already gated on isEffectivelyOnline, but nothing visually signaled offline state the way Preferences/Profile do — added the same offline hint banner plus dimmed+disabled the key list itself, and gated the sheet's own Create button too (in case Offline Mode gets toggled on while the sheet is already open).
This commit is contained in:
@@ -764,6 +764,10 @@ struct SettingsView: View {
|
|||||||
|
|
||||||
Divider().frame(maxWidth: 480)
|
Divider().frame(maxWidth: 480)
|
||||||
|
|
||||||
|
if !isEffectivelyOnline {
|
||||||
|
offlineSettingsHint
|
||||||
|
}
|
||||||
|
|
||||||
HStack {
|
HStack {
|
||||||
Text("Personal keys")
|
Text("Personal keys")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
@@ -774,6 +778,8 @@ struct SettingsView: View {
|
|||||||
.frame(maxWidth: 480)
|
.frame(maxWidth: 480)
|
||||||
|
|
||||||
apiKeysList
|
apiKeysList
|
||||||
|
.disabled(!isEffectivelyOnline)
|
||||||
|
.opacity(isEffectivelyOnline ? 1 : 0.4)
|
||||||
}
|
}
|
||||||
.task { await refreshApiKeys() }
|
.task { await refreshApiKeys() }
|
||||||
.sheet(isPresented: $isShowingCreateApiKey) {
|
.sheet(isPresented: $isShowingCreateApiKey) {
|
||||||
@@ -908,7 +914,7 @@ struct SettingsView: View {
|
|||||||
} else {
|
} else {
|
||||||
Button("Create") { Task { await createApiKey() } }
|
Button("Create") { Task { await createApiKey() } }
|
||||||
.buttonStyle(.borderedProminent)
|
.buttonStyle(.borderedProminent)
|
||||||
.disabled(newApiKeyName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty)
|
.disabled(newApiKeyName.trimmingCharacters(in: .whitespacesAndNewlines).isEmpty || !isEffectivelyOnline)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user