Skip to content

Commit a13bc92

Browse files
committed
Show "incomplete" warning when status is unavailable
https://issues.redhat.com/browse/COST-5749
1 parent 4782171 commit a13bc92

File tree

8 files changed

+59
-58
lines changed

8 files changed

+59
-58
lines changed

locales/data.json

+8-6
Original file line numberDiff line numberDiff line change
@@ -12968,6 +12968,14 @@
1296812968
}
1296912969
]
1297012970
},
12971+
"none": {
12972+
"value": [
12973+
{
12974+
"type": 0,
12975+
"value": "Incomplete"
12976+
}
12977+
]
12978+
},
1297112979
"other": {
1297212980
"value": []
1297312981
},
@@ -13027,12 +13035,6 @@
1302713035
"value": "value"
1302813036
}
1302913037
],
13030-
"statusUnavailable": [
13031-
{
13032-
"type": 0,
13033-
"value": "Unavailable"
13034-
}
13035-
],
1303613038
"storage": [
1303713039
{
1303813040
"type": 0,

locales/translations.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -612,9 +612,8 @@
612612
"start": "Start",
613613
"status": "Status",
614614
"statusActions": "Status/Actions",
615-
"statusMsg": "{value, select, complete {Complete} failed {Failed} in_progress {in-Progress} paused {Paused} pending {Pending} other {}}",
615+
"statusMsg": "{value, select, complete {Complete} failed {Failed} in_progress {in-Progress} none {Incomplete} paused {Paused} pending {Pending} other {}}",
616616
"statusStates": "{value, select, pending {Pending} running {Running} failed {Failed} other {}}",
617-
"statusUnavailable": "Unavailable",
618617
"storage": "Storage",
619618
"storageClass": "StorageClass",
620619
"storageUnattributedDistributed": "Storage unattributed",

src/locales/messages.ts

+1-5
Original file line numberDiff line numberDiff line change
@@ -3726,6 +3726,7 @@ export default defineMessages({
37263726
'complete {Complete} ' +
37273727
'failed {Failed} ' +
37283728
'in_progress {in-Progress} ' +
3729+
'none {Incomplete} ' +
37293730
'paused {Paused} ' +
37303731
'pending {Pending} ' +
37313732
'other {}}',
@@ -3737,11 +3738,6 @@ export default defineMessages({
37373738
description: 'Status states',
37383739
id: 'statusStates',
37393740
},
3740-
statusUnavailable: {
3741-
defaultMessage: 'Unavailable',
3742-
description: 'Unavailable',
3743-
id: 'statusUnavailable',
3744-
},
37453741
storage: {
37463742
defaultMessage: 'Storage',
37473743
description: 'Storage',

src/routes/details/components/providerStatus/components/overallStatus.tsx

+25-22
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import type { MessageDescriptor } from 'react-intl';
88
import { useIntl } from 'react-intl';
99
import { useSelector } from 'react-redux';
1010
import { formatDate } from 'routes/details/components/providerStatus/utils/format';
11-
import { getOverallStatusIcon, getWarningStatusIcon } from 'routes/details/components/providerStatus/utils/icon';
11+
import { getOverallStatusIcon } from 'routes/details/components/providerStatus/utils/icon';
1212
import {
1313
getProviderAvailability,
1414
getProviderStatus,
@@ -27,7 +27,6 @@ interface OverallStatusOwnProps {
2727
isStatusMsg?: boolean;
2828
providerId?: string;
2929
providerType: ProviderType;
30-
showUnavailableStatus?: boolean; // Show warning icon for no status
3130
uuId?: string;
3231
}
3332

@@ -46,15 +45,14 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
4645
isStatusMsg,
4746
providerId,
4847
providerType,
49-
showUnavailableStatus,
5048
uuId,
5149
}: OverallStatusProps) => {
5250
const { providers, providersError } = useMapToProps();
5351
const intl = useIntl();
5452

5553
// Filter providers to skip an extra API request
5654
const getFilteredProviders = () => {
57-
return filterProviders(providers, providerType)?.data?.filter(data => data.status !== null);
55+
return filterProviders(providers, providerType)?.data;
5856
};
5957

6058
const getOverallStatus = (
@@ -74,18 +72,17 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
7472
if (msg && status) {
7573
return;
7674
}
77-
if (statusType === StatusType.complete) {
78-
// A cluster may not have an integration, so cloudProvider could be undefined
79-
if (
80-
(state1 === undefined || state1?.status === statusType) &&
81-
(state2 === undefined || state2?.status === statusType) &&
82-
(state3 === undefined || state3?.status === statusType) &&
83-
(state4 === undefined || state4?.status === statusType)
84-
) {
85-
lastUpdated = state1?.lastUpdated;
86-
msg = state1?.msg;
87-
status = statusType;
88-
}
75+
// A cluster may not have an integration, so cloudProvider could be undefined
76+
if (
77+
statusType === StatusType.complete &&
78+
(state1 === undefined || state1?.status === statusType) &&
79+
(state2 === undefined || state2?.status === statusType) &&
80+
(state3 === undefined || state3?.status === statusType) &&
81+
(state4 === undefined || state4?.status === statusType)
82+
) {
83+
lastUpdated = state1?.lastUpdated;
84+
msg = state1?.msg;
85+
status = statusType;
8986
} else {
9087
if (state1?.status === statusType) {
9188
lastUpdated = state1?.lastUpdated;
@@ -113,6 +110,7 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
113110
initializeState(StatusType.paused, cloudAvailability, providerAvailability, cloudStatus, providerStatus);
114111
initializeState(StatusType.inProgress, cloudAvailability, providerAvailability, cloudStatus, providerStatus); // Availability won't likely have in-progress and pending states
115112
initializeState(StatusType.pending, cloudAvailability, providerAvailability, cloudStatus, providerStatus);
113+
initializeState(StatusType.none, providerStatus, cloudStatus, providerAvailability, cloudAvailability); // Cannot show complete with an undefined status
116114
initializeState(StatusType.complete, providerStatus, cloudStatus, providerAvailability, cloudAvailability); // Must display the cluster status msg here
117115

118116
return { lastUpdated, msg, status };
@@ -122,6 +120,7 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
122120
let completeCount = 0;
123121
let failedCount = 0;
124122
let inProgressCount = 0;
123+
let noneCount = 0;
125124
let pausedCount = 0;
126125
let pendingCount = 0;
127126

@@ -149,6 +148,9 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
149148
if (overallStatus.status === StatusType.complete) {
150149
completeCount++;
151150
}
151+
if (overallStatus.status === StatusType.none) {
152+
noneCount++;
153+
}
152154
});
153155
return (
154156
<>
@@ -182,6 +184,12 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
182184
<span style={styles.statusIcon}>{getOverallStatusIcon(StatusType.pending)}</span>
183185
</>
184186
)}
187+
{noneCount > 0 && (
188+
<>
189+
<span style={styles.count}>{noneCount}</span>
190+
<span style={styles.statusIcon}>{getOverallStatusIcon(StatusType.none)}</span>
191+
</>
192+
)}
185193
</>
186194
);
187195
};
@@ -212,12 +220,7 @@ const OverallStatus: React.FC<OverallStatusProps> = ({
212220
</>
213221
);
214222
}
215-
return showUnavailableStatus ? (
216-
<>
217-
<span style={styles.statusIcon}>{getWarningStatusIcon()}</span>
218-
<span style={styles.description}>{intl.formatMessage(messages.statusUnavailable)}</span>
219-
</>
220-
) : null;
223+
return null;
221224
};
222225

223226
if (!providers || providersError) {

src/routes/details/components/providerStatus/providerBreakdownContent.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ const ProviderBreakdownContent: React.FC<ProviderDetailsContentProps> = ({
5353
}
5454

5555
// Filter OCP providers to skip an extra API request
56-
const filteredProviders = filterProviders(providers, providerType)?.data?.filter(data => data.status !== null);
56+
const filteredProviders = filterProviders(providers, providerType)?.data;
5757
const provider = filteredProviders?.find(
5858
val =>
5959
providerId === val.id ||

src/routes/details/components/providerStatus/providerTable.tsx

+8-11
Original file line numberDiff line numberDiff line change
@@ -48,24 +48,21 @@ const ProviderTable: React.FC<ProviderTableProps> = ({ onClick, providers, provi
4848
providers?.map(item => {
4949
// const clusterId = item?.authentication?.credentials?.cluster_id;
5050

51-
const getDetailsLink = () => {
52-
return onClick ? (
53-
<Button onClick={() => onClick(item.id)} style={styles.dataDetailsButton} variant={ButtonVariant.link}>
54-
{intl.formatMessage(messages.dataDetails)}
55-
</Button>
56-
) : (
57-
<ProviderBreakdownModal providerId={item.id} providerType={providerType} />
58-
);
59-
};
6051
newRows.push({
6152
cells: [
6253
{ value: <SourceLink provider={item} showLabel={false} /> },
6354
{ value: <OverallStatus isLastUpdated providerId={item.id} providerType={providerType} /> },
6455
{
65-
value: <OverallStatus isStatusMsg providerId={item.id} providerType={providerType} showUnavailableStatus />,
56+
value: <OverallStatus isStatusMsg providerId={item.id} providerType={providerType} />,
6657
},
6758
{
68-
value: item.status !== null ? getDetailsLink() : null,
59+
value: onClick ? (
60+
<Button onClick={() => onClick(item.id)} style={styles.dataDetailsButton} variant={ButtonVariant.link}>
61+
{intl.formatMessage(messages.dataDetails)}
62+
</Button>
63+
) : (
64+
<ProviderBreakdownModal providerId={item.id} providerType={providerType} />
65+
),
6966
},
7067
],
7168
item,

src/routes/details/components/providerStatus/utils/icon.tsx

+6-10
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,19 @@ export const getOverallStatusIcon = (status: StatusType) => {
2929
switch (status) {
3030
case StatusType.complete:
3131
icon = <CheckCircleIcon />;
32-
variant = 'success'; // Use green color
32+
variant = 'success'; // Green
3333
break;
3434
case StatusType.failed:
3535
icon = <ExclamationCircleIcon />;
36-
variant = 'danger'; // Use red color
36+
variant = 'danger'; // Red
3737
break;
3838
case StatusType.inProgress:
3939
icon = <InProgressIcon />;
4040
break;
41+
case StatusType.none:
42+
icon = <WarningTriangleIcon />;
43+
variant = 'warning'; // Yellow
44+
break;
4145
case StatusType.paused:
4246
icon = <PauseIcon />;
4347
break;
@@ -49,11 +53,3 @@ export const getOverallStatusIcon = (status: StatusType) => {
4953
}
5054
return icon ? <Icon status={variant}>{icon}</Icon> : null;
5155
};
52-
53-
export const getWarningStatusIcon = () => {
54-
return (
55-
<Icon status="warning">
56-
<WarningTriangleIcon />
57-
</Icon>
58-
);
59-
};

src/routes/details/components/providerStatus/utils/status.ts

+9-1
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ export const enum StatusType {
88
complete = 'complete',
99
failed = 'failed',
1010
inProgress = 'in_progress',
11+
none = 'none',
1112
paused = 'paused',
1213
pending = 'pending',
1314
}
@@ -25,7 +26,7 @@ export const lookupKey = (value: string) => {
2526
case 'pending':
2627
return StatusType.pending;
2728
default:
28-
return undefined;
29+
return StatusType.none;
2930
}
3031
};
3132

@@ -119,6 +120,13 @@ export const getProviderStatus = (
119120
) {
120121
status = StatusType.pending;
121122
msg = getProviderStatusMsg({ downloadState, processingState, summaryState }, StatusType.pending);
123+
} else if (
124+
downloadState === StatusType.none &&
125+
processingState === StatusType.none &&
126+
summaryState === StatusType.none
127+
) {
128+
status = StatusType.none;
129+
msg = getProviderStatusMsg({ downloadState, processingState, summaryState }, StatusType.none);
122130
} else if (
123131
downloadState === StatusType.complete &&
124132
processingState === StatusType.complete &&

0 commit comments

Comments
 (0)