settings_ui: Handle enums with fields (#37945)
Closes #ISSUE
Adds handling for Enums with fields (i.e. not `enum Foo { Yes, No }`) in
Settings UI. Accomplished by creating default values for each element
with fields (in the derive macro), and rendering a toggle button group
with a button for each variant where switching the active variant sets
the value in the settings JSON to the default for the new active
variant.
Release Notes:
- N/A *or* Added/Fixed/Improved ...
---------
Co-authored-by: Conrad <conrad@zed.dev>
This commit is contained in:
@@ -23,7 +23,7 @@ impl FeatureFlags {
|
||||
return true;
|
||||
}
|
||||
|
||||
if self.staff && T::enabled_for_staff() {
|
||||
if (cfg!(debug_assertions) || self.staff) && !*ZED_DISABLE_STAFF && T::enabled_for_staff() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,10 @@ impl FeatureFlagAppExt for App {
|
||||
fn has_flag<T: FeatureFlag>(&self) -> bool {
|
||||
self.try_global::<FeatureFlags>()
|
||||
.map(|flags| flags.has_flag::<T>())
|
||||
.unwrap_or(T::enabled_for_all())
|
||||
.unwrap_or_else(|| {
|
||||
(cfg!(debug_assertions) && T::enabled_for_staff() && !*ZED_DISABLE_STAFF)
|
||||
|| T::enabled_for_all()
|
||||
})
|
||||
}
|
||||
|
||||
fn is_staff(&self) -> bool {
|
||||
|
||||
Reference in New Issue
Block a user