mirror of
https://github.com/inventree/InvenTree.git
synced 2025-04-28 11:36:44 +00:00
[PUI] Notifications (#6515)
* Add placeholder buttons * Add callback functions - Mark all notifications as read - Delete all read notifications * remove unused import
This commit is contained in:
parent
a74b29f059
commit
3b11a01966
@ -36,7 +36,6 @@ export enum ApiEndpoints {
|
|||||||
api_search = 'search/',
|
api_search = 'search/',
|
||||||
settings_global_list = 'settings/global/',
|
settings_global_list = 'settings/global/',
|
||||||
settings_user_list = 'settings/user/',
|
settings_user_list = 'settings/user/',
|
||||||
notifications_list = 'notifications/',
|
|
||||||
barcode = 'barcode/',
|
barcode = 'barcode/',
|
||||||
news = 'news/',
|
news = 'news/',
|
||||||
global_status = 'generic/status/',
|
global_status = 'generic/status/',
|
||||||
@ -45,6 +44,10 @@ export enum ApiEndpoints {
|
|||||||
group_list = 'user/group/',
|
group_list = 'user/group/',
|
||||||
owner_list = 'user/owner/',
|
owner_list = 'user/owner/',
|
||||||
|
|
||||||
|
// Notification endpoints
|
||||||
|
notifications_list = 'notifications/',
|
||||||
|
notifications_readall = 'notifications/readall/',
|
||||||
|
|
||||||
// Build API endpoints
|
// Build API endpoints
|
||||||
build_order_list = 'build/',
|
build_order_list = 'build/',
|
||||||
build_order_attachment_list = 'build/attachment/',
|
build_order_attachment_list = 'build/attachment/',
|
||||||
|
@ -1,15 +1,18 @@
|
|||||||
import { t } from '@lingui/macro';
|
import { t } from '@lingui/macro';
|
||||||
import { Stack } from '@mantine/core';
|
import { Stack } from '@mantine/core';
|
||||||
|
import { modals } from '@mantine/modals';
|
||||||
import {
|
import {
|
||||||
IconBellCheck,
|
IconBellCheck,
|
||||||
IconBellExclamation,
|
IconBellExclamation,
|
||||||
IconCircleCheck,
|
IconCircleCheck,
|
||||||
IconCircleX,
|
IconCircleX,
|
||||||
|
IconMailOpened,
|
||||||
IconTrash
|
IconTrash
|
||||||
} from '@tabler/icons-react';
|
} from '@tabler/icons-react';
|
||||||
import { useMemo } from 'react';
|
import { useCallback, useMemo } from 'react';
|
||||||
|
|
||||||
import { api } from '../App';
|
import { api } from '../App';
|
||||||
|
import { ActionButton } from '../components/buttons/ActionButton';
|
||||||
import { PageDetail } from '../components/nav/PageDetail';
|
import { PageDetail } from '../components/nav/PageDetail';
|
||||||
import { PanelGroup } from '../components/nav/PanelGroup';
|
import { PanelGroup } from '../components/nav/PanelGroup';
|
||||||
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
import { ApiEndpoints } from '../enums/ApiEndpoints';
|
||||||
@ -21,6 +24,40 @@ export default function NotificationsPage() {
|
|||||||
const unreadTable = useTable('unreadnotifications');
|
const unreadTable = useTable('unreadnotifications');
|
||||||
const readTable = useTable('readnotifications');
|
const readTable = useTable('readnotifications');
|
||||||
|
|
||||||
|
const markAllAsRead = useCallback(() => {
|
||||||
|
api
|
||||||
|
.get(apiUrl(ApiEndpoints.notifications_readall), {
|
||||||
|
params: {
|
||||||
|
read: false
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((_response) => {
|
||||||
|
unreadTable.refreshTable();
|
||||||
|
readTable.refreshTable();
|
||||||
|
})
|
||||||
|
.catch((_error) => {});
|
||||||
|
}, []);
|
||||||
|
|
||||||
|
const deleteNotifications = useCallback(() => {
|
||||||
|
modals.openConfirmModal({
|
||||||
|
title: t`Delete Notifications`,
|
||||||
|
onConfirm: () => {
|
||||||
|
api
|
||||||
|
.delete(apiUrl(ApiEndpoints.notifications_list), {
|
||||||
|
data: {
|
||||||
|
filters: {
|
||||||
|
read: true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.then((_response) => {
|
||||||
|
readTable.refreshTable();
|
||||||
|
})
|
||||||
|
.catch((_error) => {});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}, []);
|
||||||
|
|
||||||
const notificationPanels = useMemo(() => {
|
const notificationPanels = useMemo(() => {
|
||||||
return [
|
return [
|
||||||
{
|
{
|
||||||
@ -48,6 +85,13 @@ export default function NotificationsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
|
tableActions={[
|
||||||
|
<ActionButton
|
||||||
|
icon={<IconMailOpened />}
|
||||||
|
tooltip={`Mark all as read`}
|
||||||
|
onClick={markAllAsRead}
|
||||||
|
/>
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
},
|
},
|
||||||
@ -88,6 +132,14 @@ export default function NotificationsPage() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
]}
|
]}
|
||||||
|
tableActions={[
|
||||||
|
<ActionButton
|
||||||
|
color="red"
|
||||||
|
icon={<IconTrash />}
|
||||||
|
tooltip={`Delete notifications`}
|
||||||
|
onClick={deleteNotifications}
|
||||||
|
/>
|
||||||
|
]}
|
||||||
/>
|
/>
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
@ -11,10 +11,12 @@ import { RowAction } from '../RowActions';
|
|||||||
export function NotificationTable({
|
export function NotificationTable({
|
||||||
params,
|
params,
|
||||||
tableState,
|
tableState,
|
||||||
|
tableActions,
|
||||||
actions
|
actions
|
||||||
}: {
|
}: {
|
||||||
params: any;
|
params: any;
|
||||||
tableState: TableState;
|
tableState: TableState;
|
||||||
|
tableActions: any[];
|
||||||
actions: (record: any) => RowAction[];
|
actions: (record: any) => RowAction[];
|
||||||
}) {
|
}) {
|
||||||
const columns: TableColumn[] = useMemo(() => {
|
const columns: TableColumn[] = useMemo(() => {
|
||||||
@ -47,6 +49,7 @@ export function NotificationTable({
|
|||||||
columns={columns}
|
columns={columns}
|
||||||
props={{
|
props={{
|
||||||
rowActions: actions,
|
rowActions: actions,
|
||||||
|
tableActions: tableActions,
|
||||||
enableSelection: true,
|
enableSelection: true,
|
||||||
params: params
|
params: params
|
||||||
}}
|
}}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user