|
|
|
@ -17,7 +17,7 @@
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
import React from "react";
|
|
|
|
|
import {Button, Icon, notification} from "antd";
|
|
|
|
|
import {Button, Tooltip, Popconfirm, Divider} from "antd";
|
|
|
|
|
|
|
|
|
|
class BulkActionBar extends React.Component {
|
|
|
|
|
|
|
|
|
@ -25,58 +25,82 @@ class BulkActionBar extends React.Component {
|
|
|
|
|
super(props);
|
|
|
|
|
this.state = {
|
|
|
|
|
selectedMultiple: false,
|
|
|
|
|
selectedSingle:false
|
|
|
|
|
selectedSingle: false,
|
|
|
|
|
deleteable: true,
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//This method is used to trigger delete request on selected devices
|
|
|
|
|
deleteDevice = () => {
|
|
|
|
|
const deviceStatusArray = this.props.selectedRows.map(obj => obj.enrolmentInfo.status);
|
|
|
|
|
if(deviceStatusArray.includes("ACTIVE") || deviceStatusArray.includes("INACTIVE")){
|
|
|
|
|
notification["error"]({
|
|
|
|
|
message: "There was a problem",
|
|
|
|
|
duration: 0,
|
|
|
|
|
description:
|
|
|
|
|
"Cannot delete ACTIVE/INACTIVE devices.",
|
|
|
|
|
});
|
|
|
|
|
}else{
|
|
|
|
|
this.props.deleteDevice();
|
|
|
|
|
onDeleteDeviceCall = () => {
|
|
|
|
|
let i;
|
|
|
|
|
for(i=0; i < this.props.selectedRows.length; i++){
|
|
|
|
|
if(this.props.selectedRows[i].enrolmentInfo.status != "REMOVED"){
|
|
|
|
|
this.setState({deletable:false});
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
this.setState({deletable:true});
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
componentDidUpdate(prevProps, prevState, snapshot) {
|
|
|
|
|
if(prevProps.selectedRows !== this.props.selectedRows){
|
|
|
|
|
if(this.props.selectedRows.length > 1){
|
|
|
|
|
this.setState({selectedMultiple:true,selectedSingle:false})
|
|
|
|
|
}else if(this.props.selectedRows.length == 1){
|
|
|
|
|
this.setState({selectedSingle:true,selectedMultiple:true})
|
|
|
|
|
}else{
|
|
|
|
|
this.setState({selectedSingle:false,selectedMultiple:false})
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
onConfirmDelete = () => {
|
|
|
|
|
if (this.state.deletable) {
|
|
|
|
|
this.props.deleteDevice();
|
|
|
|
|
}
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
onConfirmDisenroll = () => {
|
|
|
|
|
//TODO: Implement disenrollment function
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
render() {
|
|
|
|
|
const isSelected = this.props.selectedRows.length > 0;
|
|
|
|
|
const isSelectedSingle = this.props.selectedRows.length == 1;
|
|
|
|
|
|
|
|
|
|
return (
|
|
|
|
|
<div style={{padding:'5px'}}>
|
|
|
|
|
<div
|
|
|
|
|
style={{display: isSelected ? "inline" : "none", padding: '11px'}}>
|
|
|
|
|
|
|
|
|
|
<Tooltip
|
|
|
|
|
placement="bottom"
|
|
|
|
|
title={"Delete Device"}
|
|
|
|
|
autoAdjustOverflow={true}>
|
|
|
|
|
<Popconfirm
|
|
|
|
|
placement="topLeft"
|
|
|
|
|
title={
|
|
|
|
|
this.state.deletable ?
|
|
|
|
|
"Are you sure you want to delete?" : "You can only delete disenrolled devices"}
|
|
|
|
|
onConfirm={this.onConfirmDelete}
|
|
|
|
|
okText="Ok"
|
|
|
|
|
cancelText="Cancel">
|
|
|
|
|
|
|
|
|
|
<Button
|
|
|
|
|
type="normal"
|
|
|
|
|
type="link"
|
|
|
|
|
shape="circle"
|
|
|
|
|
icon="delete"
|
|
|
|
|
size={'default'}
|
|
|
|
|
onClick={this.deleteDevice}
|
|
|
|
|
style={
|
|
|
|
|
{display:this.state.selectedMultiple ? "inline" : "none"}
|
|
|
|
|
}>Delete
|
|
|
|
|
</Button>
|
|
|
|
|
|
|
|
|
|
onClick={this.onDeleteDeviceCall}
|
|
|
|
|
disabled={isSelected ? false : true}
|
|
|
|
|
style={{margin: "2px"}}/>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
<Divider type="vertical"/>
|
|
|
|
|
<Tooltip placement="bottom" title={"Disenroll Device"}>
|
|
|
|
|
<Popconfirm
|
|
|
|
|
placement="topLeft"
|
|
|
|
|
title={"Are you sure?"}
|
|
|
|
|
onConfirm={this.onConfirmDisenroll}
|
|
|
|
|
okText="Ok"
|
|
|
|
|
disabled={isSelectedSingle ? false : true}
|
|
|
|
|
cancelText="Cancel">
|
|
|
|
|
<Button
|
|
|
|
|
type="normal"
|
|
|
|
|
icon="delete"
|
|
|
|
|
type="link"
|
|
|
|
|
shape="circle"
|
|
|
|
|
icon="close"
|
|
|
|
|
size={'default'}
|
|
|
|
|
style={
|
|
|
|
|
{display:this.state.selectedSingle ? "inline" : "none"}
|
|
|
|
|
}>Disenroll
|
|
|
|
|
</Button>
|
|
|
|
|
disabled={isSelectedSingle ? false : true}
|
|
|
|
|
style={{margin: "2px"}}/>
|
|
|
|
|
</Popconfirm>
|
|
|
|
|
</Tooltip>
|
|
|
|
|
</div>
|
|
|
|
|
)
|
|
|
|
|
}
|
|
|
|
|