Skip to content

Commit

Permalink
fix: Use asset uuid to get the ratings history (#1548)
Browse files Browse the repository at this point in the history
  • Loading branch information
aleixhub authored Nov 2, 2023
1 parent 2b96210 commit eba316b
Showing 1 changed file with 9 additions and 8 deletions.
17 changes: 9 additions & 8 deletions catalog/ui/src/app/Admin/RatingsList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,10 @@ async function fetchCatalog(namespaces: string[]): Promise<CatalogItem[]> {
return catalogItems;
}

const RatingsModal: React.FC<{ ciName: string }> = ({ ciName }) => {
const RatingsModal: React.FC<{ assetUuid: string }> = ({ assetUuid }) => {
const { data: ratingsHistory } = useSWR<{
ratings: { comment: string; rating: number; email: string; useful: boolean }[];
}>(ciName !== '' ? apiPaths.RATINGS_HISTORY({ ciName }) : null, fetcher);
}>(assetUuid !== '' ? apiPaths.RATINGS_HISTORY({ assetUuid }) : null, fetcher);

return (
<Table
Expand Down Expand Up @@ -196,8 +196,8 @@ const RatingsList: React.FC = () => {
[searchString, _catalogItems, _catalogItemsCpy],
);

function showRatingsHistory(ciName: string) {
setModalState(ciName);
function showRatingsHistory(assetUuid: string) {
setModalState(assetUuid);
openRatingModal();
}

Expand Down Expand Up @@ -242,8 +242,9 @@ const RatingsList: React.FC = () => {
cells.push(
// Name
<>
{ci.metadata.labels?.[`${CUSTOM_LABELS.RATING.domain}/${CUSTOM_LABELS.RATING.key}`] ? (
<Button variant="link" onClick={() => showRatingsHistory(ci.metadata.name)}>
{ci.metadata.labels?.[`${CUSTOM_LABELS.RATING.domain}/${CUSTOM_LABELS.RATING.key}`] &&
ci.metadata.labels?.['gpte.redhat.com/asset-uuid'] ? (
<Button variant="link" onClick={() => showRatingsHistory(ci.metadata.labels['gpte.redhat.com/asset-uuid'])}>
{ci.metadata.name}
</Button>
) : (
Expand All @@ -264,9 +265,9 @@ const RatingsList: React.FC = () => {
</Table>
</PageSection>
) : null}
<Modal ref={ratingModal} onConfirm={() => setModalState('')} title={'Ratings ' + modalState} type="ack">
<Modal ref={ratingModal} onConfirm={() => setModalState('')} title={'Ratings History'} type="ack">
<Suspense fallback={<LoadingSection />}>
<RatingsModal ciName={modalState} />
<RatingsModal assetUuid={modalState} />
</Suspense>
</Modal>
</div>
Expand Down

0 comments on commit eba316b

Please sign in to comment.