Skip to content

Commit

Permalink
Merge pull request #121 from fogbow/deleting-ui-enhancement
Browse files Browse the repository at this point in the history
Deleting UI enhancement
  • Loading branch information
fubica authored Jul 27, 2020
2 parents 8b4839d + 0bce769 commit 8bf5ae4
Showing 1 changed file with 20 additions and 13 deletions.
33 changes: 20 additions & 13 deletions src/components/OrderComponent.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ import React, { Component } from 'react';
import { connect } from 'react-redux';

import '../styles/order.css';
import { deleteAttachment } from '../actions/attachments.actions';
import { deleteCompute } from '../actions/computes.actions';
import { deleteNetwork, deleteFedNetwork } from '../actions/networks.actions';
import { deleteVolume } from '../actions/volumes.actions';
import { deletePublicIp } from '../actions/publicIps.actions';
import { deleteAttachment, getAttachments } from '../actions/attachments.actions';
import { deleteCompute, getComputes } from '../actions/computes.actions';
import { deleteNetwork, deleteFedNetwork, getNetworks, getFedNetworks } from '../actions/networks.actions';
import { deleteVolume, getVolumes } from '../actions/volumes.actions';
import { deletePublicIp, getPublicIps } from '../actions/publicIps.actions';

const mapping = {
computes: 'Compute',
Expand All @@ -18,31 +18,38 @@ const mapping = {
};

class OrderComponent extends Component {
handleDelete = (event) => {
handleDelete = async(event) => {
event.preventDefault();
const { dispatch } = this.props;
event.target.disabled = true;

const { dispatch } = this.props;
let id = this.props.order.instanceId;
let type = this.props.type;

switch (type) {
case 'computes':
dispatch(deleteCompute(id));
await dispatch(deleteCompute(id));
await dispatch(getComputes());
break;
case 'networks':
dispatch(deleteNetwork(id));
await dispatch(deleteNetwork(id));
await dispatch(getNetworks());
break;
case 'fednets':
dispatch(deleteFedNetwork(id));
await dispatch(deleteFedNetwork(id));
await dispatch(getFedNetworks());
break;
case 'volumes':
dispatch(deleteVolume(id));
await dispatch(deleteVolume(id));
await dispatch(getVolumes());
break;
case 'attachments':
dispatch(deleteAttachment(id));
await dispatch(deleteAttachment(id));
await dispatch(getAttachments());
break;
case 'publicip':
dispatch(deletePublicIp(id));
await dispatch(deletePublicIp(id));
await dispatch(getPublicIps());
break;
default:
break;
Expand Down

0 comments on commit 8bf5ae4

Please sign in to comment.