Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 28 additions & 16 deletions ui/src/features/configure/block/Utils/editVnets.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -509,11 +509,8 @@ export default function EditVnets(props) {

setVNets(newVNetData);

if(!selectionModel) {
//eslint-disable-next-line
setSelectionModel(block['vnets'].reduce((obj, vnet) => (obj[vnet.id] = vnet, obj) ,{}));
} else {
setSelectionModel(prev => {
setSelectionModel(prev => {
if(prev) {
const newSelection = {};

Object.keys(prev).forEach(key => {
Expand All @@ -523,8 +520,11 @@ export default function EditVnets(props) {
});

return newSelection;
});
}
} else {
//eslint-disable-next-line
return block['vnets'].reduce((obj, vnet) => (obj[vnet.id] = vnet, obj) ,{});
}
});
} catch (e) {
console.log("ERROR");
console.log("------------------");
Expand All @@ -536,7 +536,7 @@ export default function EditVnets(props) {
}
}
})();
}, [block, subscriptions, selectionModel, enqueueSnackbar, mockVNet]);
}, [block, subscriptions, enqueueSnackbar, mockVNet]);

function onClose() {
handleClose();
Expand Down Expand Up @@ -575,21 +575,33 @@ export default function EditVnets(props) {
React.useEffect(() => {
if(block && subscriptions) {
const newBlock = {
id: block.id,
name: block.name,
cidr: block.cidr,
vnets: block.vnets
identity: {
id: block.id,
name: block.name,
cidr: block.cidr
},
data: {
vnets: block.vnets
}
};

if(!isEqual(prevBlock, newBlock)) {
setPrevBlock(newBlock);
if(isEqual(prevBlock.identity, newBlock.identity)) {
if(!isEqual(prevBlock.data, newBlock.data)) {
refreshData();
setPrevBlock(newBlock);
}
} else {
setSelectionModel(null);
setVNets(null);
refreshData();
setPrevBlock(newBlock);
}
}

if(!block) {
setVNets(null);
if(!block && !isEmpty(prevBlock)) {
setSelectionModel(null);
setVNets(null);
setPrevBlock({});
}
}, [block, subscriptions, prevBlock, refreshData]);

Expand Down