Skip to content

Commit 8a776a7

Browse files
author
Sergiu Miclea
committed
Display a message if the selected instances have no NICs in Wizard's Networks page
1 parent 57cb230 commit 8a776a7

2 files changed

Lines changed: 43 additions & 12 deletions

File tree

src/components/WizardNetworks/WizardNetworks.js

Lines changed: 37 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ class WizardNetworks extends Component {
6565
this.state = {
6666
networks: networks || null,
6767
nextStep: "WizardSummary",
68-
valid: valid
68+
valid: valid,
69+
hasNoNics: false
6970
}
7071
}
7172

@@ -80,9 +81,14 @@ class WizardNetworks extends Component {
8081

8182
processProps(props) {
8283
let networks = []
84+
let hasNoNics = false
8385

8486
props.data.selectedInstances.forEach((vm) => {
8587
if (vm.devices && vm.devices.nics) {
88+
if (vm.devices.nics.length === 0) {
89+
hasNoNics = true
90+
}
91+
8692
vm.devices.nics.forEach((item) => {
8793
let exists = false
8894
networks.forEach(network => {
@@ -100,9 +106,12 @@ class WizardNetworks extends Component {
100106
}
101107
})
102108

103-
if (networks.length == 0) {
109+
if (networks.length === 0) {
104110
networks = null
111+
} else {
112+
hasNoNics = false
105113
}
114+
106115
if (props.data.targetNetworks && props.data.targetNetworks.length) {
107116
this.networkOptions = []
108117

@@ -116,7 +125,11 @@ class WizardNetworks extends Component {
116125
})
117126
}, this)
118127
}
119-
this.setState({ networks: networks })
128+
129+
this.setState({
130+
networks: networks,
131+
hasNoNics: hasNoNics
132+
})
120133
}
121134

122135
handleChangeNetwork(event, network) {
@@ -139,6 +152,18 @@ class WizardNetworks extends Component {
139152
}
140153

141154
render() {
155+
if (this.state.hasNoNics) {
156+
return (
157+
<div className={s.root}>
158+
<div className={s.container}>
159+
<div className="items-list">
160+
<div className={s.message}>The selected instances have no NICs.</div>
161+
</div>
162+
</div>
163+
</div>
164+
)
165+
}
166+
142167
if (this.state.networks != null) {
143168
let networks = this.state.networks.map((network, index) => {
144169
let networkDropdown
@@ -180,17 +205,17 @@ class WizardNetworks extends Component {
180205
</div>
181206
</div>
182207
);
183-
} else {
184-
return (
185-
<div className={s.root}>
186-
<div className={s.container}>
187-
<div className="items-list">
188-
<LoadingIcon text="Loading networks..." />
189-
</div>
208+
}
209+
210+
return (
211+
<div className={s.root}>
212+
<div className={s.container}>
213+
<div className="items-list">
214+
<LoadingIcon text="Loading networks..." />
190215
</div>
191216
</div>
192-
);
193-
}
217+
</div>
218+
);
194219
}
195220

196221
}

src/components/WizardNetworks/WizardNetworks.scss

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,10 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
6060
margin: 0 auto;
6161
padding: 0 0 40px;
6262
max-width: $max-content-width;
63+
64+
.message {
65+
font-size: 16px;
66+
text-align: center;
67+
margin-top: 32px;
68+
}
6369
}

0 commit comments

Comments
 (0)