Skip to content

Commit 5467a19

Browse files
committed
Add snippet for devices
1 parent 92084ef commit 5467a19

3 files changed

Lines changed: 51 additions & 2 deletions

File tree

TESTING.mdx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ title: "Testing one-two"
33
description: "This is the test file"
44
---
55

6+
import { SupportedDevices } from '/snippets/devices.jsx';
7+
68
<Info>
79
Well, let's just say we are going to test Mintlify with some custom, editor-based pages!
810
</Info>
@@ -19,4 +21,8 @@ Are those Dandelions? I don't think so.
1921
Did you know? Dandelion comes from French 'dent de lion', which means 'Lion tooth'. Crazy!
2022
</Tip>
2123

22-
So this won't be visible until I publish my changes.
24+
So this won't be visible until I publish my changes.
25+
26+
<SupportedDevices />
27+
28+
well?

docs.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
"learn/welcome/primer",
3838
"learn/welcome/production-plan",
3939
"learn/welcome/security",
40-
"learn/accounts/support-access"
40+
"learn/accounts/support-access",
41+
"TESTING"
4142
]
4243
},
4344
{

snippets/devices.jsx

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
export const SupportedDevices = () => {
2+
const [devices, setDevices] = useState();
3+
4+
useEffect(() => {
5+
(async () => {
6+
const response = await fetch('https://api.balena-cloud.com/v7/device_type?$select=name,slug,logo&$expand=is_of__cpu_architecture($select=slug)&$filter=is_default_for__application/any(idfa:((idfa/is_host%20eq%20true)%20and%20(idfa/is_archived%20eq%20false)%20and%20(idfa/owns__release/any(r:(status%20eq%20%27success%27)%20and%20(is_final%20eq%20true)%20and%20(is_invalidated%20eq%20false))))%20and%20not(contains(idfa/app_name,%27-esr%27)))&$orderby=name%20asc');
7+
const data = await response.json();
8+
setDevices(data.d);
9+
})();
10+
}, []);
11+
12+
if (!devices) {
13+
return <i>loading</i>;
14+
}
15+
16+
if (!devices.length) {
17+
return <i>No devices found</i>;
18+
}
19+
20+
return (
21+
<table className="not-prose">
22+
<thead>
23+
<tr>
24+
<th></th>
25+
<th>Device name</th>
26+
<th>Slug</th>
27+
<th>Arch</th>
28+
</tr>
29+
</thead>
30+
<tbody>
31+
{devices.map((device) => (
32+
<tr>
33+
<td><img src={device.logo} width="20" height="20" alt="" style={{ width: '40px', height: '40px' }} /></td>
34+
<td>{device.name}</td>
35+
<td><code>{device.slug}</code></td>
36+
<td><code>{device.is_of__cpu_architecture[0]?.slug}</code></td>
37+
</tr>
38+
))}
39+
</tbody>
40+
</table>
41+
)
42+
}

0 commit comments

Comments
 (0)