Skip to content

Commit aae1897

Browse files
MichaelDeBoeyCompuIves
authored andcommitted
Observe deployment components (codesandbox#2178)
* Observe components that use useStore hook * Fix typecheck
1 parent 343dbe1 commit aae1897

File tree

11 files changed

+66
-21
lines changed

11 files changed

+66
-21
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/DeployButton/DeployButton.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23

34
import { DeploymentIntegration } from 'app/components/DeploymentIntegration';
@@ -6,7 +7,11 @@ import { useSignals, useStore } from 'app/store';
67

78
import { DeployButtonContainer } from '../../elements';
89

9-
export const DeployButton = ({ isOpen, toggle }) => {
10+
type Props = {
11+
isOpen: boolean;
12+
toggle: () => void;
13+
};
14+
export const DeployButton = observer<Props>(({ isOpen, toggle }) => {
1015
const {
1116
deployment: { deployWithNetlify },
1217
} = useSignals();
@@ -34,4 +39,4 @@ export const DeployButton = ({ isOpen, toggle }) => {
3439
</DeploymentIntegration>
3540
</DeployButtonContainer>
3641
);
37-
};
42+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/Actions/Actions.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23

34
import { useStore } from 'app/store';
@@ -9,7 +10,7 @@ import { SubTitle } from '../elements';
910
import { ClaimSiteButton } from './ClaimSiteButton';
1011
import { VisitSiteButton } from './VisitSiteButton';
1112

12-
export const Actions = () => {
13+
export const Actions = observer(() => {
1314
const {
1415
deployment: { netlifyClaimUrl },
1516
} = useStore();
@@ -25,4 +26,4 @@ export const Actions = () => {
2526
</ButtonContainer>
2627
</>
2728
);
28-
};
29+
});
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,11 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23

34
import { useStore } from 'app/store';
45

56
import { Link } from '../../../../elements';
67

7-
export const ClaimSiteButton = () => {
8+
export const ClaimSiteButton = observer(() => {
89
const {
910
deployment: { building, netlifyClaimUrl },
1011
} = useStore();
@@ -14,4 +15,4 @@ export const ClaimSiteButton = () => {
1415
Claim Site
1516
</Link>
1617
);
17-
};
18+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/Actions/VisitSiteButton/VisitSiteButton.tsx

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23
import LinkIcon from 'react-icons/lib/fa/external-link';
34
import Cogs from 'react-icons/lib/fa/cogs';
@@ -6,7 +7,7 @@ import { useStore } from 'app/store';
67

78
import { Link } from '../../../../elements';
89

9-
export const VisitSiteButton = () => {
10+
export const VisitSiteButton = observer(() => {
1011
const {
1112
deployment: { building, netlifySite },
1213
} = useStore();
@@ -24,4 +25,4 @@ export const VisitSiteButton = () => {
2425
)}
2526
</Link>
2627
);
27-
};
28+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Netlify/SiteInfo/Functions/Function/Function.tsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23
import LightningIcon from 'react-icons/lib/md/flash-on';
34

45
import { useStore } from 'app/store';
56

67
import { Link } from '../../../../elements';
78

8-
export const Function = ({ function: { title } }) => {
9+
type Props = {
10+
function: {
11+
title: string;
12+
};
13+
};
14+
export const Function = observer<Props>(({ function: { title } }) => {
915
const {
1016
deployment: {
1117
building,
@@ -25,4 +31,4 @@ export const Function = ({ function: { title } }) => {
2531
{functionName}
2632
</Link>
2733
);
28-
};
34+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/DeployButton/DeployButton.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23

34
import { DeploymentIntegration } from 'app/components/DeploymentIntegration';
@@ -8,7 +9,11 @@ import { DeployButtonContainer } from '../../elements';
89

910
import { Overlay, CreateFile } from './elements';
1011

11-
export const DeployButton = ({ isOpen, toggle }) => {
12+
type Props = {
13+
isOpen: boolean;
14+
toggle: () => void;
15+
};
16+
export const DeployButton = observer<Props>(({ isOpen, toggle }) => {
1217
const {
1318
files,
1419
deployment: { deploySandboxClicked },
@@ -67,4 +72,4 @@ export const DeployButton = ({ isOpen, toggle }) => {
6772
</DeploymentIntegration>
6873
</DeployButtonContainer>
6974
);
70-
};
75+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/Deploys/Actions/Actions.tsx

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23

34
import { useStore } from 'app/store';
@@ -7,8 +8,12 @@ import { ButtonContainer } from '../../../elements';
78
import { AliasDeploymentButton } from './AliasDeploymentButton';
89
import { DeleteDeploymentButton } from './DeleteDeploymentButton';
910
import { VisitDeploymentButton } from './VisitDeploymentButton';
11+
import { Deploy } from './types';
1012

11-
export const Actions = ({ deploy }) => {
13+
type Props = {
14+
deploy: Deploy;
15+
};
16+
export const Actions = observer<Props>(({ deploy }) => {
1217
const {
1318
deployment: { hasAlias },
1419
} = useStore();
@@ -24,4 +29,4 @@ export const Actions = ({ deploy }) => {
2429
) : null}
2530
</ButtonContainer>
2631
);
27-
};
32+
});

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/Deploys/Actions/AliasDeploymentButton/AliasDeploymentButton.tsx

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,24 @@ import { useSignals } from 'app/store';
44

55
import { Action } from '../../../../elements';
66

7-
export const AliasDeploymentButton = ({ deploy: { alias, uid: id } }) => {
7+
import { Deploy } from '../types';
8+
9+
type Props = {
10+
deploy: Deploy;
11+
};
12+
export const AliasDeploymentButton = ({
13+
deploy: { alias: aliases, uid: id },
14+
}: Props) => {
815
const {
916
deployment: { aliasDeployment },
1017
} = useSignals();
1118

1219
return (
13-
<Action disabled={alias.length > 0} onClick={() => aliasDeployment({ id })}>
14-
{alias.length > 0 ? 'Aliased' : 'Alias'}
20+
<Action
21+
disabled={aliases.length > 0}
22+
onClick={() => aliasDeployment({ id })}
23+
>
24+
{aliases.length > 0 ? 'Aliased' : 'Alias'}
1525
</Action>
1626
);
1727
};

packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/Deploys/Actions/DeleteDeploymentButton/DeleteDeploymentButton.tsx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,15 @@
1+
import { observer } from 'mobx-react-lite';
12
import React from 'react';
23
import TrashIcon from 'react-icons/lib/fa/trash';
34

45
import { useSignals, useStore } from 'app/store';
56

67
import { Action } from '../../../../elements';
78

8-
export const DeleteDeploymentButton = ({ id }) => {
9+
type Props = {
10+
id: string;
11+
};
12+
export const DeleteDeploymentButton = observer<Props>(({ id }) => {
913
const {
1014
deployment: { setDeploymentToDelete },
1115
modalOpened,
@@ -29,4 +33,4 @@ export const DeleteDeploymentButton = ({ id }) => {
2933
)}
3034
</Action>
3135
);
32-
};
36+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
export type Deploy = {
2+
alias: string[];
3+
state: string;
4+
uid: string;
5+
url: string;
6+
};

0 commit comments

Comments
 (0)