Skip to content

Commit 86fc123

Browse files
committed
Allow deletion of environments via UI
1 parent 264f4d3 commit 86fc123

File tree

6 files changed

+388
-109
lines changed

6 files changed

+388
-109
lines changed

services/ui/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
"react-copy-to-clipboard": "^5.0.1",
3333
"react-dom": "^16.4.2",
3434
"react-highlight-words": "^0.14.0",
35+
"react-modal": "^3.8.1",
3536
"react-select": "^2.1.1",
3637
"react-typekit": "^1.1.3",
3738
"recompose": "^0.30.0",
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
import React from 'react';
2+
import Modal from '../Modal';
3+
import { color, fontSize, bp } from '../../variables';
4+
import withLogic from './logic';
5+
6+
const DeleteConfirm = ({
7+
deleteType,
8+
deleteName,
9+
onDelete,
10+
inputValue,
11+
setInputValue,
12+
open,
13+
openModal,
14+
closeModal
15+
}) => {
16+
return (
17+
<React.Fragment>
18+
<button className="button--page" onClick={openModal}>
19+
Delete
20+
</button>
21+
<Modal
22+
isOpen={open}
23+
onRequestClose={closeModal}
24+
contentLabel={`Confirm delete ${deleteType}`}
25+
>
26+
<React.Fragment>
27+
<p>
28+
This will delete all resources associated with the {deleteType}{' '}
29+
<span className="delete-name">{deleteName}</span> and cannot be
30+
undone. Make sure this is something you really want to do!
31+
</p>
32+
<p>Type the name of the {deleteType} to confirm.</p>
33+
<div className="form-input">
34+
<input type="text" value={inputValue} onChange={setInputValue} />
35+
<a href="#" className="hover-state" onClick={closeModal}>
36+
cancel
37+
</a>
38+
<button
39+
className="button--modal"
40+
disabled={inputValue !== deleteName}
41+
onClick={() => onDelete()}
42+
>
43+
Delete
44+
</button>
45+
</div>
46+
</React.Fragment>
47+
</Modal>
48+
<style jsx>{`
49+
input {
50+
margin-right: 10px;
51+
width: 100%;
52+
}
53+
button {
54+
margin-right: 10px;
55+
cursor: pointer;
56+
}
57+
a.hover-state {
58+
margin-right: 10px;
59+
color: ${color.blue};
60+
}
61+
.delete-name {
62+
font-weight: bold;
63+
color: ${color.lightBlue};
64+
}
65+
.form-input {
66+
display: flex;
67+
}
68+
.button--page {
69+
align-self: flex-end;
70+
background-color: ${color.midGrey};
71+
border: none;
72+
border-radius: 20px;
73+
color: ${color.darkGrey};
74+
font-family: 'source-code-pro', sans-serif;
75+
${fontSize(13)};
76+
padding: 3px 20px 2px;
77+
text-transform: uppercase;
78+
@media ${bp.tinyUp} {
79+
align-self: auto;
80+
}
81+
}
82+
.button--modal {
83+
align-self: flex-end;
84+
background-color: ${color.lightestGrey};
85+
border: none;
86+
border-radius: 20px;
87+
color: ${color.darkGrey};
88+
font-family: 'source-code-pro', sans-serif;
89+
${fontSize(13)};
90+
padding: 3px 20px 2px;
91+
text-transform: uppercase;
92+
@media ${bp.tinyUp} {
93+
align-self: auto;
94+
}
95+
96+
&:disabled {
97+
color: ${color.grey};
98+
cursor: default;
99+
}
100+
}
101+
`}</style>
102+
</React.Fragment>
103+
);
104+
};
105+
106+
export default withLogic(DeleteConfirm);
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import compose from 'recompose/compose';
2+
import withState from 'recompose/withState';
3+
import withHandlers from 'recompose/withHandlers';
4+
5+
const withInputValue = withState('inputValue', 'setInputValue', '');
6+
const withInputHandlers = withHandlers({
7+
setInputValue: ({ setInputValue }) => event =>
8+
setInputValue(event.target.value)
9+
});
10+
11+
const withModalState = withState('open', 'setOpen', false);
12+
const withModalHandlers = withHandlers({
13+
openModal: ({ setOpen }) => () => setOpen(true),
14+
closeModal: ({ setOpen }) => () => setOpen(false)
15+
});
16+
17+
export default compose(
18+
withInputValue,
19+
withInputHandlers,
20+
withModalState,
21+
withModalHandlers
22+
);

0 commit comments

Comments
 (0)