Skip to content

Commit 217286f

Browse files
authored
fix(datagrid): distinguish missing and empty descriptions (#1398)
1 parent 29b1b12 commit 217286f

6 files changed

Lines changed: 22 additions & 0 deletions

File tree

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
- `stacked` is now ignored on chart types that cannot stack, instead of displaying an empty chart.
1515
- Screen readers now announce the title of the modal component instead of an unnamed dialog.
1616
- `sqlpage.request_body` and `sqlpage.request_body_base64` now return NULL when the request has no body. A body that cannot be read, such as one exceeding the payload limit, is now reported as an error instead of being silently replaced with an empty body.
17+
- Datagrid rows with an icon or image no longer display an unnecessary en-dash placeholder, and an explicitly empty description remains empty.
1718
- Charts can display reference lines. A row with a `yline` is drawn as a line across the chart at that value of the y axis, with the row's `label` and `color` for its text and its color. Reference lines are rows, so a chart can have as many of them as the query returns. A line follows its axis, so on a `horizontal` bar chart a `yline` is drawn down the chart rather than across it. They are not added to the total of a `stacked` chart, and are not filled in an `area` chart.
1819

1920
## v0.45
27.7 KB
Loading
27.7 KB
Loading

sqlpage/templates/datagrid.handlebars

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,9 @@
4242
{{/if}}
4343
{{#if description}}
4444
{{description}}
45+
{{else if (eq description "")}}
46+
{{else if icon}}
47+
{{else if image_url}}
4548
{{else}}
4649
4750
{{/if}}
Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
SELECT 'datagrid' AS component;
2+
SELECT 'Facebook' AS title, 'brand-facebook' AS icon;
3+
SELECT 'Empty' AS title, '' AS description;
4+
SELECT 'Missing' AS title;

tests/core/mod.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,20 @@ async fn test_concurrent_requests() {
4040
}
4141
}
4242

43+
#[actix_web::test]
44+
async fn test_datagrid_description_presence_controls_placeholder() {
45+
let resp = req_path("/tests/components/datagrid_icon_only.sql")
46+
.await
47+
.unwrap();
48+
assert_eq!(resp.status(), StatusCode::OK);
49+
let body = String::from_utf8(test::read_body(resp).await.to_vec()).unwrap();
50+
assert!(body.contains("Facebook"), "{body}");
51+
assert!(body.contains("Empty"), "{body}");
52+
assert!(body.contains("Missing"), "{body}");
53+
assert!(body.contains("<svg"), "{body}");
54+
assert_eq!(body.matches('–').count(), 1, "{body}");
55+
}
56+
4357
#[actix_web::test]
4458
async fn test_routing_with_db_fs() {
4559
let mut config = test_config();

0 commit comments

Comments
 (0)