Skip to content

Commit aca4520

Browse files
Now the Offers list includes the information on availability issues in the cards
1 parent d1fd238 commit aca4520

2 files changed

Lines changed: 24 additions & 9 deletions

File tree

frontend/src/locale/en.json

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,9 @@
516516
"filter_property_placeholder": "Filter by properties",
517517
"backend": "Backend",
518518
"backend_plural": "Backends",
519-
"availability": "Availability",
519+
"availability_not_available": "Not available",
520+
"availability_no_quota": "No quota",
521+
"availability_no_balance": "No balance",
520522
"groupBy": "Group by properties",
521523
"region": "Region",
522524
"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';
@@ -181,15 +181,28 @@ export const OfferList: React.FC<OfferListProps> = ({ withSearchParams, onChange
181181
{
182182
id: 'availability',
183183
content: (gpu: IGpu) => {
184-
// FIXME: array to string comparison never passes.
185-
// Additionally, there are more availability statuses that are worth displaying,
186-
// and several of them may be present at once.
184+
const availabilityIssues =
185+
gpu.availability.length > 0 &&
186+
gpu.availability.every((a) => a === 'not_available' || a === 'no_quota' || a === 'no_balance');
187187

188-
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
189-
// @ts-expect-error
190-
if (gpu.availability === 'not_available') {
191-
return <StatusIndicator type="warning">Not Available</StatusIndicator>;
188+
if (!availabilityIssues) {
189+
return null;
192190
}
191+
192+
if (gpu.availability.length === 1) {
193+
return <span className={styles.greyText}>{t(`offer.availability_${gpu.availability[0]}`)}</span>;
194+
}
195+
196+
return (
197+
<Popover
198+
dismissButton={false}
199+
position="top"
200+
size="small"
201+
content={gpu.availability.map((a) => t(`offer.availability_${a}`)).join(', ')}
202+
>
203+
<span className={styles.greyText}>{t('offer.availability_not_available')}</span>
204+
</Popover>
205+
);
193206
},
194207
width: 50,
195208
},

0 commit comments

Comments
 (0)