From d313b5c8fcca9c2f5f04ee7d3dab9f221d4eed03 Mon Sep 17 00:00:00 2001 From: xiaor2 Date: Fri, 26 Apr 2024 20:37:46 -0500 Subject: [PATCH] Connected the install chaincode to the backend Signed-off-by: xiaor2 --- .../src/pages/ChainCode/ChainCode.js | 20 +++++++++++++++- .../src/pages/ChainCode/forms/InstallForm.js | 23 ++++++++++++++++++- src/dashboard/src/services/chaincode.js | 7 ++++++ 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/src/dashboard/src/pages/ChainCode/ChainCode.js b/src/dashboard/src/pages/ChainCode/ChainCode.js index c06751953..f4ce9a17e 100644 --- a/src/dashboard/src/pages/ChainCode/ChainCode.js +++ b/src/dashboard/src/pages/ChainCode/ChainCode.js @@ -228,7 +228,7 @@ class ChainCode extends PureComponent { if (visible) { this.fetchNodes(); this.setState({ - chainCodeName: record.packageID, + chainCodeName: record.package_id, }); } this.setState({ @@ -248,6 +248,23 @@ class ChainCode extends PureComponent { }); }; + handleInstall = (values, callback) => { + const { dispatch } = this.props; + const formData = new FormData(); + + Object.keys(values) + .filter(key => !(key === 'description' && !values[key])) // filter out empty description + .forEach(key => { + formData.append(key, values[key]); + }); + + dispatch({ + type: 'chainCode/installChainCode', + payload: formData, + callback, + }); + }; + handleUpload = (values, callback) => { const { dispatch } = this.props; const formData = new FormData(); @@ -308,6 +325,7 @@ class ChainCode extends PureComponent { installModalVisible, handleInstallModalVisible: this.handleInstallModalVisible, fetchChainCodes: this.fetchChainCodes, + handleInstall: this.handleInstall, installing, chainCodeName, nodes, diff --git a/src/dashboard/src/pages/ChainCode/forms/InstallForm.js b/src/dashboard/src/pages/ChainCode/forms/InstallForm.js index 53674b9fe..abb6e6431 100644 --- a/src/dashboard/src/pages/ChainCode/forms/InstallForm.js +++ b/src/dashboard/src/pages/ChainCode/forms/InstallForm.js @@ -1,6 +1,6 @@ import React, { useState, useEffect } from 'react'; import { injectIntl, useIntl } from 'umi'; -import { Modal, message, Select, Form, Tag } from 'antd'; +import { Modal, message, Select, Form, Tag, Input } from 'antd'; import { listNode } from '@/services/node'; import styles from '../styles.less'; @@ -17,6 +17,7 @@ const InstallForm = props => { installing, fetchChainCodes, handleInstall, + chainCodeName, } = props; useEffect(() => { @@ -101,6 +102,26 @@ const InstallForm = props => { onCancel={() => handleInstallModalVisible(false)} >
+ + +