Skip to content

Commit

Permalink
Merge pull request #147 from K-Phoen/banner-card-category
Browse files Browse the repository at this point in the history
Display announcements by category for the banner and card
  • Loading branch information
K-Phoen authored Apr 8, 2023
2 parents 2968d96 + e9101d0 commit 9106242
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 1 deletion.
5 changes: 5 additions & 0 deletions .changeset/brave-carrots-turn.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@k-phoen/backstage-plugin-announcements': patch
---

Display announcements by category for the banner and card
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,14 @@ const useStyles = makeStyles({
type AnnouncementsCardOpts = {
title?: string;
max?: number;
category?: string;
};

export const AnnouncementsCard = ({ title, max }: AnnouncementsCardOpts) => {
export const AnnouncementsCard = ({
title,
max,
category,
}: AnnouncementsCardOpts) => {
const classes = useStyles();
const announcementsApi = useApi(announcementsApiRef);
const announcementsLink = useRouteRef(rootRouteRef);
Expand All @@ -47,6 +52,7 @@ export const AnnouncementsCard = ({ title, max }: AnnouncementsCardOpts) => {
} = useAsync(async () =>
announcementsApi.announcements({
max: max || 5,
category,
}),
);
const { announcementCreatePermission } = announcementEntityPermissions;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ const AnnouncementBanner = (props: AnnouncementBannerProps) => {
type NewAnnouncementBannerProps = {
variant?: 'block' | 'floating';
max?: number;
category?: string;
};

export const NewAnnouncementBanner = (props: NewAnnouncementBannerProps) => {
Expand All @@ -119,6 +120,7 @@ export const NewAnnouncementBanner = (props: NewAnnouncementBannerProps) => {
} = useAsync(async () =>
announcementsApi.announcements({
max: props.max || 1,
category: props.category,
}),
);
const lastSeen = announcementsApi.lastSeenDate();
Expand Down

0 comments on commit 9106242

Please sign in to comment.