|
1 | | -import { inject, hooksObserver } from 'app/componentConnectors'; |
2 | | -import React from 'react'; |
| 1 | +import React, { FunctionComponent } from 'react'; |
3 | 2 | import TrashIcon from 'react-icons/lib/fa/trash'; |
4 | 3 |
|
| 4 | +import { useOvermind } from 'app/overmind'; |
| 5 | + |
5 | 6 | import { Action } from '../../../../elements'; |
6 | 7 |
|
7 | 8 | type Props = { |
8 | 9 | id: string; |
9 | | - store: any; |
10 | | - signals: any; |
11 | 10 | }; |
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