Skip to content

Commit

Permalink
Merge pull request #5750 from mzazrivec/fix_catalog_item_delete
Browse files Browse the repository at this point in the history
Fix catalog item delete when part of catalog bundle
  • Loading branch information
h-kataria authored Jul 8, 2019
2 parents a717862 + bb0162c commit ec487e2
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions app/javascript/components/remove-catalog-item-modal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,11 @@ import { Modal } from 'patternfly-react';
import { API } from '../http_api';

const parseApiError = (error) => {
const { data: { error: { message } } } = error;
return message;
if (error.hasOwnProperty('data')) {
return error.data.error.message;
} else if (error.hasOwnProperty('message')) {
return error.message;
}
};

export const removeCatalogItems = (catalogItems) => {
Expand All @@ -15,7 +18,7 @@ export const removeCatalogItems = (catalogItems) => {
miqSparkleOn();
catalogItems.forEach(item => {
apiPromises.push(API.post(`/api/service_templates/${item.id}`, {action: 'delete'}, {skipErrors: [400, 500]})
.then((apiResult) => ({result: 'success', data: apiResult, name: item.name}))
.then((apiResult) => ({result: apiResult.success ? 'success' : 'error', data: apiResult, name: item.name}))
.catch((apiResult) => ({result: 'error', data: apiResult, name: item.name})))
});
Promise.all(apiPromises)
Expand Down

0 comments on commit ec487e2

Please sign in to comment.