From 54250a090ae97b32da6d7c115b755cec748466c3 Mon Sep 17 00:00:00 2001 From: Kavashen Pather Date: Wed, 5 May 2021 10:28:39 +1000 Subject: [PATCH] feat: add node multi entity select (#68) --- .../components/node/manage.js | 22 ++++++++++++++----- 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/nerdlets/observability-maps-nerdlet/components/node/manage.js b/nerdlets/observability-maps-nerdlet/components/node/manage.js index 508c6bc..9370f5c 100644 --- a/nerdlets/observability-maps-nerdlet/components/node/manage.js +++ b/nerdlets/observability-maps-nerdlet/components/node/manage.js @@ -39,7 +39,6 @@ export default class ManageNodes extends React.PureComponent { action = async (action, mapConfig, updateDataContextState, entity, node) => { let { selectedAccount, selectedNodeType, customNodeName } = this.state; - this.setState({ open: false }); if (entity) selectedNodeType = 'entity'; if (node) selectedNodeType = 'node'; @@ -121,11 +120,15 @@ export default class ManageNodes extends React.PureComponent { } updateDataContextState({ mapConfig }, ['saveMap']); - this.setState({ - selectedNodeType: null, - searchedEntities: [], - customNodeName: '' - }); + const stateUpdate = { + [`${entity.name} [${entity.domain}]`]: action === 'add' + }; + + if (selectedNodeType === 'custom') { + stateUpdate.customNodeName = ''; + } + + this.setState(stateUpdate); }; fetchEntities = async cursor => { @@ -363,12 +366,19 @@ export default class ManageNodes extends React.PureComponent { : false ) .map((entity, i) => { + // check artifical status + const stateStatus = this.state[ + `${entity.name} [${entity.domain}]` + ]; + // keep both for backwards compatibility const exists = + stateStatus || mapConfig.nodeData[entity.name] || mapConfig.nodeData[ `${entity.name} [${entity.domain}]` ]; + return ( {entity.name}