Skip to content
This repository has been archived by the owner on Dec 27, 2024. It is now read-only.

Commit

Permalink
refactor: replace card by generic infocard
Browse files Browse the repository at this point in the history
  • Loading branch information
gaelgoth committed Nov 8, 2023
1 parent f64bf71 commit 8708b31
Showing 1 changed file with 6 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@ import {
Link,
ItemCardGrid,
Progress,
ItemCardHeader,
ContentHeader,
LinkButton,
InfoCard,
} from '@backstage/core-components';
import { alertApiRef, useApi, useRouteRef } from '@backstage/core-plugin-api';
import { parseEntityRef } from '@backstage/catalog-model';
Expand All @@ -30,10 +30,8 @@ import DeleteIcon from '@material-ui/icons/Delete';
import EditIcon from '@material-ui/icons/Edit';
import {
Button,
Card,
CardActions,
CardContent,
CardMedia,
makeStyles,
} from '@material-ui/core';
import {
Expand Down Expand Up @@ -81,8 +79,8 @@ const AnnouncementCard = ({
{announcement.title}
</Link>
);
const subTitle = (
<>
const subHeader = (
<span>
By{' '}
<EntityPeekAheadPopover entityRef={announcement.publisher}>
<Link to={entityLink(publisherRef)}>{publisherRef.name}</Link>
Expand All @@ -99,18 +97,15 @@ const AnnouncementCard = ({
</>
)}
, {DateTime.fromISO(announcement.created_at).toRelative()}
</>
</span>
);
const { loading: loadingDeletePermission, allowed: canDelete } =
usePermission({ permission: announcementDeletePermission });
const { loading: loadingUpdatePermission, allowed: canUpdate } =
usePermission({ permission: announcementUpdatePermission });

return (
<Card>
<CardMedia>
<ItemCardHeader title={title} subtitle={subTitle} />
</CardMedia>
<InfoCard title={title} subheader={subHeader}>
<CardContent>{announcement.excerpt}</CardContent>
<CardActions>
{!loadingUpdatePermission && canUpdate && (
Expand All @@ -127,7 +122,7 @@ const AnnouncementCard = ({
</Button>
)}
</CardActions>
</Card>
</InfoCard>
);
};

Expand Down

0 comments on commit 8708b31

Please sign in to comment.