diff --git a/src/pages/infrastructure/dialogs/new-ic-dialog.js b/src/pages/infrastructure/dialogs/new-ic-dialog.js index a4380e7..c12a01f 100644 --- a/src/pages/infrastructure/dialogs/new-ic-dialog.js +++ b/src/pages/infrastructure/dialogs/new-ic-dialog.js @@ -27,7 +27,6 @@ class NewICDialog extends React.Component { constructor(props) { super(props); - this.state = { name: '', websocketurl: '', @@ -103,9 +102,9 @@ class NewICDialog extends React.Component { setManager(e) { this.setState({ [e.target.id]: e.target.value }); - if (this.props.managers) { - let schema = this.props.managers.find(m => m.uuid === e.target.value).createparameterschema + let manager = this.props.managers.find(m => m.uuid === e.target.value) + let schema = manager ? manager.createparameterschema : false if (schema) { $RefParser.dereference(schema, (err, deref) => { if (err) { @@ -116,6 +115,9 @@ class NewICDialog extends React.Component { } }) } + else{ + this.setState({schema:{}}) + } } } diff --git a/src/pages/infrastructure/infrastructure.js b/src/pages/infrastructure/infrastructure.js index 0c22168..e992c27 100644 --- a/src/pages/infrastructure/infrastructure.js +++ b/src/pages/infrastructure/infrastructure.js @@ -77,14 +77,30 @@ const Infrastructure = () => { newAction["action"] = "create"; newAction["parameters"] = data.parameters; newAction["when"] = new Date(); - // find the manager IC const managerIC = 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; } - + switch (managerIC.type){ + case "kubernetes","kubernetes-simple": + newAction["parameters"]["type"] = "kubernetes" + newAction["parameters"]["category"] = "simulator" + delete newAction.parameters.location + delete newAction.parameters.description + if (newAction.parameters.uuid === undefined){ + delete newAction.parameters.uuid + } + break; + case "generic": + // should check that the form contains following VALID MANDATORY fields: + // name, type , owner,realm,ws_url,api_url,category and location <= generic create action schema + break; + default: + NotificationsDataManager.addNotification(NotificationsFactory.ADD_ERROR("Creation not supported for manager type " + managerIC.type)); + return; + } dispatch(sendActionToIC({token: sessionToken, id: managerIC.id, actions: newAction})) } }