From 5eaab42f7a6ee567f31fec389b9124a448f1e8d6 Mon Sep 17 00:00:00 2001 From: jasonyess Date: Wed, 22 Oct 2025 20:22:57 -0400 Subject: [PATCH 1/3] change tab names in user area and hide list staff related fields behind elevated perms --- pointercrate-core/src/permission.rs | 4 + .../src/account/mod.rs | 2 +- .../{list_integration.rs => profile.rs} | 10 +- .../static/ftl/en-us/player.ftl | 4 +- .../js/account/{integration.js => profile.js} | 0 pointercrate-example/src/main.rs | 12 +- pointercrate-user-pages/src/account/mod.rs | 2 +- .../src/account/{profile.rs => settings.rs} | 140 +++++++++--------- .../static/ftl/en-us/user.ftl | 26 ++-- .../js/account/{profile.js => settings.js} | 74 +++++---- 10 files changed, 145 insertions(+), 129 deletions(-) rename pointercrate-demonlist-pages/src/account/{list_integration.rs => profile.rs} (97%) rename pointercrate-demonlist-pages/static/js/account/{integration.js => profile.js} (100%) rename pointercrate-user-pages/src/account/{profile.rs => settings.rs} (64%) rename pointercrate-user-pages/static/js/account/{profile.js => settings.js} (83%) diff --git a/pointercrate-core/src/permission.rs b/pointercrate-core/src/permission.rs index c6ba48a6e..b2739a73b 100644 --- a/pointercrate-core/src/permission.rs +++ b/pointercrate-core/src/permission.rs @@ -210,6 +210,10 @@ impl PermissionsManager { Ok(()) } + + pub fn is_elevated(&self, permission_bits: u16) -> bool { + permission_bits > 0 + } } #[cfg(test)] diff --git a/pointercrate-demonlist-pages/src/account/mod.rs b/pointercrate-demonlist-pages/src/account/mod.rs index 7dda25d9f..1a3137d4e 100644 --- a/pointercrate-demonlist-pages/src/account/mod.rs +++ b/pointercrate-demonlist-pages/src/account/mod.rs @@ -1,7 +1,7 @@ //! Module containing the tabs of the management web interfaces shown on the account page pub mod demons; -pub mod list_integration; pub mod players; +pub mod profile; pub mod records; pub mod submitters; diff --git a/pointercrate-demonlist-pages/src/account/list_integration.rs b/pointercrate-demonlist-pages/src/account/profile.rs similarity index 97% rename from pointercrate-demonlist-pages/src/account/list_integration.rs rename to pointercrate-demonlist-pages/src/account/profile.rs index 6a939aafe..33867d6a1 100644 --- a/pointercrate-demonlist-pages/src/account/list_integration.rs +++ b/pointercrate-demonlist-pages/src/account/profile.rs @@ -15,16 +15,16 @@ use pointercrate_user::{ use pointercrate_user_pages::account::AccountPageTab; use sqlx::PgConnection; -pub struct ListIntegrationTab(#[doc = "discord invite url"] pub &'static str); +pub struct ProfileTab(#[doc = "discord invite url"] pub &'static str); #[async_trait::async_trait] -impl AccountPageTab for ListIntegrationTab { +impl AccountPageTab for ProfileTab { fn should_display_for(&self, _permissions_we_have: u16, _permissions: &PermissionsManager) -> bool { true } fn initialization_script(&self) -> String { - "/static/demonlist/js/account/integration.js".into() + "/static/demonlist/js/account/profile.js".into() } fn tab_id(&self) -> u8 { @@ -34,10 +34,10 @@ impl AccountPageTab for ListIntegrationTab { fn tab(&self) -> Markup { html! { b { - (tr("list-integration")) + (tr("profile")) } (PreEscaped("  ")) - i class = "fa fa-list fa-2x" aria-hidden="true" {} + i class = "fa fa-user fa-2x" aria-hidden="true" {} } } diff --git a/pointercrate-demonlist-pages/static/ftl/en-us/player.ftl b/pointercrate-demonlist-pages/static/ftl/en-us/player.ftl index 352cd0ba6..7c6e03f60 100644 --- a/pointercrate-demonlist-pages/static/ftl/en-us/player.ftl +++ b/pointercrate-demonlist-pages/static/ftl/en-us/player.ftl @@ -36,8 +36,8 @@ player-name-dialog = Change player name .name-validator-valuemissing = Please provide a name for the player -## List integration tab -list-integration = List Integration +## Profile tab +profile = Profile claimed-player = Claimed Player .verified = Verified diff --git a/pointercrate-demonlist-pages/static/js/account/integration.js b/pointercrate-demonlist-pages/static/js/account/profile.js similarity index 100% rename from pointercrate-demonlist-pages/static/js/account/integration.js rename to pointercrate-demonlist-pages/static/js/account/profile.js diff --git a/pointercrate-example/src/main.rs b/pointercrate-example/src/main.rs index 035c5240e..d339e6a15 100644 --- a/pointercrate-example/src/main.rs +++ b/pointercrate-example/src/main.rs @@ -11,11 +11,9 @@ use pointercrate_core_pages::{ }; use pointercrate_demonlist::LIST_ADMINISTRATOR; use pointercrate_demonlist_api::GeolocationProvider; -use pointercrate_demonlist_pages::account::{ - demons::DemonsTab, list_integration::ListIntegrationTab, players::PlayersPage, records::RecordsPage, -}; +use pointercrate_demonlist_pages::account::{demons::DemonsTab, players::PlayersPage, profile::ProfileTab, records::RecordsPage}; use pointercrate_user::MODERATOR; -use pointercrate_user_pages::account::{profile::ProfileTab, users::UsersTab, AccountPageConfig}; +use pointercrate_user_pages::account::{settings::SettingsTab, users::UsersTab, AccountPageConfig}; use rocket::{async_trait, fs::FileServer, response::Redirect, serde, uri, Request}; use std::net::IpAddr; use unic_langid::lang; @@ -146,9 +144,9 @@ async fn rocket() -> _ { // [`AccountPageTab::should_display_for`] returns `true`. let account_page_config = AccountPageConfig::default() // Tab where users can modify their own accounts - .with_page(ProfileTab) - // Tab where users can initiate player claims and manage their claimed players - .with_page(ListIntegrationTab("https://discord.gg/tMBzYP77ag")) + .with_page(SettingsTab) + // Tab where users can initiate player claims and manage their claimed players (formerly "List Integration" tab) + .with_page(ProfileTab("https://discord.gg/tMBzYP77ag")) // Tab where website moderators can manage permissions. // The vector below specified which permissions a user needs to have for the tab to be displayed. .with_page(UsersTab(vec![MODERATOR, LIST_ADMINISTRATOR])) diff --git a/pointercrate-user-pages/src/account/mod.rs b/pointercrate-user-pages/src/account/mod.rs index ba5854215..dad1a6e0d 100644 --- a/pointercrate-user-pages/src/account/mod.rs +++ b/pointercrate-user-pages/src/account/mod.rs @@ -7,7 +7,7 @@ use pointercrate_core_pages::{ use pointercrate_user::auth::{AuthenticatedUser, NonMutating}; use sqlx::PgConnection; -pub mod profile; +pub mod settings; pub mod users; #[async_trait::async_trait] diff --git a/pointercrate-user-pages/src/account/profile.rs b/pointercrate-user-pages/src/account/settings.rs similarity index 64% rename from pointercrate-user-pages/src/account/profile.rs rename to pointercrate-user-pages/src/account/settings.rs index 3897b7333..ce171d53d 100644 --- a/pointercrate-user-pages/src/account/profile.rs +++ b/pointercrate-user-pages/src/account/settings.rs @@ -12,16 +12,16 @@ use pointercrate_user::{ }; use sqlx::PgConnection; -pub struct ProfileTab; +pub struct SettingsTab; #[async_trait::async_trait] -impl AccountPageTab for ProfileTab { +impl AccountPageTab for SettingsTab { fn should_display_for(&self, _permissions_we_have: u16, _permissions: &PermissionsManager) -> bool { true } fn initialization_script(&self) -> String { - "/static/user/js/account/profile.js".into() + "/static/user/js/account/settings.js".into() } fn additional_scripts(&self) -> Vec