From dab0beedc0d8ba277630248dfee700fe2fdc822c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Se=CC=81rgio=20Ramos?= Date: Thu, 27 Jul 2017 17:58:37 +0100 Subject: [PATCH] feat(cp-frontend): don't show options when service is in a transitional state --- .../src/components/services/list-item.js | 22 +++++---- .../src/containers/services/menu.js | 8 +--- .../ui-toolkit/src/topology/node/index.js | 47 +++++++++++-------- 3 files changed, 40 insertions(+), 37 deletions(-) diff --git a/packages/cp-frontend/src/components/services/list-item.js b/packages/cp-frontend/src/components/services/list-item.js index feafaca2..e2719b7b 100644 --- a/packages/cp-frontend/src/components/services/list-item.js +++ b/packages/cp-frontend/src/components/services/list-item.js @@ -15,11 +15,7 @@ import { Anchor } from 'joyent-ui-toolkit'; -import { - InstancesIcon, - HealthyIcon, - UnhealthyIcon -} from 'joyent-ui-toolkit'; +import { InstancesIcon, HealthyIcon, UnhealthyIcon } from 'joyent-ui-toolkit'; import Status from './status'; @@ -40,6 +36,8 @@ const ServiceListItem = ({ service = {}, isChild = false }) => { + const isServiceActive = service.status === 'ACTIVE'; + const children = service.children ? service.children.map(service => + const options = isServiceActive + ? + : null; + + const header = !isChild + ? {title} - - ; + {options} + + : null; const healthyInfo = service.instancesHealthy ? { const { left, top, width, height } = data.nodeRect; + const { connected, id, children, instancesActive, isConsul, status } = data; let x = data.x; let y = data.y; - if (data.connected) { + + if (connected) { x = data.x + left; y = data.y + top; } @@ -30,7 +32,7 @@ const GraphNode = ({ y: data.y + Constants.buttonRect.y + Constants.buttonRect.height }; - if (data.connected) { + if (connected) { tooltipPosition.x += left; tooltipPosition.y += top; } @@ -50,18 +52,19 @@ const GraphNode = ({ const onStart = evt => { evt.preventDefault(); - onDragStart(evt, data.id); + onDragStart(evt, id); }; - const nodeRectEvents = data.connected + const nodeRectEvents = connected ? { onMouseDown: onStart, onTouchStart: onStart } : {}; - const nodeContent = data.children - ? data.children.reduce( + const nodeContent = !children + ? + : children.reduce( (acc, d, i) => { acc.children.push( @@ -70,20 +73,29 @@ const GraphNode = ({ return acc; }, { y: Constants.contentRect.y, children: [] } - ).children - : ; + ).children; - const nodeShadow = data.instancesActive + const nodeShadow = instancesActive ? : null; + const nodeButton = + status === 'ACTIVE' + ? + : null; + return ( {nodeShadow} @@ -92,18 +104,13 @@ const GraphNode = ({ y={0} width={width} height={height} - consul={data.isConsul} - active={data.instancesActive} - connected={data.connected} + consul={isConsul} + active={instancesActive} + connected={connected} {...nodeRectEvents} /> - + {nodeButton} {nodeContent} );