1
0
Fork 0
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:
itsconquest 2022-10-11 14:05:53 +13:00 committed by GitHub
parent c6ae8467c0
commit 724f1f63b7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 114 additions and 43 deletions

View file

@ -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}
/>
</>
);

View file

@ -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),