Skip to content

Commit 13a266a

Browse files
committed
refactor NetlifyLogs
1 parent 8a2bad7 commit 13a266a

File tree

4 files changed

+51
-53
lines changed

4 files changed

+51
-53
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,7 @@ Thanks goes to these wonderful people
231231
<td align="center"><a href="https://github.com/chinmay17"><img src="https://avatars2.githubusercontent.com/u/7131231?v=4" width="100px;" alt="Chinmay Chaudhary"/><br /><sub><b>Chinmay Chaudhary</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=chinmay17" title="Code">💻</a></td>
232232
<td align="center"><a href="https://github.com/Sakthivel"><img src="https://avatars3.githubusercontent.com/u/205201?v=4" width="100px;" alt="Sakthivel Sengodan Sapient"/><br /><sub><b>Sakthivel Sengodan Sapient</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=sakthivel" title="Code">💻</a></td>
233233
<td align="center"><a href="https://github.com/vanya829"><img src="https://avatars0.githubusercontent.com/u/1397979?v=4" width="100px;" alt="vanya829"/><br /><sub><b>vanya829</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=vanya829" title="Code">💻</a></td>
234+
<td align="center"><a href="https://github.com/nileshpatel17"><img src="https://avatars0.githubusercontent.com/u/27020381?v=4" width="100px;" alt="Nilesh Patel"/><br /><sub><b>Nilesh Patel</b></sub></a><br /><a href="https://github.com/codesandbox/codesandbox-client/commits?author=nileshpatel17" title="Code">💻</a></td>
234235
</tr>
235236
</table>
236237

packages/app/src/app/pages/common/Modals/NetlifyLogs/index.js

Lines changed: 0 additions & 53 deletions
This file was deleted.
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import React, { FunctionComponent, useState, useEffect } from 'react';
2+
import { useOvermind } from 'app/overmind';
3+
4+
import { Button } from '@codesandbox/common/lib/components/Button';
5+
import { Container } from '../LiveSessionEnded/elements';
6+
import { Heading, Explanation } from '../elements';
7+
8+
import { List, Item } from './elements';
9+
10+
const NetlifyLogs: FunctionComponent = () => {
11+
const [logs, setLogs] = useState(['Contacting Netlify']);
12+
const {
13+
state: {
14+
deployment: { netlifyLogs: url },
15+
},
16+
actions: { modalClosed },
17+
} = useOvermind();
18+
19+
useEffect(() => {
20+
const getLogs = async apiUrl => {
21+
const data = await fetch(apiUrl);
22+
const { logs: newLogs } = await data.json();
23+
setLogs(newLogs);
24+
};
25+
const interval = setInterval(getLogs, 2000);
26+
return () => {
27+
clearInterval(interval);
28+
};
29+
}, [url]);
30+
31+
return (
32+
<Container>
33+
<Heading>Sandbox Site Logs</Heading>
34+
<Explanation>
35+
Builds typically take a minute or two to complete
36+
</Explanation>
37+
<List>
38+
{logs.map((log, i) => (
39+
// eslint-disable-next-line react/no-array-index-key
40+
<Item key={i}>{log}</Item>
41+
))}
42+
</List>
43+
<Button small onClick={() => modalClosed()}>
44+
Close
45+
</Button>
46+
</Container>
47+
);
48+
};
49+
50+
export default NetlifyLogs;

0 commit comments

Comments
 (0)