|
1 | 1 | import { useMemo, useState } from "react"; |
2 | | -import WarningIcon from "@mui/icons-material/Warning"; |
3 | 2 | import ChevronRight from "@mui/icons-material/ChevronRight"; |
4 | 3 | import Button from "@mui/material/Button"; |
5 | 4 | import Box from "@mui/material/Box"; |
6 | 5 | import Link from "@mui/material/Link"; |
7 | | -import Alert from "@mui/material/Alert"; |
8 | | -import Typography from "@mui/material/Typography"; |
9 | 6 |
|
10 | 7 | interface Props { |
11 | 8 | manifest: Manifest; |
@@ -44,6 +41,23 @@ const useTree = ({ manifest }: { manifest: Manifest }) => { |
44 | 41 | return object; |
45 | 42 | }; |
46 | 43 |
|
| 44 | + Object.keys(manifest?.staticFiles || {}).forEach(fileName => { |
| 45 | + const pieces = fileName.replace(/^\//, "").split("/"); |
| 46 | + const file = { fileName, headers: manifest.staticFiles![fileName] }; |
| 47 | + |
| 48 | + if (pieces.length === 1) { |
| 49 | + tree["/"].files.push(file); |
| 50 | + } else { |
| 51 | + let lastLeaf = tree["/"].folders; |
| 52 | + |
| 53 | + pieces.pop(); // last name is file name |
| 54 | + pieces.forEach(path => { |
| 55 | + recursiveFolder(lastLeaf, path, file); |
| 56 | + lastLeaf = lastLeaf[path].folders; |
| 57 | + }); |
| 58 | + } |
| 59 | + }); |
| 60 | + |
47 | 61 | manifest.cdnFiles?.forEach(file => { |
48 | 62 | const pieces = file.fileName.replace(/^\//, "").split("/"); |
49 | 63 |
|
@@ -145,27 +159,6 @@ const recursiveRender = (deployment: DeploymentV2, treeNode: TreeNode) => { |
145 | 159 | }; |
146 | 160 |
|
147 | 161 | export default function TabCDNFiles({ manifest, deployment }: Props) { |
148 | | - const ssrEnabled = Boolean(manifest?.functionHandler); |
149 | | - const indexHTMLWarning = |
150 | | - !ssrEnabled && |
151 | | - !manifest?.cdnFiles?.find(file => file.fileName === "/index.html"); |
152 | | - |
153 | 162 | const tree = useTree({ manifest }); |
154 | | - |
155 | | - return ( |
156 | | - <> |
157 | | - {indexHTMLWarning && ( |
158 | | - <Alert color="warning" sx={{ mb: 2 }} icon={<WarningIcon />}> |
159 | | - <Typography> |
160 | | - Top level <span className="font-bold">/index.html</span> is missing |
161 | | - and server side rendering is not detected.{" "} |
162 | | - <Link href="https://www.stormkit.io/docs/other/troubleshooting#index-html-missing"> |
163 | | - Learn more. |
164 | | - </Link> |
165 | | - </Typography> |
166 | | - </Alert> |
167 | | - )} |
168 | | - <Box>{recursiveRender(deployment, tree["/"])}</Box> |
169 | | - </> |
170 | | - ); |
| 163 | + return <Box>{recursiveRender(deployment, tree["/"])}</Box>; |
171 | 164 | } |
0 commit comments