From 7f6aafb034e3ca841749d0ecc34f05b7d02a77a3 Mon Sep 17 00:00:00 2001 From: Jandiasnow <88074479@qq.com> Date: Fri, 10 Mar 2023 17:17:12 +0800 Subject: [PATCH] fix: change add node message (#78) --- src/pages/NetworkChannelDetail/index.jsx | 2 +- src/pages/NetworkContractDetail/index.jsx | 37 +- src/pages/NetworkDetail/index.jsx | 1943 +++++++++++---------- src/pages/OrganizationDetail/index.jsx | 4 +- 4 files changed, 1015 insertions(+), 971 deletions(-) diff --git a/src/pages/NetworkChannelDetail/index.jsx b/src/pages/NetworkChannelDetail/index.jsx index 2d8d431..800f847 100644 --- a/src/pages/NetworkChannelDetail/index.jsx +++ b/src/pages/NetworkChannelDetail/index.jsx @@ -81,7 +81,7 @@ class NetworkChannelDetail$$Page extends React.Component { actions={[]} bordered={false} hoverable={false} - loading={false} + loading={__$$eval(() => this.props.useGetChannel?.loading)} size="default" style={{ height: '250px' }} type="default" diff --git a/src/pages/NetworkContractDetail/index.jsx b/src/pages/NetworkContractDetail/index.jsx index 26b73e3..18176d4 100644 --- a/src/pages/NetworkContractDetail/index.jsx +++ b/src/pages/NetworkContractDetail/index.jsx @@ -83,7 +83,9 @@ class NetworkContractDetail$$Page extends React.Component { actions={[]} bordered={false} hoverable={false} - loading={false} + loading={__$$eval( + () => this.props.useGetChaincodebuild?.loading + )} size="default" style={{ height: '300px' }} type="default" @@ -116,7 +118,11 @@ class NetworkContractDetail$$Page extends React.Component { strong={false} style={{ fontSize: '' }} > - text + {__$$eval( + () => + this.props.useGetChaincodebuild?.data + ?.chaincodebuild?.name + )} ), key: '9qhq7vaoun', @@ -132,7 +138,11 @@ class NetworkContractDetail$$Page extends React.Component { strong={false} style={{ fontSize: '' }} > - text + {__$$eval( + () => + this.props.useGetChaincodebuild?.data + ?.chaincodebuild?.version + )} ), key: 'pvlb9npuf1', @@ -145,7 +155,11 @@ class NetworkContractDetail$$Page extends React.Component { __component_name="Typography.Time" format="" relativeTime={false} - time="" + time={__$$eval( + () => + this.props.useGetChaincodebuild?.data + ?.chaincodebuild?.creationTimestamp + )} /> ), key: '3fvfujee7p7', @@ -178,7 +192,11 @@ class NetworkContractDetail$$Page extends React.Component { strong={false} style={{ fontSize: '' }} > - text + {__$$eval( + () => + this.props.useGetChaincodebuild?.data + ?.chaincodebuild?.initiator + )} ), key: 'zvaiq32eosn', @@ -364,6 +382,9 @@ class NetworkContractDetail$$Page extends React.Component { { title: this.i18n('i18n-6uzygunv') /* 合约日志 */ }, ]} dataSource={__$$eval(() => [{}])} + loading={__$$eval( + () => this.props.useGetChaincodebuild?.loading + )} pagination={false} rowKey="id" scroll={{ scrollToFirstRowOnChange: true, y: 180 }} @@ -447,6 +468,9 @@ class NetworkContractDetail$$Page extends React.Component { this.props.useGetChaincodebuild?.data ?.chaincodebuild?.organizations || [] )} + loading={__$$eval( + () => this.props.useGetChaincodebuild?.loading + )} pagination={false} rowKey="id" scroll={{ scrollToFirstRowOnChange: true, y: 180 }} @@ -523,6 +547,9 @@ class NetworkContractDetail$$Page extends React.Component { this.props.useGetChaincodebuild?.data ?.chaincodebuild?.channels || [] )} + loading={__$$eval( + () => this.props.useGetChaincodebuild?.loading + )} pagination={false} rowKey="id" scroll={{ scrollToFirstRowOnChange: true, y: 180 }} diff --git a/src/pages/NetworkDetail/index.jsx b/src/pages/NetworkDetail/index.jsx index 38af051..b44d4c3 100644 --- a/src/pages/NetworkDetail/index.jsx +++ b/src/pages/NetworkDetail/index.jsx @@ -64,26 +64,28 @@ class NetworkDetail$$Page extends React.Component { __$$i18n._inject2(this); this.state = { - isOpenModal: false, - modalType: 'addchannel', - organization: { + allPeers: [], + channel: { filter: 'ALL', searchValue: undefined, searchKey: 'name', size: 10, current: 1, record: {}, + step: 0, }, - channel: { + channelPeers: [], + contract: { filter: 'ALL', searchValue: undefined, searchKey: 'name', size: 10, current: 1, record: {}, - step: 0, }, - contract: { + isOpenModal: false, + modalType: 'addchannel', + organization: { filter: 'ALL', searchValue: undefined, searchKey: 'name', @@ -91,6 +93,8 @@ class NetworkDetail$$Page extends React.Component { current: 1, record: {}, }, + organizations: [], + peers: [], strategy: { filter: 'ALL', searchValue: undefined, @@ -101,10 +105,6 @@ class NetworkDetail$$Page extends React.Component { list: [], channels: [], }, - organizations: [], - peers: [], - channelPeers: [], - allPeers: [], }; } @@ -118,44 +118,89 @@ class NetworkDetail$$Page extends React.Component { componentWillUnmount() {} - async getChannelsForCreateEpolicy(callback) { - var _this$match, - _this$match$params, - _res$channelsForCreat, - _this$$, - _this$$$formRef, - _this$$$formRef$curre, - _res$channelsForCreat2; - const res = - await this.props.appHelper.utils.bff.getChannelsForCreateEpolicy({ - network: - (_this$match = this.match) === null || _this$match === void 0 + beforeUpload() { + return false; + } + + changeContractVersion(e, payload) { + var _payload$record; + this.setState({ + initVersions: { + ...this.state.initVersions, + [payload === null || payload === void 0 + ? void 0 + : (_payload$record = payload.record) === null || + _payload$record === void 0 + ? void 0 + : _payload$record.displayName]: e.key, + }, + }); + } + + async channelAddModalConfirm(e, payload) { + var _this$props$useGetNet, _this$props$useGetNet2; + const network = + ((_this$props$useGetNet = this.props.useGetNetwork) === null || + _this$props$useGetNet === void 0 + ? void 0 + : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || + _this$props$useGetNet2 === void 0 + ? void 0 + : _this$props$useGetNet2.network) || {}; + try { + var _this$state, _this$state$channel, _this$state$channelPe; + const res = await this.props.appHelper.utils.bff.createChannel({ + network: network === null || network === void 0 ? void 0 : network.name, + channel: { + ...(((_this$state = this.state) === null || _this$state === void 0 ? void 0 - : (_this$match$params = _this$match.params) === null || - _this$match$params === void 0 + : (_this$state$channel = _this$state.channel) === null || + _this$state$channel === void 0 ? void 0 - : _this$match$params.id, - }); - this.setState( - { - strategy: { - ...this.state.strategy, - channels: - (res === null || res === void 0 - ? void 0 - : (_res$channelsForCreat = res.channelsForCreateEpolicy) === - null || _res$channelsForCreat === void 0 + : _this$state$channel.addData) || {}), + peers: + (_this$state$channelPe = this.state.channelPeers) === null || + _this$state$channelPe === void 0 ? void 0 - : _res$channelsForCreat.map((item) => ({ - value: JSON.stringify(item), - label: item.name, - }))) || [], + : _this$state$channelPe.map((key) => { + var _this$state$allPeers; + const item = + (_this$state$allPeers = this.state.allPeers) === null || + _this$state$allPeers === void 0 + ? void 0 + : _this$state$allPeers.find((item) => item.key === key); + return { + name: item.name, + namespace: item.namespace, + }; + }), }, - }, - callback - ); + }); + // this.closeModal() + // this.utils.notification.success({ + // message: this.i18n('i18n-l8fybssesij'), + // }) + this.openAddChannelSuccessModal(); + this.props.useGetNetwork.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-85kkwp67i5u'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + } + + channelAddModalNext() { + var _this$$, _this$$$formRef, _this$$$formRef$curre; const form = - (_this$$ = this.$('formily_create_strategy')) === null || + (_this$$ = this.$('formily_create_channel')) === null || _this$$ === void 0 ? void 0 : (_this$$$formRef = _this$$.formRef) === null || @@ -165,130 +210,470 @@ class NetworkDetail$$Page extends React.Component { _this$$$formRef$curre === void 0 ? void 0 : _this$$$formRef$curre.form; - form.setFieldState('channel', { - dataSource: - (res === null || res === void 0 - ? void 0 - : (_res$channelsForCreat2 = res.channelsForCreateEpolicy) === null || - _res$channelsForCreat2 === void 0 - ? void 0 - : _res$channelsForCreat2.map((item) => ({ - value: JSON.stringify(item), - label: item.name, - }))) || [], + form.submit(async (v) => { + this.setState({ + channel: { + ...this.state.channel, + addData: v, + step: 1, + }, + }); + this.getPeers(v, () => {}); }); } - async getEpolicies() { - var _this$match, _this$match$params; - const res = await this.props.appHelper.utils.bff.getEpolicies({ - network: - (_this$match = this.match) === null || _this$match === void 0 - ? void 0 - : (_this$match$params = _this$match.params) === null || - _this$match$params === void 0 - ? void 0 - : _this$match$params.id, - }); - this.setState({ - strategy: { - ...this.state.strategy, - list: (res === null || res === void 0 ? void 0 : res.epolicies) || [], + channelAddModalPre() { + this.setState( + { + channel: { + ...this.state.channel, + step: 0, + }, }, - }); + () => { + var _this$$, _this$$$formRef, _this$$$formRef$curre; + const form = + (_this$$ = this.$('formily_create_channel')) === null || + _this$$ === void 0 + ? void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.setValues(this.state.channel.addData); + } + ); } - async getPeers(v, callback, usedPeers) { - var _ref, - _res$ibppeersForCreat, - _res$ibppeersForCreat2, - _res$ibppeersForCreat3; - const { initiator, organizations } = v; - const res = - await this.props.appHelper.utils.bff.getIbppeersForCreateChannel({ - members: - (_ref = [initiator, ...organizations]) === null || _ref === void 0 + channelAddOrganizationModalConfirm(e, payload) { + this.openAddChannelOrganizationSuccessModal(); + // const network = this.props.useGetNetwork?.data?.network || {} + // const form = this.$('formily_create')?.formRef?.current?.form + // form.submit(async v => { + // console.log(v) + // try { + // // const res = await this.props.appHelper.utils.bff.updateChannel({ + // // name: network?.name, + // // organizations: v.organizations, + // // initiator: network?.initiator?.name + // // }) + // // this.closeModal() + // // this.utils.notification.success({ + // // message: this.i18n('i18n-l8fybssesij'), + // // }) + // this.openAddChannelSuccessModal() + // this.props.useGetNetwork.mutate() + // } catch (error) { + // this.utils.notification.warnings({ + // message: this.i18n('i18n-85kkwp67i5u'), + // errors: error?.response?.errors + // }) + // } + // }) + } + + async channelAddPeerModalConfirm(e, payload) { + var _this$props$useGetNet, _this$props$useGetNet2; + const network = + ((_this$props$useGetNet = this.props.useGetNetwork) === null || + _this$props$useGetNet === void 0 + ? void 0 + : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || + _this$props$useGetNet2 === void 0 + ? void 0 + : _this$props$useGetNet2.network) || {}; + try { + var _this$state$channel, _this$state$channel$r, _this$state$channelPe; + const res = await this.props.appHelper.utils.bff.updateChannel({ + name: + (_this$state$channel = this.state.channel) === null || + _this$state$channel === void 0 ? void 0 - : _ref.filter((item) => item), - }); - const allPeers = []; - res === null || res === void 0 - ? void 0 - : (_res$ibppeersForCreat = res.ibppeersForCreateChannel) === null || - _res$ibppeersForCreat === void 0 - ? void 0 - : _res$ibppeersForCreat.forEach((item) => { - var _item$ibppeers; - (_item$ibppeers = item.ibppeers) === null || _item$ibppeers === void 0 + : (_this$state$channel$r = _this$state$channel.record) === null || + _this$state$channel$r === void 0 ? void 0 - : _item$ibppeers.forEach((peer) => { - allPeers.push({ - name: peer.name, - namespace: item.name, - key: item.name + peer.name, - }); - }); + : _this$state$channel$r.name, + channel: { + operate: 'add', + // remove + peers: + (_this$state$channelPe = this.state.channelPeers) === null || + _this$state$channelPe === void 0 + ? void 0 + : _this$state$channelPe.map((key) => { + var _this$state$allPeers; + const item = + (_this$state$allPeers = this.state.allPeers) === null || + _this$state$allPeers === void 0 + ? void 0 + : _this$state$allPeers.find((item) => item.key === key); + return { + name: item.name, + namespace: item.namespace, + }; + }), + }, + }); + this.closeModal(); + this.utils.notification.success({ + message: this.i18n('i18n-knuex06q'), + }); + // this.openAddChannelSuccessModal() + this.props.useGetNetwork.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-sunw6qwy'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + } + + channelPeersChange(channelPeers) { + this.setState({ + channelPeers, + }); + } + + closeModal() { + this.setState({ + isOpenModal: false, + channelPeers: [], + }); + } + + confirmAddContractModal(e, payload) { + var _this$props$useGetNet, + _this$props$useGetNet2, + _this$$, + _this$$$formRef, + _this$$$formRef$curre; + const network = + ((_this$props$useGetNet = this.props.useGetNetwork) === null || + _this$props$useGetNet === void 0 + ? void 0 + : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || + _this$props$useGetNet2 === void 0 + ? void 0 + : _this$props$useGetNet2.network) || {}; + const form = + (_this$$ = this.$('formily_create_contract')) === null || + _this$$ === void 0 + ? void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.submit(async (v) => { + try { + var _this$match, _this$match$params, _v$files, _v$files$fileList; + const res = await this.props.appHelper.utils.bff.createChaincodebuild({ + ...v, + network: + (_this$match = this.match) === null || _this$match === void 0 + ? void 0 + : (_this$match$params = _this$match.params) === null || + _this$match$params === void 0 + ? void 0 + : _this$match$params.id, + files: + (_v$files = v.files) === null || _v$files === void 0 + ? void 0 + : (_v$files$fileList = _v$files.fileList) === null || + _v$files$fileList === void 0 + ? void 0 + : _v$files$fileList.map((item) => item.originFileObj), }); - const peers = - (res === null || res === void 0 + this.closeModal(); + this.utils.notification.success({ + message: this.i18n('i18n-5eg2znpg'), + }); + this.props.useGetChaincodebuilds.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-rw4x2dt7'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + }); + } + + confirmAddStrategyModal(e, payload) { + var _this$props$useGetNet, + _this$props$useGetNet2, + _this$$, + _this$$$formRef, + _this$$$formRef$curre; + const network = + ((_this$props$useGetNet = this.props.useGetNetwork) === null || + _this$props$useGetNet === void 0 ? void 0 - : (_res$ibppeersForCreat2 = res.ibppeersForCreateChannel) === null || - _res$ibppeersForCreat2 === void 0 + : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || + _this$props$useGetNet2 === void 0 ? void 0 - : (_res$ibppeersForCreat3 = _res$ibppeersForCreat2.map((item) => { - var _item$ibppeers2, _item$ibppeers2$filte, _item$ibppeers2$filte2; - return { - key: item.name, - title: item.name, - children: - (_item$ibppeers2 = item.ibppeers) === null || - _item$ibppeers2 === void 0 - ? void 0 - : (_item$ibppeers2$filte = _item$ibppeers2.filter( - (item) => item.status === 'Deployed' - )) === null || _item$ibppeers2$filte === void 0 + : _this$props$useGetNet2.network) || {}; + const form = + (_this$$ = this.$('formily_create_strategy')) === null || + _this$$ === void 0 + ? void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.submit(async (v) => { + var _JSON$parse, _v$content, _v$content$value, _v$content$value$map; + const epolicy = { + channel: + (_JSON$parse = JSON.parse(v.channel || '{}')) === null || + _JSON$parse === void 0 + ? void 0 + : _JSON$parse.name, + description: v.description, + name: v.name, + value: + 'OR(' + + ((_v$content = v.content) === null || _v$content === void 0 + ? void 0 + : (_v$content$value = _v$content.value) === null || + _v$content$value === void 0 + ? void 0 + : (_v$content$value$map = _v$content$value.map((valueitem) => { + var _valueitem$item, _valueitem$item$map; + return (_valueitem$item = valueitem.item) === null || + _valueitem$item === void 0 ? void 0 - : (_item$ibppeers2$filte2 = _item$ibppeers2$filte.map( - (peer) => ({ - key: item.name + peer.name, - title: peer.name, - }) - )) === null || _item$ibppeers2$filte2 === void 0 + : (_valueitem$item$map = _valueitem$item.map((item, i) => { + item = `'${item}.member'`; + if (i === 0) { + return 'AND(' + item; + } + if (i === valueitem.item.length - 1) { + return item + ')'; + } + return item; + })) === null || _valueitem$item$map === void 0 ? void 0 - : _item$ibppeers2$filte2.filter((peer) => { - return usedPeers !== null && - usedPeers !== void 0 && - usedPeers.length - ? usedPeers.every( - (used) => - !( - used.name === peer.title && - used.namespace === item.name - ) - ) - : true; - }), - }; - })) === null || _res$ibppeersForCreat3 === void 0 + : _valueitem$item$map.join(','); + })) === null || _v$content$value$map === void 0 + ? void 0 + : _v$content$value$map.join(',')) + + ')', + }; + try { + const res = await this.props.appHelper.utils.bff.createEpolicy({ + epolicy, + }); + this.closeModal(); + this.utils.notification.success({ + message: this.i18n('i18n-636u5idg'), + }); + this.props.useGetNetwork.mutate(); + this.getEpolicies(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-sivjo10j'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + }); + } + + async confirmDeleteChannelModal(e, payload) { + // const federation = this.props.useGetFederation?.data?.federation || {} + // try { + // await this.props.appHelper.utils.bff.removeOrganizationToFederation({ + // name: federation?.name, + // organization: this.state.channelRecord?.name, + // initiator: federation?.initiator?.name + // }) + // this.closeModal() + // this.utils.notification.success({ + // message: this.i18n('i18n-yy3f9rxigm'), + // }) + // this.props.useGetFederation.mutate() + // } catch (error) { + // this.utils.notification.warnings({ + // message: this.i18n('i18n-p5gea1q7fem'), + // errors: error?.response?.errors + // }) + // } + } + + async confirmDeleteContractModal(e, payload) { + try { + var _this$match, + _this$match$params, + _this$state$contract, + _this$state$contract$; + await this.props.appHelper.utils.bff.deleteChaincodebuild({ + network: + (_this$match = this.match) === null || _this$match === void 0 + ? void 0 + : (_this$match$params = _this$match.params) === null || + _this$match$params === void 0 + ? void 0 + : _this$match$params.id, + displayName: + (_this$state$contract = this.state.contract) === null || + _this$state$contract === void 0 + ? void 0 + : (_this$state$contract$ = _this$state$contract.record) === null || + _this$state$contract$ === void 0 + ? void 0 + : _this$state$contract$.displayName, + }); + this.closeModal(); + this.utils.notification.success({ + message: this.i18n('i18n-5m5bdexs'), + }); + this.props.useGetChaincodebuilds.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-esbyfrwe'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + } + + confirmDeploymentContractModal(e, payload) { + var _this$$, _this$$$formRef, _this$$$formRef$curre; + const form = + (_this$$ = this.$('formily_contract_deploy')) === null || + _this$$ === void 0 ? void 0 - : _res$ibppeersForCreat3.filter((item) => { - var _item$children; - return ( - (item === null || item === void 0 - ? void 0 - : (_item$children = item.children) === null || - _item$children === void 0 - ? void 0 - : _item$children.length) > 0 - ); - })) || []; - this.setState( - { - peers, - allPeers, - }, - callback - ); + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.submit(async (v) => { + const chaincode = { + channel: v.channel, + epolicy: v.epolicy, + name: v.name, + version: v.version, + // edit + // ibppeer: v.ibppeer + }; + + try { + const res = await this.props.appHelper.utils.bff.deployChaincode({ + chaincode, + }); + // this.closeModal() + // this.utils.notification.success({ + // message: this.i18n('i18n-l8fybssesij'), + // }) + this.openDeploymentContractSuccessModal(); + this.props.useGetChaincodebuilds.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-ekujezos'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + }); + } + + confirmUpgradeContractModal(e, payload) { + var _this$$, _this$$$formRef, _this$$$formRef$curre; + const form = + (_this$$ = this.$('formily_contract_upgrade')) === null || + _this$$ === void 0 + ? void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.submit(async (v) => { + const { versoin, ...params } = v; + try { + var _this$match, _this$match$params, _v$files, _v$files$fileList; + const res = await this.props.appHelper.utils.bff.upgradeChaincodebuild({ + ...params, + network: + (_this$match = this.match) === null || _this$match === void 0 + ? void 0 + : (_this$match$params = _this$match.params) === null || + _this$match$params === void 0 + ? void 0 + : _this$match$params.id, + files: + (_v$files = v.files) === null || _v$files === void 0 + ? void 0 + : (_v$files$fileList = _v$files.fileList) === null || + _v$files$fileList === void 0 + ? void 0 + : _v$files$fileList.map((item) => item.originFileObj), + }); + this.closeModal(); + this.utils.notification.success({ + message: this.i18n('i18n-a4rcftyd'), + }); + this.openAddChannelSuccessModal(); + this.props.useGetChaincodebuilds.mutate(); + } catch (error) { + var _error$response; + this.utils.notification.warnings({ + message: this.i18n('i18n-7fxj402s'), + errors: + error === null || error === void 0 + ? void 0 + : (_error$response = error.response) === null || + _error$response === void 0 + ? void 0 + : _error$response.errors, + }); + } + }); } formatContract() { @@ -296,7 +681,9 @@ class NetworkDetail$$Page extends React.Component { _ref$filter, _this$props$useGetCha, _this$props$useGetCha2, - _Object$keys; + _Object$keys, + _Object$keys2, + _Object$keys3; const list = (_ref = ((_this$props$useGetCha = this.props.useGetChaincodebuilds) === null || @@ -384,7 +771,17 @@ class NetworkDetail$$Page extends React.Component { })), }; }); - if (!this.state.initVersions) { + if ( + !this.state.initVersions || + ((_Object$keys2 = Object.keys(this.state.initVersions || {})) === null || + _Object$keys2 === void 0 + ? void 0 + : _Object$keys2.length) !== + ((_Object$keys3 = Object.keys(result || {})) === null || + _Object$keys3 === void 0 + ? void 0 + : _Object$keys3.length) + ) { this.setState({ initVersions, }); @@ -392,204 +789,44 @@ class NetworkDetail$$Page extends React.Component { return formatList; } - getContractVersion(record) { - var _this$state$initVersi, _record$versions, _record$versions$find; - const name = - (_this$state$initVersi = this.state.initVersions) === null || - _this$state$initVersi === void 0 - ? void 0 - : _this$state$initVersi[ - record === null || record === void 0 ? void 0 : record.displayName - ]; - return record === null || record === void 0 - ? void 0 - : (_record$versions = record.versions) === null || - _record$versions === void 0 - ? void 0 - : (_record$versions$find = _record$versions.find( - (item) => item.name === name - )) === null || _record$versions$find === void 0 - ? void 0 - : _record$versions$find.version; - } - - getContractVersions(record) { - return ( - (record === null || record === void 0 ? void 0 : record.versions) || [] - ); - } - - changeContractVersion(e, payload) { - var _payload$record; - this.setState({ - initVersions: { - ...this.state.initVersions, - [payload === null || payload === void 0 - ? void 0 - : (_payload$record = payload.record) === null || - _payload$record === void 0 - ? void 0 - : _payload$record.displayName]: e.key, - }, - }); - } - - closeModal() { - this.setState({ - isOpenModal: false, - channelPeers: [], - }); - } - - handleFilterChange(e) { - this.setState({ - filter: e.target.value, - }); - } - - handleSearchValueChange(e) { - this.setState({ - searchValue: e.target.value, - }); - } - - handlePaginationChange(c, s) { - this.setState({ - size: s, - current: c, - }); - } - - handleTableChange(pagination, filters, sorter, extra) { - this.setState({ - pagination, - filters, - sorter, - }); - } - - paginationShowTotal(total, range) { - return `${this.i18n('i18n-5xl7aihzcuy')} ${total} ${this.i18n( - 'i18n-v7xu122b9o' - )}`; - } - - handleOrganizationPaginationChange(c, s) { - this.setState({ - organization: { - ...this.state.organization, - size: s, - current: c, - }, - }); - } - - handleOrganizationTableChange(pagination, filters, sorter, extra) { - this.setState({ - organization: { - ...this.state.organization, - pagination, - filters, - sorter, - }, - }); - } - - handleChannelSearchValueChange(e) { - this.setState({ - channel: { - ...this.state.channel, - searchValue: e.target.value, - }, - }); - } - - handleChannelPaginationChange(c, s) { - this.setState({ - channel: { - ...this.state.channel, - size: s, - current: c, - }, - }); - } - - handleChannelTableChange(pagination, filters, sorter, extra) { - this.setState({ - channel: { - ...this.state.channel, - pagination, - filters, - sorter, - }, - }); - } - - openAddChannelModal() { - this.setState({ - isOpenModal: true, - modalType: 'addchannel', - }); - } - - openAddChannelSuccessModal() { - this.setState({ - isOpenModal: true, - modalType: 'addchannelsuccess', - }); - } - - openAddChannelOrganizationModal(e, payload) { - this.setState({ - channel: { - ...this.state.channel, - record: payload.record, - }, - isOpenModal: true, - modalType: 'addchannelorganization', - }); - } - - openAddChannelOrganizationSuccessModal() { - this.setState({ - isOpenModal: true, - modalType: 'addchannelorganizationsuccess', - }); - } - - openAddChannelPeerModal(e, payload) { - var _payload$record, _payload$record$membe; - this.setState({ - channel: { - ...this.state.channel, - record: payload.record, - }, - isOpenModal: true, - modalType: 'addchannelpeer', - peers: [], - }); - this.getPeers( - { - organizations: - (payload === null || payload === void 0 - ? void 0 - : (_payload$record = payload.record) === null || - _payload$record === void 0 + async getChannelsForCreateEpolicy(callback) { + var _this$match, + _this$match$params, + _res$channelsForCreat, + _this$$, + _this$$$formRef, + _this$$$formRef$curre, + _res$channelsForCreat2; + const res = + await this.props.appHelper.utils.bff.getChannelsForCreateEpolicy({ + network: + (_this$match = this.match) === null || _this$match === void 0 ? void 0 - : (_payload$record$membe = _payload$record.members) === null || - _payload$record$membe === void 0 + : (_this$match$params = _this$match.params) === null || + _this$match$params === void 0 ? void 0 - : _payload$record$membe.map((item) => item.name)) || [], + : _this$match$params.id, + }); + this.setState( + { + strategy: { + ...this.state.strategy, + channels: + (res === null || res === void 0 + ? void 0 + : (_res$channelsForCreat = res.channelsForCreateEpolicy) === + null || _res$channelsForCreat === void 0 + ? void 0 + : _res$channelsForCreat.map((item) => ({ + value: JSON.stringify(item), + label: item.name, + }))) || [], + }, }, - () => {}, - payload.record.peers || [] + callback ); - } - - channelAddModalNext() { - var _this$$, _this$$$formRef, _this$$$formRef$curre; const form = - (_this$$ = this.$('formily_create_channel')) === null || + (_this$$ = this.$('formily_create_strategy')) === null || _this$$ === void 0 ? void 0 : (_this$$$formRef = _this$$.formRef) === null || @@ -599,248 +836,204 @@ class NetworkDetail$$Page extends React.Component { _this$$$formRef$curre === void 0 ? void 0 : _this$$$formRef$curre.form; - form.submit(async (v) => { - this.setState({ - channel: { - ...this.state.channel, - addData: v, - step: 1, - }, - }); - this.getPeers(v, () => {}); + form.setFieldState('channel', { + dataSource: + (res === null || res === void 0 + ? void 0 + : (_res$channelsForCreat2 = res.channelsForCreateEpolicy) === null || + _res$channelsForCreat2 === void 0 + ? void 0 + : _res$channelsForCreat2.map((item) => ({ + value: JSON.stringify(item), + label: item.name, + }))) || [], }); } - channelAddModalPre() { - this.setState( - { - channel: { - ...this.state.channel, - step: 0, - }, - }, - () => { - var _this$$, _this$$$formRef, _this$$$formRef$curre; - const form = - (_this$$ = this.$('formily_create_channel')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.setValues(this.state.channel.addData); - } - ); + getContractVersion(record) { + var _this$state$initVersi, _record$versions, _record$versions$find; + const name = + (_this$state$initVersi = this.state.initVersions) === null || + _this$state$initVersi === void 0 + ? void 0 + : _this$state$initVersi[ + record === null || record === void 0 ? void 0 : record.displayName + ]; + return record === null || record === void 0 + ? void 0 + : (_record$versions = record.versions) === null || + _record$versions === void 0 + ? void 0 + : (_record$versions$find = _record$versions.find( + (item) => item.name === name + )) === null || _record$versions$find === void 0 + ? void 0 + : _record$versions$find.version; } - async channelAddModalConfirm(e, payload) { - var _this$props$useGetNet, _this$props$useGetNet2; - const network = - ((_this$props$useGetNet = this.props.useGetNetwork) === null || - _this$props$useGetNet === void 0 - ? void 0 - : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || - _this$props$useGetNet2 === void 0 - ? void 0 - : _this$props$useGetNet2.network) || {}; - try { - var _this$state, _this$state$channel, _this$state$channelPe; - const res = await this.props.appHelper.utils.bff.createChannel({ - network: network === null || network === void 0 ? void 0 : network.name, - channel: { - ...(((_this$state = this.state) === null || _this$state === void 0 - ? void 0 - : (_this$state$channel = _this$state.channel) === null || - _this$state$channel === void 0 - ? void 0 - : _this$state$channel.addData) || {}), - peers: - (_this$state$channelPe = this.state.channelPeers) === null || - _this$state$channelPe === void 0 - ? void 0 - : _this$state$channelPe.map((key) => { - var _this$state$allPeers; - const item = - (_this$state$allPeers = this.state.allPeers) === null || - _this$state$allPeers === void 0 - ? void 0 - : _this$state$allPeers.find((item) => item.key === key); - return { - name: item.name, - namespace: item.namespace, - }; - }), - }, - }); - // this.closeModal() - // this.utils.notification.success({ - // message: this.i18n('i18n-l8fybssesij'), - // }) - this.openAddChannelSuccessModal(); - this.props.useGetNetwork.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-85kkwp67i5u'), - errors: - error === null || error === void 0 - ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 - ? void 0 - : _error$response.errors, - }); - } + getContractVersions(record) { + return ( + (record === null || record === void 0 ? void 0 : record.versions) || [] + ); } - channelAddOrganizationModalConfirm(e, payload) { - this.openAddChannelOrganizationSuccessModal(); - // const network = this.props.useGetNetwork?.data?.network || {} - // const form = this.$('formily_create')?.formRef?.current?.form - // form.submit(async v => { - // console.log(v) - // try { - // // const res = await this.props.appHelper.utils.bff.updateChannel({ - // // name: network?.name, - // // organizations: v.organizations, - // // initiator: network?.initiator?.name - // // }) - // // this.closeModal() - // // this.utils.notification.success({ - // // message: this.i18n('i18n-l8fybssesij'), - // // }) - // this.openAddChannelSuccessModal() - // this.props.useGetNetwork.mutate() - // } catch (error) { - // this.utils.notification.warnings({ - // message: this.i18n('i18n-85kkwp67i5u'), - // errors: error?.response?.errors - // }) - // } - // }) + async getEpolicies() { + var _this$match, _this$match$params; + const res = await this.props.appHelper.utils.bff.getEpolicies({ + network: + (_this$match = this.match) === null || _this$match === void 0 + ? void 0 + : (_this$match$params = _this$match.params) === null || + _this$match$params === void 0 + ? void 0 + : _this$match$params.id, + }); + this.setState({ + strategy: { + ...this.state.strategy, + list: (res === null || res === void 0 ? void 0 : res.epolicies) || [], + }, + }); } - async channelAddPeerModalConfirm(e, payload) { - var _this$props$useGetNet, _this$props$useGetNet2; - const network = - ((_this$props$useGetNet = this.props.useGetNetwork) === null || - _this$props$useGetNet === void 0 - ? void 0 - : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || - _this$props$useGetNet2 === void 0 - ? void 0 - : _this$props$useGetNet2.network) || {}; - try { - var _this$state$channel, _this$state$channel$r, _this$state$channelPe; - const res = await this.props.appHelper.utils.bff.updateChannel({ - name: - (_this$state$channel = this.state.channel) === null || - _this$state$channel === void 0 - ? void 0 - : (_this$state$channel$r = _this$state$channel.record) === null || - _this$state$channel$r === void 0 - ? void 0 - : _this$state$channel$r.name, - channel: { - operate: 'add', - // remove - peers: - (_this$state$channelPe = this.state.channelPeers) === null || - _this$state$channelPe === void 0 - ? void 0 - : _this$state$channelPe.map((key) => { - var _this$state$allPeers; - const item = - (_this$state$allPeers = this.state.allPeers) === null || - _this$state$allPeers === void 0 - ? void 0 - : _this$state$allPeers.find((item) => item.key === key); - return { - name: item.name, - namespace: item.namespace, - }; - }), - }, - }); - this.closeModal(); - this.utils.notification.success({ - message: this.i18n('i18n-knuex06q'), - }); - // this.openAddChannelSuccessModal() - this.props.useGetNetwork.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-sunw6qwy'), - errors: - error === null || error === void 0 - ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 + async getPeers(v, callback, usedPeers) { + var _ref, + _res$ibppeersForCreat, + _res$ibppeersForCreat2, + _res$ibppeersForCreat3; + const { initiator, organizations } = v; + const res = + await this.props.appHelper.utils.bff.getIbppeersForCreateChannel({ + members: + (_ref = [initiator, ...organizations]) === null || _ref === void 0 ? void 0 - : _error$response.errors, + : _ref.filter((item) => item), }); - } + const allPeers = []; + res === null || res === void 0 + ? void 0 + : (_res$ibppeersForCreat = res.ibppeersForCreateChannel) === null || + _res$ibppeersForCreat === void 0 + ? void 0 + : _res$ibppeersForCreat.forEach((item) => { + var _item$ibppeers; + (_item$ibppeers = item.ibppeers) === null || _item$ibppeers === void 0 + ? void 0 + : _item$ibppeers.forEach((peer) => { + allPeers.push({ + name: peer.name, + namespace: item.name, + key: item.name + peer.name, + }); + }); + }); + const peers = + (res === null || res === void 0 + ? void 0 + : (_res$ibppeersForCreat2 = res.ibppeersForCreateChannel) === null || + _res$ibppeersForCreat2 === void 0 + ? void 0 + : (_res$ibppeersForCreat3 = _res$ibppeersForCreat2.map((item) => { + var _item$ibppeers2, _item$ibppeers2$filte, _item$ibppeers2$filte2; + return { + key: item.name, + title: item.name, + children: + (_item$ibppeers2 = item.ibppeers) === null || + _item$ibppeers2 === void 0 + ? void 0 + : (_item$ibppeers2$filte = _item$ibppeers2.filter( + (item) => item.status === 'Deployed' + )) === null || _item$ibppeers2$filte === void 0 + ? void 0 + : (_item$ibppeers2$filte2 = _item$ibppeers2$filte.map( + (peer) => ({ + key: item.name + peer.name, + title: peer.name, + }) + )) === null || _item$ibppeers2$filte2 === void 0 + ? void 0 + : _item$ibppeers2$filte2.filter((peer) => { + return usedPeers !== null && + usedPeers !== void 0 && + usedPeers.length + ? usedPeers.every( + (used) => + !( + used.name === peer.title && + used.namespace === item.name + ) + ) + : true; + }), + }; + })) === null || _res$ibppeersForCreat3 === void 0 + ? void 0 + : _res$ibppeersForCreat3.filter((item) => { + var _item$children; + return ( + (item === null || item === void 0 + ? void 0 + : (_item$children = item.children) === null || + _item$children === void 0 + ? void 0 + : _item$children.length) > 0 + ); + })) || []; + this.setState( + { + peers, + allPeers, + }, + callback + ); } - channelPeersChange(channelPeers) { + handleChannelPaginationChange(c, s) { this.setState({ - channelPeers, + channel: { + ...this.state.channel, + size: s, + current: c, + }, }); } - openDeleteChannelModal(e, payload) { + handleChannelSearchValueChange(e) { this.setState({ - isOpenModal: true, - modalType: 'delete', channel: { ...this.state.channel, - record: - payload === null || payload === void 0 ? void 0 : payload.record, + searchValue: e.target.value, }, }); } - async confirmDeleteChannelModal(e, payload) { - // const federation = this.props.useGetFederation?.data?.federation || {} - // try { - // await this.props.appHelper.utils.bff.removeOrganizationToFederation({ - // name: federation?.name, - // organization: this.state.channelRecord?.name, - // initiator: federation?.initiator?.name - // }) - // this.closeModal() - // this.utils.notification.success({ - // message: this.i18n('i18n-yy3f9rxigm'), - // }) - // this.props.useGetFederation.mutate() - // } catch (error) { - // this.utils.notification.warnings({ - // message: this.i18n('i18n-p5gea1q7fem'), - // errors: error?.response?.errors - // }) - // } + handleChannelTableChange(pagination, filters, sorter, extra) { + this.setState({ + channel: { + ...this.state.channel, + pagination, + filters, + sorter, + }, + }); } - handleContractSearchValueChange(e) { + handleContractPaginationChange(c, s) { this.setState({ contract: { ...this.state.contract, - searchValue: e.target.value, + size: s, + current: c, }, }); } - handleContractPaginationChange(c, s) { + handleContractSearchValueChange(e) { this.setState({ contract: { ...this.state.contract, - size: s, - current: c, + searchValue: e.target.value, }, }); } @@ -856,468 +1049,292 @@ class NetworkDetail$$Page extends React.Component { }); } - openAddContractModal() { + handleFilterChange(e) { this.setState({ - isOpenModal: true, - modalType: 'addcontract', + filter: e.target.value, }); } - openDeploymentContractModal(e, payload) { - this.setState( - { - contract: { - ...this.state.contract, - record: payload.record, - }, - isOpenModal: true, - modalType: 'deploymentcontract', + handleOrganizationPaginationChange(c, s) { + this.setState({ + organization: { + ...this.state.organization, + size: s, + current: c, }, - () => { - setTimeout(() => { - var _this$$, - _this$$$formRef, - _this$$$formRef$curre, - _payload$record, - _payload$record2, - _payload$record3; - const form = - (_this$$ = this.$('formily_contract_deploy')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.setValues({ - displayName: - (_payload$record = payload.record) === null || - _payload$record === void 0 - ? void 0 - : _payload$record.displayName, - // edit - version: - (_payload$record2 = payload.record) === null || - _payload$record2 === void 0 - ? void 0 - : _payload$record2.version, - name: - (_payload$record3 = payload.record) === null || - _payload$record3 === void 0 - ? void 0 - : _payload$record3.name, - }); - }, 0); - } - ); + }); } - openDeploymentContractSuccessModal() { + handleOrganizationTableChange(pagination, filters, sorter, extra) { this.setState({ - isOpenModal: true, - modalType: 'deploymentcontractsuccess', + organization: { + ...this.state.organization, + pagination, + filters, + sorter, + }, }); } - openUpgradeContractModal(e, payload) { - this.setState( - { - contract: { - ...this.state.contract, - record: payload.record, - }, - isOpenModal: true, - modalType: 'upgradecontract', - }, - () => { - setTimeout(() => { - var _this$$, - _this$$$formRef, - _this$$$formRef$curre, - _payload$record, - _payload$record2; - const form = - (_this$$ = this.$('formily_contract_upgrade')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.setValues({ - displayName: - (_payload$record = payload.record) === null || - _payload$record === void 0 - ? void 0 - : _payload$record.displayName, - // edit - version: - (_payload$record2 = payload.record) === null || - _payload$record2 === void 0 - ? void 0 - : _payload$record2.version, - }); - }, 0); - } - ); + handlePaginationChange(c, s) { + this.setState({ + size: s, + current: c, + }); + } + + handleSearchValueChange(e) { + this.setState({ + searchValue: e.target.value, + }); } - openDeleteContractModal(e, payload) { + handleStrategyPaginationChange(c, s) { this.setState({ - contract: { - ...this.state.contract, - record: payload.record, + strategy: { + ...this.state.strategy, + size: s, + current: c, }, - isOpenModal: true, - modalType: 'deletecontract', }); } - confirmAddContractModal(e, payload) { - var _this$props$useGetNet, - _this$props$useGetNet2, - _this$$, - _this$$$formRef, - _this$$$formRef$curre; - const network = - ((_this$props$useGetNet = this.props.useGetNetwork) === null || - _this$props$useGetNet === void 0 - ? void 0 - : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || - _this$props$useGetNet2 === void 0 - ? void 0 - : _this$props$useGetNet2.network) || {}; - const form = - (_this$$ = this.$('formily_create_contract')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.submit(async (v) => { - console.log(v, 'vvvvvvvv'); - try { - var _this$match, _this$match$params, _v$files; - const res = await this.props.appHelper.utils.bff.createChaincodebuild({ - ...v, - network: - (_this$match = this.match) === null || _this$match === void 0 - ? void 0 - : (_this$match$params = _this$match.params) === null || - _this$match$params === void 0 - ? void 0 - : _this$match$params.id, - files: - (_v$files = v.files) === null || _v$files === void 0 - ? void 0 - : _v$files.fileList, - }); - this.closeModal(); - this.utils.notification.success({ - message: this.i18n('i18n-5eg2znpg'), - }); - this.props.useGetChaincodebuilds.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-rw4x2dt7'), - errors: - error === null || error === void 0 - ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 - ? void 0 - : _error$response.errors, - }); - } + handleStrategySearchValueChange(e) { + this.setState({ + strategy: { + ...this.state.strategy, + searchValue: e.target.value, + }, }); } - confirmUpgradeContractModal(e, payload) { - var _this$$, _this$$$formRef, _this$$$formRef$curre; - const form = - (_this$$ = this.$('formily_contract_upgrade')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.submit(async (v) => { - const { versoin, ...params } = v; - try { - var _this$match, _this$match$params, _v$files; - const res = await this.props.appHelper.utils.bff.upgradeChaincodebuild({ - ...params, - network: - (_this$match = this.match) === null || _this$match === void 0 - ? void 0 - : (_this$match$params = _this$match.params) === null || - _this$match$params === void 0 - ? void 0 - : _this$match$params.id, - files: - (_v$files = v.files) === null || _v$files === void 0 - ? void 0 - : _v$files.fileList, - }); - this.closeModal(); - this.utils.notification.success({ - message: this.i18n('i18n-a4rcftyd'), - }); - this.openAddChannelSuccessModal(); - this.props.useGetChaincodebuilds.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-7fxj402s'), - errors: - error === null || error === void 0 - ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 - ? void 0 - : _error$response.errors, - }); - } + handleStrategyTableChange(pagination, filters, sorter, extra) { + this.setState({ + strategy: { + ...this.state.strategy, + pagination, + filters, + sorter, + }, }); } - confirmDeploymentContractModal(e, payload) { - var _this$$, _this$$$formRef, _this$$$formRef$curre; - const form = - (_this$$ = this.$('formily_contract_deploy')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.submit(async (v) => { - const chaincode = { - channel: v.channel, - epolicy: v.epolicy, - name: v.name, - version: v.version, - // edit - // ibppeer: v.ibppeer - }; + handleTableChange(pagination, filters, sorter, extra) { + this.setState({ + pagination, + filters, + sorter, + }); + } - try { - const res = await this.props.appHelper.utils.bff.deployChaincode({ - chaincode, - }); - // this.closeModal() - // this.utils.notification.success({ - // message: this.i18n('i18n-l8fybssesij'), - // }) - this.openDeploymentContractSuccessModal(); - this.props.useGetChaincodebuilds.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-ekujezos'), - errors: - error === null || error === void 0 - ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 - ? void 0 - : _error$response.errors, - }); - } + openAddChannelModal() { + this.setState({ + isOpenModal: true, + modalType: 'addchannel', }); } - async confirmDeleteContractModal(e, payload) { - try { - var _this$match, - _this$match$params, - _this$state$contract, - _this$state$contract$; - await this.props.appHelper.utils.bff.deleteChaincodebuild({ - network: - (_this$match = this.match) === null || _this$match === void 0 - ? void 0 - : (_this$match$params = _this$match.params) === null || - _this$match$params === void 0 - ? void 0 - : _this$match$params.id, - displayName: - (_this$state$contract = this.state.contract) === null || - _this$state$contract === void 0 - ? void 0 - : (_this$state$contract$ = _this$state$contract.record) === null || - _this$state$contract$ === void 0 + openAddChannelOrganizationModal(e, payload) { + this.setState({ + channel: { + ...this.state.channel, + record: payload.record, + }, + isOpenModal: true, + modalType: 'addchannelorganization', + }); + } + + openAddChannelOrganizationSuccessModal() { + this.setState({ + isOpenModal: true, + modalType: 'addchannelorganizationsuccess', + }); + } + + openAddChannelPeerModal(e, payload) { + var _payload$record, _payload$record$membe; + this.setState({ + channel: { + ...this.state.channel, + record: payload.record, + }, + isOpenModal: true, + modalType: 'addchannelpeer', + peers: [], + }); + this.getPeers( + { + organizations: + (payload === null || payload === void 0 ? void 0 - : _this$state$contract$.displayName, - }); - this.closeModal(); - this.utils.notification.success({ - message: this.i18n('i18n-5m5bdexs'), - }); - this.props.useGetChaincodebuilds.mutate(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-esbyfrwe'), - errors: - error === null || error === void 0 + : (_payload$record = payload.record) === null || + _payload$record === void 0 ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 + : (_payload$record$membe = _payload$record.members) === null || + _payload$record$membe === void 0 ? void 0 - : _error$response.errors, - }); - } + : _payload$record$membe.map((item) => item.name)) || [], + }, + () => {}, + payload.record.peers || [] + ); } - handleStrategySearchValueChange(e) { + openAddChannelSuccessModal() { this.setState({ - strategy: { - ...this.state.strategy, - searchValue: e.target.value, - }, + isOpenModal: true, + modalType: 'addchannelsuccess', }); } - handleStrategyPaginationChange(c, s) { + openAddContractModal() { this.setState({ - strategy: { - ...this.state.strategy, - size: s, - current: c, - }, + isOpenModal: true, + modalType: 'addcontract', }); } - handleStrategyTableChange(pagination, filters, sorter, extra) { + openAddStrategyModal() { this.setState({ - strategy: { - ...this.state.strategy, - pagination, - filters, - sorter, + isOpenModal: true, + modalType: 'addstrategy', + }); + this.getChannelsForCreateEpolicy(() => {}); + } + + openDeleteChannelModal(e, payload) { + this.setState({ + isOpenModal: true, + modalType: 'delete', + channel: { + ...this.state.channel, + record: + payload === null || payload === void 0 ? void 0 : payload.record, }, }); } - openAddStrategyModal() { + openDeleteContractModal(e, payload) { this.setState({ + contract: { + ...this.state.contract, + record: payload.record, + }, isOpenModal: true, - modalType: 'addstrategy', + modalType: 'deletecontract', }); - this.getChannelsForCreateEpolicy(() => {}); } - confirmAddStrategyModal(e, payload) { - var _this$props$useGetNet, - _this$props$useGetNet2, - _this$$, - _this$$$formRef, - _this$$$formRef$curre; - const network = - ((_this$props$useGetNet = this.props.useGetNetwork) === null || - _this$props$useGetNet === void 0 - ? void 0 - : (_this$props$useGetNet2 = _this$props$useGetNet.data) === null || - _this$props$useGetNet2 === void 0 - ? void 0 - : _this$props$useGetNet2.network) || {}; - const form = - (_this$$ = this.$('formily_create_strategy')) === null || - _this$$ === void 0 - ? void 0 - : (_this$$$formRef = _this$$.formRef) === null || - _this$$$formRef === void 0 - ? void 0 - : (_this$$$formRef$curre = _this$$$formRef.current) === null || - _this$$$formRef$curre === void 0 - ? void 0 - : _this$$$formRef$curre.form; - form.submit(async (v) => { - var _JSON$parse, _v$content, _v$content$value, _v$content$value$map; - const epolicy = { - channel: - (_JSON$parse = JSON.parse(v.channel || '{}')) === null || - _JSON$parse === void 0 - ? void 0 - : _JSON$parse.name, - description: v.description, - name: v.name, - value: - 'OR(' + - ((_v$content = v.content) === null || _v$content === void 0 - ? void 0 - : (_v$content$value = _v$content.value) === null || - _v$content$value === void 0 - ? void 0 - : (_v$content$value$map = _v$content$value.map((valueitem) => { - var _valueitem$item, _valueitem$item$map; - return (_valueitem$item = valueitem.item) === null || - _valueitem$item === void 0 - ? void 0 - : (_valueitem$item$map = _valueitem$item.map((item, i) => { - item = `'${item}.member'`; - if (i === 0) { - return 'AND(' + item; - } - if (i === valueitem.item.length - 1) { - return item + ')'; - } - return item; - })) === null || _valueitem$item$map === void 0 - ? void 0 - : _valueitem$item$map.join(','); - })) === null || _v$content$value$map === void 0 - ? void 0 - : _v$content$value$map.join(',')) + - ')', - }; - try { - const res = await this.props.appHelper.utils.bff.createEpolicy({ - epolicy, - }); - this.closeModal(); - this.utils.notification.success({ - message: this.i18n('i18n-636u5idg'), - }); - this.props.useGetNetwork.mutate(); - this.getEpolicies(); - } catch (error) { - var _error$response; - this.utils.notification.warnings({ - message: this.i18n('i18n-sivjo10j'), - errors: - error === null || error === void 0 + openDeploymentContractModal(e, payload) { + this.setState( + { + contract: { + ...this.state.contract, + record: payload.record, + }, + isOpenModal: true, + modalType: 'deploymentcontract', + }, + () => { + setTimeout(() => { + var _this$$, + _this$$$formRef, + _this$$$formRef$curre, + _payload$record, + _payload$record2, + _payload$record3; + const form = + (_this$$ = this.$('formily_contract_deploy')) === null || + _this$$ === void 0 ? void 0 - : (_error$response = error.response) === null || - _error$response === void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 ? void 0 - : _error$response.errors, - }); + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.setValues({ + displayName: + (_payload$record = payload.record) === null || + _payload$record === void 0 + ? void 0 + : _payload$record.displayName, + // edit + version: + (_payload$record2 = payload.record) === null || + _payload$record2 === void 0 + ? void 0 + : _payload$record2.version, + name: + (_payload$record3 = payload.record) === null || + _payload$record3 === void 0 + ? void 0 + : _payload$record3.name, + }); + }, 0); } + ); + } + + openDeploymentContractSuccessModal() { + this.setState({ + isOpenModal: true, + modalType: 'deploymentcontractsuccess', }); } - beforeUpload() { - return false; + openUpgradeContractModal(e, payload) { + this.setState( + { + contract: { + ...this.state.contract, + record: payload.record, + }, + isOpenModal: true, + modalType: 'upgradecontract', + }, + () => { + setTimeout(() => { + var _this$$, + _this$$$formRef, + _this$$$formRef$curre, + _payload$record, + _payload$record2; + const form = + (_this$$ = this.$('formily_contract_upgrade')) === null || + _this$$ === void 0 + ? void 0 + : (_this$$$formRef = _this$$.formRef) === null || + _this$$$formRef === void 0 + ? void 0 + : (_this$$$formRef$curre = _this$$$formRef.current) === null || + _this$$$formRef$curre === void 0 + ? void 0 + : _this$$$formRef$curre.form; + form.setValues({ + displayName: + (_payload$record = payload.record) === null || + _payload$record === void 0 + ? void 0 + : _payload$record.displayName, + // edit + version: + (_payload$record2 = payload.record) === null || + _payload$record2 === void 0 + ? void 0 + : _payload$record2.version, + }); + }, 0); + } + ); + } + + paginationShowTotal(total, range) { + return `${this.i18n('i18n-5xl7aihzcuy')} ${total} ${this.i18n( + 'i18n-v7xu122b9o' + )}`; } componentDidMount() { @@ -1685,13 +1702,13 @@ class NetworkDetail$$Page extends React.Component { __component_name="FormilyUpload" componentProps={{ 'x-component-props': { - directory: true, beforeUpload: function () { return this.beforeUpload.apply( this, Array.prototype.slice.call(arguments).concat([]) ); }.bind(this), + directory: true, }, }} fieldProps={{ @@ -5603,7 +5620,7 @@ class NetworkDetail$$Page extends React.Component { ]} dataSource={__$$eval(() => this.formatContract())} loading={__$$eval( - () => this.props.useGetNetwork?.loading + () => this.props.useGetChaincodebuilds?.loading )} onChange={function () { return this.handleChannelTableChange.apply( @@ -6854,14 +6871,14 @@ class NetworkDetail$$Page extends React.Component { __component_name="FormilyUpload" componentProps={{ 'x-component-props': { - directory: true, - multiple: false, beforeUpload: function () { return this.beforeUpload.apply( this, Array.prototype.slice.call(arguments).concat([]) ); }.bind(this), + directory: true, + multiple: false, }, }} fieldProps={{ diff --git a/src/pages/OrganizationDetail/index.jsx b/src/pages/OrganizationDetail/index.jsx index a82bdd3..0a51cff 100644 --- a/src/pages/OrganizationDetail/index.jsx +++ b/src/pages/OrganizationDetail/index.jsx @@ -181,13 +181,13 @@ class OrganizationDetail$$Page extends React.Component { }); this.closeModal(); this.utils.notification.success({ - message: this.i18n('i18n-x26twb9oy0l'), + message: this.i18n('i18n-knuex06q'), }); this.getIbppeers(); } catch (error) { var _error$response; this.utils.notification.warnings({ - message: this.i18n('i18n-43getajmxf3'), + message: this.i18n('i18n-sunw6qwy'), errors: error === null || error === void 0 ? void 0