|
1 | 1 | import getTemplate from '@codesandbox/common/lib/templates'; |
2 | | -import { inject, hooksObserver } from 'app/componentConnectors'; |
3 | | -import React, { useEffect, useState } from 'react'; |
| 2 | + |
| 3 | +import React, { FunctionComponent, useEffect, useState } from 'react'; |
| 4 | + |
| 5 | +import { useOvermind } from 'app/overmind'; |
4 | 6 |
|
5 | 7 | import { Wrapper } from '../elements'; |
6 | 8 |
|
7 | 9 | import { DeployButton } from './DeployButton'; |
8 | 10 | import { SiteInfo } from './SiteInfo'; |
9 | 11 |
|
10 | | -export const Netlify = inject('store', 'signals')( |
11 | | - hooksObserver( |
12 | | - ({ |
13 | | - signals: { |
14 | | - deployment: { getNetlifyDeploys }, |
15 | | - }, |
16 | | - store: { |
17 | | - deployment: { deploying, netlifySite }, |
18 | | - editor: { currentSandbox }, |
19 | | - }, |
20 | | - }) => { |
21 | | - const [isVisible, setVisible] = useState(false); |
22 | | - |
23 | | - useEffect(() => { |
24 | | - getNetlifyDeploys(); |
25 | | - }, [getNetlifyDeploys]); |
26 | | - |
27 | | - const template = getTemplate(currentSandbox.template); |
28 | | - |
29 | | - return ( |
30 | | - template.netlify !== false && ( |
31 | | - <Wrapper loading={deploying}> |
32 | | - <DeployButton |
33 | | - isOpen={isVisible} |
34 | | - toggle={() => setVisible(show => !show)} |
35 | | - /> |
36 | | - |
37 | | - {netlifySite && isVisible ? <SiteInfo /> : null} |
38 | | - </Wrapper> |
39 | | - ) |
40 | | - ); |
41 | | - } |
42 | | - ) |
43 | | -); |
| 12 | +export const Netlify: FunctionComponent = () => { |
| 13 | + const { |
| 14 | + actions: { |
| 15 | + deployment: { getNetlifyDeploys }, |
| 16 | + }, |
| 17 | + state: { |
| 18 | + deployment: { deploying, netlifySite }, |
| 19 | + editor: { currentSandbox }, |
| 20 | + }, |
| 21 | + } = useOvermind(); |
| 22 | + const [isVisible, setVisible] = useState(false); |
| 23 | + |
| 24 | + useEffect(() => { |
| 25 | + getNetlifyDeploys(); |
| 26 | + }, [getNetlifyDeploys]); |
| 27 | + |
| 28 | + const template = getTemplate(currentSandbox.template); |
| 29 | + |
| 30 | + return ( |
| 31 | + template.netlify !== false && ( |
| 32 | + <Wrapper loading={deploying}> |
| 33 | + <DeployButton |
| 34 | + isOpen={isVisible} |
| 35 | + toggle={() => setVisible(show => !show)} |
| 36 | + /> |
| 37 | + |
| 38 | + {netlifySite && isVisible ? <SiteInfo /> : null} |
| 39 | + </Wrapper> |
| 40 | + ) |
| 41 | + ); |
| 42 | +}; |
0 commit comments