From 939a168ce3e0a72ff50b340746efad3a8682eb25 Mon Sep 17 00:00:00 2001 From: Sonja Happ Date: Tue, 23 Feb 2021 15:57:50 +0100 Subject: [PATCH] enable create action via add IC button for new externally managed IC --- src/ic/ic-action.js | 1 - src/ic/ics.js | 36 +++++++++++++++++++++++++++++++----- src/ic/new-ic.js | 2 +- 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/src/ic/ic-action.js b/src/ic/ic-action.js index c2e4455..02d3a63 100644 --- a/src/ic/ic-action.js +++ b/src/ic/ic-action.js @@ -103,7 +103,6 @@ class ICAction extends React.Component { } } if (managerIC == null){ - console.log("DELETE action", newAction); NotificationsDataManager.addNotification(NotificationsFactory.DELETE_ERROR("Could not find manager IC with UUID " + ic.manager)); continue; } diff --git a/src/ic/ics.js b/src/ic/ics.js index 9c1f2db..95d224f 100644 --- a/src/ic/ics.js +++ b/src/ic/ics.js @@ -36,6 +36,8 @@ import ICDialog from './ic-dialog'; import ICAction from './ic-action'; import DeleteDialog from '../common/dialogs/delete-dialog'; +import NotificationsDataManager from "../common/data-managers/notifications-data-manager"; +import NotificationsFactory from "../common/data-managers/notifications-factory"; class InfrastructureComponents extends Component { static getStores() { @@ -149,11 +151,35 @@ class InfrastructureComponents extends Component { this.setState({ newModal : false }); if (data) { - AppDispatcher.dispatch({ - type: 'ics/start-add', - data, - token: this.state.sessionToken, - }); + if (!data.managedexternally) { + AppDispatcher.dispatch({ + type: 'ics/start-add', + data, + token: this.state.sessionToken, + }); + } else { + // externally managed IC: dispatch create action to selected manager + let newAction = {}; + newAction["action"] = "create"; + newAction["parameters"] = data; + newAction["when"] = new Date() + + // find the manager IC + let managerIC = this.state.ics.find(ic => ic.uuid === data.manager) + if (managerIC === null || managerIC === undefined){ + NotificationsDataManager.addNotification(NotificationsFactory.ADD_ERROR("Could not find manager IC with UUID " + data.manager)); + return; + } + + AppDispatcher.dispatch({ + type: 'ics/start-action', + icid: managerIC.id, + action: newAction, + result: null, + token: this.state.sessionToken + }); + + } } } diff --git a/src/ic/new-ic.js b/src/ic/new-ic.js index 2e81887..39aeebd 100644 --- a/src/ic/new-ic.js +++ b/src/ic/new-ic.js @@ -170,7 +170,7 @@ class NewICDialog extends React.Component { {this.props.managers.length > 0 ? <> - An externally managed component is created and managed by an IC manager via AMQP} > + An externally managed component is created and managed by an IC manager via AMQP} > this.handleChange(e)}>