v0.36.1_hf1
This commit is contained in:
1 parent
6f52ac3d00
commit
4793af758f
9 files changed
+66
-19
No files matched your search
@@ -292,3 +292,22 @@ fn dashboard_width_preferences_preserve_legacy_and_allow_custom_grids() {
|
||||
.contains_key("not_a_card"));
|
||||
assert!(validate_admin_preferences(&prefs).is_ok());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn customized_dashboard_preferences_fit_persistent_storage_limit() {
|
||||
let mut prefs = AdminPreferences {
|
||||
dashboard_widget_sizes: Some(std::collections::BTreeMap::new()),
|
||||
..Default::default()
|
||||
};
|
||||
for widget in DASHBOARD_WIDGETS.iter() {
|
||||
prefs
|
||||
.dashboard_widget_sizes
|
||||
.as_mut()
|
||||
.unwrap()
|
||||
.insert(widget.id.clone(), 12);
|
||||
}
|
||||
assert!(validate_admin_preferences(&prefs).is_ok());
|
||||
let document = serde_json::to_string(&prefs).unwrap();
|
||||
assert!(document.len() > 4096);
|
||||
assert!(document.len() <= crate::db::ADMIN_PREFERENCES_MAX_BYTES);
|
||||
}
|
||||
@@ -3518,6 +3518,7 @@ mod tests {
|
||||
.unwrap();
|
||||
assert_eq!(invalid.status(), StatusCode::BAD_REQUEST);
|
||||
let bad_sse = router
|
||||
.clone()
|
||||
.oneshot(
|
||||
request("/api/events?interval=4")
|
||||
.header("cookie", &cookie)
|
||||
|
||||
@@ -617,15 +617,21 @@ body[data-density=compact] .pool-card .table-scroll {
|
||||
#panel-overview .stat-with-action .stat-corner-badge {
|
||||
min-height: 0;
|
||||
border-radius: 999px;
|
||||
border-color: var(--line);
|
||||
background: transparent;
|
||||
color: var(--muted);
|
||||
font-size: 9px;
|
||||
font-weight: 400;
|
||||
letter-spacing: 0;
|
||||
cursor: pointer;
|
||||
text-transform: none;
|
||||
}
|
||||
|
||||
#panel-overview .stat-with-action .stat-corner-badge:hover,
|
||||
#panel-overview .stat-with-action .stat-corner-badge:focus-visible {
|
||||
border-color: var(--accent);
|
||||
background: var(--notice-bg);
|
||||
border-color: var(--line);
|
||||
background: var(--panel2);
|
||||
color: var(--text);
|
||||
}
|
||||
|
||||
#panel-overview .dashboard-overview-grid.is-unlocked .stat-with-action .stat-corner-action {
|
||||
|
||||
+1
-1
@@ -174,7 +174,7 @@ impl Store {
|
||||
}
|
||||
pub async fn save_admin_preferences(&self, username: &str, document: &str) -> Result<bool> {
|
||||
ensure!(
|
||||
(2..=4096).contains(&document.len()),
|
||||
(2..=crate::db::ADMIN_PREFERENCES_MAX_BYTES).contains(&document.len()),
|
||||
"administrator preferences document is too large"
|
||||
);
|
||||
let result = sqlx::query(
|
||||
|
||||
@@ -13,7 +13,8 @@ use sqlx::{
|
||||
};
|
||||
use std::{path::Path, time::Duration};
|
||||
|
||||
pub const SCHEMA_VERSION: i64 = 11;
|
||||
pub const SCHEMA_VERSION: i64 = 12;
|
||||
pub const ADMIN_PREFERENCES_MAX_BYTES: usize = 64 * 1024;
|
||||
pub const CERTIFICATE_API_CREDENTIAL_CAPACITY: i64 = 32;
|
||||
pub const AUDIT_CAPACITY: i64 = 10_000;
|
||||
|
||||
@@ -129,6 +130,11 @@ impl Store {
|
||||
sqlx::raw_sql(include_str!("../migrations/0011_tokens.sql"))
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
if version < 12 {
|
||||
sqlx::raw_sql(include_str!("../migrations/0012_admin_preferences_size.sql"))
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
}
|
||||
sqlx::query("INSERT OR IGNORE INTO configuration(id, revision, document) VALUES(1, 0, ?)")
|
||||
.bind(serde_json::to_string(initial)?)
|
||||
.execute(&mut *tx)
|
||||
@@ -139,7 +145,7 @@ impl Store {
|
||||
.bind(crate::auth::now())
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
sqlx::query("PRAGMA user_version = 11")
|
||||
sqlx::query("PRAGMA user_version = 12")
|
||||
.execute(&mut *tx)
|
||||
.await?;
|
||||
tx.commit().await?;
|
||||
|
||||
Reference in new issue
Block a user