forked from owid/owid-grapher
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathIndexPage.tsx
51 lines (49 loc) · 1.56 KB
/
IndexPage.tsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
import React from "react"
import {
ENV,
GITHUB_USERNAME,
DATA_API_FOR_ADMIN_UI,
} from "../settings/serverSettings.js"
import { viteAssetsForAdmin } from "../site/viteUtils.js"
export const IndexPage = (props: {
username: string
isSuperuser: boolean
gitCmsBranchName: string
}) => {
const assets = viteAssetsForAdmin()
const script = `
window.isEditor = true
window.admin = new Admin({ username: "${
props.username
}", isSuperuser: ${props.isSuperuser.toString()}, settings: ${JSON.stringify(
{ ENV, GITHUB_USERNAME, DATA_API_FOR_ADMIN_UI }
)}})
admin.start(document.querySelector("#app"), '${props.gitCmsBranchName}')
`
return (
<html lang="en">
<head>
<title>owid-admin</title>
<meta name="description" content="" />
<meta
name="viewport"
content="width=device-width, initial-scale=1"
/>
{assets.forHeader}
</head>
<body>
<div id="app"></div>
{assets.forFooter}
<script
type="module"
dangerouslySetInnerHTML={{ __html: script }}
/>
{/* This lets the public frontend know to show edit links and such */}
<iframe
src="https://ourworldindata.org/identifyadmin"
style={{ display: "none" }}
/>
</body>
</html>
)
}