Skip to content

Commit 2cde17d

Browse files
committed
refctor component
1 parent 8814a08 commit 2cde17d

File tree

1 file changed

+6
-5
lines changed
  • app/javascript/components/vm-edit-form

1 file changed

+6
-5
lines changed

app/javascript/components/vm-edit-form/index.jsx

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,12 @@ const VmEditForm = ({
1818
if (displayName === 'Image' || displayName === 'Instance') {
1919
returnURL = '/vm_cloud/explorer/';
2020
}
21+
22+
let URL = `/api/vms/${recordId}`;
23+
if (isTemplate) {
24+
URL = `/api/templates/${recordId}`;
25+
}
26+
2127
const [{
2228
initialValues, parentOptions, isLoading,
2329
}, setState] = useState({
@@ -43,7 +49,6 @@ const VmEditForm = ({
4349
/** Function to update just the description of the record on form submit. */
4450
const updateDescription = (values) => {
4551
const data = descriptionData(values);
46-
const URL = `/api/vms/${recordId}`;
4752
return API.post(URL, data)
4853
.then(() => {
4954
miqSparkleOn();
@@ -56,10 +61,6 @@ const VmEditForm = ({
5661
/** Function to update the entire record on form submit. */
5762
const updateRecord = (values) => {
5863
const data = getSubmitData(values);
59-
let URL = `/api/vms/${recordId}`;
60-
if (isTemplate) {
61-
URL = `/api/templates/${recordId}`;
62-
}
6364
return API.post(URL, data)
6465
.then(() => {
6566
miqSparkleOn();

0 commit comments

Comments
 (0)