-
Notifications
You must be signed in to change notification settings - Fork 8.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ResponceOps][MaintenanceWindow] MX Pagination #202539
Changes from 48 commits
be73cbb
8a84cc2
815bfe4
3e40644
1995414
6009cd0
32f87a6
a6d02f0
cbb3185
f1e2e49
9d4850b
1d20bee
2698ca5
7427123
8b83618
d53050b
f06b777
4efdc44
5a3bc92
a8cf7d7
7d406eb
b4e2210
c9a211f
00387e6
546419a
4a50a1a
1e8d11f
3f83447
9ddf9b5
d8758e9
af9038a
8cb00ee
57f3826
c81fb63
fc58627
585c785
fce0170
788681c
59f3516
2d8ee8c
4642d73
4094bd2
5138f64
00342f2
eabb0f8
a5b1df5
c2bb6e2
54a7575
3ef396f
cfbcdbc
24db939
faa01f8
0b1485d
d3b12e2
c6f18cb
0350f87
2af24c5
f0c5380
5b6e3b2
4ad30d9
8af17a7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,21 +9,32 @@ import { i18n } from '@kbn/i18n'; | |
import { useQuery } from '@tanstack/react-query'; | ||
import { useKibana } from '../utils/kibana_react'; | ||
import { findMaintenanceWindows } from '../services/maintenance_windows_api/find'; | ||
import { type MaintenanceWindowStatus } from '../../common'; | ||
|
||
interface UseFindMaintenanceWindowsProps { | ||
enabled?: boolean; | ||
page: number; | ||
perPage: number; | ||
search: string; | ||
selectedStatus: MaintenanceWindowStatus[]; | ||
} | ||
|
||
export const useFindMaintenanceWindows = (props?: UseFindMaintenanceWindowsProps) => { | ||
const { enabled = true } = props || {}; | ||
export const useFindMaintenanceWindows = (params: UseFindMaintenanceWindowsProps) => { | ||
const { enabled = true, page, perPage, search, selectedStatus } = params; | ||
|
||
const { | ||
http, | ||
notifications: { toasts }, | ||
} = useKibana().services; | ||
|
||
const queryFn = () => { | ||
return findMaintenanceWindows({ http }); | ||
return findMaintenanceWindows({ | ||
http, | ||
page, | ||
perPage, | ||
search, | ||
selectedStatus, | ||
}); | ||
}; | ||
|
||
const onErrorFn = (error: Error) => { | ||
|
@@ -36,14 +47,10 @@ export const useFindMaintenanceWindows = (props?: UseFindMaintenanceWindowsProps | |
} | ||
}; | ||
|
||
const { | ||
isLoading, | ||
isFetching, | ||
isInitialLoading, | ||
data = [], | ||
refetch, | ||
} = useQuery({ | ||
queryKey: ['findMaintenanceWindows'], | ||
const queryKey = ['findMaintenanceWindows', page, perPage, search, selectedStatus]; | ||
|
||
const { isLoading, isFetching, isInitialLoading, data, refetch } = useQuery({ | ||
queryKey, | ||
queryFn, | ||
onError: onErrorFn, | ||
refetchOnWindowFocus: false, | ||
|
@@ -53,7 +60,7 @@ export const useFindMaintenanceWindows = (props?: UseFindMaintenanceWindowsProps | |
}); | ||
|
||
return { | ||
maintenanceWindows: data, | ||
data: data || { maintenanceWindows: [], total: 0 }, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it is better to use the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I did not know about There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, this is happening because on an error
|
||
isLoading: enabled && (isLoading || isFetching), | ||
isInitialLoading, | ||
refetch, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's also add
keepPreviousData: true
to avoid having the table clear every time we change status.