-
Notifications
You must be signed in to change notification settings - Fork 52
/
AWSProfile.js
77 lines (69 loc) · 1.86 KB
/
AWSProfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
import React from 'react';
import List from '@material-ui/core/List';
import ListItem from '@material-ui/core/ListItem';
import ListItemText from '@material-ui/core/ListItemText';
import MenuItem from '@material-ui/core/MenuItem';
import Menu from '@material-ui/core/Menu';
export default class AWSProfile extends React.Component {
constructor(props) {
super(props);
this.state = {
selectedProfile: 0,
anchorEl: null,
};
}
profiles = [
'default'
];
toggle = (index) => {
this.setState({ selectedRegion: index })
}
setAnchorEl = element => {
this.setState({ anchorEl: element })
}
handleClickListItem = event => {
this.setAnchorEl(event.currentTarget);
};
handleMenuItemClick = (event, index) => {
this.toggle(index);
this.setAnchorEl(null);
this.props.setProfile(this.profiles[index]);
};
handleClose = () => {
this.setAnchorEl(null);
};
render() {
return (
<div>
<List component="nav" aria-label="Profile">
<ListItem
button
aria-haspopup="true"
aria-controls="lock-menu"
aria-label="Profile"
onClick={this.handleClickListItem}
>
<ListItemText primary="Profile" secondary={this.profiles[this.state.selectedProfile]} />
</ListItem>
</List>
<Menu
id="lock-menu"
anchorEl={this.state.anchorEl}
keepMounted
open={Boolean(this.state.anchorEl)}
onClose={this.handleClose}
>
{this.profiles.map((profile, index) => (
<MenuItem
key={profile}
selected={index === this.state.selectedProfile}
onClick={event => this.handleMenuItemClick(event, index)}
>
{profile}
</MenuItem>
))}
</Menu>
</div>
)
}
}