Skip to content

Commit 7324844

Browse files
displaguena3d
authored andcommitted
handle more situations where config_id selection doesnt allow for boot (#17)
1 parent f2753d3 commit 7324844

File tree

2 files changed

+30
-6
lines changed

2 files changed

+30
-6
lines changed

src/linodes/components/ConfigSelectModalBody.js

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import PropTypes from 'prop-types';
22
import React, { Component } from 'react';
3+
import { push } from 'react-router-redux';
34

45
import { ModalFormGroup, Radio } from 'linode-components/forms';
56
import { FormModalBody } from 'linode-components/modals';
@@ -8,7 +9,6 @@ import { hideModal } from '~/actions/modal';
89
import { rebootLinode } from '~/api/ad-hoc/linodes';
910
import { dispatchOrStoreErrors } from '~/api/util';
1011

11-
1212
export default class ConfigSelectModalBody extends Component {
1313
constructor(props) {
1414
super();
@@ -31,13 +31,33 @@ export default class ConfigSelectModalBody extends Component {
3131
]));
3232
}
3333

34+
onCreateConfig = () => {
35+
const { dispatch, linode } = this.props;
36+
37+
return dispatch(push(`/linodes/${linode.label}/settings/advanced/configs/create`));
38+
}
39+
3440
render() {
3541
const { dispatch, linode, action, title } = this.props;
3642
const { errors, configId } = this.state;
3743

3844
const buttonText = action === rebootLinode ? 'Reboot' : 'Power On';
3945
const buttonDisabledText = action === rebootLinode ? 'Rebooting' : 'Powering On';
4046

47+
if (Object.values(linode._configs.configs).length === 0) {
48+
return (
49+
<FormModalBody
50+
onCancel={() => dispatch(hideModal())}
51+
onSubmit={this.onCreateConfig}
52+
buttonText="Create A Config"
53+
buttonDisabledText={buttonDisabledText}
54+
>
55+
This Linode has no configuration profiles associated with it.
56+
You must create one to boot this Linode.
57+
</FormModalBody>
58+
);
59+
}
60+
4161
return (
4262
<FormModalBody
4363
onCancel={() => dispatch(hideModal())}

src/linodes/components/StatusDropdown.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import PropTypes from 'prop-types';
33
import React, { Component } from 'react';
44
import { push } from 'react-router-redux';
55

6+
import { FormGroup } from 'linode-components/forms';
67
import { Dropdown } from 'linode-components/dropdowns';
78
import { ConfirmModalBody, DeleteModalBody } from 'linode-components/modals';
89

@@ -161,15 +162,16 @@ export default class StatusDropdown extends Component {
161162
const configs = linode._configs.configs;
162163
const configCount = Object.keys(configs).length;
163164

164-
if (configCount <= 1) {
165-
dispatch(callback(linode.id, parseInt(Object.keys(configs)[0]) || null));
166-
dispatch(hideModal());
167-
return;
165+
if (configCount === 1) {
166+
return dispatch(dispatchOrStoreErrors.call(this, [
167+
() => callback(linode.id, parseInt(Object.keys(configs)[0]) || null),
168+
() => hideModal(),
169+
]));
168170
}
169171

170172
const title = 'Select Configuration Profile';
171173

172-
dispatch(showModal(title, (
174+
return dispatch(showModal(title, (
173175
<ConfigSelectModalBody
174176
linode={linode}
175177
title={title}
@@ -232,6 +234,7 @@ export default class StatusDropdown extends Component {
232234

233235
render() {
234236
const { linode } = this.props;
237+
const { errors } = this.state;
235238

236239
const groups = this.linodeToGroups(linode);
237240

@@ -247,6 +250,7 @@ export default class StatusDropdown extends Component {
247250
className={`StatusDropdown-progress ${this.state.hiddenClass}`}
248251
/>
249252
</div>
253+
<FormGroup errors={errors} name="config_id" />
250254
</div>
251255
);
252256
}

0 commit comments

Comments
 (0)