Files
template-showcase/src/views/platform/ui/PlatformPage.tsx
T

34 lines
1.1 KiB
TypeScript

import { platformInfo } from '@/shared/api'
import { getEnv, modules } from '@/shared/config'
/**
* The platform's own description, read through the typed API (plan §4.4), and the
* optional services this deployment is linked to. The platform has no token-accessible
* listing of a project's services (D8), so the linked list is read from the variables
* the platform injected at deploy time. When the description read fails the page
* renders the list it owns and a placeholder.
*/
export async function PlatformPage() {
const info = await platformInfo()
const linked = modules(getEnv())
return (
<main>
<h1>Platform</h1>
<h2>Linked services</h2>
<ul>
{(Object.keys(linked) as Array<keyof typeof linked>).map((name) => (
<li key={name}>
{name}: {linked[name] ? 'linked' : 'not linked'}
</li>
))}
</ul>
<h2>Description</h2>
{info ? (
<pre>{JSON.stringify(info, null, 2)}</pre>
) : (
<p>The platform description is unavailable.</p>
)}
</main>
)
}