Skip to content

Commit fc638ea

Browse files
Now the Offers list includes the information on availability issues in the cards (#3607)
1 parent 80f9c39 commit fc638ea

File tree

2 files changed

+24
-9
lines changed

2 files changed

+24
-9
lines changed

frontend/src/locale/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -529,7 +529,9 @@
529529
"filter_property_placeholder": "Filter by properties",
530530
"backend": "Backend",
531531
"backend_plural": "Backends",
532-
"availability": "Availability",
532+
"availability_not_available": "Not available",
533+
"availability_no_quota": "No quota",
534+
"availability_no_balance": "No balance",
533535
"groupBy": "Group by properties",
534536
"region": "Region",
535537
"count": "Count",

frontend/src/pages/Offers/List/index.tsx

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import React, { useEffect, useState } from 'react';
22
import { useTranslation } from 'react-i18next';
33

4-
import { Cards, CardsProps, MultiselectCSD, PropertyFilter, StatusIndicator } from 'components';
4+
import { Cards, CardsProps, MultiselectCSD, Popover, PropertyFilter } from 'components';
55

66
import { useCollection } from 'hooks';
77
import { useGetGpusListQuery } from 'services/gpu';
@@ -198,15 +198,28 @@ export const OfferList: React.FC<OfferListProps> = ({
198198
{
199199
id: 'availability',
200200
content: (gpu: IGpu) => {
201-
// FIXME: array to string comparison never passes.
202-
// Additionally, there are more availability statuses that are worth displaying,
203-
// and several of them may be present at once.
201+
const availabilityIssues =
202+
gpu.availability.length > 0 &&
203+
gpu.availability.every((a) => a === 'not_available' || a === 'no_quota' || a === 'no_balance');
204204

205-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
206-
// @ts-expect-error
207-
if (gpu.availability === 'not_available') {
208-
return <StatusIndicator type="warning">Not Available</StatusIndicator>;
205+
if (!availabilityIssues) {
206+
return null;
209207
}
208+
209+
if (gpu.availability.length === 1) {
210+
return <span className={styles.greyText}>{t(`offer.availability_${gpu.availability[0]}`)}</span>;
211+
}
212+
213+
return (
214+
<Popover
215+
dismissButton={false}
216+
position="top"
217+
size="small"
218+
content={gpu.availability.map((a) => t(`offer.availability_${a}`)).join(', ')}
219+
>
220+
<span className={styles.greyText}>{t('offer.availability_not_available')}</span>
221+
</Popover>
222+
);
210223
},
211224
width: 50,
212225
},

0 commit comments

Comments
 (0)