mirror of
https://github.com/portainer/portainer.git
synced 2025-08-09 15:55:23 +02:00
fix(notifications): cleanup notifications code [EE-4274] (#7790)
* fix(notifications): cleanup notifications code [EE-4274] * break long words
This commit is contained in:
parent
c6ae8467c0
commit
724f1f63b7
7 changed files with 114 additions and 43 deletions
|
@ -1,5 +1,6 @@
|
|||
import { Bell, Trash2 } from 'react-feather';
|
||||
import { useStore } from 'zustand';
|
||||
import { useCurrentStateAndParams } from '@uirouter/react';
|
||||
|
||||
import { withCurrentUser } from '@/react-tools/withCurrentUser';
|
||||
import { react2angular } from '@/react-tools/react2angular';
|
||||
|
@ -17,19 +18,22 @@ import { columns } from './columns';
|
|||
import { createStore } from './datatable-store';
|
||||
|
||||
const storageKey = 'notifications-list';
|
||||
const useSettingsStore = createStore(storageKey);
|
||||
const useSettingsStore = createStore(storageKey, 'time');
|
||||
|
||||
export function NotificationsView() {
|
||||
const settingsStore = useSettingsStore();
|
||||
const { user } = useUser();
|
||||
|
||||
const userNotifications: ToastNotification[] = useStore(
|
||||
notificationsStore,
|
||||
(state) => state.userNotifications[user.Id]
|
||||
);
|
||||
const userNotifications: ToastNotification[] =
|
||||
useStore(notificationsStore, (state) => state.userNotifications[user.Id]) ||
|
||||
[];
|
||||
|
||||
const breadcrumbs = 'Notifications';
|
||||
|
||||
const {
|
||||
params: { id },
|
||||
} = useCurrentStateAndParams();
|
||||
|
||||
return (
|
||||
<>
|
||||
<PageHeader title="Notifications" breadcrumbs={breadcrumbs} reload />
|
||||
|
@ -47,6 +51,7 @@ export function NotificationsView() {
|
|||
renderTableActions={(selectedRows) => (
|
||||
<TableActions selectedRows={selectedRows} />
|
||||
)}
|
||||
initialActiveItem={id}
|
||||
/>
|
||||
</>
|
||||
);
|
||||
|
|
|
@ -19,11 +19,11 @@ interface TableSettings
|
|||
SettableColumnsTableSettings,
|
||||
RefreshableTableSettings {}
|
||||
|
||||
export function createStore(storageKey: string) {
|
||||
export function createStore(storageKey: string, initialSortBy?: string) {
|
||||
return create<TableSettings>()(
|
||||
persist(
|
||||
(set) => ({
|
||||
...sortableSettings(set),
|
||||
...sortableSettings(set, initialSortBy),
|
||||
...paginationSettings(set),
|
||||
...hiddenColumnsSettings(set),
|
||||
...refreshableSettings(set),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue