From 6470ea81a7c26d308feecb70577f77ca6f3f1a9d Mon Sep 17 00:00:00 2001 From: Hamzah Mansour Date: Tue, 10 Oct 2023 03:17:27 -0700 Subject: [PATCH] add keyboard navigation setting (#3569) Co-authored-by: Dessalines Co-authored-by: Dessalines --- crates/api_common/src/person.rs | 2 ++ crates/db_schema/src/schema.rs | 1 + crates/db_schema/src/source/local_user.rs | 4 ++++ crates/db_views/src/registration_application_view.rs | 1 + .../down.sql | 3 +++ .../2023-10-06-133405_add_keyboard_navigation_setting/up.sql | 3 +++ 6 files changed, 14 insertions(+) create mode 100644 migrations/2023-10-06-133405_add_keyboard_navigation_setting/down.sql create mode 100644 migrations/2023-10-06-133405_add_keyboard_navigation_setting/up.sql diff --git a/crates/api_common/src/person.rs b/crates/api_common/src/person.rs index feb945b17..07ef91151 100644 --- a/crates/api_common/src/person.rs +++ b/crates/api_common/src/person.rs @@ -123,6 +123,8 @@ pub struct SaveUserSettings { pub open_links_in_new_tab: Option, /// Enable infinite scroll pub infinite_scroll_enabled: Option, + /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). + pub enable_keyboard_navigation: Option, } #[derive(Debug, Serialize, Deserialize, Clone, Default)] diff --git a/crates/db_schema/src/schema.rs b/crates/db_schema/src/schema.rs index 0d9f08b82..42d90dbec 100644 --- a/crates/db_schema/src/schema.rs +++ b/crates/db_schema/src/schema.rs @@ -442,6 +442,7 @@ diesel::table! { admin -> Bool, post_listing_mode -> PostListingModeEnum, totp_2fa_enabled -> Bool, + enable_keyboard_navigation -> Bool, } } diff --git a/crates/db_schema/src/source/local_user.rs b/crates/db_schema/src/source/local_user.rs index 709a34410..05c2eaefb 100644 --- a/crates/db_schema/src/source/local_user.rs +++ b/crates/db_schema/src/source/local_user.rs @@ -58,6 +58,8 @@ pub struct LocalUser { pub admin: bool, pub post_listing_mode: PostListingMode, pub totp_2fa_enabled: bool, + /// Whether to allow keyboard navigation (for browsing and interacting with posts and comments). + pub enable_keyboard_navigation: bool, } #[derive(Clone, TypedBuilder)] @@ -91,6 +93,7 @@ pub struct LocalUserInsertForm { pub admin: Option, pub post_listing_mode: Option, pub totp_2fa_enabled: Option, + pub enable_keyboard_navigation: Option, } #[derive(Clone, Default)] @@ -120,4 +123,5 @@ pub struct LocalUserUpdateForm { pub admin: Option, pub post_listing_mode: Option, pub totp_2fa_enabled: Option, + pub enable_keyboard_navigation: Option, } diff --git a/crates/db_views/src/registration_application_view.rs b/crates/db_views/src/registration_application_view.rs index a83b4c5df..b4a952002 100644 --- a/crates/db_views/src/registration_application_view.rs +++ b/crates/db_views/src/registration_application_view.rs @@ -267,6 +267,7 @@ mod tests { admin: false, post_listing_mode: inserted_sara_local_user.post_listing_mode, totp_2fa_enabled: inserted_sara_local_user.totp_2fa_enabled, + enable_keyboard_navigation: inserted_sara_local_user.enable_keyboard_navigation, }, creator: Person { id: inserted_sara_person.id, diff --git a/migrations/2023-10-06-133405_add_keyboard_navigation_setting/down.sql b/migrations/2023-10-06-133405_add_keyboard_navigation_setting/down.sql new file mode 100644 index 000000000..31b3c0503 --- /dev/null +++ b/migrations/2023-10-06-133405_add_keyboard_navigation_setting/down.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + DROP COLUMN enable_keyboard_navigation; + diff --git a/migrations/2023-10-06-133405_add_keyboard_navigation_setting/up.sql b/migrations/2023-10-06-133405_add_keyboard_navigation_setting/up.sql new file mode 100644 index 000000000..d1ba37c30 --- /dev/null +++ b/migrations/2023-10-06-133405_add_keyboard_navigation_setting/up.sql @@ -0,0 +1,3 @@ +ALTER TABLE local_user + ADD COLUMN enable_keyboard_navigation boolean DEFAULT FALSE NOT NULL; +