Skip to content

Commit 7c85822

Browse files
MichaelDeBoeySaraVieira
authored andcommitted
🔨 Switch DeleteDeploymentButton to use useOvermind (codesandbox#2572)
1 parent fce4193 commit 7c85822

File tree

1 file changed

+34
-36
lines changed
  • packages/app/src/app/pages/Sandbox/Editor/Workspace/items/Deployment/Zeit/Deploys/Actions/DeleteDeploymentButton

1 file changed

+34
-36
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,43 +1,41 @@
1-
import { inject, hooksObserver } from 'app/componentConnectors';
2-
import React from 'react';
1+
import React, { FunctionComponent } from 'react';
32
import TrashIcon from 'react-icons/lib/fa/trash';
43

4+
import { useOvermind } from 'app/overmind';
5+
56
import { Action } from '../../../../elements';
67

78
type Props = {
89
id: string;
9-
store: any;
10-
signals: any;
1110
};
12-
export const DeleteDeploymentButton = inject('store', 'signals')(
13-
hooksObserver(
14-
({
15-
id,
16-
signals: {
17-
deployment: { setDeploymentToDelete },
18-
modalOpened,
19-
},
20-
store: { deployment },
21-
}: Props) => (
22-
<Action
23-
disabled={
24-
deployment.deploysBeingDeleted
25-
? deployment.deploysBeingDeleted.includes(id)
26-
: deployment[`${id}Deleting`]
27-
}
28-
onClick={() => {
29-
setDeploymentToDelete({ id });
30-
modalOpened({ modal: 'deleteDeployment' });
31-
}}
32-
>
33-
{deployment[`${id}Deleting`] ? (
34-
'Deleting'
35-
) : (
36-
<>
37-
<TrashIcon /> <span>Delete</span>
38-
</>
39-
)}
40-
</Action>
41-
)
42-
)
43-
);
11+
export const DeleteDeploymentButton: FunctionComponent<Props> = ({ id }) => {
12+
const {
13+
actions: {
14+
deployment: { setDeploymentToDelete },
15+
modalOpened,
16+
},
17+
state: { deployment },
18+
} = useOvermind();
19+
20+
return (
21+
<Action
22+
disabled={
23+
deployment.deploysBeingDeleted
24+
? deployment.deploysBeingDeleted.includes(id)
25+
: deployment[`${id}Deleting`]
26+
}
27+
onClick={() => {
28+
setDeploymentToDelete({ id });
29+
modalOpened({ modal: 'deleteDeployment' });
30+
}}
31+
>
32+
{deployment[`${id}Deleting`] ? (
33+
'Deleting'
34+
) : (
35+
<>
36+
<TrashIcon /> <span>Delete</span>
37+
</>
38+
)}
39+
</Action>
40+
);
41+
};

0 commit comments

Comments
 (0)