Skip to content

Commit

Permalink
Merge pull request #756 from ckpaliwal/dropdown-change-fix
Browse files Browse the repository at this point in the history
Dropdown change issue and ordering node issue fix
  • Loading branch information
ckpaliwal authored Jun 24, 2024
2 parents 15827ba + 8d884a4 commit 4c5a279
Show file tree
Hide file tree
Showing 5 changed files with 104 additions and 55 deletions.
24 changes: 14 additions & 10 deletions packages/apollo/src/components/Form/Form.js
Original file line number Diff line number Diff line change
Expand Up @@ -531,19 +531,23 @@ class Form extends Component {
return '';
}}
onChange={(item) => {
console.log('dropdown on change');
const data = {};
data[field.name] = this.fixChangedItem(field.options, item.selectedItem);
if (JSON.stringify(this.props.scope[field.name]) !== JSON.stringify(data[field.name])) {
this.props.updateState(this.props.scope, data);
if (this.props.onChange) {
const valid = this.isFormValid({
...this.props,
...data,
});
this.props.onChange(data, valid, field, this.props.formProps);
setTimeout(() => {
if (JSON.stringify(this.props.scope[field.name]) !== JSON.stringify(data[field.name])) {
this.props.updateState(this.props.scope, data);
// Setting it to above updateState digest before update child state
setTimeout(() => {
if (this.props.onChange) {
const valid = this.isFormValid({
...this.props,
...data,
});
this.props.onChange(data, valid, field, this.props.formProps);
}
}, 50);
}
}
}, 20);
}}
/>
{field.inlineLoading && <InlineLoading className="ibp-inline-loading-icon" />}
Expand Down
128 changes: 87 additions & 41 deletions packages/apollo/src/components/OrdererDetails/OrdererDetails.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,7 @@ class OrdererDetails extends Component {
}

checkHealth(orderer, skipStatusCache) {
let nodeStatus = {};
NodeStatus.getStatus(
{
...orderer,
Expand All @@ -302,7 +303,7 @@ class OrdererDetails extends Component {
SCOPE,
'details',
(id, status) => {
const nodeStatus = { ...this.props.nodeStatus };
// nodeStatus = { ...nodeStatus, ...this.props.nodeStatus };
nodeStatus[id] = status;
this.props.updateState(SCOPE, { nodeStatus });
if (this.timestamp) {
Expand Down Expand Up @@ -629,7 +630,11 @@ class OrdererDetails extends Component {
>
{translate('view_release_notes')}
</a>
<Button id="patch_node" kind="primary" className="ibp-patch-button" onClick={() => this.openOrdererSettings('upgrade')}>
<Button id="patch_node"
kind="primary"
className="ibp-patch-button"
onClick={() => this.openOrdererSettings('upgrade')}
>
{translate('update_version')}
</Button>
</div>
Expand Down Expand Up @@ -786,12 +791,16 @@ class OrdererDetails extends Component {
const translate = this.props.t;
return status ? (
<div className="ibp-node-status-container">
<span className={`ibp-node-status ${className}`} tabIndex="0" />
<span className={`ibp-node-status ${className}`}
tabIndex="0"
/>
<span className="ibp-node-status-label">{translate(node.operations_url ? status : 'status_undetected')}</span>
</div>
) : (
<div className="ibp-node-status-container">
<span className="ibp-node-status ibp-node-status-skeleton" tabIndex="0" />
<span className="ibp-node-status ibp-node-status-skeleton"
tabIndex="0"
/>
<span className="ibp-node-status-label">{translate('status_pending')}</span>
</div>
);
Expand Down Expand Up @@ -850,15 +859,24 @@ class OrdererDetails extends Component {
}}
/>
) : (
<Button id="connect-node-button" className="connect-node-button" onClick={() => this.addToSystemChannel()} disabled={this.props.disabled}>
<Button id="connect-node-button"
className="connect-node-button"
onClick={() => this.addToSystemChannel()}
disabled={this.props.disabled}
>
{translate('add_to_system_channel')}
<SVGs type="arrowRight" width="16px" height="16px" />
<SVGs type="arrowRight"
width="16px"
height="16px"
/>
</Button>
)}
</div>
{this.props.error && <SidePanelError error={this.props.error} />}
</div>
<RequiresAttentionImage2 className="ibp-requires-attention-image" alt="" />
<RequiresAttentionImage2 className="ibp-requires-attention-image"
alt=""
/>
</div>
);
}
Expand All @@ -876,7 +894,9 @@ class OrdererDetails extends Component {
<h3>{translate('running_partial')}</h3>
<p>{translate('running_partial_desc')}</p>
</div>
<RequiresAttentionImage className="ibp-requires-attention-image" alt="" />
<RequiresAttentionImage className="ibp-requires-attention-image"
alt=""
/>
</div>
);
}
Expand All @@ -896,7 +916,9 @@ class OrdererDetails extends Component {
<Trans>{translate('missing_endorsement_policy_desc', { orgs: this.props.missingEndorsementOrgs.join(',') })}</Trans>
</p>
</div>
<RequiresAttentionImage className="ibp-requires-attention-image ibp-requires-attention-small-image" alt="" />
<RequiresAttentionImage className="ibp-requires-attention-image ibp-requires-attention-small-image"
alt=""
/>
</div>
);
}
Expand Down Expand Up @@ -931,11 +953,16 @@ class OrdererDetails extends Component {
}}
>
{translate('go_to_node')}
<SVGs type="arrowRight" width="16px" height="16px" />
<SVGs type="arrowRight"
width="16px"
height="16px"
/>
</Button>
</div>
</div>
<RequiresAttentionImage className="ibp-requires-attention-image" alt="" />
<RequiresAttentionImage className="ibp-requires-attention-image"
alt=""
/>
</div>
);
}
Expand Down Expand Up @@ -1290,10 +1317,12 @@ class OrdererDetails extends Component {
/* [details section] - an orderer node is NOT selected, this is the top level content */
}
tabItems.push({
tab: () => <Tab id="ibp-orderer-details">{translate('details')}</Tab>,
panel: () => {
tab: (index) => <Tab id="ibp-orderer-details"
key={index}
>{translate('details')}</Tab>,
panel: (index) => {
return (
<TabPanel>
<TabPanel key={index}>
{!this.props.loading && this.channelParticipationEnabled(this.props.details) && !this.props.orderer_tls_identity && (
<div>
<SidePanelWarning
Expand Down Expand Up @@ -1323,7 +1352,9 @@ class OrdererDetails extends Component {
{!this.props.loading && !hasAssociatedIdentities && (
<div className="ibp-orderer-no-identity">
<p>{translate('orderer_no_identity')}</p>
<Button id="no-identity-button" onClick={() => this.openOrdererSettings('associate')}>
<Button id="no-identity-button"
onClick={() => this.openOrdererSettings('associate')}
>
{translate('associate_identity')}
</Button>
</div>
Expand Down Expand Up @@ -1365,10 +1396,12 @@ class OrdererDetails extends Component {
/* [all nodes section] - an orderer node is NOT selected, this is the top level content */
}
tabItems.push({
tab: () => <Tab id="ibp-orderer-nodes">{translate('ordering_nodes')}</Tab>,
panel: () => {
tab: (index) => <Tab id="ibp-orderer-nodes"
key={index}
>{translate('ordering_nodes')}</Tab>,
panel: (index) => {
return (
<TabPanel>
<TabPanel key={index}>
<div className="orderer-details-nodes-container">
<ItemContainer
containerTitle="ordering_nodes"
Expand Down Expand Up @@ -1398,34 +1431,37 @@ class OrdererDetails extends Component {
/* [drill down section] - an orderer node is selected, this is the drill down "info and usage" tab */
}
tabItems.push({
tab: () => (
tab: (index) => (
<Tab
id="ibp-orderer-usage"
className={
this.props.selectedNode.isUpgradeAvailable &&
this.props.selectedNode.location === 'ibm_saas' &&
ActionsHelper.canCreateComponent(this.props.userInfo, this.props.feature_flags)
this.props.selectedNode.location === 'ibm_saas' &&
ActionsHelper.canCreateComponent(this.props.userInfo, this.props.feature_flags)
? 'ibp-patch-available-tab'
: ''
}
key={index}
>
{translate('usage_info')}
{this.props.selectedNode.isUpgradeAvailable &&
this.props.selectedNode.location === 'ibm_saas' &&
ActionsHelper.canCreateComponent(this.props.userInfo, this.props.feature_flags) ? (
<div className="ibp-details-patch-container">
<div className="ibp-patch-available-tag ibp-node-details" onClick={() => this.openOrdererSettings('upgrade')}>
{translate('patch_available')}
this.props.selectedNode.location === 'ibm_saas' &&
ActionsHelper.canCreateComponent(this.props.userInfo, this.props.feature_flags) ? (
<div className="ibp-details-patch-container">
<div className="ibp-patch-available-tag ibp-node-details"
onClick={() => this.openOrdererSettings('upgrade')}
>
{translate('patch_available')}
</div>
</div>
</div>
) : (
''
)}
) : (
''
)}
</Tab>
),
panel: () => {
panel: (index) => {
return (
<TabPanel>
<TabPanel key={index}>
<NodeDetails node={this.props.selectedNode} />
{this.renderUsage(translate)}
</TabPanel>
Expand All @@ -1438,10 +1474,12 @@ class OrdererDetails extends Component {
/* [drill down section] - an orderer nodes is selected and it is systemless, this is the drill down "Channels" tab */
}
tabItems.push({
tab: () => <Tab id="ibp-orderer-channels">{translate('channels')}</Tab>,
panel: () => {
tab: (index) => <Tab id="ibp-orderer-channels"
key={index}
>{translate('channels')}</Tab>,
panel: (index) => {
return (
<TabPanel>
<TabPanel key={index}>
<ChannelParticipationDetails
selectedNode={this.props.selectedNode}
channelList={this.props.channelList}
Expand All @@ -1460,7 +1498,9 @@ class OrdererDetails extends Component {
return (
<PageContainer>
<Row>
<PageHeader history={this.props.history} headerName={ordererName ? translate('orderer_details_title', { ordererName: ordererName }) : ''} />
<PageHeader history={this.props.history}
headerName={ordererName ? translate('orderer_details_title', { ordererName: ordererName }) : ''}
/>
</Row>
<Row>
{ordererNameSkeleton}
Expand Down Expand Up @@ -1603,13 +1643,19 @@ class OrdererDetails extends Component {
<div className="ibp-column width-75 p-lr-10">
{this.props.notAvailable && (
<div className="ibp-not-available ibp-error-panel">
<SidePanelWarning title="orderer_not_available_title" subtitle="orderer_not_available_text" />
<SidePanelWarning title="orderer_not_available_title"
subtitle="orderer_not_available_text"
/>
</div>
)}
{_.get(this.props, 'usageInfo.crstatus.type') === 'Warning' && _.get(this.props, 'usageInfo.crstatus.reason') === 'certRenewalRequired' && (
<div className="ibp-orderer-warning ibp-error-panel">
<SidePanelWarning title="orderer_warning_title" subtitle="orderer_warning_text" />
<TranslateLink className="ibp-orderer-details-cert-expiry-link" text="cert_renew" />
<SidePanelWarning title="orderer_warning_title"
subtitle="orderer_warning_text"
/>
<TranslateLink className="ibp-orderer-details-cert-expiry-link"
text="cert_renew"
/>
</div>
)}
{this.props.selectedNode && !this.props.selectedNode.consenter_proposal_fin ? (
Expand All @@ -1625,9 +1671,9 @@ class OrdererDetails extends Component {
this.props.updateState(SCOPE, { selectedTab });
}}
>
<TabList contained>{tabItems.map((item) => item.tab())}</TabList>
<TabList contained>{tabItems.map((item, index) => item.tab(index))}</TabList>

<TabPanels>{tabItems.map((item) => item.panel())}</TabPanels>
<TabPanels>{tabItems.map((item, index) => item.panel(index))}</TabPanels>
</Tabs>
)}
</div>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1203,7 +1203,6 @@ class OrdererModal extends React.Component {
id={SCOPE + '-associate'}
fields={fields}
onChange={data => {
console.log('triggering with data', data);
const changed = Object.keys(data);
const associatedIdentities = { ...this.props.associatedIdentities };
changed.forEach(field => {
Expand Down
2 changes: 1 addition & 1 deletion packages/apollo/src/components/TitleBar/TitleBar.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class TitleBar extends Component {

goToDocs = (event, translate, type) => {
if ((event.key === 'Enter' && type === 'keypress') || type === 'click') {
if (this.props.console_type == 'hlfoc') {
if (this.props.console_type === 'hlfoc') {
window.open(translate('mainDocs2', { DOC_PREFIX: this.props.docPrefix }));
} else {
window.open(translate('mainDocs', { DOC_PREFIX: this.props.docPrefix }));
Expand Down
4 changes: 2 additions & 2 deletions packages/apollo/src/redux/LocalizeWrapper.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
import React from 'react';
import PropTypes from 'prop-types';
import { withTranslation } from 'react-i18next';
import localization from '../utils/localization';
// import localization from '../utils/localization';

class LocalizeWrapper extends React.Component {
constructor(props) {
super(props);
localization.init(props);
// localization.init(props);
}
render() {
const { children } = this.props;
Expand Down

0 comments on commit 4c5a279

Please sign in to comment.