Refactor edge frontend code and reporter

- Refactor dotted edge logic.
- Change Storage view to show storage components as well as all
  the pods.
- Sentence case storage related variables.

Signed-off-by: Satyam Zode <satyam.zode@openebs.io>
This commit is contained in:
Satyam Zode
2018-06-05 21:23:58 +05:30
parent 24741bec2a
commit d9bd17af8a
4 changed files with 24 additions and 37 deletions

View File

@@ -5,20 +5,28 @@ import classNames from 'classnames';
import { enterEdge, leaveEdge } from '../actions/app-actions';
import { encodeIdAttribute, decodeIdAttribute } from '../utils/dom-utils';
function isStorageComponent(id) {
if (id === '<persistent_volume>' || id === '<storage_class>' || id === '<persistent_volume_claim>') {
return true;
}
return false;
}
// getAdjacencyClass takes id which contains information about edge as a topology
// of parent and child node.
// For example: id is of form "nodeA;<storage_class>---nodeB;<persistent_volume_claim>"
function getAdjacencyClass(id) {
const topologyId = id.split('---');
const from = topologyId[0].split(';');
const to = topologyId[1].split(';');
if (from[1] !== undefined && to[1] !== undefined) {
from[1] = from[1].slice(1, -1);
to[1] = to[1].slice(1, -1);
if ((from[1] === 'persistent_volume' || from[1] === 'storage_class' || from[1] === 'persistent_volume_claim') || (to[1] === 'persistent_volume' || to[1] === 'storage_class' || to[1] === 'persistent_volume_claim')) {
const fromNode = topologyId[0].split(';');
const toNode = topologyId[1].split(';');
if (fromNode[1] !== undefined && toNode[1] !== undefined) {
if (isStorageComponent(fromNode[1]) || isStorageComponent(toNode[1])) {
return 'link-storage';
}
}
return 'link-none';
}
class Edge extends React.Component {
constructor(props, context) {
super(props, context);