Skip to content

Commit 5d224ec

Browse files
committed
chore(core): revert changes in shared_filesystem_storage
1 parent 6f5f0d6 commit 5d224ec

File tree

15 files changed

+140
-1943
lines changed

15 files changed

+140
-1943
lines changed
Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
import { Modal, Button } from "react-bootstrap"
2+
import { Form } from "lib/elektra-form"
3+
import { Link } from "react-router-dom"
4+
import React from "react"
5+
// import PropTypes from 'prop-types';
6+
7+
const FormBody = ({ values, networks, subnets, securityGroups }) => {
8+
const network =
9+
networks && networks.items.find((n) => n.id == values.network_id)
10+
11+
const renderIp = (ip) => {
12+
let subnet = subnets && subnets.items.find((i) => i.id == ip.subnet_id)
13+
if (subnet)
14+
return (
15+
<>
16+
{ip.ip_address} <span className="info-text">{subnet.name}</span>
17+
</>
18+
)
19+
else return ip.ip_address
20+
}
21+
22+
return (
23+
<Modal.Body>
24+
<Form.Errors />
25+
26+
<Form.ElementHorizontal label="Network" required={true} name="network_id">
27+
<p className="form-control-static">{network && network.name}</p>
28+
</Form.ElementHorizontal>
29+
30+
<Form.ElementHorizontal label="Fixed IPs" required name="fixed_ips">
31+
{values.fixed_ips &&
32+
values.fixed_ips.map((ip, index) => (
33+
<div key={index} className="form-control-static">
34+
{renderIp(ip)}
35+
</div>
36+
))}
37+
</Form.ElementHorizontal>
38+
39+
{securityGroups &&
40+
securityGroups.items &&
41+
securityGroups.items.length > 0 && (
42+
<Form.ElementHorizontal
43+
label="Security Groups"
44+
name="security_groups"
45+
>
46+
<Form.FormMultiselect
47+
name="security_groups"
48+
options={securityGroups.items}
49+
showSelectedLabel={true}
50+
selectedLabelLength={3}
51+
showIDs
52+
/>
53+
</Form.ElementHorizontal>
54+
)}
55+
56+
<Form.ElementHorizontal label="Description" name="description">
57+
<Form.Input
58+
elementType="textarea"
59+
className="text optional form-control"
60+
name="description"
61+
/>
62+
</Form.ElementHorizontal>
63+
</Modal.Body>
64+
)
65+
}
66+
67+
export default class NewPortForm extends React.Component {
68+
state = { show: true }
69+
70+
componentDidMount() {
71+
this.loadDependencies(this.props)
72+
}
73+
74+
UNSAFE_componentWillReceiveProps(nextProps) {
75+
this.loadDependencies(nextProps)
76+
}
77+
78+
loadDependencies(props) {
79+
props.loadNetworksOnce()
80+
props.loadSubnetsOnce()
81+
props.loadSecurityGroupsOnce()
82+
}
83+
84+
validate = (values) => {
85+
return true
86+
}
87+
88+
close = (e) => {
89+
if (e) e.stopPropagation()
90+
this.setState({ show: false })
91+
setTimeout(() => this.props.history.replace("/ports"), 300)
92+
}
93+
94+
onSubmit = (values) => {
95+
return this.props.handleSubmit(values).then(() => this.close())
96+
}
97+
98+
render() {
99+
return (
100+
<Modal
101+
show={this.state.show}
102+
onHide={this.close}
103+
bsSize="large"
104+
aria-labelledby="contained-modal-title-lg"
105+
>
106+
<Modal.Header closeButton>
107+
<Modal.Title id="contained-modal-title-lg">
108+
Edit Port{" "}
109+
{this.props.port &&
110+
`${this.props.port.name} (${this.props.port.id})`}
111+
</Modal.Title>
112+
</Modal.Header>
113+
114+
<Form
115+
className="form form-horizontal"
116+
validate={this.validate}
117+
onSubmit={this.onSubmit}
118+
initialValues={this.props.port}
119+
>
120+
{!this.props.port ? (
121+
<Modal.Body>
122+
<span className="spinner"></span> Loading ...
123+
</Modal.Body>
124+
) : (
125+
<FormBody
126+
networks={this.props.networks}
127+
subnets={this.props.subnets}
128+
securityGroups={this.props.securityGroups}
129+
/>
130+
)}
131+
132+
<Modal.Footer>
133+
<Button onClick={this.close}>Cancel</Button>
134+
<Form.SubmitButton label="Save" />
135+
</Modal.Footer>
136+
</Form>
137+
</Modal>
138+
)
139+
}
140+
}

plugins/networking/app/javascript/widgets/ports/components/ports/edit.tsx

Lines changed: 0 additions & 194 deletions
This file was deleted.

0 commit comments

Comments
 (0)