From 7e75443d15748ae7104a791e8583aa1a2c6b7ce8 Mon Sep 17 00:00:00 2001 From: Prakash P S Date: Tue, 12 Sep 2023 20:48:52 +0530 Subject: [PATCH] update the logic to check the OU of cert and show Signed-off-by: Prakash P S --- .../apollo/src/assets/i18n/en/messages.json | 1 + .../UpdateChannelMspModal.js | 54 ++++++++++--------- 2 files changed, 31 insertions(+), 24 deletions(-) diff --git a/packages/apollo/src/assets/i18n/en/messages.json b/packages/apollo/src/assets/i18n/en/messages.json index b0df4a450..8b25288f6 100644 --- a/packages/apollo/src/assets/i18n/en/messages.json +++ b/packages/apollo/src/assets/i18n/en/messages.json @@ -120,6 +120,7 @@ "grant_tooltip": "The only supported grant is \"authorization_code\".", "response_type_label": "Response type", "response_type_tooltip": "The only supported response type is \"code\".", + "msp_admin_type_tooltip": "These are identities in your wallet that are also admins on this channel", "debug_label": "User login debug logs", "debug_logs_tooltip": "Extra console server logs during user login can help debug OAuth2.0 setup issues, but for maximum user privacy this setting should be off once login problems are resolved.", "default_password_placeholder": "Enter a password here", diff --git a/packages/apollo/src/components/UpdateChannelMspModal/UpdateChannelMspModal.js b/packages/apollo/src/components/UpdateChannelMspModal/UpdateChannelMspModal.js index 13095607f..5e8c0e6d4 100644 --- a/packages/apollo/src/components/UpdateChannelMspModal/UpdateChannelMspModal.js +++ b/packages/apollo/src/components/UpdateChannelMspModal/UpdateChannelMspModal.js @@ -176,6 +176,7 @@ class UpdateChannelMspModal extends React.Component { disableSubmit: !this.props.isOrdererMSP, }); } + async onSelectMSP(event) { if (event.selectedMsp) { this.populateMSP(event.selectedMsp); @@ -342,30 +343,21 @@ class UpdateChannelMspModal extends React.Component { default: 'select_msp_id', }, ]; - if (this.props.submit_identity_options && !this.props.isOrdererMSP && this.props.submit_identity_options.length < 6) { - this.props.submit_identity_options.map((admin, index) => { - if (!admin.cas) { - if (index < 1) { - fields.push({ - label: 'Admins', - name: 'admin_identity', - type: 'text', - default: admin.name, - readonly: true, - }); - } - else { - fields.push({ - label: 'Admins', - name: 'admin_identity', - type: 'text', - default: admin.name, - readonly: true, - hideLabel: true, - }); - } - } - }) + if (this.props.submit_identity_options && !this.props.isOrdererMSP) { + let mspAdmins = this.populateMSPAdmins(); + fields.push({ + label: 'Known channel admins', + name: 'admin_identity', + type: 'component', + default: + mspAdmins.map((val, idx) => +
+

{val}

+
), + readonly: true, + tooltip: 'msp_admin_type_tooltip', + tooltipDirection: 'top', + }); } if (!this.props.isOrdererMSP) { fields.push({ @@ -379,6 +371,20 @@ class UpdateChannelMspModal extends React.Component { return fields; } + populateMSPAdmins() + { + const admin_identites = []; + this.props.submit_identity_options.forEach(value => { + const parsed_msp_cert = StitchApi.parseCertificate(value.cert); + if (admin_identites.length < 6) + { + if (parsed_msp_cert.subject_parts.OU === 'admin') { + admin_identites.push(value.name); + } + } + }); + return admin_identites; + } renderUploadMSPDefinition(translate) { return (