Hide NotificationsPage toolbar for empty list

Signed-off-by: Marek Libra <marek.libra@gmail.com>
This commit is contained in:
Marek Libra
2024-06-20 10:23:18 +02:00
parent 08a6bd7bc4
commit 3bf0697eb8
2 changed files with 26 additions and 20 deletions
+5
View File
@@ -0,0 +1,5 @@
---
'@backstage/plugin-notifications': patch
---
The toolbar on the Notifications page is hidden when there are no listed notifications.
@@ -173,12 +173,14 @@ export const NotificationsTable = ({
}
}, [notifications, selectedNotifications]);
const compactColumns = React.useMemo(
(): TableColumn<Notification>[] => [
const compactColumns = React.useMemo((): TableColumn<Notification>[] => {
const showToolbar = notifications.length > 0;
return [
{
/* selection column */
width: '1rem',
title: (
title: showToolbar ? (
<SelectAll
count={selectedNotifications.size}
totalCount={notifications.length}
@@ -189,7 +191,7 @@ export const NotificationsTable = ({
)
}
/>
),
) : undefined,
render: (notification: Notification) => (
<CheckBox
color="primary"
@@ -254,7 +256,7 @@ export const NotificationsTable = ({
{
/* actions column */
width: '1rem',
title: (
title: showToolbar ? (
<BulkActions
notifications={notifications}
selectedNotifications={selectedNotifications}
@@ -263,7 +265,7 @@ export const NotificationsTable = ({
onSwitchSavedStatus={onSwitchSavedStatus}
onMarkAllRead={onMarkAllRead}
/>
),
) : undefined,
render: (notification: Notification) => (
<BulkActions
notifications={[notification]}
@@ -274,20 +276,19 @@ export const NotificationsTable = ({
/>
),
},
],
[
markAsReadOnLinkOpen,
selectedNotifications,
notifications,
isUnread,
onSwitchReadStatus,
onSwitchSavedStatus,
onMarkAllRead,
onNotificationsSelectChange,
classes.severityItem,
classes.description,
],
);
];
}, [
markAsReadOnLinkOpen,
selectedNotifications,
notifications,
isUnread,
onSwitchReadStatus,
onSwitchSavedStatus,
onMarkAllRead,
onNotificationsSelectChange,
classes.severityItem,
classes.description,
]);
return (
<Table<Notification>