Skip to content

Commit

Permalink
HDDS-11229. Chain optionals in Recon Insight (apache#7064)
Browse files Browse the repository at this point in the history
  • Loading branch information
smitajoshi12 authored Aug 27, 2024
1 parent 2236041 commit fab56b4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -101,9 +101,7 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
// Disable bucket selection dropdown if more than one volume is selected
// If there is only one volume, bucket selection dropdown should not be disabled.
const isBucketSelectionDisabled = !selectedVolumes ||
(selectedVolumes &&
(selectedVolumes.length > 1 &&
(volumeBucketMap.size !== 1)));
(selectedVolumes?.length > 1 && volumeBucketMap.size !== 1);
let bucketOptions: IOption[] = [];
// When volume is changed and more than one volume is selected,
// selected buckets value should be reset to all buckets
Expand Down Expand Up @@ -455,7 +453,7 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
<Tabs.TabPane tab='File Size' key='1'>
<div className='content-div'>
{isLoading ? <span><LoadingOutlined /> Loading...</span> :
((fileCountsResponse && fileCountsResponse.length > 0) ?
((fileCountsResponse?.length > 0) ?
<div>
<Row>
<Col xs={24} xl={18}>
Expand Down Expand Up @@ -506,7 +504,7 @@ export class Insights extends React.Component<Record<string, object>, IInsightsS
<Tabs.TabPane tab='Container Size' key='2'>
<div className='content-div'>
{isLoading ? <span><LoadingOutlined /> Loading...</span> :
((containerCountResponse && containerCountResponse.length > 0) ?
((containerCountResponse?.length > 0) ?
<div>
<Row>
<Col style={{ margin: 'auto', marginTop: '2%' }}>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -530,7 +530,7 @@ export class Om extends React.Component<Record<string, object>, IOmdbInsightsSta
const { request, controller } = AxiosGetHelper(mismatchEndpoint, cancelMismatchedEndpointSignal)
cancelMismatchedEndpointSignal = controller;
request.then(mismatchContainersResponse => {
const mismatchContainers: IContainerResponse[] = mismatchContainersResponse && mismatchContainersResponse.data && mismatchContainersResponse.data.containerDiscrepancyInfo;
const mismatchContainers: IContainerResponse[] = mismatchContainersResponse?.data?.containerDiscrepancyInfo && [];

this.setState({
loading: false,
Expand Down Expand Up @@ -567,7 +567,7 @@ export class Om extends React.Component<Record<string, object>, IOmdbInsightsSta
const { request, controller } = AxiosGetHelper(openKeysEndpoint, cancelOpenKeysSignal)
cancelOpenKeysSignal = controller
request.then(openKeysResponse => {
const openKeys = openKeysResponse && openKeysResponse.data;
const openKeys = openKeysResponse?.data ?? {"fso": []};
let allopenKeysResponse: any[] = [];
for (let key in openKeys) {
if (Array.isArray(openKeys[key])) {
Expand Down Expand Up @@ -614,7 +614,7 @@ export class Om extends React.Component<Record<string, object>, IOmdbInsightsSta
cancelDeletePendingSignal = controller;

request.then(deletePendingKeysResponse => {
const deletePendingKeys = deletePendingKeysResponse && deletePendingKeysResponse.data && deletePendingKeysResponse.data.deletedKeyInfo;
const deletePendingKeys = deletePendingKeysResponse?.data?.deletedKeyInfo ?? [];
//Use Summation Logic iterate through all object and find sum of all datasize
let deletedKeyInfoData = [];
deletedKeyInfoData = deletePendingKeys && deletePendingKeys.flatMap((infoObject: any) => {
Expand Down Expand Up @@ -714,7 +714,7 @@ export class Om extends React.Component<Record<string, object>, IOmdbInsightsSta
cancelDeletedKeysSignal = controller
request.then(deletedKeysResponse => {
let deletedContainerKeys = [];
deletedContainerKeys = deletedKeysResponse && deletedKeysResponse.data && deletedKeysResponse.data.containers;
deletedContainerKeys = deletedKeysResponse?.data?.containers ?? [];
this.setState({
loading: false,
deletedContainerKeysDataSource: deletedContainerKeys
Expand Down Expand Up @@ -748,7 +748,7 @@ export class Om extends React.Component<Record<string, object>, IOmdbInsightsSta
cancelDeletedPendingDirSignal = controller
request.then(deletePendingDirResponse => {
let deletedDirInfo = [];
deletedDirInfo = deletePendingDirResponse && deletePendingDirResponse.data && deletePendingDirResponse.data.deletedDirInfo;
deletedDirInfo = deletePendingDirResponse?.data?.deletedDirInfo ?? [];
this.setState({
loading: false,
pendingDeleteDirDataSource: deletedDirInfo
Expand Down

0 comments on commit fab56b4

Please sign in to comment.