Skip to content

Commit

Permalink
ui/utils: Add util function to format the data for batch volume
Browse files Browse the repository at this point in the history
Refs: #2964
  • Loading branch information
ChengYanJin committed Dec 14, 2020
1 parent c1386d8 commit 20d7b8d
Showing 1 changed file with 25 additions and 0 deletions.
25 changes: 25 additions & 0 deletions ui/src/services/NodeVolumesUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -276,3 +276,28 @@ export const getVolumeListData = createSelector(
return nodeVolumes.sort((a, b) => compareHealth(b.health, a.health));
},
);

export const formatDataForBatchVolumeCreation = (newVolumes) => {
const {
multiVolumeCreation,
volumes,
node,
labels,
type,
size,
storageClass,
} = newVolumes;
if (multiVolumeCreation) {
// multi volume creation mode
return (
volumes?.map((volume) => {
volume.node = node;
volume.labels = labels;
volume.type = type;
volume.size = size;
volume.storageClass = storageClass;
return volume;
}) ?? []
);
}
};

0 comments on commit 20d7b8d

Please sign in to comment.